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

Commit

Permalink
Mount public key to dashboard as secret
Browse files Browse the repository at this point in the history
Signed-off-by: Brandon Wilson <[email protected]>
  • Loading branch information
wilsonianb authored and alexellis committed Dec 14, 2020
1 parent 5b51d3b commit c4da635
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
17 changes: 8 additions & 9 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,29 +362,28 @@ func process(plan types.Plan, prefs InstallPreferences, additionalPaths []string
}
}

var pubCert string
fmt.Println("Creating stack.yml")

planErr := stack.Apply(plan)
if planErr != nil {
log.Println(planErr)
}

if !prefs.SkipSealedSecrets {
sealedSecretsErr := installSealedSecrets()
if sealedSecretsErr != nil {
log.Println(sealedSecretsErr)
return sealedSecretsErr
}

pubCert = exportSealedSecretPubCert()
pubCert := exportSealedSecretPubCert()
writeErr := ioutil.WriteFile("tmp/pubcert.pem", []byte(pubCert), 0700)
if writeErr != nil {
log.Println(writeErr)
return writeErr
}
}

fmt.Println("Creating stack.yml")

planErr := stack.Apply(plan, pubCert)
if planErr != nil {
log.Println(planErr)
}

cloneErr := cloneCloudComponents(plan.OpenFaaSCloudVersion, additionalPaths)
if cloneErr != nil {
return cloneErr
Expand Down
5 changes: 1 addition & 4 deletions pkg/stack/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"html/template"
"io/ioutil"
"os"
"strings"

"github.com/openfaas/ofc-bootstrap/pkg/types"
)
Expand Down Expand Up @@ -56,11 +55,10 @@ type dashboardConfig struct {
Scheme string
GitHubAppUrl string
GitLabInstance string
PublicKey string
}

// Apply creates `templates/gateway_config.yml` to be referenced by stack.yml
func Apply(plan types.Plan, pubCert string) error {
func Apply(plan types.Plan) error {
scheme := "http"
if plan.TLS {
scheme += "s"
Expand Down Expand Up @@ -118,7 +116,6 @@ func Apply(plan types.Plan, pubCert string) error {
Scheme: scheme,
GitHubAppUrl: gitHubAppUrl,
GitLabInstance: gitLabInstance,
PublicKey: strings.ReplaceAll(pubCert, "\n", "\n "),
})
if dashboardConfigErr != nil {
return dashboardConfigErr
Expand Down
3 changes: 3 additions & 0 deletions scripts/deploy-cloud-components.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ if [ "$ENABLE_AWS_ECR" = "true" ] ; then
faas-cli deploy -f ./aws.yml
fi

kubectl create secret generic sealedsecrets-public-key -n openfaas-fn --from-file=../pub-cert.pem \
--dry-run=client -o yaml | kubectl apply -f -

TAG=0.14.4 faas-cli deploy -f ./dashboard/stack.yml

sleep 2
Expand Down
1 change: 1 addition & 0 deletions scripts/export-sealed-secret-pubcert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ then
chmod +x /tmp/kubeseal
fi

/tmp/kubeseal --version
/tmp/kubeseal --fetch-cert --controller-name=ofc-sealedsecrets-sealed-secrets > tmp/pub-cert.pem && \
cat tmp/pub-cert.pem
3 changes: 0 additions & 3 deletions templates/dashboard_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ environment:
github_app_url: {{.GitHubAppUrl}}
# Public URL for your GitLab instance
gitlab_url: {{.GitLabInstance}}
# SealedSecrets public key
public_key: |
{{.PublicKey}}

0 comments on commit c4da635

Please sign in to comment.