mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
feat(k8s): pushsecret go templating
This commit is contained in:
@@ -401,6 +401,82 @@ After applying the InfisicalPushSecret CRD, you should notice that the secrets y
|
||||
</Accordion>
|
||||
|
||||
|
||||
## Using templating to push secrets
|
||||
|
||||
Pushing secrets to Infisical from the operator may not always be enough.
|
||||
Templating is a useful utility of the Infisical secrets operator that allows you to use Go Templating to template the secrets you want to push to Infisical.
|
||||
Using Go templates, you can format, combine, and create new key-value pairs of secrets that you want to push to Infisical.
|
||||
|
||||
<Accordion title="push.secret.template"/>
|
||||
<Accordion title="push.secret.template.includeAllSecrets">
|
||||
This property controls what secrets are included in your push to Infisica.
|
||||
When set to `true`, all secrets included in the `push.secret.secretName` Kubernetes secret will be pushed to Infisical.
|
||||
**Use this option when you would like to push all secrets to Infisical from the secrets operator, but want to template a subset of them.**
|
||||
|
||||
When set to `false`, only secrets defined in the `push.secret.template.data` field of the template will be pushed to Infisical.
|
||||
Use this option when you would like to push **only** a subset of secrets from the Kubernetes secret to Infisical.
|
||||
</Accordion>
|
||||
<Accordion title="push.secret.template.data">
|
||||
Define secret keys and their corresponding templates.
|
||||
Each data value uses a Golang template with access to all secrets defined in the `push.secret.secretName` Kubernetes secret.
|
||||
|
||||
Secrets are structured as follows:
|
||||
|
||||
```go
|
||||
type TemplateSecret struct {
|
||||
Value string `json:"value"`
|
||||
SecretPath string `json:"secretPath"`
|
||||
}
|
||||
```
|
||||
|
||||
#### Example template configuration:
|
||||
|
||||
```yaml
|
||||
# This example assumes that the `push-secret-demo` Kubernetes secret contains the following secrets:
|
||||
# SITE_URL = "https://example.com"
|
||||
# REGION = "us-east-1"
|
||||
# OTHER_SECRET = "other-secret"
|
||||
|
||||
push:
|
||||
secret:
|
||||
secretName: push-secret-demo
|
||||
secretNamespace: default
|
||||
template:
|
||||
includeAllSecrets: true # Includes all secrets from the `push-secret-demo` Kubernetes secret
|
||||
data:
|
||||
SITE_URL: "{{ .SITE_URL.Value }}"
|
||||
API_URL: "https://api.{{.SITE_URL.Value}}.{{.REGION.Value}}.com" # Will create a new secret in Infisical with the key `API_URL` with the value of the `SITE_URL` and `REGION` secrets
|
||||
```
|
||||
|
||||
To help transform your config map data further, the operator provides a set of built-in functions that you can use in your templates.
|
||||
|
||||
### Available templating functions
|
||||
|
||||
<Accordion title="encodeBase64">
|
||||
**Function name**: encodeBase64
|
||||
|
||||
**Description**:
|
||||
Given a string, this function will encode the string as a base64 encoded string.
|
||||
This function is useful when you want to store a string as a base64 encoded value in Infisical.
|
||||
|
||||
**Returns**: The base64 encoded string.
|
||||
|
||||
**Example**:
|
||||
The example below assumes that the `PLAIN_KEY` secret is stored in your source secret as a plaintext string.
|
||||
|
||||
```yaml
|
||||
push:
|
||||
secret:
|
||||
secretName: push-secret-demo
|
||||
secretNamespace: default
|
||||
template:
|
||||
includeAllSecrets: true
|
||||
data:
|
||||
PLAIN_KEY: "{{ encodeBase64 .PLAIN_KEY.Value }}" # Will be stored in Infisical as a base64 encoded string
|
||||
```
|
||||
</Accordion>
|
||||
</Accordion>
|
||||
|
||||
## Applying the InfisicalPushSecret CRD to your cluster
|
||||
|
||||
Once you have configured the `InfisicalPushSecret` CRD with the required fields, you can apply it to your cluster.
|
||||
|
||||
Reference in New Issue
Block a user