Skip to content

Commit

Permalink
Removed Docker Swarm references
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Caderno <[email protected]>
  • Loading branch information
kadern0 committed Mar 16, 2021
1 parent 74f50f4 commit 9fb70b3
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 128 deletions.
2 changes: 1 addition & 1 deletion lab1.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ export OPENFAAS_PREFIX="" # Populate with your Docker Hub username

### Setup a single-node cluster

The labs use Kubernetes, and still have some references to Docker Swarm. Please ignore those references as Swarm is no longer supported by the OpenFaaS community. Some of the workshop labs will work for faasd, but you may need to alter the commands and we do not provide support for the workshop when taken with faasd.
The labs use Kubernetes, Swarm is no longer supported by the OpenFaaS community. Some of the workshop labs will work for faasd, but you may need to alter the commands and we do not provide support for the workshop when taken with faasd.

* Kubernetes: [Lab 1b](./lab1b.md)
17 changes: 1 addition & 16 deletions lab10.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ This is a more secure alternative to environmental variables. Environmental vari
From a terminal run the following command:

#### _Docker Swarm_

```
$ echo -n <auth_token> | faas-cli secret create auth-token
```

#### _Kubernetes_

```
$ echo -n <auth_token> | faas-cli secret create auth-token
```
Expand All @@ -43,8 +35,6 @@ $ faas-cli secret ls
```
> Note: Remember that the `-g` flag enables easy switching between gateways. This works for secrets too.
#### _Kubernetes_

```
kubectl get secret auth-token -n openfaas-fn -o json
```
Expand All @@ -69,18 +59,13 @@ functions:
image: <your-username>/issue-bot
environment:
write_debug: true
gateway_hostname: "gateway"
gateway_hostname: "gateway.openfaas"
positive_threshold: 0.25
secrets:
- auth-token

```

> Note: If you're running on Kubernetes, suffix the `gateway_hostname` with `openfaas` namespace:
> ```
> gateway_hostname: "gateway.openfaas"
> ```
### Update the `issue-bot` function

The function handler requires changing in order to cause it to read the `auth-token` secret, rather than the environment variable. This is a single line change where:
Expand Down
25 changes: 1 addition & 24 deletions lab2.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,6 @@ $ cat lab2.md | faas-cli invoke markdown

