Search documentation
karat

+

K

Reference and use secrets

Reference secrets

After creating a secret, you can reference the secret in the Entity config, located in the Config tab of the Entity page.

You can reference the secret using the following syntax:

{{ preprocess .Values.apollo.secrets.<secret-name>.k8sSecretName }}

You should substitute <secret-name> with the Kubernetes secret name, which is the Secret name that you defined in Apollo. Here is an example invocation:

{{ preprocess .Values.apollo.secrets.examplesecret.k8sSecretName }}

In the above example, examplesecret is the Secret name.

Use secrets

You can use secrets that you created in Apollo to create a volume mount, define an environment variable, or use it from within your application code.

For example, consider the following Helm chart manifest.yml, which requires a user-defined secret to be mounted as a volume:

Copied!
1 2 3 4 5 6 7 8 9 volumes: {{ if .Values.admin.existingSecretName }} - name: admin-secret secret: secretName: {{ .Values.admin.existingSecretName }} items: - key: {{ .Values.admin.existingSecretKey }} path: secret.txt {{ end }}

The Helm chart expects a Kubernetes secret defined in its values.yml file at .Values.admin.existingSecretName with a secret value located under the key .Values.admin.existingSecretKey.

Copied!
1 2 3 4 5 6 # values.yml: admin: # existingSecretName is the name of a Kubernetes secret in the environment existingSecretName: '{{ preprocess .Values.apollo.secrets.examplesecret.k8sSecretName }}' # existingSecretKey is the key that corresponds to the secret value in the secret existingSecretName existingSecretKey: "token"