Skip to content

Commit aa63a58

Browse files
committed
Updates for CLI which uses stack.yaml by default
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent 45882f7 commit aa63a58

File tree

53 files changed

+127
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+127
-176
lines changed

_includes/landing-page/code-examples/javascript.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div id="Javascript" class="tabcontent">
2-
<pre><code class="language-shell">$ faas-cli new --lang node18 javascript-fn
2+
<pre><code class="language-shell">$ faas-cli new --lang node20 javascript-fn
33
</code></pre>
44
<div class="has-text-grey-darker has-text-weight-light">
55
handler.js

_includes/products-page/products-cards.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ <h3 class="title is-size-12 is-size-8-desktop has-text-grey-darker">
8686
<subtitle class="is-size-5 mb-3">
8787
Expose services to the Internet from localhost or Kubernetes
8888
</subtitle>
89-
<p style="padding-bottom: 20px" class="has-text-weight-light">Expose TCP & HTTP endpoints without rate-limits and complete privacy.</p>
89+
<p style="padding-bottom: 20px" class="has-text-weight-light">Expose TCP & HTTP endpoints through cloud VMs for complete privacy.</p>
9090
</div>
9191
<div>
9292
<a class="button is-primary is-medium" href="https://inlets.dev">inlets.dev</a>