OpenFaaS tracks metrics on your functions automatically using Prometheus. The metrics can be turned into a useful dashboard with free and Open Source tools like [Grafana](https://grafana.com).

Deploy OpenFaaS Grafana with:

#### _Docker Swarm_

```bash
$ docker service create -d \
--name=grafana \
--publish=3000:3000 \
--network=func_functions \
stefanprodan/faas-grafana:4.6.3
```

#### _Kubernetes_

Run Grafana in OpenFaaS Kubernetes namespace:

```sh
Expand Down Expand Up @@ -186,16 +172,7 @@ $ kubectl port-forward pod/grafana 3000:3000 -n openfaas

If you're using Kubernetes 1.17 or older, use `deploy/grafana` instead of `pod/` in the command above.

After the service has been created open Grafana in your browser, login with username `admin` password `admin` and navigate to the pre-made OpenFaaS dashboard at:


#### _Docker Swarm_

[http://127.0.0.1:3000/dashboard/db/openfaas](http://127.0.0.1:3000/dashboard/db/openfaas)

#### _Kubernetes_

Use `$GRAFANA_URL` instead
After the service has been created open Grafana in your browser, login with username `admin` password `admin` and navigate to the pre-made OpenFaaS dashboard at `$GRAFANA_URL`.

<a href="https://camo.githubusercontent.com/24915ac87ecf8a31285f273846e7a5ffe82eeceb/68747470733a2f2f7062732e7477696d672e636f6d2f6d656469612f4339636145364358554141585f36342e6a70673a6c61726765"><img src="https://camo.githubusercontent.com/24915ac87ecf8a31285f273846e7a5ffe82eeceb/68747470733a2f2f7062732e7477696d672e636f6d2f6d656469612f4339636145364358554141585f36342e6a70673a6c61726765" width="600px" /></a>

Expand Down
22 changes: 0 additions & 22 deletions lab3.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,6 @@ Joe Acaba is in space

You can find out high-level information on every invocation of your function via the container's logs:

#### _Docker Swarm_

```sh
$ docker service logs -f astronaut-finder
astronaut-finder.1.1e1ujtsijf6b@nuc | 2018/02/21 14:53:25 Forking fprocess.
astronaut-finder.1.1e1ujtsijf6b@nuc | 2018/02/21 14:53:26 Wrote 18 Bytes - Duration: 0.063269 seconds
```

#### _Kubernetes_

```sh
$ kubectl logs deployment/astronaut-finder -n openfaas-fn
```
Expand Down Expand Up @@ -304,18 +294,6 @@ Now deploy your function again with `faas-cli deploy -f ./astronaut-finder.yml`.

Invoke the function and then checkout the logs again to view the function responses:

#### _Docker Swarm_
```sh
$ docker service logs -f astronaut-finder
astronaut-finder.1.tp6k14i8kf6s | 2019/04/25 18:28:36 Forking fprocess.
astronaut-finder.1.tp6k14i8kf6s | 2019/04/25 18:28:36 Query
astronaut-finder.1.tp6k14i8kf6s | 2019/04/25 18:28:36 Path /
astronaut-finder.1.tp6k14i8kf6s | 2019/04/25 18:28:37 Duration: 1.128897 seconds
astronaut-finder.1.tp6k14i8kf6s | Alexey Ovchinin is in space
```

#### _Kubernetes_
```sh
$ kubectl logs deployment/astronaut-finder -n openfaas-fn
```
Expand Down
17 changes: 0 additions & 17 deletions lab4.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ Let's try it out with a querystring and a function that lists off all environmen

* Deploy a function that prints environmental variables using a built-in BusyBox command:

#### _Docker Swarm_

```
$ faas-cli deploy --name env --fprocess="env" --image="functions/alpine:latest" --network=func_functions
```

#### _Kubernetes_

```
$ faas-cli deploy --name env --fprocess="env" --image="functions/alpine:latest"
```
Expand Down Expand Up @@ -372,15 +364,6 @@ So the result shows us that our test sentence was both very subjective (75%) and

The following code can be used to call the *Sentiment Analysis* function or any other function:

#### _Docker Swarm_

```python
test_sentence = "California is great, it's always sunny there."
r = requests.get("http://gateway:8080/function/sentimentanalysis", data= test_sentence)
```

#### _Kubernetes_

Suffix the gateway host with `openfaas` namespace:
```python
r = requests.get("http://gateway.openfaas:8080/function/sentimentanalysis", text= test_sentence)
Expand Down
21 changes: 3 additions & 18 deletions lab5.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ You will need to receive incoming webhooks from GitHub. In production you will h

Open a new Terminal and type in:

### _Docker Swarm_

```
$ docker run -p 4040:4040 -d --name=ngrok --net=func_functions \
alexellis2/ngrok-admin http gateway:8080
```

#### _Kubernetes_

```
$ kubectl -n openfaas run \
--image=alexellis2/ngrok-admin \
Expand Down Expand Up @@ -201,11 +192,11 @@ Update your `requirements.txt` file with the requests module for HTTP/HTTPs:
requests
```

Add `gateway_hostname` environment variable to `issue-bot.yml` file and set its value to `gateway` for Swarm or `gateway.openfaas` for Kubernetes.
Add `gateway_hostname` environment variable to `issue-bot.yml` file and set its value to `gateway.openfaas`.
```
...
environment:
gateway_hostname: "gateway"
gateway_hostname: "gateway.openfaas"
...
```

Expand Down Expand Up @@ -269,17 +260,11 @@ functions:
image: <your-username>/issue-bot
environment:
write_debug: true
gateway_hostname: "gateway"
gateway_hostname: "gateway.openfaas"
positive_threshold: 0.25
environment_file:
- env.yml
```

> Note: If you're running on Kubernetes, suffix the `gateway_hostname` with `openfaas` namespace:
> ```
> gateway_hostname: "gateway.openfaas"
> ```

> The `positive_threshold` environmental variable is used to fine-tune whether an Issue gets the `positive` or `review` label.

Any sensitive information is placed in an external file (i.e. `env.yml`) so that it can be included in a `.gitignore` file which will help prevent that information getting stored in a public Git repository.
Expand Down
8 changes: 0 additions & 8 deletions lab7.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ Asynchronous function calls are well-suited to tasks where you can defer the exe

The default stack for OpenFaaS uses NATS Streaming for queueing and deferred execution. You can view the logs with the following command:

#### _Docker Swarm_

```
docker service logs -f func_queue-worker
```

#### _Kubernetes_

```
kubectl logs deployment/queue-worker -n openfaas
```
Expand Down
4 changes: 0 additions & 4 deletions lab8.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ Finished the sleep
There is also a maximum timeout duration set at the gateway and it will override the function timeout. At the time of writing the maximum timeout is configured at "20s", but can be configured to a longer or shorter value.
#### _Docker Swarm_
To update the gateway value, set `read_timeout` and `write_timeout` in the `docker-compose.yml` file for the `gateway` and `faas-swarm` service then run `./deploy_stack.sh`.
#### _Kubernetes_
To update the gateway value, set `gateway.readTimeout` and `gateway.writeTimeout` in the [values.yaml](https://github.com/openfaas/faas-netes/blob/master/chart/openfaas/values.yaml) file or use the Helm parameters `--set gateway.readTimeout=value` and `--set gateway.writeTimeout=value`.
Now move onto [Lab 9](lab9.md)
20 changes: 2 additions & 18 deletions lab9.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ You can control the maximum amount of replicas that can spawn for a function by
### Check out Prometheus

Open Prometheus in a web-browser:

#### _Docker Swarm_

`http://127.0.0.1:9090/graph`

#### _Kubernetes_

You will need to run this port-forwarding command in order to be able to access Prometheus on `http://127.0.0.1:9090`:
```
$ kubectl port-forward deployment/prometheus 9090:9090 -n openfaas
Expand Down Expand Up @@ -160,21 +152,13 @@ See also: [hey on GitHub](https://github.com/rakyll/hey)
If you scale down your function to 0 replicas, you can still invoke it. The invocation will trigger the gateway into scaling the function to a non-zero value.
Try it out with the following commands:
Try it out with the following command:
Docker Swarm:
```
$ docker service scale nodeinfo=0
```
Kubernetes:
```
$ kubectl scale deployment --replicas=0 nodeinfo -n openfaas-fn
```
Open the OpenFaaS UI and check that nodeinfo has 0 replicas, or by `docker service ls | grep nodeinfo`.
> For Kubernetes use `kubectl get deployment nodeinfo -n openfaas-fn`
Open the OpenFaaS UI and check that nodeinfo has 0 replicas, or by `kubectl get deployment nodeinfo -n openfaas-fn`.
Now invoke the function and check back that it scaled to 1 replicas.
Expand Down

0 comments on commit 9fb70b3

Please sign in to comment.