You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenFaaS runs on top of several major platforms including Docker Swarm and Kubernetes. For this tutorial you can choose one of both on your local computer.
5
+
OpenFaaS requires a [Kubernetes](https://kubernetes.io) or [Docker Swarm](https://docs.docker.com/engine/swarm/) cluster to operate. You can use a single-node cluster or a multi-node cluster, whether that's on your laptop or in the cloud.
6
6
7
7
The basic primitive for any OpenFaaS function is a Docker image, which is built using the `faas-cli` tool-chain.
8
8
9
9
## Pre-requisites:
10
10
11
+
Let's install Docker, the OpenFaaS CLI and pick Kubernetes or Swarm to proceed.
12
+
11
13
### Docker
12
14
13
15
For Mac
@@ -35,15 +37,32 @@ Linux - Ubuntu or Debian
35
37
36
38
Note: As a last resort if you have an incompatible PC you can run the workshop on https://labs.play-with-docker.com/.
37
39
38
-
### Pre-pull the system images
40
+
### OpenFaaS CLI
39
41
40
-
Pull the most recent OpenFaaS images.
42
+
You can install the OpenFaaS CLI using the official bash script, `brew` is also available but can lag one or two versions behind.
43
+
44
+
With MacOS or Linux run the following in a Terminal:
This should offset the impact on the workshop WiFi of multiple attendees trying to pull the images at the same time.
56
+
> If you run into any issues then you can download the latest `faas-cli.exe` manually from the [releases page](https://github.com/openfaas/faas-cli/releases). You can place it in a local directory or in the `C:\Windows\` path so that it's available from a command prompt.
57
+
58
+
We will use the `faas-cli` to scaffold new functions, build, deploy and invoke functions. You can find out commands available for the cli with `faas-cli --help`.
59
+
60
+
Test the `faas-cli`. Open a Terminal or Git Bash window and type in:
61
+
62
+
```sh
63
+
$ faas-cli help
64
+
$ faas-cli version
65
+
```
47
66
48
67
### Setup a single-node cluster
49
68
@@ -57,3 +76,13 @@ Start the first lab by picking one of the tracks below:
57
76
58
77
* Kubernetes: [Lab 1b](./lab1b.md)
59
78
79
+
80
+
### Pre-pull the system images (only if using Swarm)
Copy file name to clipboardExpand all lines: lab1a.md
-25Lines changed: 0 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,31 +30,6 @@ $ docker login
30
30
31
31
> Note: Tip from community - if you get an error while trying to run this command on a Windows machine, then click on the Docker for Windows icon in the taskbar and log into Docker there instead "Sign in / Create Docker ID".
32
32
33
-
### OpenFaaS CLI
34
-
35
-
You can install the OpenFaaS CLI with `brew` on a Mac or with a utility script on Mac or Linux:
36
-
37
-
Using a Terminal on Mac or Linux:
38
-
39
-
```sh
40
-
$ curl -sL cli.openfaas.com | sudo sh
41
-
```
42
-
43
-
On Windows download the the latest `faas-cli.exe` from the [releases page](https://github.com/openfaas/faas-cli/releases). You can place it in a local directory or in the `C:\Windows\` path so that it's available from a command prompt.
44
-
45
-
> If you're an advanced Windows user, place the CLI in a directory of your choice and then add that folder to your PATH environmental variable.
46
-
47
-
We will use the `faas-cli` to scaffold new functions, build, deploy and invoke functions. You can find out commands available for the cli with `faas-cli --help`.
48
-
49
-
Test the `faas-cli`
50
-
51
-
Open a Terminal or Git Bash window and type in:
52
-
53
-
```sh
54
-
$ faas-cli help
55
-
$ faas-cli version
56
-
```
57
-
58
33
### Deploy OpenFaaS
59
34
60
35
The instructions for deploying OpenFaaS change from time to time as we strive to make this easier. The following will get OpenFaaS deployed in around 60 seconds:
Copy file name to clipboardExpand all lines: lab1b.md
+37-49Lines changed: 37 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@
4
4
5
5
## Install latest `kubectl`
6
6
7
-
Install kubectl for your operating system using the [official instructions](https://kubernetes.io/docs/tasks/tools/install-kubectl/). If you're on Windows use the instructions on the page and place the binary in `/usr/local/bin/` or `C:\windows\`.
7
+
Install `kubectl` for your operating system using the instructions below or the [official documentation](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
You can install the OpenFaaS CLI with `brew` on a Mac or with a utility script on Mac or Linux:
46
-
47
-
Using a Terminal on Mac or Linux:
37
+
## Setup a Kubernetes cluster
48
38
49
-
```sh
50
-
$ curl -sL cli.openfaas.com | sudo sh
51
-
```
39
+
You can follow the labs whilst using Kubernetes, but you may need to make some small changes along the way. The service address for the gateway changes from `http://gateway:8080` to `http://gateway.openfaas:8080`. As far as possible these differences have been documented and alternatives are provided in each lab.
52
40
53
-
On Windows download the the latest `faas-cli.exe` from the [releases page](https://github.com/openfaas/faas-cli/releases). You can place it in `C:\Windows\` or `/usr/local/bin/`
41
+
### Create a local cluster on your laptop
54
42
55
-
> If you're an advanced Windows user, place the CLI in a directory of your choice and then add that folder to your PATH environmental variable.
43
+
#### *k3s using k3d*
56
44
57
-
We will use the `faas-cli` to scaffold new functions, build, deploy and invoke functions. You can find out commands available for the cli with `faas-cli --help`.
45
+
If you have Docker on your computer, then you can use `k3d` from Rancher Labs. It installs a lightweight version of Kubernetes called `k3s`and runs it within a Docker container, meaning it will work on any computer that has Docker.
58
46
59
-
Test the `faas-cli`
47
+
*[Install k3d](https://github.com/rancher/k3d)
60
48
61
-
Open a Terminal or Git Bash window and type in:
49
+
* Start a cluster
62
50
63
-
```
64
-
$ faas-cli help
65
-
$ faas-cli version
51
+
```sh
52
+
$ k3d create
53
+
INFO[0000] Created cluster network with ID 9a7d5887754d3e317b5c1500f706a5ae602077a18bc71bcedb9fae86ebd84c0b
54
+
INFO[0000] Created docker volume k3d-k3s-default-images
55
+
INFO[0000] Creating cluster [k3s-default]
56
+
INFO[0000] Creating server using docker.io/rancher/k3s:v0.9.1...
57
+
INFO[0000] SUCCESS: created cluster [k3s-default]
66
58
```
67
59
68
-
Later in the lab, after setting up OpenFaaS we will run `faas-cli login` to save the password for our OpenFaaS gateway.
60
+
Switch into the k3d context:
69
61
70
-
## Setup a Kubernetes cluster
71
-
72
-
You can follow the labs whilst using Kubernetes, but you may need to make some small changes along the way. The service address for the gateway changes from `http://gateway:8080` to `http://gateway.openfaas:8080`. As far as possible these differences have been documented and alternatives are provided in each lab.
Depending on the option you may also need to install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/).
67
+
> Note: You have to run this on any new terminal you open.
77
68
78
69
#### _Docker for Mac_
79
70
80
71
*[Install Docker for Mac](https://docs.docker.com/v17.12/docker-for-mac/install/)
72
+
81
73
> Note that Kubernetes is only available in Docker for Mac 17.12 CE and higher
82
74
83
75
#### _With Minikube_
@@ -94,6 +86,8 @@ $ minikube start
94
86
The minikube VM is exposed to the host system via a host-only IP address. Check this IP with `minikube ip`.
95
87
This is the IP you will later use for the gateway URL.
96
88
89
+
> Note: Minikube also requires a Hypervisor such as VirtualBox or Hyperkit (on MacOS). Follow the minikube instructions and documentation
90
+
97
91
### Create a remote cluster on the cloud
98
92
99
93
You can create a remote cluster in the cloud and enjoy the same experience as if you were developing locally whilst saving on RAM/CPU and battery. The costs for running a cluster for 1-2 days is minimal.
@@ -104,7 +98,7 @@ You can use free credits to create a cluster through DigitalOcean's UI.
104
98
105
99
The DigitalOcean dashboard will then guide you through how to configure your `kubectl` and `KUBECONFIG` file for use in the labs.
106
100
107
-
*[Claim your free credits - $100 in credit over 60 days](https://m.do.co/c/8d4e75e9886f)
101
+
*[Claim your free credits - $50 in credit over 30 days.](https://m.do.co/c/8d4e75e9886f)
108
102
109
103
Even if you have already claimed free credit, the running costs for a 2-3 node cluster for 24-48 hours is negligible.
110
104
@@ -117,7 +111,8 @@ It is recommended to use the latest Kubernetes version available and the to sele
117
111
* Under "Add node pool(s)"
118
112
119
113
Use 2x 4GB / 2vCPU
120
-
(More can be added at a later date.)
114
+
115
+
> Note: You can add more capacity at a later time, if required
121
116
122
117
* Download the [doctl](https://github.com/digitalocean/doctl#installing-doctl) CLI and place it in your path.
You now need to switch your Kubernetes context to point at the new cluster.
150
145
151
-
Find the cluster name with `kubectx`, if it's not highlighted type in `kubectx <context-name>`.
146
+
Find the cluster name with `kubectl config get-contexts`, if it's not highlighted type in `kubectl config set-context <context-name>`.
152
147
153
148
#### _Run on GKE (Google Kubernetes Engine)_
154
149
@@ -228,11 +223,6 @@ $ docker login
228
223
229
224
The instructions for deploying OpenFaaS change from time to time as we strive to make this even easier.
230
225
231
-
Deploy OpenFaaS to Kubernetes using the instructions for Helm:
232
-
233
-
* Install helm (required step)
234
-
235
-
236
226
### Install the helm CLI/client
237
227
238
228
Instructions for latest Helm install
@@ -324,7 +314,6 @@ helm repo update \
324
314
--set functionNamespace=openfaas-fn
325
315
```
326
316
327
-
328
317
### Determine your Gateway URL
329
318
330
319
Depending on your installation method and Kubernetes distribution the Gateway URL may vary as will how you access it from your laptop during the workshop.
@@ -400,4 +389,3 @@ export OPENFAAS_URL=http://
400
389
This URL will now be saved for each new terminal window that you open.
0 commit comments