_posts/2018-08-02-read-only-functions.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ The example code will be available [on GitHub here](https://github.com/alexellis
5454

5555
```bash
5656
faas-cli new --lang node access-control --prefix=alexellis2
57-
mv access-control.yml stack.yml
5857
echo "alexellis" > ./access-control/valid_user.txt
5958
```
6059

_posts/2018-08-22-five-cli-tips.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Now if you were to run a `build`, `push` or `deploy` you'd carry that step out f
4141

4242
You can simply type in `faas-cli build --filter=filter2` for instance.
4343

44-
Now if you do happen to edit most of your functions most of the time such as with [OpenFaaS Cloud](https://github.com/openfaas/openfaas-cloud/blob/master/stack.yml), then you can use the `--parallel` flag and your images will be built concurrently. If you have 16 functions in one YAML file and use `--parallel=4` they will build in batches of 4 saving time overall. This speed-boosting feature isn't available when working with Docker outside of OpenFaaS.
44+
Now if you do happen to edit most of your functions most of the time such as with [OpenFaaS Cloud](https://github.com/openfaas/openfaas-cloud/blob/master/stack.yaml), then you can use the `--parallel` flag and your images will be built concurrently. If you have 16 functions in one YAML file and use `--parallel=4` they will build in batches of 4 saving time overall. This speed-boosting feature isn't available when working with Docker outside of OpenFaaS.
4545

4646
You can also split your functions into separate folders, repos or YAML files.
4747

@@ -111,7 +111,7 @@ Successfully tagged alexellis2/test1:latest-b6d5661
111111

112112
If we change the tag in the YAML file from `latest` to `0.1` then the image tag would have been: `test1:0.1-b6d5661`. This is useful for CI/CD jobs and is supported by the verbs: `build`, `push`, `deploy` and `up`.
113113

114-
You can also omit the `--yaml/-f` flag if you rename your YAML file to `stack.yml`
114+
You can also omit the `--yaml/-f` flag if you rename your YAML file to `stack.yaml`
115115

116116
## Tip 5: Use `faas-cli up` and save on typing
117117

_posts/2018-09-06-stateless-microservices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ The guestbook code stores its state in a MySQL table which means that it can be
294294

295295
To enable [scaling to zero](https://www.openfaas.com/blog/zero-scale/) simply [follow the documentation](https://docs.openfaas.com/architecture/autoscaling/#zero-scale) to enable the `faas-idler`.
296296

297-
Then add a label to your `stack.yml` file to tell OpenFaaS that your function is eligible for zero-scaling:
297+
Then add a label to your `stack.yaml` file to tell OpenFaaS that your function is eligible for zero-scaling:
298298

299299
```yaml
300300
labels:

_posts/2019-01-24-unified-secrets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ environment variables can be used to configure non-confidential data such as fea
3434

3535
* Do manage config with environment variables
3636

37-
You can manage configuration with environment variables by declaring an `environment:` section in your function's `stack.yml` file. Or you can create an external file for your environmental configuration with `environment_file:`.
37+
You can manage configuration with environment variables by declaring an `environment:` section in your function's `stack.yaml` file. Or you can create an external file for your environmental configuration with `environment_file:`.
3838

3939
Read more about using environment variables for config in the [YAML reference](https://docs.openfaas.com/reference/yaml/#function-environmental-variables).
4040

_posts/2019-01-29-multifile-python-functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The project should now look like
4949

5050
```txt
5151
.
52-
├── stack.yml
52+
├── stack.yaml
5353
├── template
5454
│   ├── python27-flask
5555
│   │   ├ ...
@@ -78,7 +78,7 @@ The project should now look like this
7878

7979
```txt
8080
.
81-
├── stack.yml
81+
├── stack.yaml
8282
├── template
8383
│   ├── ...
8484
└── wordcount

_posts/2019-02-04-digitalocean-one-click.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ Function created in folder: hello-digitalocean
118118
Stack file written: hello-digitalocean.yml
119119
```
120120
121-
* Rename `hello-digitalocean.yml` to `stack.yml`:
122-
123-
```sh
124-
$ mv hello-digitalocean.yml stack.yml
125-
```
126-
127121
* Edit `hello-digitalocean/handler.py` to add our function's code:
128122
129123
```python

_posts/2019-02-12-openfaas-on-fargate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ scheduled in a `private subnet` that has no access to the Internet
5959
to manage service registration / de-registration
6060
* **\[logging\]** we configure each container workload to log to [AWS cloudwatch](https://aws.amazon.com/cloudwatch).
6161
* **\[secrets\]** managed using [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/) and assigned access to functions
62-
in the `stack.yml`
62+
in the `stack.yaml`
6363
* **\[tls\]** ingress TLS is automatically provisioned using [Certbot](https://certbot.eff.org/) and the
6464
[Let's Encrypt](https://letsencrypt.org/) certificate authority.
6565

_posts/2019-02-14-serverless-single-page-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ Functions:
231231

232232
Other files:
233233

234-
* `stack.yml` - defines the functions and is generated by the `faas-cli`
234+
* `stack.yaml` - defines the functions and is generated by the `faas-cli`
235235
* `secrets.yaml` - defines encrypted or "sealed" secrets generated by `faas-cli cloud seal`
236236

237237
The database schema is written in the README.md file at the root.

_posts/2019-03-06-google-form-response.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ In your terminal of choice, create the new function from the `csharp` template:
119119

120120
```sh
121121
$ faas-cli new signup-form --lang csharp
122-
123-
# Rename signup-form.yml to the default "stack.yml", to reduce on typing.
124-
125-
$ mv signup-form.yml stack.yml
126122
```
127123

128124
We're going to need to add a dependency to `Newtonsoft.Json` to parse the JSON request from the form. We'll also add the C# Slack SDK to make it easy to post a message to the appropriate channel. The dependencies will be added from Nuget via `dotnet add`:

_posts/2019-03-30-openfaas-cloud-gitlab.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Now add a tag to the repo so that OpenFaaS Cloud knows that it can manage this r
324324

325325
* Create a new function:
326326

327-
```
327+
```bash
328328
faas-cli template store pull node10-express
329329
faas-cli new --lang node10-express timezone-shift --prefix=dockerhub_username
330330
```
@@ -333,14 +333,14 @@ Now let's create a quick function to shift timezones for meetings.
333333

334334
We'll install an `npm` module so you'll need to have Node.js installed on your local machine, or run this command in a container and grab the resulting `package.json` file.
335335

336-
```
336+
```bash
337337
cd timezone-shift
338338
npm install --save moment
339339
```
340340

341341
Enter into `handler.js`:
342342

343-
```
343+
```js
344344
"use strict"
345345
const moment = require('moment');
346346
module.exports = (event, context) => {
@@ -352,15 +352,11 @@ module.exports = (event, context) => {
352352
}
353353
```
354354

355-
We need to rename our function’s YAML file to `stack.yml`, so that it can be picked up by the OpenFaaS Cloud CI/CD pipeline.
356-
357-
```
358-
mv timezone-shift.yml stack.yml
359-
```
355+
We need to rename our function’s YAML file to `stack.yaml`, so that it can be picked up by the OpenFaaS Cloud CI/CD pipeline.
360356

361357
Push the code:
362358

363-
```
359+
```bash
364360
git add .
365361
git commit
366362
git push origin master

_posts/2019-04-09-openfaas-cloudrun.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Now go over to your fork of my GitHub repo and edit your `cloudbuild.yaml` file.
198198

199199
When complete it will deploy a second revision to the Cloud Run Service and we'll get a URL on the Cloud Run dashboard.
200200

201-
> Don't like managing a `cloudbuild.yaml` file for every one of your GitHub repositories? No problem - checkout [OpenFaaS Cloud](https://docs.openfaas.com/openfaas-cloud/intro/) which uses your existing stack.yml file to automate CI/CD for any linked repository on GitHub or self-hosted GitLab.
201+
> Don't like managing a `cloudbuild.yaml` file for every one of your GitHub repositories? No problem - checkout [OpenFaaS Cloud](https://docs.openfaas.com/openfaas-cloud/intro/) which uses your existing stack.yaml file to automate CI/CD for any linked repository on GitHub or self-hosted GitLab.
202202

203203
### Monitor the function
204204

_posts/2019-04-10-golang-serverless.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ OK
341341

342342
As part of a blog post on how to build a full Single Page App with OpenFaaS I used the golang-middleware template to build a function to consume events from GitHub and to store them in a Postgres database.
343343

344-
You can read the code here for [handler.go](https://github.com/alexellis/leaderboard-app/blob/master/github-sub/handler.go). Confidential data is configured through the use of secrets and non-confidential configuration us set through environment variables in [stack.yml](https://github.com/alexellis/leaderboard-app/blob/master/stack.yml#L18).
344+
You can read the code here for [handler.go](https://github.com/alexellis/leaderboard-app/blob/master/github-sub/handler.go). Confidential data is configured through the use of secrets and non-confidential configuration us set through environment variables in [stack.yaml](https://github.com/alexellis/leaderboard-app/blob/master/stack.yaml#L18).
345345

346346
## Custom templates
347347

_posts/2019-04-17-kafka-connector.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ See also: [Apache Kafka Documentation](https://kafka.apache.org/documentation/).
3535

3636
## Kafka Connector
3737

38-
The [kafka-connector](https://github.com/openfaas-incubator/kafka-connector) is designed to connect Kafka topics to OpenFaaS Functions. After deploying the kafka-connector and pointing it at your broker, you can connect functions to topics by adding a simple annotation via your functions' stack.yml file.
38+
The [kafka-connector](https://github.com/openfaas-incubator/kafka-connector) is designed to connect Kafka topics to OpenFaaS Functions. After deploying the kafka-connector and pointing it at your broker, you can connect functions to topics by adding a simple annotation via your functions' stack.yaml file.
3939

4040
Conceptual architecture diagram:
4141

@@ -123,14 +123,14 @@ $ export OPENFAAS_PREFIX=docker.io/alexellis2
123123
# Create a function in Go
124124
$ faas-cli new email-receipt \
125125
--lang=go
126-
$ mv email-receipt.yml stack.yml
126+
$ mv email-receipt.yml stack.yaml
127127
```
128128

129-
> We also renamed the function's YAML file to `stack.yml` (the default)
129+
> We also renamed the function's YAML file to `stack.yaml` (the default)
130130
131131
The function is a simple `Hello World` written in Go, you can edit it if you want, but for simplicity in our example we will keep the default message.
132132

133-
Edit the `stack.yml` file by adding `topic` annotation with the value which which we pointed in the Kafka Connector `payment-received`. The file should look like this:
133+
Edit the `stack.yaml` file by adding `topic` annotation with the value which which we pointed in the Kafka Connector `payment-received`. The file should look like this:
134134

135135
```yaml
136136
provider:

_posts/2019-08-29-five-security-tips.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ spec:
131131
image: functions/nodeinfo:latest
132132
```
133133
134-
* How to generate a CRD entry from a `stack.yml` file:
134+
* How to generate a CRD entry from a `stack.yaml` file:
135135

136136
```bash
137137
# create a go function for Docker Hub user `alexellis2`
@@ -141,7 +141,7 @@ faas-cli new --lang go --prefix alexellis2 crd-example
141141
faas-cli build -f crd-example.yaml
142142
faas-cli push -f crd-example.yaml
143143

144-
# generate the CRD entry from the "stack.yml" file and apply in the cluster
144+
# generate the CRD entry from the "stack.yaml" file and apply in the cluster
145145
faas-cli generate -f crd-example.yaml | kubectl apply -f -
146146
```
147147

@@ -183,7 +183,7 @@ Any containers deployed with "privileged mode" on Kubernetes, if compromised cou
183183

184184
The OpenFaaS core components run as non-root users to reduce attack surface.
185185

186-
Templates contain a Dockerfile and an entrypoint, which is usually a HTTP server. These allow developers to avoid repeating themselves with hundreds of lines of Kubernetes YAML, instead they get 3-4 lines in a CRD or OpenFaaS `stack.yml` file. The official OpenFaaS templates use a non-root user so that functions are running as normal users.
186+
Templates contain a Dockerfile and an entrypoint, which is usually a HTTP server. These allow developers to avoid repeating themselves with hundreds of lines of Kubernetes YAML, instead they get 3-4 lines in a CRD or OpenFaaS `stack.yaml` file. The official OpenFaaS templates use a non-root user so that functions are running as normal users.
187187

188188
See an example: [openfaas-incubator/node10-express-service](https://github.com/openfaas-incubator/node10-express-service/blob/master/template/node10-express-service/Dockerfile)
189189

@@ -199,7 +199,7 @@ OpenFaaS Pods can make use of Kubernetes secrets. To create a secret use `faas-c
199199
echo SECRET | faas-cli secret create api-key
200200
```
201201

202-
You can then attach the secret to a function by editing its stack.yml file, or by using the `--secret` flag with `faas-cli up`.
202+
You can then attach the secret to a function by editing its stack.yaml file, or by using the `--secret` flag with `faas-cli up`.
203203

204204
See also: [OpenFaaS workshop: Lab 10 - Secrets](https://github.com/openfaas/workshop/blob/master/lab10.md)
205205

_posts/2019-10-08-lambda-to-openfaas.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ exports.handler = async (event) => {
6060
};
6161
```
6262

63-
Let's examine the example for OpenFaaS. When you create a new function with the OpenFaaS CLI and the `node18` template, sample code is provided as shown here:
63+
Let's examine the example for OpenFaaS. When you create a new function with the OpenFaaS CLI and the `node20` template, sample code is provided as shown here:
6464

6565
```js
6666
'use strict'
@@ -176,39 +176,35 @@ Now, create the new "shortener" function:
176176

177177
```sh
178178
$ faas-cli new shortener \
179-
--lang node18
179+
--lang node20
180180
```
181181

182182
This will create a `shortener.yml` file, and a directory with the same name containing the sample function code to work from. By setting the `OPENFAAS_PREFIX` environment variable your registry name is added to the image so that the image can be pushed.
183183

184-
OpenFaaS uses the convention of having a `stack.yml` file that contains all of the function definitions to operate on. You can use the `--yaml` or `-f` flags to provide a differently named file, but for this post, we'll rename the generated yml file making the remainder of the commands simpler.
185-
186-
```bash
187-
mv shortener.yml stack.yml
188-
```
184+
OpenFaaS uses the convention of having a `stack.yaml` file that contains all of the function definitions to operate on. You can use the `--yaml` or `-f` flags to provide a differently named file, but for this post, we'll rename the generated yml file making the remainder of the commands simpler.
189185

190186
When we create the "redirector" function, we can pass the `--append` flag to automatically add the new function's definition to the existing file.
191187

192188
```sh
193189
$ faas-cli new redirector \
194-
--lang node18 \
195-
--append stack.yml
190+
--lang node20 \
191+
--append stack.yaml
196192
```
197193

198-
The resulting `stack.yml` file will look something like this:
194+
The resulting `stack.yaml` file will look something like this:
199195

200196
```yaml
201197
functions:
202198
shortener:
203-
lang: node18
199+
lang: node20
204200
handler: ./shortener
205201
image: burtonr/shortener:latest
206202
redirector:
207-
lang: node18
203+
lang: node20
208204
handler: ./redirector
209205
image: burtonr/redirector:latest
210206
```
211-
_file source: [openfaas/stack.yml](https://github.com/welteki/lambda-openfaas-blog/blob/master/openfaas/stack.yml)_
207+
_file source: [openfaas/stack.yaml](https://github.com/welteki/lambda-openfaas-blog/blob/master/openfaas/stack.yaml)_
212208
213209
### Migrate the Function Code
214210
@@ -286,13 +282,13 @@ Finally, we'll add the secrets to the function's `yml` file so that the function
286282
```yaml
287283
functions:
288284
shortener:
289-
lang: node18
285+
lang: node20
290286
...
291287
secrets:
292288
- shorturl-dynamo-key
293289
- shorturl-dynamo-secret
294290
```
295-
_file source: [openfaas/stack.yml](https://github.com/welteki/lambda-openfaas-blog/blob/master/openfaas/stack.yml)_
291+
_file source: [openfaas/stack.yaml](https://github.com/welteki/lambda-openfaas-blog/blob/master/openfaas/stack.yaml)_
296292

297293
> Read more about [Unifying Secrets with OpenFaaS](/blog/unified-secrets)
298294

@@ -306,12 +302,12 @@ Below is the additions that would need to be added to the function's yaml file:
306302
```yaml
307303
functions:
308304
shortener:
309-
lang: node18
305+
lang: node20
310306
...
311307
annotations:
312308
com.openfaas.serviceaccount: "iamserviceaccount"
313309
```
314-
_file source: [openfaas/stack.yml](https://github.com/welteki/lambda-openfaas-blog/blob/master/openfaas/stack.yml)_
310+
_file source: [openfaas/stack.yaml](https://github.com/welteki/lambda-openfaas-blog/blob/master/openfaas/stack.yaml)_
315311

316312

317313
### Code differences

_posts/2019-11-04-github-badges.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ I started off by building my function for OpenFaaS Cloud on [The Community Clust
118118

119119
# This generated my badge/handler.js and badge/handler.json files
120120
faas-cli new --lang node10-express badge
121-
122-
# The YAML file must be called stack.yml
123-
mv badge.yml stack.yml
124121
```
125122

126123
* Add the dependencies
@@ -308,7 +305,7 @@ OpenFaaS Official functions:
308305

309306
* [Bot to thank new Patreon backers](https://github.com/openfaas/backer-thankyou/)
310307

311-
* [HTTPS short-URLs](https://github.com/openfaas/cloud-functions/blob/master/stack.yml) - we built a number of short/pretty-URLs for the community to use for joining Slack, Zoom calls and for [becoming an OpenFaaS Insider](https://insiders.openfaas.io/)
308+
* [HTTPS short-URLs](https://github.com/openfaas/cloud-functions/blob/master/stack.yaml) - we built a number of short/pretty-URLs for the community to use for joining Slack, Zoom calls and for [becoming an OpenFaaS Insider](https://insiders.openfaas.io/)
312309

313310
The UK-based cloud company [Civo.com](https://civo.com/) has an OpenFaaS function on The Community Cluster which filters Twitter mentions and then forwards them onto their Slack community so that the team can engage better with their own community:
314311

_posts/2019-12-03-asp-net-core.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ We should also create a `openfaas-api/.gitignore` file to prevent us committing
191191

192192
Run: `cp .dockerignore .gitignore`
193193

194-
* Create an OpenFaaS stack.yml file
194+
* Create an OpenFaaS stack.yaml file
195195

196196
Let's use the OpenFaaS template called `dockerfile` to define a new template for the project and call it `api`.
197197

@@ -201,7 +201,7 @@ faas-cli new --lang dockerfile api
201201

202202
Now you'll see a folder generated called `api` containing a `Dockerfile` and `api.yml`
203203

204-
Let's edit stack.yml and have it point at our `Dockerfile` we created earlier:
204+
Let's edit stack.yaml and have it point at our `Dockerfile` we created earlier:
205205

206206
```yaml
207207
version: 1.0
@@ -216,7 +216,7 @@ functions:
216216
image: api:latest
217217
```
218218
219-
* Let's rename the file to the default `stack.yml`
219+
* Let's rename the file to the default `stack.yaml`
220220
* And also change the `handler` folder to point at the existing folder
221221
* Then add our Docker Hub username or private Docker container registry as a prefix to `image:`
222222

@@ -233,7 +233,7 @@ functions:
233233
You should now have:
234234

235235
```
236-
./stack.yml
236+
./stack.yaml
237237
./openfaas-api/
238238
./openfaas-api/Dockerfile
239239
./openfaas-api/Program.cs
@@ -438,7 +438,7 @@ That's fine, you can create different templates or you can just specify the runt
438438

439439
* 12-factor configuration
440440

441-
You can apply 12-factor configuration through the `environment` section of your OpenFaaS stack.yml file.
441+
You can apply 12-factor configuration through the `environment` section of your OpenFaaS stack.yaml file.
442442

443443
See also: [Configure your OpenFaaS functions for staging and production](https://www.openfaas.com/blog/custom-environments/)
444444

0 commit comments

Comments
 (0)