> ## Documentation Index
> Fetch the complete documentation index at: https://infisical.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Using the InfisicalStaticSecretPush CRD

> Learn how to push native Kubernetes secret resources to Infisical using the v1beta1 InfisicalStaticSecretPush CRD.

The `InfisicalStaticSecretPush` CRD pushes native Kubernetes Secrets from your cluster to one or more paths in Infisical and keeps them in sync.
It replaces the v1alpha1 `InfisicalPushSecret` CRD with a cleaner design: authentication and connection details are defined as separate reusable resources ([InfisicalAuth](https://infisical.com/docs/integrations/platforms/kubernetes/infisical-auth-crd.md) and [InfisicalConnection](https://infisical.com/docs/integrations/platforms/kubernetes/infisical-connection-crd.md)) instead of inline blocks.

### Prerequisites

Before creating an `InfisicalStaticSecretPush`, you need:

1. The Infisical Kubernetes operator v0.11.17 or later, [installed in your cluster](https://infisical.com/docs/integrations/platforms/kubernetes/overview#install). Earlier versions don't include `InfisicalStaticSecretPush`.
2. An [InfisicalConnection](https://infisical.com/docs/integrations/platforms/kubernetes/infisical-connection-crd.md) resource configured with your Infisical host and TLS settings.
3. An [InfisicalAuth](https://infisical.com/docs/integrations/platforms/kubernetes/infisical-auth-crd.md) resource configured with your machine identity authentication method. The machine identity needs permission to read, create, edit, and delete secrets at each target, and to create folders when `createMissingFolders` is enabled.

### Examples

Each example below contains every resource you need to apply: the credential `Secret`, `InfisicalConnection`, `InfisicalAuth`, the `Secret` to push, and `InfisicalStaticSecretPush`.
Copy the one that matches your environment, replace the placeholder values, and `kubectl apply -f` it.

For more details on each resource, see the [InfisicalConnection](https://infisical.com/docs/integrations/platforms/kubernetes/infisical-connection-crd.md) and [InfisicalAuth](https://infisical.com/docs/integrations/platforms/kubernetes/infisical-auth-crd.md) documentation or access our [samples](https://github.com/Infisical/kubernetes-operator/tree/main/examples/v1beta1/infisicalstaticsecretpush).

> [accordion] Kubernetes Auth (Recommended)
>
> Best for workloads already running in Kubernetes.
>
> This example uses short-lived service account tokens. If you prefer to use a Gateway as the token reviewer instead, see the [Kubernetes Auth guide](https://infisical.com/docs/documentation/platform/identities/kubernetes-auth.md) for alternative setup options.
>
> ```yaml complete-kubernetes-auth.yaml expandable theme={"dark"}
> # 1. Service account used by the operator for token review
> apiVersion: v1
> kind: ServiceAccount
> metadata:
>   name: infisical-service-account
>   namespace: default
> ---
> # 2. Bind the service account to system:auth-delegator so it can
> #    validate tokens via the Kubernetes TokenReview API
> apiVersion: rbac.authorization.k8s.io/v1
> kind: ClusterRoleBinding
> metadata:
>   name: infisical-service-account-role-binding
> roleRef:
>   apiGroup: rbac.authorization.k8s.io
>   kind: ClusterRole
>   name: system:auth-delegator
> subjects:
>   - kind: ServiceAccount
>     name: infisical-service-account
>     namespace: default
> ---
> # 3. Kubernetes secret holding the machine identity ID
> apiVersion: v1
> kind: Secret
> metadata:
>   name: kubernetes-credentials
>   namespace: default
> type: Opaque
> stringData:
>   identityId: <your-machine-identity-id>
> ---
> # 4. Connection to the Infisical instance
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalConnection
> metadata:
>   name: my-infisical-connection
>   namespace: default
> spec:
>   address: https://app.infisical.com
> ---
> # 5. Auth using a Kubernetes service account token
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalAuth
> metadata:
>   name: my-infisical-auth
>   namespace: default
> spec:
>   infisicalConnectionRef:
>     name: my-infisical-connection
>     namespace: default
>   method: kubernetes
>   kubernetes:
>     identityIdRef:
>       name: kubernetes-credentials
>       namespace: default
>       key: identityId
>     serviceAccountRef:
>       name: infisical-service-account
>       namespace: default
> ---
> # 6. Kubernetes Secret to push to Infisical
> apiVersion: v1
> kind: Secret
> metadata:
>   name: app-credentials
>   namespace: default
> type: Opaque
> stringData:
>   DB_PASSWORD: <your-db-password>
>   API_KEY: <your-api-key>
> ---
> # 7. Push the Kubernetes Secret to Infisical
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalStaticSecretPush
> metadata:
>   name: my-static-secret-push
>   namespace: default
> spec:
>   infisicalAuthRef:
>     name: my-infisical-auth
>     namespace: default
>   syncOptions:
>     refreshInterval: 60s
>   sources:
>     secrets:
>       - name: app-credentials
>         namespace: default
>   targets:
>     - projectId: <your-project-id>
>       environmentSlug: dev
>       secretPath: /app
> ```

> [accordion] Universal Auth
>
> Platform-agnostic authentication using a client ID and client secret. Works in any environment.
>
> ```yaml complete-universal-auth.yaml expandable theme={"dark"}
> # 1. Kubernetes secret holding the client credentials
> apiVersion: v1
> kind: Secret
> metadata:
>   name: universal-auth-credentials
>   namespace: default
> type: Opaque
> stringData:
>   clientId: <your-identity-client-id>
>   clientSecret: <your-identity-client-secret>
> ---
> # 2. Connection to the Infisical instance
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalConnection
> metadata:
>   name: my-infisical-connection
>   namespace: default
> spec:
>   address: https://app.infisical.com
> ---
> # 3. Auth using Universal Auth credentials
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalAuth
> metadata:
>   name: my-infisical-auth
>   namespace: default
> spec:
>   infisicalConnectionRef:
>     name: my-infisical-connection
>     namespace: default
>   method: universal
>   universal:
>     clientIdRef:
>       name: universal-auth-credentials
>       namespace: default
>       key: clientId
>     clientSecretRef:
>       name: universal-auth-credentials
>       namespace: default
>       key: clientSecret
> ---
> # 4. Kubernetes Secret to push to Infisical
> apiVersion: v1
> kind: Secret
> metadata:
>   name: app-credentials
>   namespace: default
> type: Opaque
> stringData:
>   DB_PASSWORD: <your-db-password>
>   API_KEY: <your-api-key>
> ---
> # 5. Push the Kubernetes Secret to Infisical
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalStaticSecretPush
> metadata:
>   name: my-static-secret-push
>   namespace: default
> spec:
>   infisicalAuthRef:
>     name: my-infisical-auth
>     namespace: default
>   syncOptions:
>     refreshInterval: 60s
>   sources:
>     secrets:
>       - name: app-credentials
>         namespace: default
>   targets:
>     - projectId: <your-project-id>
>       environmentSlug: dev
>       secretPath: /app
> ```

> [accordion] AWS IAM Auth
>
> For workloads running in AWS (EC2, Lambda, EKS). The operator uses the instance's IAM role to authenticate.
>
> ```yaml complete-aws-iam-auth.yaml expandable theme={"dark"}
> # 1. Kubernetes secret holding the machine identity ID
> apiVersion: v1
> kind: Secret
> metadata:
>   name: aws-iam-credentials
>   namespace: default
> type: Opaque
> stringData:
>   identityId: <your-machine-identity-id>
> ---
> # 2. Connection to the Infisical instance
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalConnection
> metadata:
>   name: my-infisical-connection
>   namespace: default
> spec:
>   address: https://app.infisical.com
> ---
> # 3. Auth using AWS IAM
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalAuth
> metadata:
>   name: my-infisical-auth
>   namespace: default
> spec:
>   infisicalConnectionRef:
>     name: my-infisical-connection
>     namespace: default
>   method: aws-iam
>   awsIam:
>     identityIdRef:
>       name: aws-iam-credentials
>       namespace: default
>       key: identityId
> ---
> # 4. Kubernetes Secret to push to Infisical
> apiVersion: v1
> kind: Secret
> metadata:
>   name: app-credentials
>   namespace: default
> type: Opaque
> stringData:
>   DB_PASSWORD: <your-db-password>
>   API_KEY: <your-api-key>
> ---
> # 5. Push the Kubernetes Secret to Infisical
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalStaticSecretPush
> metadata:
>   name: my-static-secret-push
>   namespace: default
> spec:
>   infisicalAuthRef:
>     name: my-infisical-auth
>     namespace: default
>   syncOptions:
>     refreshInterval: 60s
>   sources:
>     secrets:
>       - name: app-credentials
>         namespace: default
>   targets:
>     - projectId: <your-project-id>
>       environmentSlug: dev
>       secretPath: /app
> ```

> [accordion] Azure Auth
>
> For workloads running in Azure. Uses the Azure managed identity attached to the compute resource.
>
> ```yaml complete-azure-auth.yaml expandable theme={"dark"}
> # 1. Kubernetes secret holding the machine identity ID
> apiVersion: v1
> kind: Secret
> metadata:
>   name: azure-credentials
>   namespace: default
> type: Opaque
> stringData:
>   identityId: <your-machine-identity-id>
> ---
> # 2. Connection to the Infisical instance
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalConnection
> metadata:
>   name: my-infisical-connection
>   namespace: default
> spec:
>   address: https://app.infisical.com
> ---
> # 3. Auth using Azure managed identity
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalAuth
> metadata:
>   name: my-infisical-auth
>   namespace: default
> spec:
>   infisicalConnectionRef:
>     name: my-infisical-connection
>     namespace: default
>   method: azure
>   azure:
>     identityIdRef:
>       name: azure-credentials
>       namespace: default
>       key: identityId
> ---
> # 4. Kubernetes Secret to push to Infisical
> apiVersion: v1
> kind: Secret
> metadata:
>   name: app-credentials
>   namespace: default
> type: Opaque
> stringData:
>   DB_PASSWORD: <your-db-password>
>   API_KEY: <your-api-key>
> ---
> # 5. Push the Kubernetes Secret to Infisical
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalStaticSecretPush
> metadata:
>   name: my-static-secret-push
>   namespace: default
> spec:
>   infisicalAuthRef:
>     name: my-infisical-auth
>     namespace: default
>   syncOptions:
>     refreshInterval: 60s
>   sources:
>     secrets:
>       - name: app-credentials
>         namespace: default
>   targets:
>     - projectId: <your-project-id>
>       environmentSlug: dev
>       secretPath: /app
> ```

> [accordion] GCP ID Token Auth
>
> For workloads running in GCP. Uses the GCP metadata server to obtain an ID token.
>
> ```yaml complete-gcp-id-token-auth.yaml expandable theme={"dark"}
> # 1. Kubernetes secret holding the machine identity ID
> apiVersion: v1
> kind: Secret
> metadata:
>   name: gcp-id-token-credentials
>   namespace: default
> type: Opaque
> stringData:
>   identityId: <your-machine-identity-id>
> ---
> # 2. Connection to the Infisical instance
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalConnection
> metadata:
>   name: my-infisical-connection
>   namespace: default
> spec:
>   address: https://app.infisical.com
> ---
> # 3. Auth using a GCP ID token
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalAuth
> metadata:
>   name: my-infisical-auth
>   namespace: default
> spec:
>   infisicalConnectionRef:
>     name: my-infisical-connection
>     namespace: default
>   method: gcp-id-token
>   gcpIdToken:
>     identityIdRef:
>       name: gcp-id-token-credentials
>       namespace: default
>       key: identityId
> ---
> # 4. Kubernetes Secret to push to Infisical
> apiVersion: v1
> kind: Secret
> metadata:
>   name: app-credentials
>   namespace: default
> type: Opaque
> stringData:
>   DB_PASSWORD: <your-db-password>
>   API_KEY: <your-api-key>
> ---
> # 5. Push the Kubernetes Secret to Infisical
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalStaticSecretPush
> metadata:
>   name: my-static-secret-push
>   namespace: default
> spec:
>   infisicalAuthRef:
>     name: my-infisical-auth
>     namespace: default
>   syncOptions:
>     refreshInterval: 60s
>   sources:
>     secrets:
>       - name: app-credentials
>         namespace: default
>   targets:
>     - projectId: <your-project-id>
>       environmentSlug: dev
>       secretPath: /app
> ```

> [accordion] GCP IAM Auth
>
> Uses a GCP service account key file for authentication. Works both inside and outside GCP.
>
> > [!NOTE]
> >
> > The `serviceAccountKeyFilePath` must point to a file that exists inside the operator pod. You'll need to create a Kubernetes Secret with your GCP service account key and mount it as a volume in the operator Deployment (or via Helm values). See the [GCP IAM Auth](https://infisical.com/docs/documentation/platform/identities/gcp-auth.md) guide for details.
>
> ```yaml complete-gcp-iam-auth.yaml expandable theme={"dark"}
> # 1. Kubernetes secret holding the machine identity ID
> apiVersion: v1
> kind: Secret
> metadata:
>   name: gcp-iam-credentials
>   namespace: default
> type: Opaque
> stringData:
>   identityId: <your-machine-identity-id>
> ---
> # 2. Connection to the Infisical instance
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalConnection
> metadata:
>   name: my-infisical-connection
>   namespace: default
> spec:
>   address: https://app.infisical.com
> ---
> # 3. Auth using GCP IAM with a service account key
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalAuth
> metadata:
>   name: my-infisical-auth
>   namespace: default
> spec:
>   infisicalConnectionRef:
>     name: my-infisical-connection
>     namespace: default
>   method: gcp-iam
>   gcpIam:
>     identityIdRef:
>       name: gcp-iam-credentials
>       namespace: default
>       key: identityId
>     serviceAccountKeyFilePath: /path/to/service-account-key.json
> ---
> # 4. Kubernetes Secret to push to Infisical
> apiVersion: v1
> kind: Secret
> metadata:
>   name: app-credentials
>   namespace: default
> type: Opaque
> stringData:
>   DB_PASSWORD: <your-db-password>
>   API_KEY: <your-api-key>
> ---
> # 5. Push the Kubernetes Secret to Infisical
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalStaticSecretPush
> metadata:
>   name: my-static-secret-push
>   namespace: default
> spec:
>   infisicalAuthRef:
>     name: my-infisical-auth
>     namespace: default
>   syncOptions:
>     refreshInterval: 60s
>   sources:
>     secrets:
>       - name: app-credentials
>         namespace: default
>   targets:
>     - projectId: <your-project-id>
>       environmentSlug: dev
>       secretPath: /app
> ```

> [accordion] LDAP Auth
>
> Authenticates using LDAP credentials (username and password).
>
> ```yaml complete-ldap-auth.yaml expandable theme={"dark"}
> # 1. Kubernetes secret holding LDAP credentials and the machine identity ID
> apiVersion: v1
> kind: Secret
> metadata:
>   name: ldap-credentials
>   namespace: default
> type: Opaque
> stringData:
>   identityId: <your-machine-identity-id>
>   username: <your-ldap-username>
>   password: <your-ldap-password>
> ---
> # 2. Connection to the Infisical instance
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalConnection
> metadata:
>   name: my-infisical-connection
>   namespace: default
> spec:
>   address: https://app.infisical.com
> ---
> # 3. Auth using LDAP
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalAuth
> metadata:
>   name: my-infisical-auth
>   namespace: default
> spec:
>   infisicalConnectionRef:
>     name: my-infisical-connection
>     namespace: default
>   method: ldap
>   ldap:
>     identityIdRef:
>       name: ldap-credentials
>       namespace: default
>       key: identityId
>     usernameRef:
>       name: ldap-credentials
>       namespace: default
>       key: username
>     passwordRef:
>       name: ldap-credentials
>       namespace: default
>       key: password
> ---
> # 4. Kubernetes Secret to push to Infisical
> apiVersion: v1
> kind: Secret
> metadata:
>   name: app-credentials
>   namespace: default
> type: Opaque
> stringData:
>   DB_PASSWORD: <your-db-password>
>   API_KEY: <your-api-key>
> ---
> # 5. Push the Kubernetes Secret to Infisical
> apiVersion: secrets.infisical.com/v1beta1
> kind: InfisicalStaticSecretPush
> metadata:
>   name: my-static-secret-push
>   namespace: default
> spec:
>   infisicalAuthRef:
>     name: my-infisical-auth
>     namespace: default
>   syncOptions:
>     refreshInterval: 60s
>   sources:
>     secrets:
>       - name: app-credentials
>         namespace: default
>   targets:
>     - projectId: <your-project-id>
>       environmentSlug: dev
>       secretPath: /app
> ```

## CRD properties

> [accordion] infisicalAuthRef
>
> A reference to the `InfisicalAuth` resource that defines how to authenticate with Infisical. The connection to the Infisical instance is resolved through the `InfisicalAuth` resource's `infisicalConnectionRef` field.
>
> | Field | Required | Description |
> | - | - | - |
> | `name` | Yes | The name of the `InfisicalAuth` resource. |
> | `namespace` | Yes | The namespace of the `InfisicalAuth` resource. |
>
> See the [InfisicalAuth CRD](https://infisical.com/docs/integrations/platforms/kubernetes/infisical-auth-crd.md) documentation for details.

> [accordion] syncOptions
>
> Controls the synchronization behavior.
>
> | Field | Required | Description |
> | - | - | - |
> | `refreshInterval` | No | How often to push again (e.g. `60s`, `5m`, `1h`). The minimum is `5s`. When omitted, the operator pushes only when a source Secret or the `InfisicalStaticSecretPush` changes. |
> | `updatePolicy` | No | Whether keys that already exist in Infisical are updated. Must be `Replace` or `None`. Defaults to `Replace`. |
> | `deletionPolicy` | No | Whether the operator deletes the secrets it pushed. Must be `Delete` or `None`. Defaults to `Delete`. |
> | `createMissingFolders` | No | Whether to create the target folder, and any missing parent folders, when it doesn't exist. Defaults to `true`. |
>
> Behavior of each `updatePolicy`:
>
> * `Replace`: The operator keeps existing keys in sync with the sources, and takes over keys at a target that were created outside this resource
> * `None`: The operator only creates missing keys and never changes an existing key (including the keys this resource created), so later changes to the sources don't reach Infisical
>
> Behavior of each `deletionPolicy`:
>
> * `Delete`: The operator deletes a pushed secret from Infisical when its key is removed from the sources, when its target is removed, or when the `InfisicalStaticSecretPush` is deleted
> * `None`: The operator never deletes secrets from Infisical
>
> ```yaml theme={"dark"}
> syncOptions:
>   refreshInterval: 60s
>   updatePolicy: Replace
>   deletionPolicy: Delete
>   createMissingFolders: true
> ```

> [accordion] sources
>
> The Kubernetes Secrets to push. Every key of every Secret is pushed to every target, except to a target with a [template](#templating), which pushes what its template renders instead.
>
> When multiple Secrets contain the same key, the first occurrence wins: Secrets listed earlier in the array take precedence over later ones.
>
> | Field | Required | Description |
> | - | - | - |
> | `secrets` | Yes | The Kubernetes Secrets to push, each with a `name` and a `namespace`. |
>
> If a source Secret doesn't exist, the sync fails and nothing is deleted from Infisical.
>
> ```yaml theme={"dark"}
> sources:
>   secrets:
>     - name: db-credentials
>       namespace: default
>     - name: api-keys
>       namespace: default
> ```
>
> > [!WARNING]
> >
> > An `InfisicalStaticSecretPush` can push any Secret the operator can read, including Secrets in other namespaces, and a template can write a source value into Infisical or into the resource's status, for example as a key name in `status.managedSecrets`. Treat permission to create or edit `InfisicalStaticSecretPush` resources like permission to read those Secrets.

> [accordion] targets
>
> An array of Infisical paths to push the secrets to.
>
> | Field | Required | Description |
> | - | - | - |
> | `projectId` | No | The Infisical project ID. |
> | `projectSlug` | No | The Infisical project slug. |
> | `environmentSlug` | Yes | The environment slug (e.g. `dev`, `staging`, `prod`). |
> | `secretPath` | Yes | The folder to push the secrets to. Root is `/`. |
> | `template` | No | Optional templating configuration (see [Templating](#templating) below). |
>
> > [!NOTE]
> >
> > You have to provide either `projectId` or `projectSlug`. If none or both are set, the sync fails.
>
> Each target is synced separately. If a target fails, the operator still pushes to the other targets, but it doesn't delete secrets from any target until every target succeeds.
>
> ```yaml theme={"dark"}
> targets:
>   - projectId: <your-project-id>
>     environmentSlug: dev
>     secretPath: /app
>   - projectSlug: <your-project-slug>
>     environmentSlug: staging
>     secretPath: /app/backend
> ```

## Templating

Pushing the keys of your Kubernetes Secrets as-is 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 the source keys before pushing them to Infisical.

When a target has a template, only the keys defined in `template.data` are pushed to that target.
When no template is set, all source keys are pushed as-is.

Each source key is available in the template context as `.KEY`, which is an object with two accessors:

* `.Value`: the value of the key in the source Secret
* `.SecretPath`: the target's `secretPath`

### Key/value template map

```yaml theme={"dark"}
targets:
  - projectId: <your-project-id>
    environmentSlug: dev
    secretPath: /app
    template:
      engineVersion: v1
      data:
        DATABASE_URL: "postgres://{{ .DB_USER.Value }}:{{ .DB_PASS.Value }}@{{ .DB_HOST.Value }}:5432/app"
        REDIS_URL: "redis://{{ .REDIS_HOST.Value }}:6379"
```

### Bulk string template with a loop

```yaml theme={"dark"}
targets:
  - projectId: <your-project-id>
    environmentSlug: dev
    secretPath: /app
    template:
      engineVersion: v1
      data: |
        {{- range $key, $secret := . }}
        {{ $key }}: {{ $secret.Value | quote }}
        {{- end }}
```

The Sprig `quote` function escapes each value, so values that contain quotes, backslashes, or line breaks are pushed unchanged.

### How templates are applied

* A key that the template stops rendering is deleted from the target according to `deletionPolicy`, like a key removed from the sources
* If a template fails, only its target fails, and nothing is deleted from Infisical until the template is fixed
* When a template fails while running, the status shows where it failed but not why, because the reason can contain secret values (syntax errors are shown in full)
* A template whose `data` is empty or only contains whitespace is rejected, because it would delete every secret pushed to the target
* Only the values pushed to Infisical must be valid UTF-8, so a template can leave out a binary source value or encode it with `encodeBase64`

> [!NOTE]
>
> `secretFrom` and `foldersIn` look up secrets and folders fetched from Infisical, so they don't work in an `InfisicalStaticSecretPush` template.

To help transform your secrets further, the operator provides a set of built-in functions that you can use in your templates.

### Available helper functions

The Infisical Secrets Operator exposes a wide range of helper functions to make it easier to work with secrets in Kubernetes.

> [accordion] encodeBase64
>
> Encodes a string to a base64-encoded string (e.g. `hello world` becomes `aGVsbG8gd29ybGQ=`).
>
> **Signature**
>
> ```go theme={"dark"}
> encodeBase64(plainString string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     ENCODED_SECRET: "{{ .MY_SECRET.Value | encodeBase64 }}"
> ```

> [accordion] decodeBase64ToBytes
>
> Decodes a base64-encoded string back to its original value (e.g. `aGVsbG8gd29ybGQ=` becomes `hello world`).
>
> **Signature**
>
> ```go theme={"dark"}
> decodeBase64ToBytes(encodedString string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     DECODED_SECRET: "{{ .MY_BASE64_SECRET.Value | decodeBase64ToBytes }}"
> ```

> [accordion] pkcs12key
>
> Extracts all private keys from a PKCS#12 archive and returns them as PKCS#8 PEM-encoded blocks (`-----BEGIN PRIVATE KEY-----...`).
> The archive must not be password-protected — use `pkcs12keyPass` for password-protected archives.
>
> **Signature**
>
> ```go theme={"dark"}
> pkcs12key(input string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     tls.key: "{{ .TLS_CERT_PKCS12.Value | pkcs12key }}"
> ```

> [accordion] pkcs12keyPass
>
> Same as `pkcs12key`, but uses the provided password to decrypt the PKCS#12 archive.
>
> **Signature**
>
> ```go theme={"dark"}
> pkcs12keyPass(password string, input string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     tls.key: '{{ pkcs12keyPass "my-password" .TLS_CERT_PKCS12.Value }}'
> ```

> [accordion] pkcs12cert
>
> Extracts all certificates from a PKCS#12 archive and returns them as an ordered PEM chain (`-----BEGIN CERTIFICATE-----...`).
> Sort order: **leaf → intermediate(s) → root**. If disjunct or multiple leaf certs are provided, they are returned as-is.
> The archive must not be password-protected — use `pkcs12certPass` for password-protected archives.
>
> **Signature**
>
> ```go theme={"dark"}
> pkcs12cert(input string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     tls.crt: "{{ .TLS_CERT_PKCS12.Value | pkcs12cert }}"
> ```

> [accordion] pkcs12certPass
>
> Same as `pkcs12cert`, but uses the provided password to decrypt the PKCS#12 archive.
>
> **Signature**
>
> ```go theme={"dark"}
> pkcs12certPass(password string, input string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     tls.crt: '{{ pkcs12certPass "my-password" .TLS_CERT_PKCS12.Value }}'
> ```

> [accordion] pemToPkcs12
>
> Takes a PEM-encoded certificate and private key and creates a base64-encoded PKCS#12 archive.
> The output is not password-protected — use `pemToPkcs12Pass` to set a password.
>
> **Signature**
>
> ```go theme={"dark"}
> pemToPkcs12(cert string, key string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     keystore.p12: '{{ pemToPkcs12 .TLS_CERT.Value .TLS_KEY.Value }}'
> ```

> [accordion] pemToPkcs12Pass
>
> Same as `pemToPkcs12`, but encrypts the PKCS#12 archive with the provided password.
>
> **Signature**
>
> ```go theme={"dark"}
> pemToPkcs12Pass(cert string, key string, password string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     keystore.p12: '{{ pemToPkcs12Pass .TLS_CERT.Value .TLS_KEY.Value "my-password" }}'
> ```

> [accordion] fullPemToPkcs12
>
> Takes a full PEM-encoded certificate chain (leaf + intermediates + root) and a private key, and creates a base64-encoded PKCS#12 archive that includes the entire chain.
> The output is not password-protected — use `fullPemToPkcs12Pass` to set a password.
>
> **Signature**
>
> ```go theme={"dark"}
> fullPemToPkcs12(cert string, key string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     keystore.p12: '{{ fullPemToPkcs12 .TLS_FULL_CHAIN.Value .TLS_KEY.Value }}'
> ```

> [accordion] fullPemToPkcs12Pass
>
> Same as `fullPemToPkcs12`, but encrypts the PKCS#12 archive with the provided password.
>
> **Signature**
>
> ```go theme={"dark"}
> fullPemToPkcs12Pass(cert string, key string, password string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     keystore.p12: '{{ fullPemToPkcs12Pass .TLS_FULL_CHAIN.Value .TLS_KEY.Value "my-password" }}'
> ```

> [accordion] filterPEM
>
> Filters PEM blocks by type from a bundle containing multiple PEM blocks (e.g. extract only `CERTIFICATE` or `PRIVATE KEY` blocks).
> Common PEM types: `CERTIFICATE`, `PRIVATE KEY`, `PUBLIC KEY`, `RSA PRIVATE KEY`.
>
> **Signature**
>
> ```go theme={"dark"}
> filterPEM(pemType string, input string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     ca.crt: '{{ filterPEM "CERTIFICATE" .TLS_BUNDLE.Value }}'
>     tls.key: '{{ filterPEM "PRIVATE KEY" .TLS_BUNDLE.Value }}'
> ```

> [accordion] filterCertChain
>
> Filters PEM certificates by their position in a certificate chain. The chain is automatically ordered before filtering.
> Accepted types: `leaf` (end-entity certificate), `intermediate` (all intermediate CA certificates), `root` (root CA certificate).
> Returns an empty string if the requested type is not present in the chain.
>
> **Signature**
>
> ```go theme={"dark"}
> filterCertChain(certType string, input string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     tls.crt: '{{ filterCertChain "leaf" .TLS_CHAIN.Value }}'
>     ca.crt: '{{ filterCertChain "root" .TLS_CHAIN.Value }}'
>     intermediate.crt: '{{ filterCertChain "intermediate" .TLS_CHAIN.Value }}'
> ```

> [accordion] jwkPublicKeyPem
>
> Takes a JSON-serialized JWK and returns a PEM block of type `PUBLIC KEY` containing the public key.
> Uses [`x509.MarshalPKIXPublicKey`](https://pkg.go.dev/crypto/x509#MarshalPKIXPublicKey) internally.
>
> **Signature**
>
> ```go theme={"dark"}
> jwkPublicKeyPem(jwkJson string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     public.pem: "{{ .MY_JWK.Value | jwkPublicKeyPem }}"
> ```

> [accordion] jwkPrivateKeyPem
>
> Takes a JSON-serialized JWK and returns a PEM block of type `PRIVATE KEY` containing the private key.
> Uses [`x509.MarshalPKCS8PrivateKey`](https://pkg.go.dev/crypto/x509#MarshalPKCS8PrivateKey) internally.
>
> **Signature**
>
> ```go theme={"dark"}
> jwkPrivateKeyPem(jwkJson string) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     private.pem: "{{ .MY_JWK.Value | jwkPrivateKeyPem }}"
> ```

> [accordion] toYaml
>
> Marshals a value to a YAML string. Returns an empty string on marshal error.
>
> **Signature**
>
> ```go theme={"dark"}
> toYaml(v any) string
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     config.yaml: "{{ .APP_CONFIG.Value | fromYaml | toYaml }}"
> ```

> [accordion] fromYaml
>
> Parses a YAML string into a `map[string]any`, useful for extracting individual fields from a YAML-formatted secret (e.g. `(fromYaml .DB_CONFIG.Value).host` returns the `host` field).
>
> **Signature**
>
> ```go theme={"dark"}
> fromYaml(str string) map[string]any
> ```
>
> **Template usage**
>
> ```yaml theme={"dark"}
> template:
>   data:
>     DB_HOST: '{{ (fromYaml .DB_CONFIG.Value).host }}'
>     DB_PORT: '{{ (fromYaml .DB_CONFIG.Value).port }}'
> ```

### Sprig functions

The Infisical Secrets Operator integrates with the [Sprig library](https://github.com/Masterminds/sprig) to provide additional helper functions.

> [!NOTE]
>
> We've removed `expandEnv` and `env` from the supported functions for security reasons.

## Managing pushed secrets

The operator records the ID of every secret it pushes to Infisical in the resource's `status.managedSecrets`, and it only ever deletes those secrets.

> [accordion] Keys that already exist in Infisical
>
> With `updatePolicy: Replace`, the operator takes over a key that already exists at a target: it writes the source value and records the secret in `status.managedSecrets`, so the key is deleted with the resource when `deletionPolicy` is `Delete`. With `updatePolicy: None`, the operator leaves the key unchanged and never deletes it.
>
> If the operator stops right after creating a secret, before it records the secret's ID, the next sync takes the key over again when `updatePolicy` is `Replace`. When `updatePolicy` is `None`, the key isn't recorded, so the operator never deletes it.

> [accordion] Keys pushed by another InfisicalStaticSecretPush
>
> Two resources that push the same key to the same path would overwrite each other on every sync. The operator never changes or deletes a key that another `InfisicalStaticSecretPush` pushed, even while that resource is being deleted. The resource that didn't push the key first reports an error that names the keys it left unchanged.
>
> The operator only checks the resources it manages: the ones in its own cluster, and if it's [namespace-scoped](https://infisical.com/docs/integrations/platforms/kubernetes/overview#install), only the ones in the namespaces it watches. Resources that different operators manage, for example in two clusters, can't see each other's keys: they overwrite each other, and deleting one with `deletionPolicy: Delete` deletes keys the other still pushes.
>
> Push each key from only one `InfisicalStaticSecretPush`.

> [accordion] Secret values
>
> Infisical stores secret values as text, so every value pushed must be valid UTF-8. To push binary data, store it base64-encoded in the source Secret, or encode it with `encodeBase64` in a [template](#templating).
>
> Infisical removes whitespace at the start and end of a value, and keeps a single trailing newline when the value ends with one.

> [accordion] Approval workflows
>
> If an [approval policy](https://infisical.com/docs/documentation/platform/pr-workflows.md) covers a target, Infisical turns the operator's changes into an approval request instead of applying them, and the sync of that target fails with an explanation. Once the request is approved, the operator takes over the secrets when `updatePolicy` is `Replace`.
>
> The operator doesn't track approval requests yet, so every sync submits a new request. To let the operator push without approval, enable **Bypass Approval for Machine Identities** in the approval policy.

> [accordion] Deleting the resource
>
> When `deletionPolicy` is `Delete`, Kubernetes keeps the `InfisicalStaticSecretPush` until the operator has deleted every secret in `status.managedSecrets` from Infisical. If the operator can't delete them within 5 minutes, for example because Infisical is unreachable, it lets Kubernetes delete the resource, leaves the secrets in Infisical, and logs their IDs.
>
> > [!WARNING]
> >
> > To delete the pushed secrets, the operator needs the `InfisicalAuth`, its `InfisicalConnection`, and their credential Secrets. If you delete them together with the `InfisicalStaticSecretPush`, for example by deleting their namespace or by running `kubectl delete -f` on a file that contains all of them, the operator can't log in, and the pushed secrets stay in Infisical after the 5 minutes.
> >
> > Delete the `InfisicalStaticSecretPush` first and wait until it's gone, or keep the `InfisicalAuth` and `InfisicalConnection` outside the namespaces of your applications.
>
> If you change `infisicalAuthRef` to an `InfisicalAuth` that connects to another Infisical instance, the secrets pushed to the previous instance stay there. To remove them, delete the `InfisicalStaticSecretPush` before you change the `InfisicalAuth`, or delete them in Infisical.

## Applying the CRD

```bash theme={"dark"}
kubectl apply -f infisical-static-secret-push.yaml
```

Verify the secrets were pushed:

```bash theme={"dark"}
kubectl get infisicalstaticsecretpush -n <namespace>
```

When the `SYNCED` column shows `True`, the secrets are in Infisical at every target.

## Migrating from InfisicalPushSecret

If you push secrets with the v1alpha1 [InfisicalPushSecret CRD](https://infisical.com/docs/integrations/platforms/kubernetes/infisical-push-secret-crd.md), an `InfisicalStaticSecretPush` can take over the secrets that the `InfisicalPushSecret` pushed. The secrets aren't deleted or recreated in Infisical during the migration.

The `InfisicalStaticSecretPush` spec is different from the `InfisicalPushSecret` spec:

* It authenticates through an [InfisicalAuth](https://infisical.com/docs/integrations/platforms/kubernetes/infisical-auth-crd.md) resource, which connects to Infisical through an [InfisicalConnection](https://infisical.com/docs/integrations/platforms/kubernetes/infisical-connection-crd.md) resource
* `push.secret` becomes an entry in `sources.secrets`, and `destination` becomes an entry in `targets`, with `secretsPath` renamed to `secretPath`
* `resyncInterval` becomes `syncOptions.refreshInterval`, and `updatePolicy` and `deletionPolicy` move under `syncOptions`
* `updatePolicy` defaults to `Replace` and `deletionPolicy` defaults to `Delete`, while both default to `None` on an `InfisicalPushSecret`
* Its templates use the [v1 template syntax](#templating), which has no `includeAllSecrets` option (to push every source key along with the keys a template adds, use a bulk template that ranges over `.`)
* It doesn't support generators (`push.generators`) yet

**Step 1**

Upgrade the operator to v0.11.17 or later. Earlier versions don't include `InfisicalStaticSecretPush`.

**Step 2**

On the `InfisicalPushSecret`, remove `deletionPolicy` or set it to `None`, and apply the change.

> [!WARNING]
>
> If you skip this step, deleting the `InfisicalPushSecret` at the end of the migration deletes the secrets from Infisical.

**Step 3**

Create an `InfisicalStaticSecretPush` that pushes the same Secret to the same project, environment, and path as the `InfisicalPushSecret`. Keep `updatePolicy` set to `Replace`, so the `InfisicalStaticSecretPush` takes over the secrets that already exist in Infisical.

**Step 4**

Check that the `SYNCED` column shows `True` for the `InfisicalStaticSecretPush`:

```bash theme={"dark"}
kubectl get infisicalstaticsecretpush <static-secret-push-name> -n <namespace>
```

**Step 5**

Delete the `InfisicalPushSecret`:

```bash theme={"dark"}
kubectl delete infisicalpushsecret <infisical-push-secret-name> -n <namespace>
```

The secrets stay in Infisical, and the `InfisicalStaticSecretPush` manages them from now on.

## Troubleshooting

You can check the status of your `InfisicalStaticSecretPush` resource by inspecting its conditions:

```bash theme={"dark"}
kubectl get infisicalstaticsecretpush my-static-secret-push -o jsonpath='{.status.conditions}' | jq
```

When reconciliation is successful, the `secrets.infisical.com/LastReconcileStatus` condition will have `Status: "True"`, `Reason: "OK"`, and `Message: "Reconciliation successful"`.

If reconciliation fails, `Status` will be `"False"`, `Reason` will be set to `Error`, and `Message` will contain details about what went wrong. While the operator deletes the pushed secrets from Infisical, `Reason` is set to `Deleting`.

The `ObservedGeneration` field indicates which generation of the resource spec the operator has last processed. If `ObservedGeneration` is less than `metadata.generation`, the operator hasn't yet reconciled the latest changes to the resource.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.