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

Commit 508bb16

Browse files
committed
Allow cloud components only to be upgraded
This should allow passing the --update-cloud flag which will only upgrade/install the OFC core components (chart AND stack.yaml etc) This also fixes the ClusterIssuer -> Issuer move so the secrets for DNS need to be in the issuer namespace Signed-off-by: Alistair Hey <[email protected]>
1 parent eb7d9ed commit 508bb16

13 files changed

+408
-74
lines changed

USER_GUIDE.md

+7-47
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ You will need admin access to a Kubernetes cluster, some CLI tooling and a GitHu
44

55
## Pre-reqs
66

7-
This tool automates the installation of OpenFaaS Cloud on Kubernetes. Before starting you will need to install some tools and then create either a local or remote cluster.
7+
This tool automates the installation of OpenFaaS Cloud on Kubernetes. Before starting, you will need to install some tools and then create either a local or remote cluster.
88

99
For your cluster the following specifications are recommended:
1010

@@ -513,28 +513,8 @@ At this point you can also view your UI dashboard at: http://127.0.0.1:31112
513513

514514
## Re-deploy the OpenFaaS Cloud functions (advanced)
515515

516-
If you run the step above `Access your OpenFaaS UI or API`, then you can edit settings for OpenFaaS Cloud and redeploy your functions. This is an advanced step.
517-
518-
```
519-
cd tmp/openfaas-cloud/
520-
521-
# Edit stack.yml
522-
# Edit github.yml or gitlab.yml
523-
# Edit gateway_config.yml
524-
# Edit buildshiprun_limits.yml
525-
526-
# Edit aws.yml if you want to change AWS ECR settings such as the region
527-
528-
# Update all functions
529-
faas-cli deploy -f stack.yml
530-
531-
532-
# Update AWS ECR functions if needed
533-
faas-cli deploy -f aws.yml
534-
535-
# Update a single function, such as "buildshiprun"
536-
faas-cli deploy -f stack.yml --filter=buildshiprun
537-
```
516+
Run `ofc-bootstrap` passing `--update-cloud` as a flag.
517+
This will re-deploy the ofc helm chart using the new settings in init.yaml
538518

539519
## Invite your team
540520

@@ -549,29 +529,9 @@ alexellis
549529

550530
When you want to switch to the Production issuer from staging do the following:
551531

552-
Flush out the staging certificates and orders
532+
Update the staging setting in init.yaml to "prod" and re-run `ofc-bootstrap` passing `--update-cloud` as a flag.
533+
This will re-deploy the ofc helm chart using the new settings.
553534

