Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit dd96b4b

Browse files
committed
Add get.sh for installation and other feedback
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
1 parent 804e3b6 commit dd96b4b

File tree

3 files changed

+307
-59
lines changed

3 files changed

+307
-59
lines changed

README.md

Lines changed: 178 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,48 @@ kubectl create clusterrolebinding "cluster-admin-$(whoami)" \
6565
--user="$(gcloud config get-value core/account)"
6666
```
6767

68-
#### Create a cluster
68+
### Create a Kubernetes cluster
6969

70-
* Create a production cluster
70+
You may already have a Kubernetes cluster, if not, then follow the instructions below picking either 1) or 2).
7171

72-
You can create a managed or self-hosted Kubernetes cluster using a Kubernetes engine such as GKE, AWS, DigitalOcean or by using `kubeadm`. Once set up make sure you have set your `KUBECONFIG` and / or `kubectl` tool to point at a the new cluster.
72+
#### 1) Create a production cluster
7373

74-
* Create a local cluster for testing
74+
You can create a managed or self-hosted Kubernetes cluster using a Kubernetes engine from a cloud provider, or by running either `kubeadm` or `k3s`.
75+
76+
Cloud-services:
77+
78+
* [DigitalOcean Kubernetes](https://www.digitalocean.com/products/kubernetes/) (recommended)
79+
* [AKS](https://docs.microsoft.com/en-us/azure/aks/)
80+
* [EKS](https://docs.aws.amazon.com/eks/latest/userguide/what-is-eks.html)
81+
* [GKE](https://cloud.google.com/kubernetes-engine/)
82+
83+
Local / on-premises:
84+
85+
* [k3s](https://k3s.io) (recommended)
86+
* [kubeadm](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/)
87+
88+
Once set up make sure you have set your `KUBECONFIG` and / or `kubectl` tool to point at a the new cluster.
89+
90+
Check this with:
91+
92+
```sh
93+
kubectl config get-contexts
94+
```
95+
96+
#### 2) Create a local cluster for development / testing
7597

7698
For testing you can create a local cluster using `kind`, `minikube` or Docker Desktop. This is how you can install `kind` to setup a local cluster in a Docker container.
7799

78100
First install [Go 1.10 or newer](https://golang.org/dl/)
79101

102+
* Set your `GOPATH` if you don't already have one
103+
104+
```bash
105+
export GOPATH=$HOME/go
106+
```
107+
108+
* Download and build `kind`
109+
80110
Now use `go get` to install `kind` and point your `KUBECONFIG` variable at the new cluster.
81111

82112
```bash
@@ -88,90 +118,125 @@ export KUBECONFIG=$(kind get kubeconfig-path --name 1)
88118

89119
### Get `ofc-bootstrap`
90120

91-
* Set your `GOPATH` if you don't already have one
92-
93-
```bash
94-
export GOPATH=$HOME/go
95-
```
121+
Now clone the GitHub repository, download the binary release and start customising your own `init.yaml` file.
96122

97-
* Clone the GitHub repo
123+
* Clone the `ofc-bootstrap` repository
98124

99125
```bash
100126
mkdir -p $GOPATH/src/github.com/openfaas-incubator
101127
cd $GOPATH/src/github.com/openfaas-incubator/
102128
git clone https://github.com/openfaas-incubator/ofc-bootstrap
103129
```
104130

105-
* Download the latest binary release from GitHub
131+
* Download the latest `ofc-bootstrap` binary release from GitHub
106132

