Skip to content

Commit 6bcdde0

Browse files
committed
Add k3sup instructions
k3sup is a prototype of "faas-cli install" and makes the experience much easier for newcomers. The longer, manual, and more detailed instructions are retained in the documentation. Advanced users are welcome to follow them. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 578306a commit 6bcdde0

File tree

1 file changed

+35
-86
lines changed

1 file changed

+35
-86
lines changed

lab1b.md

Lines changed: 35 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -258,134 +258,83 @@ kubectl -n kube-system create sa tiller \
258258
helm init --skip-refresh --upgrade --service-account tiller
259259
```
260260

261-
### Install OpenFaaS with helm
261+
### Install OpenFaaS
262262

263-
* Install the OpenFaaS helm chart
263+
There is a new tool called `k3sup` which can install helm charts, including OpenFaaS. This makes the installation procedure much faster.
264264

265-
We first create two namespaces `openfaas` and `openfaas-fn`:
265+
#### Install with `k3sup`
266266

267-
```sh
268-
kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml
269-
```
267+
* Get k3sup
270268

271-
Now add the helm chart repo for the project:
269+
For Windows:
272270

273271
```sh
274-
helm repo add openfaas https://openfaas.github.io/faas-netes/
272+
curl -SLsf https://get.k3sup.dev/ | sh
275273
```
276274

277-
Create a password for your OpenFaaS gateway:
275+
For MacOS / Linux:
278276

279277
```sh
280-
# generate a random password
281-
PASSWORD=$(head -c 12 /dev/urandom | shasum| cut -d' ' -f1)
282-
283-
kubectl -n openfaas create secret generic basic-auth \
284-
--from-literal=basic-auth-user=admin \
285-
--from-literal=basic-auth-password="$PASSWORD"
286-
287-
echo $PASSWORD > gateway-password.txt
278+
curl -SLsf https://get.k3sup.dev/ | sudo sh
288279
```
289280

290-
>Note: If you get any issues with `helm upgrade` then you can reset it with `helm delete --purge openfaas`
281+
* Install the OpenFaaS app
291282

292-
### A) For local clusters
293-
294-
If you're running on a local cluster run the following:
283+
If you're using a managed cloud Kubernetes service which supplies LoadBalancers, then run the following:
295284

296285
```sh
297-
helm repo update \
298-
&& helm upgrade openfaas --install openfaas/openfaas \
299-
--namespace openfaas \
300-
--set basic_auth=true \
301-
--set functionNamespace=openfaas-fn
286+
k3sup app install openfaas --loadbalancer
302287
```
303288

304-
### B) For remote clusters
305-
306-
If you're running on a remote cluster run the following which will also expose a LoadBalancer with a public IP so that you can access it easily from your own laptop.
289+
If you're using a local Kubernetes cluster or a VM, then run:
307290

308291
```sh
309-
helm repo update \
310-
&& helm upgrade openfaas --install openfaas/openfaas \
311-
--namespace openfaas \
312-
--set basic_auth=true \
313-
--set serviceType=LoadBalancer \
314-
--set functionNamespace=openfaas-fn
292+
k3sup app install openfaas
315293
```
316294

317-
### Determine your Gateway URL
318-
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.
295+
#### Or install with helm (advanced)
320296

321-
#### NodePort (local Kubernetes, excluding KinD)
297+
If you prefer, you can install OpenFaaS using the [helm chart](https://github.com/openfaas/faas-netes/blob/master/chart/openfaas/README.md) instructions.
322298

323-
The default installation for OpenFaaS exposes the gateway through a Kubernetes Service of type `NodePort`. The gateway address will generally be: `http://IP_ADDRESS:31112/`
299+
### Log into your OpenFaaS gateway
324300