554-
```sh
555-
kubectl delete certificates --all -n openfaas
556-
kubectl delete secret -n openfaas -l="cert-manager.io/certificate-name"
557-
kubectl delete order -n openfaas --all
535+
```sh
536+
ofc-bootstrap apply -f init.yaml --update-cloud
558537
```
559-
560-
Now update the staging references to "prod":
561-
562-
```sh
563-
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-ingress-ingress-wildcard.yaml
564-
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-ingress-ingress-auth.yaml
565-
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-tls-auth-domain-cert.yml
566-
sed -i '' s/letsencrypt-staging/letsencrypt-prod/g ./tmp/generated-tls-wildcard-domain-cert.yml
567-
```
568-
569-
Now create the new ingress and certificates:
570-
571-
```sh
572-
kubectl apply -f ./tmp/generated-ingress-ingress-wildcard.yaml
573-
kubectl apply -f ./tmp/generated-ingress-ingress-auth.yaml
574-
kubectl apply -f ./tmp/generated-tls-auth-domain-cert.yml
575-
kubectl apply -f ./tmp/generated-tls-wildcard-domain-cert.yml
576-
```
577-

cmd/apply.go

+39-22
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func init() {
3434
applyCmd.Flags().Bool("skip-minio", false, "Skip Minio installation")
3535
applyCmd.Flags().Bool("skip-create-secrets", false, "Skip creating secrets")
3636
applyCmd.Flags().Bool("print-plan", false, "Print merged plan and exit")
37+
applyCmd.Flags().Bool("update-cloud", false, "set to true to only upgrade OFC components")
3738
}
3839

3940
var applyCmd = &cobra.Command{
@@ -158,15 +159,28 @@ func runApplyCommandE(command *cobra.Command, _ []string) error {
158159
os.MkdirAll("tmp", 0700)
159160
ioutil.WriteFile("tmp/go.mod", []byte("\n"), 0700)
160161

161-
fmt.Fprint(os.Stdout, "Validating registry credentials file")
162+
fmt.Fprint(os.Stdout, "Validating registry credentials file\n")
162163

163164
registryAuthErr := validateRegistryAuth(plan.Registry, plan.Secrets, plan.EnableECR)
164165
if registryAuthErr != nil {
165166
fmt.Fprint(os.Stderr, "error with registry credentials file. Please ensure it has been created correctly")
166167
}
167168

169+
cloudOnly, err := command.Flags().GetBool("update-cloud")
170+
if err != nil {
171+
return err
172+
}
173+
174+
if cloudOnly {
175+
err := cloudComponentsInstall(plan)
176+
if err != nil {
177+
return err
178+
}
179+
return nil
180+
}
181+
168182
start := time.Now()
169-
err = process(plan, prefs, additionalPaths)
183+
err = process(plan, prefs)
170184
done := time.Since(start)
171185

172186
if err != nil {
@@ -264,7 +278,7 @@ func filesExists(files []types.FileSecret) error {
264278
return nil
265279
}
266280

267-
func process(plan types.Plan, prefs InstallPreferences, additionalPaths []string) error {
281+
func process(plan types.Plan, prefs InstallPreferences) error {
268282

269283
if plan.OpenFaaSCloudVersion == "" {
270284
plan.OpenFaaSCloudVersion = "master"
@@ -297,7 +311,7 @@ func process(plan types.Plan, prefs InstallPreferences, additionalPaths []string
297311
return err
298312
}
299313

300-
installIngressErr := installIngressController(plan.Ingress, additionalPaths)
314+
installIngressErr := installIngressController(plan.Ingress)
301315
if installIngressErr != nil {
302316
log.Println(installIngressErr.Error())
303317
return installIngressErr
@@ -332,7 +346,7 @@ func process(plan types.Plan, prefs InstallPreferences, additionalPaths []string
332346
log.Println(functionAuthErr.Error())
333347
}
334348

335-
ofErr := installOpenfaas(plan.ScaleToZero, plan.IngressOperator, additionalPaths)
349+
ofErr := installOpenfaas(plan.ScaleToZero, plan.IngressOperator)
336350
if ofErr != nil {
337351
log.Println(ofErr)
338352
}
@@ -372,7 +386,16 @@ func process(plan types.Plan, prefs InstallPreferences, additionalPaths []string
372386
}
373387
}
374388

375-
cloneErr := cloneCloudComponents(plan.OpenFaaSCloudVersion, additionalPaths)
389+
err := cloudComponentsInstall(plan)
390+
if err != nil {
391+
return err
392+
}
393+
394+
return nil
395+
}
396+
397+
func cloudComponentsInstall(plan types.Plan) error {
398+
cloneErr := cloneCloudComponents(plan.OpenFaaSCloudVersion)
376399
if cloneErr != nil {
377400
return cloneErr
378401
}
@@ -382,11 +405,10 @@ func process(plan types.Plan, prefs InstallPreferences, additionalPaths []string
382405
return ofcValuesErr
383406
}
384407

385-
deployErr := deployCloudComponents(plan, additionalPaths)
408+
deployErr := deployCloudComponents(plan)
386409
if deployErr != nil {
387410
return deployErr
388411
}
389-
390412
return nil
391413
}
392414

@@ -431,13 +453,10 @@ func writeOFCValuesYaml(plan types.Plan) error {
431453
ofcOptions.TLS.Enabled = false
432454
}
433455

434-
if plan.CustomersSecret {
435-
ofcOptions.Customers.CustomersSecret = true
436-
} else {
437-
if len(plan.CustomersURL) == 0 {
438-
return errors.New("unable to continue without a customers secret or url")
439-
}
440-
ofcOptions.Customers.URL = plan.CustomersURL
456+
ofcOptions.Customers.CustomersSecret = plan.CustomersSecret
457+
ofcOptions.Customers.URL = plan.CustomersURL
458+
if len(plan.CustomersURL) == 0 && !plan.CustomersSecret {
459+
return errors.New("unable to continue without a customers secret or url")
441460
}
442461

443462
ofcOptions.Global.EnableECR = plan.EnableECR
@@ -524,7 +543,7 @@ func createFunctionsAuth() error {
524543
return nil
525544
}
526545

527-
func installIngressController(ingress string, additionalPaths []string) error {
546+
func installIngressController(ingress string) error {
528547
log.Println("Creating Ingress Controller")
529548

530549
var env []string
@@ -572,7 +591,7 @@ func installSealedSecrets() error {
572591
return nil
573592
}
574593

575-
func installOpenfaas(scaleToZero, ingressOperator bool, additionalPaths []string) error {
594+
func installOpenfaas(scaleToZero, ingressOperator bool) error {
576595
log.Println("Creating OpenFaaS")
577596

578597
task := execute.ExecTask{
@@ -725,7 +744,7 @@ func certManagerReady() bool {
725744
return res.Stdout == "True"
726745
}
727746

728-
func cloneCloudComponents(tag string, additionalPaths []string) error {
747+
func cloneCloudComponents(tag string) error {
729748
task := execute.ExecTask{
730749
Command: "./scripts/clone-cloud-components.sh",
731750
Shell: true,
@@ -735,17 +754,15 @@ func cloneCloudComponents(tag string, additionalPaths []string) error {
735754
StreamStdio: true,
736755
}
737756

738-
res, err := task.Execute()
757+
_, err := task.Execute()
739758
if err != nil {
740759
return err
741760
}
742761

743-
fmt.Println(res)
744-
745762
return nil
746763
}
747764

748-
func deployCloudComponents(plan types.Plan, additionalPaths []string) error {
765+
func deployCloudComponents(plan types.Plan) error {
749766

750767
authEnv := ""
751768
if plan.EnableOAuth {

example.init.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ secrets:
104104
value_from: "~/Downloads/do-access-token"
105105
filters:
106106
- "do_dns01"
107-
namespace: "cert-manager"
107+
namespace: "openfaas"
108108

109109
## Use Google Cloud DNS
110110
### Create a service account for DNS management and export it
@@ -114,7 +114,7 @@ secrets:
114114
value_from: "~/Downloads/service-account.json"
115115
filters:
116116
- "gcp_dns01"
117-
namespace: "cert-manager"
117+
namespace: "openfaas"
118118

119119
## Use Route 53
120120
### Create role and download its secret access key
@@ -124,7 +124,7 @@ secrets:
124124
value_from: "~/Downloads/route53-secret-access-key"
125125
filters:
126126
- "route53_dns01"
127-
namespace: "cert-manager"
127+
namespace: "openfaas"
128128

129129
## Use Cloudflare
130130
### Create role and download its secret access key
@@ -134,7 +134,7 @@ secrets:
134134
value_from: "~/Downloads/cloudflare-secret-access-key"
135135
filters:
136136
- "cloudflare_dns01"
137-
namespace: "cert-manager"
137+
namespace: "openfaas"
138138

139139
# Used by Buildkit to push images to your registry
140140
- name: "registry-secret"

scripts/clone-cloud-components.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
rm -rf ./tmp/openfaas-cloud
44

5-
git clone https://github.com/openfaas/openfaas-cloud ./tmp/openfaas-cloud
5+
git clone https://github.com/openfaas/openfaas-cloud --depth 1 ./tmp/openfaas-cloud
66

77
cd ./tmp/openfaas-cloud
88
echo "Checking out openfaas/openfaas-cloud@$TAG"

templates/edge-auth-dep.yml

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: edge-auth
5+
namespace: openfaas
6+
labels:
7+
app: edge-auth
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: edge-auth
13+
template:
14+
metadata:
15+
annotations:
16+
prometheus.io.scrape: "false"
17+
labels:
18+
app: edge-auth
19+
spec:
20+
volumes:
21+
- name: jwt-private-key
22+
secret:
23+
secretName: jwt-private-key
24+
- name: jwt-public-key
25+
secret:
26+
secretName: jwt-public-key
27+
- name: of-client-secret
28+
secret:
29+
secretName: of-client-secret
30+
- name: of-customers
31+
secret:
32+
secretName: of-customers
33+
containers:
34+
- name: edge-auth
35+
image: openfaas/edge-auth:0.7.1
36+
imagePullPolicy: Always
37+
livenessProbe:
38+
httpGet:
39+
path: /healthz
40+
port: 8080
41+
initialDelaySeconds: 2
42+
periodSeconds: 10
43+
timeoutSeconds: 2
44+
env:
45+
- name: port
46+
value: "8080"
47+
- name: oauth_client_secret_path
48+
value: "/var/secrets/of-client-secret/of-client-secret"
49+
- name: public_key_path
50+
value: "/var/secrets/public/key.pub"
51+
- name: private_key_path
52+
value: "/var/secrets/private/key"
53+
- name: customers_path
54+
value: "{{.OFCustomersSecretPath}}"
55+
# Update for your configuration:
56+
- name: client_secret # this can also be provided via a secret named of-client-secret
57+
value: ""
58+
- name: client_id
59+
value: "{{.ClientId}}"
60+
- name: oauth_provider_base_url
61+
value: "{{.OAuthProviderBaseURL}}"
62+
- name: oauth_provider
63+
value: "{{.OAuthProvider}}"
64+
# Local test config
65+
# - name: external_redirect_domain
66+
# value: "http://auth.system.gw.io:8081"
67+
# - name: cookie_root_domain
68+
# value: ".system.gw.io"
69+
70+
# Community cluster config:
71+
- name: external_redirect_domain
72+
value: "{{.Scheme}}://auth.system.{{.RootDomain}}"
73+
- name: cookie_root_domain
74+
value: ".system.{{.RootDomain}}"
75+
# This is a default and can be overridden
76+
- name: customers_url
77+
value: "{{.CustomersURL}}"
78+
- name: write_debug
79+
value: "false"
80+
# Config for setting the cookie to "secure", set this to true for HTTPS only OAuth
81+
- name: secure_cookie
82+
value: "{{.TLSEnabled}}"
83+
84+
85+
ports:
86+
- containerPort: 8080
87+
protocol: TCP
88+
volumeMounts:
89+
- name: jwt-private-key
90+
readOnly: true
91+
mountPath: "/var/secrets/private/"
92+
- name: jwt-public-key
93+
readOnly: true
94+
mountPath: "/var/secrets/public"
95+
- name: of-client-secret
96+
readOnly: true
97+
mountPath: "/var/secrets/of-client-secret"
98+
- name: of-customers
99+
readOnly: true
100+
mountPath: "/var/secrets/of-customers"

0 commit comments

Comments
 (0)