Skip to content

Use stringData when declaring Secrets

Summary

As noted in !401 (comment 860378369), we should switch to using stringData instead of data when populating the cert-manager secrets in this repository. Using stringData will remove the need to base64-encode values before rendering them into Secret manifest, which has proven to be error-prone.

Before:

---
apiVersion: v1
kind: Secret
metadata:
  name: gitlab-dns-credentials
  namespace: default
type: Opaque
data:
  credentials.json: 'GOOGLE_CREDENTIALS'
local google_credentials_json="$(echo -n $GOOGLE_CREDENTIALS | base64 -w 0)"
...
template_data="$(echo "${template_data//GOOGLE_CREDENTIALS/$google_credentials_json}")"

After:

---
apiVersion: v1
kind: Secret
metadata:
  name: gitlab-dns-credentials
  namespace: default
type: Opaque
stringData:
  credentials.json: 'GOOGLE_CREDENTIALS'
template_data="$(echo "${template_data//GOOGLE_CREDENTIALS/$GOOGLE_CREDENTIALS}")"

Relates to gitlab-org/charts/gitlab#2843 (closed)

We may want to look into doing this for our other repositories as well.

Edited by Dustin Collins