Skip to content

Commit 578306a

Browse files
committed
Updates for Windows users
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent acd4cee commit 578306a

File tree

3 files changed

+71
-79
lines changed

3 files changed

+71
-79
lines changed

lab1.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
<img src="https://github.com/openfaas/media/raw/master/OpenFaaS_Magnet_3_1_png.png" width="500px"></img>
44

5-
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.
66

77
The basic primitive for any OpenFaaS function is a Docker image, which is built using the `faas-cli` tool-chain.
88

99
## Pre-requisites:
1010

11+
Let's install Docker, the OpenFaaS CLI and pick Kubernetes or Swarm to proceed.
12+
1113
### Docker
1214

1315
For Mac
@@ -35,15 +37,32 @@ Linux - Ubuntu or Debian
3537
3638
Note: As a last resort if you have an incompatible PC you can run the workshop on https://labs.play-with-docker.com/.
3739

38-
### Pre-pull the system images
40+
### OpenFaaS CLI
3941

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:
4145

46+
```sh
47+
$ curl -sLSf https://cli.openfaas.com | sudo sh
4248
```
43-
curl -sSL https://raw.githubusercontent.com/openfaas/faas/master/docker-compose.yml | grep image | awk -F " " '{print $NF}' | xargs -L1 docker pull
49+
50+
For Windows, run this in *Git Bash*:
51+
52+
```sh
53+
$ curl -sLSf https://cli.openfaas.com | sh
4454
```
4555

46-
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+
```
4766

4867
### Setup a single-node cluster
4968

@@ -57,3 +76,13 @@ Start the first lab by picking one of the tracks below:
5776

5877
* Kubernetes: [Lab 1b](./lab1b.md)
5978

79+
80+
### Pre-pull the system images (only if using Swarm)
81+
82+
Pull the most recent OpenFaaS images.
83+
84+
```
85+
curl -sSL https://raw.githubusercontent.com/openfaas/faas/master/docker-compose.yml | grep image | awk -F " " '{print $NF}' | xargs -L1 docker pull
86+
```
87+
88+
This should offset the impact on the workshop WiFi of multiple attendees trying to pull the images at the same time.

lab1a.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,6 @@ $ docker login
3030

3131
> 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".
3232
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-
5833
### Deploy OpenFaaS
5934

6035
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:

lab1b.md

Lines changed: 37 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
## Install latest `kubectl`
66

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/)
88

9-
### Linux
9+
* Linux
1010

1111
```sh
1212
export VER=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
@@ -15,69 +15,61 @@ chmod +x kubectl
1515
mv kubectl /usr/local/bin/
1616
```
1717

18-
### MacOS
18+
* MacOS
1919

2020
```sh
2121
export VER=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
22-
curl -LO https://storage.googleapis.com/kubernetes-release/release/$VER/bin/darwin/amd64/kubectl
22+
curl -LO https://storage.googleapis.com/kubernetes-release/release/$VER/bin/darwin/amd64/kubectl.exe
2323
chmod +x kubectl
2424
mv kubectl /usr/local/bin/
2525
```
2626

27-
> Note: you should install the latest version because the version you have may be out of date.
28-
29-
## Install kubectx
30-
31-
[kubectx](https://github.com/ahmetb/kubectx/blob/master/kubectx) can help you switch between multiple clusters.
32-
33-
If you're using Windows then download from the [releases page](https://github.com/ahmetb/kubectx/releases) and place in `/usr/bin/` or `C:\Windows\`.
34-
35-
On MacOS or Linux:
27+
* Windows
3628

3729
```sh
38-
curl -sSLf https://raw.githubusercontent.com/ahmetb/kubectx/master/kubectx > kubectx
39-
chmod +x kubectx
40-
sudo mv kubectx /usr/local/bin/
30+
export VER=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
31+
curl -LO https://storage.googleapis.com/kubernetes-release/release/$VER/bin/windows/amd64/kubectl.exe
32+
chmod +x kubectl.exe
33+
mkdir -p $HOME/bin/
34+
mv kubectl $HOME/bin/
4135
```
4236

43-
## OpenFaaS CLI
44-
45-
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
4838

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.
5240

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
5442

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*
5644

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.
5846

59-
Test the `faas-cli`
47+
* [Install k3d](https://github.com/rancher/k3d)
6048

61-
Open a Terminal or Git Bash window and type in:
49+
* Start a cluster
6250

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]
6658
```
6759

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:
6961

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.
73-
74-
### Create a local cluster on your laptop
62+
```sh
63+
export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
64+
kubectl cluster-info
65+
```
7566

76-
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.
7768
7869
#### _Docker for Mac_
7970

8071
* [Install Docker for Mac](https://docs.docker.com/v17.12/docker-for-mac/install/)
72+
8173
> Note that Kubernetes is only available in Docker for Mac 17.12 CE and higher
8274
8375
#### _With Minikube_
@@ -94,6 +86,8 @@ $ minikube start
9486
The minikube VM is exposed to the host system via a host-only IP address. Check this IP with `minikube ip`.
9587
This is the IP you will later use for the gateway URL.
9688

89+
> Note: Minikube also requires a Hypervisor such as VirtualBox or Hyperkit (on MacOS). Follow the minikube instructions and documentation
90+
9791
### Create a remote cluster on the cloud
9892

9993
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.
10498

10599
The DigitalOcean dashboard will then guide you through how to configure your `kubectl` and `KUBECONFIG` file for use in the labs.
106100

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)
108102

109103
Even if you have already claimed free credit, the running costs for a 2-3 node cluster for 24-48 hours is negligible.
110104

@@ -117,7 +111,8 @@ It is recommended to use the latest Kubernetes version available and the to sele
117111
* Under "Add node pool(s)"
118112

119113
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
121116
122117
* Download the [doctl](https://github.com/digitalocean/doctl#installing-doctl) CLI and place it in your path.
123118

@@ -148,7 +143,7 @@ $ doctl k8s cluster kubeconfig save workshop-lon1
148143

149144
You now need to switch your Kubernetes context to point at the new cluster.
150145

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>`.
152147

153148
#### _Run on GKE (Google Kubernetes Engine)_
154149

@@ -228,11 +223,6 @@ $ docker login
228223

229224
The instructions for deploying OpenFaaS change from time to time as we strive to make this even easier.
230225

231-
Deploy OpenFaaS to Kubernetes using the instructions for Helm:
232-
233-
* Install helm (required step)
234-
235-
236226
### Install the helm CLI/client
237227

238228
Instructions for latest Helm install
@@ -324,7 +314,6 @@ helm repo update \
324314
--set functionNamespace=openfaas-fn
325315
```
326316

327-
328317
### Determine your Gateway URL
329318

330319
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://
400389
This URL will now be saved for each new terminal window that you open.
401390

402391
Now move onto [Lab 2](./lab2.md)
403-

0 commit comments

Comments
 (0)