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

Commit d9987a4

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 dde768f commit d9987a4

File tree

4 files changed

+52
-74
lines changed

4 files changed

+52
-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

+40-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+
175+
if cloudOnly {
176+
err := cloudComponentsInstall(plan); 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,17 @@ 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+
398+
func cloudComponentsInstall(plan types.Plan) error {
399+
cloneErr := cloneCloudComponents(plan.OpenFaaSCloudVersion)
376400
if cloneErr != nil {
377401
return cloneErr
378402
}
@@ -382,11 +406,10 @@ func process(plan types.Plan, prefs InstallPreferences, additionalPaths []string
382406
return ofcValuesErr
383407
}
384408

385-
deployErr := deployCloudComponents(plan, additionalPaths)
409+
deployErr := deployCloudComponents(plan)
386410
if deployErr != nil {
387411
return deployErr
388412
}
389-
390413
return nil
391414
}
392415

@@ -431,13 +454,10 @@ func writeOFCValuesYaml(plan types.Plan) error {
431454
ofcOptions.TLS.Enabled = false
432455
}
433456

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
457+
ofcOptions.Customers.CustomersSecret = plan.CustomersSecret
458+
ofcOptions.Customers.URL = plan.CustomersURL
459+
if len(plan.CustomersURL) == 0 && !plan.CustomersSecret {
460+
return errors.New("unable to continue without a customers secret or url")
441461
}
442462

443463
ofcOptions.Global.EnableECR = plan.EnableECR
@@ -524,7 +544,7 @@ func createFunctionsAuth() error {
524544
return nil
525545
}
526546

527-
func installIngressController(ingress string, additionalPaths []string) error {
547+
func installIngressController(ingress string) error {
528548
log.Println("Creating Ingress Controller")
529549

530550
var env []string
@@ -572,7 +592,7 @@ func installSealedSecrets() error {
572592
return nil
573593
}
574594

575-
func installOpenfaas(scaleToZero, ingressOperator bool, additionalPaths []string) error {
595+
func installOpenfaas(scaleToZero, ingressOperator bool) error {
576596
log.Println("Creating OpenFaaS")
577597

578598
task := execute.ExecTask{
@@ -725,7 +745,7 @@ func certManagerReady() bool {
725745
return res.Stdout == "True"
726746
}
727747

728-
func cloneCloudComponents(tag string, additionalPaths []string) error {
748+
func cloneCloudComponents(tag string) error {
729749
task := execute.ExecTask{
730750
Command: "./scripts/clone-cloud-components.sh",
731751
Shell: true,
@@ -735,17 +755,15 @@ func cloneCloudComponents(tag string, additionalPaths []string) error {
735755
StreamStdio: true,
736756
}
737757

738-
res, err := task.Execute()
758+
_, err := task.Execute()
739759
if err != nil {
740760
return err
741761
}
742762

743-
fmt.Println(res)
744-
745763
return nil
746764
}
747765

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

750768
authEnv := ""
751769
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"

0 commit comments

Comments
 (0)