325-
The default for Docker for Mac would be `http://127.0.0.1:31112`
326-
327-
#### LoadBalancer (remote Kubernetes, or KinD)
328-
329-
If you're using a remote cluster or KinD then you can either use a LoadBalancer or run a command to port-forward the gateway to your local computer over the internet.
330-
331-
* A) Get the LoadBalancer address
332-
333-
It may take a couple of minutes for the `EXTERNAL-IP` address to become available, it will remain `<pending>` during that time.
301+
* Check the gateway is ready
334302

335303
```sh
336-
kubectl get svc -o wide gateway-external -n openfaas
304+
kubectl rollout status -n openfaas deploy/gateway
337305
```
338306

339-
* B) Or start port-forwarding:
307+
If you're using your laptop, a VM, or any other kind of Kubernetes distribution run the following instead:
340308

341309
```sh
342310
kubectl port-forward svc/gateway -n openfaas 8080:8080
343311
```
344312

345-
Now set the `OPENFAAS_URL` variable to link to the proper IP:
346-
```bash
347-
export OPENFAAS_URL=http://IP_ADDRESS:8080
348-
```
349-
You should now have OpenFaaS deployed. If you are on a shared WiFi connection at an event then it may take several minutes to pull down all the Docker images and start them.
313+
This command will open a tunnel from your Kubernetes cluster to your local computer so that you can access the OpenFaaS gateway. There are other ways to access OpenFaaS, but that is beyond the scope of this workshop.
350314

351-
Check the services show `1/1` on this screen:
315+
Your gateway URL is: `http://127.0.0.1:8080`
352316

353-
```
354-
$ kubectl get pods -n openfaas
355-
NAME READY STATUS RESTARTS AGE
356-
alertmanager-f5b4dfb8b-ztbb7 1/1 Running 0 1h
357-
gateway-d8477b4b6-m962x 2/2 Running 0 1h
358-
nats-86955fb749-8w65j 1/1 Running 0 1h
359-
prometheus-7d78d54b57-nncss 1/1 Running 0 1h
360-
queue-worker-8698f5bb78-qfv6n 1/1 Running 0 1h
361-
```
362-
363-
If you run into any problems, please consult the [helm chart README](https://github.com/openfaas/faas-netes/blob/master/chart/openfaas/README.md).
317+
If you're using a managed cloud Kubernetes service then get the LoadBalancer's IP address or DNS entry from the `EXTERNAL-IP` field from the command below.
364318

365-
### Login to the OpenFaaS Gateway
366-
367-
If you are running on a remote cluster and deployed openfaas with `basic_auth=true`, then you need to log in to access openfaas gateway.
319+
```sh
320+
kubectl get svc -o wide gateway-external -n openfaas
321+
```
368322

369-
If you are accessing the gateway in the browser then it will prompt you for username and password. Username will be `admin` and password will be the value of environment variable `PASSWORD`
323+
Your URL will be the IP or DNS entry above on port `8080`.
370324

371-
To access openfaas gateway from openfaas CLI, you need to log in using `faas-cli login` command.
325+
* Log in:
372326

373-
Log in with the CLI and check connectivity:
327+
```sh
328+
export OPENFAAS_URL="" # Populate as above
374329

330+
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
331+
echo -n $PASSWORD | faas-cli login --username admin --password-stdin
375332
```
376-
echo -n $PASSWORD | faas-cli login -g $OPENFAAS_URL -u admin --password-stdin
377-
```
378-
379-
### Permanently save your OpenFaaS URL
380-
381-
Edit `~/.bashrc` or `~/.bash_profile` - create the file if it doesn't exist.
382333

383-
Now add the following - changing the URL as per the one you saw above.
334+
* Check that `faas-cli list` works:
384335

336+
```sh
337+
faas-cli list
385338
```
386-
export OPENFAAS_URL=http://
387-
```
388-
389-
This URL will now be saved for each new terminal window that you open.
390339

391-
Now move onto [Lab 2](./lab2.md)
340+
Now move onto [Lab 2](lab2.md)

0 commit comments

Comments
 (0)