docs/snippets/kubernetes-operator-v1beta1-templating.mdx
import KubernetesOperatorTemplatingHelpers from "/snippets/kubernetes-operator-templating-helpers.mdx";
Fetching secrets from Infisical as-is via the operator may not be enough. This is where templating functionality may be helpful. Using Go templates, you can format, combine, and create new key-value pairs from secrets fetched from Infisical before storing them as Kubernetes Secrets or ConfigMaps.
When a template is set, only the keys defined in template.data are included in the output.
When no template is set, all fetched secrets are included as-is.
Each secret is available in the template context as .SECRET_KEY, which is an object with two accessors:
.Value: the secret value..SecretPath: the path of the secret in Infisical.targets:
- name: my-app-config
namespace: default
kind: Secret
creationPolicy: Owner
template:
engineVersion: v1
data:
DSN: "{{ .SECRET.Value }}.namespace:{{ .SECRET2.Value }}"
ANOTHER_ONE: "{{ .SECRET3.Value }}"
targets:
- name: all-secrets
namespace: default
kind: Secret
creationPolicy: Owner
template:
engineVersion: v1
data: |
{{- range $key, $secret := . }}
{{ $key }}: "{{ $secret.Value }}"
{{- end }}
To help transform your secrets further, the operator provides a set of built-in functions that you can use in your templates.
<KubernetesOperatorTemplatingHelpers />