107-
Download [ofc-boostrap](https://github.com/openfaas-incubator/ofc-bootstrap/releases) from the GitHub releases page and move it to `/usr/local/bin/`. You may also need to run `chmod +x /usr/local/bin/ofc-bootstrap`.
133+
Either run the following script, or follow the manual steps below.
134+
135+
```sh
136+
# Download and move to /usr/local/bin
137+
curl -sLSf https://raw.githubusercontent.com/openfaas-incubator/ofc-bootstrap/master/get.sh | \
138+
sudo sh
139+
140+
# Or, download and move manually
141+
curl -sLSf https://raw.githubusercontent.com/openfaas-incubator/ofc-bootstrap/master/get.sh | \
142+
sh
143+
```
144+
145+
Manual steps:
146+
147+
Download [ofc-boostrap](https://github.com/openfaas-incubator/ofc-bootstrap/releases) from the GitHub releases page and move it to `/usr/local/bin/`.
148+
149+
You may also need to run `chmod +x /usr/local/bin/ofc-bootstrap`.
150+
151+
For Linux use the binary with no suffix, for MacOS, use the binary with the `-darwin` suffix.
108152

109153
### Create your own `init.yaml`
110154

155+
You will need to read the whole `init.yaml` file carefully including all the comments. Each setting is described with a comment to help you decide what value to set.
156+
111157
First run `cp example.init.yaml init.yaml` to get your own `init.yaml` file.
112158

113159
#### Set the `root_domain`
114160

115161
Edit `root_domain` and add your own domain i.e. `example.com` or `ofc.example.com`
116162

117-
See the appendix for how to set up DNS A records for this, or edit your hosts file later.
163+
If you picked a root domain of `example.com`, then your URLs would correspond to the following:
164+
165+
* `system.example.com`
166+
* `auth.system.example.com`
167+
* `*.example.com`
168+
169+
After the installation has completed in a later step, you will need to create DNS A records with your DNS provider. You don't need to create these records now.
118170

119171
#### Prepare your Docker registry
120172

121-
Log into your Docker registry or the Docker Hub:
173+
Log into your own private Docker registry, or the [Docker Hub](https://hub.docker.com):
122174

123175
* Open the Docker for Mac/Windows settings and uncheck "store my password securely" / "in a keychain"
124176
* Run `docker login` to populate `~/.docker/config.json` - this will be used to configure your Docker registry or Docker Hub account for functions.
125177

126-
#### Pick your SCM
178+
#### Pick your Source Control Management (SCM)
127179

128-
Choose SCM between GitHub and GitLab, by setting `scm: github` or `scm: gitlab`
180+
Choose SCM between GitHub.com or GitLab self-hosted, by setting `scm: github` or `scm: gitlab`
129181

130182
#### Setup your GitHub or GitLab integration
131183

132184
Setup the GitHub / GitLab App and OAuth App
133185

186+
Your SCM will need to send webhooks to OpenFaaS Cloud's github-event or gitlab-event function for CI/CD. This is protected by a confidential secret called a *Webhook secret*. You can leave the field blank to have one generated for you, or you can set your own in `init.yaml`.
187+
134188
* For GitHub create a GitHub App and download the private key file
135189
* Read the docs for how to [configure your GitHub App](https://docs.openfaas.com/openfaas-cloud/self-hosted/github/)
190+
* Leave the `value:` for `github-webhook-secret` blank, or set your own password
136191
* Update `init.yaml` where you see the `### User-input` section including your GitHub App's ID, Webhook secret and the path to its private key
192+
137193
* For GitLab create a System Hook
138-
* Update the `### User-input` section including your System Hook's API Token and Webhook secret
194+
* Leave the `value:` for `gitlab-webhook-secret` blank, or set your own password
195+
* Update the `### User-input` section including your System Hook's API Token and *Webhook secret*
139196
* Create your GitHub / GitLab OAuth App which is used for logging in to the dashboard
140197
* For GitLab update `init.yaml` with your `gitlab_instance`
141198

142199
#### Setup your access control
143200

144-
Create your own GitHub repo with a CUSTOMERS ACL file
201+
Access control to your OFC is controlled by a text file containing a list of valid usernames.
202+
203+
Create a new GitHub repository with a CUSTOMERS ACL file. This repository should not contain any code or functions.
145204

146205
* Create a new public GitHub repo
147206
* Add a file named `CUSTOMERS` and place each username or GitHub org you will use on a separate line
148-
* Add the GitHub RAW CDN URL into the init.yaml file
207+
* Add the GitHub RAW CDN URL into the `init.yaml` file
149208

150209
#### Decide if you're using a LoadBalancer
151210

152-
It can be set up on a public cloud provider with a managed Kubernetes offering, where a `LoadBalancer` is available. If you are deploying to a cloud or Kubernetes cluster where the type `LoadBalancer` is unavailable then you will need to change `ingress: loadbalancer` to `ingress: host` in `init.yaml`. This will provision Nginx as a `DaemonSet` exposed on port `80` and `443`.
211+
If you are using a public cloud offering and you know that they can offer a `LoadBalancer`, then the `ingress:` field will be set to `loadbalancer` which is the default.
212+
213+
If you are deploying to a cloud or Kubernetes cluster where the type `LoadBalancer` is unavailable then you will need to change `ingress: loadbalancer` to `ingress: host` in `init.yaml`. Nginx will be configured as a `DaemonSet` exposed on port `80` and `443` on each node in your cluster. It is recommended that you create a DNS mapping between a chosen name and the IP of each node.
153214

154215
> Note: it is a common error for new users to try to access the dashboard using the IP address of the load-balancer.
155216
> You must use the DNS name for the dashboard: i.e. `system.example.com/dashboard/username`
156217
157-
#### Use authz (optional)
218+
#### Use authz (recommended)
219+
220+
> This feature is optional, but highly recommended
158221
159222
If you'd like to restrict who can log in to just those who use a GitHub account then create a GitHub OAuth App.
160223

161224
Enable `auth` and fill out the OAuth App `client_id`. Configure `of-client-secret` with the OAuth App Client Secret.
162225
For GitLab set your `oauth_provider_base_url`.
163226

164-
#### Use TLS (optional)
227+
#### Use TLS (recommended)
228+
229+
> This feature is optional, but highly recommended
165230
166231
We can automatically provision TLS certificates for your OpenFaaS Cloud cluster using the DNS01 challenge.
167232

168233
Pick between the following providers for the DNS01 challenge:
169234

235+
* DigitalOcean DNS
170236
* Google Cloud DNS
171237
* AWS Route53
172-
* DigitalOcean DNS via cert-manager 0.6.0
173238

174-
> Note: At time of writing DigitalOcean are offering free management of DNS.
239+
> Note: At time of writing DigitalOcean are offering management of DNS records for free.
175240
176241
Configure or comment out as required in the relevant section.
177242

@@ -186,60 +251,45 @@ In order to enable TLS, edit the following configuration:
186251

187252
You can start out by using the Staging issuer, then switch to the production issuer.
188253

189-
* Set `issuer_type: "staging"`
190-
* Run ofc-bootstrap with the instructions bellow
191-
192-
When you want to switch to the Production issuer do the following:
254+
* Set `issuer_type: "production"` (recommended) or `issuer_type: "staging"` (for testing)
193255

194-
Flush out the staging certificates and orders
195-
196-
```sh
197-
kubectl delete certificates --all -n openfaas
198-
kubectl delete secret -n openfaas -l="certmanager.k8s.io/certificate-name"
199-
kubectl delete order -n openfaas --all
200-
```
201-
202-
Now update the staging references to "prod":
203-
204-
```sh
205-
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-ingress-ingress-wildcard.yaml
206-
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-ingress-ingress.yaml
207-
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-tls-auth-domain-cert.yml
208-
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-tls-wildcard-domain-cert.yml
209-
```
210-
211-
Now create the new ingress and certificates:
212-
213-
```sh
214-
kubectl apply -f ./tmp/generated-ingress-ingress-wildcard.yaml
215-
kubectl apply -f ./tmp/generated-ingress-ingress.yaml
216-
kubectl apply -f ./tmp/generated-tls-auth-domain-cert.yml
217-
kubectl apply -f ./tmp/generated-tls-wildcard-domain-cert.yml
218-
```
256+
> Note if you want to switch from the staging TLS certificates to production certificates, see the appendix.
219257
220258
#### Enable dockerfile language support (optional)
259+
221260
If you are planning on building functions using the `dockerfile` template you need to set `enable_dockerfile_lang: true`.
222261

262+
When this value is set to false, your users can only use your recommended set of templates.
263+
223264
#### Enable scaling to zero
265+
224266
If you want your functions to scale to zero then you need to set `scale_to_zero: true`.
225267

226268
#### Toggle network policies
227269

228-
Network policies restriction for the openfaas and openfaas-fn namespaces are applied by default. If you would like to remove that restriction set `network_policies: false`.
270+
Network policies restriction for the `openfaas` and `openfaas-fn` namespaces are applied by default.
229271

230272
When deployed, network policies restrict communication so that functions cannot talk to the core OpenFaaS components in the `openfaas` namespace. They also prevent functions from invoking each other directly. It is recommended to enable this feature.
231273

232-
### Run the `ofc-bootstrap`
274+
If you would like to remove that restriction set `network_policies: false`.
275+
276+
### Run `ofc-bootstrap`
277+
278+
If you are now ready, you can run the `ofc-bootstrap` tool:
233279

234280
```bash
235281
cd $GOPATH/src/github.com/openfaas-incubator/ofc-bootstrap
236282

237283
./ofc-bootstrap -yaml=init.yaml
238284
```
239285

286+
Pay attention to the output from the tool and watch out for any errors that may come up. You will need to store the logs and share them with the maintainers if you run into any issues.
287+
240288
### Finish the configuration
241289

242-
If you get anything wrong, don't worry you can use the `./scripts/reset.sh` file to remove all the components. Then edit `init.yaml` and start over. Be careful running this script and make 100% sure that you are pointing at the correct cluster.
290+
If you get anything wrong, don't worry you can use the `./scripts/reset.sh` file to remove all the components. Then edit `init.yaml` and start over.
291+
292+
> Note: Be careful running this script and make 100% sure that you are pointing at the correct cluster.
243293
244294
#### Configure DNS
245295

@@ -256,10 +306,13 @@ When ofc-bootstrap has completed and you know the IP of your LoadBalancer:
256306
Now over on GitHub / GitLab enter the URL for webhooks:
257307

258308
GitHub:
309+
259310
```
260311
http://system.example.com/github-event
261312
```
313+
262314
GitLab:
315+
263316
```
264317
http://system.example.com/gitlab-event
265318
```
@@ -268,13 +321,23 @@ For more details see the [GitLab instructions](https://github.com/openfaas/openf
268321

269322
Then you need to enter the Webhook secret that was generated during the bootstrap process. Run the following commands to extract and decode it:
270323

271-
```echo $(kubectl get secret -n openfaas-fn github-webhook-secret -o jsonpath="{.data.github-webhook-secret}" | base64 --decode; echo)```
324+
```sh
325+
export SECRET=$(kubectl get secret -n openfaas-fn github-webhook-secret -o jsonpath="{.data.github-webhook-secret}" | base64 --decode; echo)
326+
327+
echo "Your webhook secret is: $SECRET"
328+
```
272329

273330
Open the Github App UI and paste in the value into the "Webhook Secret" field.
274331

275332
### Smoke-test
276333

277-
Now run a smoke-test to check the dashboard shows correctly and that you can trigger a successful build.
334+
Now check the following and run a smoke test:
335+
336+
* DNS is configured to the correct IP
337+
* Check TLS certificates are issued as expected
338+
* Check that you can trigger a build
339+
* Check that your build is pushing images to your registry or the Docker Hub
340+
* Check that your endpoint can be accessed
278341

279342
#### View your dashboard
280343

@@ -290,6 +353,8 @@ Just replace `<username>` with your GitHub account.
290353

291354
Now you can install your GitHub app on a repo, run `faas-cli new` and then rename the YAML file to `stack.yml` and do a `git push`. Your OpenFaaS Cloud cluster will build and deploy the functions found in that GitHub repo.
292355

356+
If you're unsure how to do this, then you could use the [QuickStart for the Community Cluster](https://github.com/openfaas/community-cluster/tree/master/docs), just remember to change the URLs to your own cluster.
357+
293358
### Something went wrong?
294359

295360
If you think that everything is set up correctly but want to troubleshoot then head over to the GitHub App webpage and click "Advanced" - here you can find each request/response from the GitHub push events. You can resend them or view any errors.
@@ -298,6 +363,30 @@ If you think that everything is set up correctly but want to troubleshoot then h
298363

299364
Follow the detailed [Troubleshooting Guide](https://docs.openfaas.com/openfaas-cloud/self-hosted/troubleshoot/#still-not-working) in the OpenFaaS docs. If you are still stuck after that please chat with us in #openfas-cloud on Slack.
300365

366+
#### Access your OpenFaaS UI or API
367+
368+
OpenFaaS Cloud abstracts away the core OpenFaaS UI and API. Your new API is driven by pushing changes into a Git repository, rather than running commands, or browsing a UI.
369+
370+
You may still want access to your OpenFaaS cluster, in which case run the following:
371+
372+
```sh
373+
# Fetch your generated admin password:
374+
375+
export PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
376+
echo -n $PASSWORD | faas-cli login --username admin --password-stdin
377+
378+
# Open a tunnel to the gateway using `kubectl`:
379+
kubectl port-forward -n openfaas deploy/gateway 31112:8080 &
380+
381+
# Point the CLI to the tunnel:
382+
export OPENFAAS_URL=http://127.0.0.1:31112
383+
384+
# Log in:
385+
echo -n $PASSWORD | faas-cli login --username admin --password-stdin
386+
```
387+
388+
At this point you can also view your UI dashboard at: http://127.0.0.1:31112
389+
301390
### Invite your team
302391

303392
For each user or org you want to enroll into your OpenFaaS Cloud edit the CUSTOMERS ACL file and add their username on a new line. For example if I wanted the user `alexellis` and the org `openfaas` to host git repos containing functions:
@@ -307,8 +396,39 @@ openfaas
307396
alexellis
308397
```
309398

399+
#### Switch from staging to production TLS
400+
401+
When you want to switch to the Production issuer from staging do the following:
402+
403+
Flush out the staging certificates and orders
404+
405+
```sh
406+
kubectl delete certificates --all -n openfaas
407+
kubectl delete secret -n openfaas -l="certmanager.k8s.io/certificate-name"
408+
kubectl delete order -n openfaas --all
409+
```
410+
411+
Now update the staging references to "prod":
412+
413+
```sh
414+
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-ingress-ingress-wildcard.yaml
415+
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-ingress-ingress.yaml
416+
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-tls-auth-domain-cert.yml
417+
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-tls-wildcard-domain-cert.yml
418+
```
419+
420+
Now create the new ingress and certificates:
421+
422+
```sh
423+
kubectl apply -f ./tmp/generated-ingress-ingress-wildcard.yaml
424+
kubectl apply -f ./tmp/generated-ingress-ingress.yaml
425+
kubectl apply -f ./tmp/generated-tls-auth-domain-cert.yml
426+
kubectl apply -f ./tmp/generated-tls-wildcard-domain-cert.yml
427+
```
428+
310429
### Join us on Slack
311430

312431
Got questions, comments or suggestions?
313432

314433
Join the team and community over on [Slack](https://docs.openfaas.com/community)
434+

0 commit comments

Comments
 (0)