Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
import KubernetesOperatorTemplatingHelpers from "/snippets/kubernetes-operator-templating-helpers.mdx";
## Templating
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.
### Key/value template map
```yaml
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 }}"
```
### Bulk string template with a loop
```yaml
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 />