Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

docs(k8-operator): updated infisicalsecret crd docs

Daniel Hougaard3013d1977cef
diff --git a/docs/integrations/platforms/kubernetes/infisical-secret-crd.mdx b/docs/integrations/platforms/kubernetes/infisical-secret-crd.mdx
index df0730d877..7adcca699d 100644
--- a/docs/integrations/platforms/kubernetes/infisical-secret-crd.mdx
+++ b/docs/integrations/platforms/kubernetes/infisical-secret-crd.mdx
@@ -1,11 +1,10 @@
---
sidebarTitle: "InfisicalSecret CRD"
-title: "Using the InfisicalSecret CRD"
+title: "InfisicalSecret CRD"
description: "Learn how to use the InfisicalSecret CRD to fetch secrets from Infisical and store them as native Kubernetes secret resource"
---
Once you have installed the operator to your cluster, you'll need to create a `InfisicalSecret` custom resource definition (CRD).
-In this CRD, you'll define the authentication method to use, the secrets to fetch, and the target location to store the secrets within your cluster.
```yaml example-infisical-secret-crd.yaml
apiVersion: secrets.infisical.com/v1alpha1
@@ -20,28 +19,104 @@ spec:
hostAPI: https://app.infisical.com/api
resyncInterval: 10
authentication:
+ # Make sure to only have 1 authentication method defined, serviceToken/universalAuth.
+ # If you have multiple authentication methods defined, it may cause issues.
+
+ # (Deprecated) Service Token Auth
+ serviceToken:
+ serviceTokenSecretReference:
+ secretName: service-token
+ secretNamespace: default
+ secretsScope:
+ envSlug: <env-slug>
+ secretsPath: <secrets-path>
+ recursive: true
+
+ # Universal Auth
+ universalAuth:
+ secretsScope:
+ projectSlug: new-ob-em
+ envSlug: dev # "dev", "staging", "prod", etc..
+ secretsPath: "/" # Root is "/"
+ recursive: true # Whether or not to use recursive mode (Fetches all secrets in an environment from a given secret path, and all folders inside the path) / defaults to false
+ credentialsRef:
+ secretName: universal-auth-credentials
+ secretNamespace: default
+
+ # Native Kubernetes Auth
kubernetesAuth:
identityId: <machine-identity-id>
serviceAccountRef:
name: <service-account-name>
namespace: <service-account-namespace>
- managedSecretReference:
- secretName: managed-secret
- secretNamespace: default
- creationPolicy: "Orphan"
- template:
- includeAllSecrets: true
- data:
- NEW_KEY_NAME: "{{ .KEY.SecretPath }} {{ .KEY.Value }}"
- KEY_WITH_BINARY_VALUE: "{{ .KEY.SecretPath }} {{ .KEY.Value }}"
-```
+ # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
+ secretsScope:
+ projectSlug: your-project-slug
+ envSlug: prod
+ secretsPath: "/path"
+ recursive: true
+
+ # AWS IAM Auth
+ awsIamAuth:
+ identityId: <your-machine-identity-id>
+
+ # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
+ secretsScope:
+ projectSlug: your-project-slug
+ envSlug: prod
+ secretsPath: "/path"
+ recursive: true
+
+ # Azure Auth
+ azureAuth:
+ identityId: <your-machine-identity-id>
+ resource: https://management.azure.com/&client_id=CLIENT_ID # (Optional) This is the Azure resource that you want to access. For example, "https://management.azure.com/". If no value is provided, it will default to "https://management.azure.com/"
-## CRD properties
+ # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
+ secretsScope:
+ projectSlug: your-project-slug
+ envSlug: prod
+ secretsPath: "/path"
+ recursive: true
+
+ # GCP ID Token Auth
+ gcpIdTokenAuth:
+ identityId: <your-machine-identity-id>
+
+ # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
+ secretsScope:
+ projectSlug: your-project-slug
+ envSlug: prod
+ secretsPath: "/path"
+ recursive: true
-### Generic
+ # GCP IAM Auth
+ gcpIamAuth:
+ identityId: <your-machine-identity-id>
+
+ # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
+ secretsScope:
+ projectSlug: your-project-slug
+ envSlug: prod
+ secretsPath: "/path"
+ recursive: true
+
+ managedSecretReferences:
+ - secretName: managed-secret
+ secretNamespace: default
+ creationPolicy: "Orphan" ## Owner | Orphan
+ - secretName: managed-secret-2
+ secretNamespace: default
+ creationPolicy: "Owner" ## Owner | Orphan
+ # secretType: kubernetes.io/dockerconfigjson
+ # template:
+ # includeAllSecrets: true
+ # data:
+ # CUSTOM_KEY: "{{ .KEY.SecretPath }} {{ .KEY.Value }}"
+```
-The following properties help define what instance of Infisical the operator will interact with, the interval it will sync secrets and any CA certificates that may be required to connect.
+### InfisicalSecret CRD properties
<Accordion title="hostAPI">
If you are fetching secrets from a self-hosted instance of Infisical set the value of `hostAPI` to
@@ -71,36 +146,33 @@ When `hostAPI` is not defined the operator fetches secrets from Infisical Cloud.
<Accordion title="tls">
This block defines the TLS settings to use for connecting to the Infisical
instance.
-</Accordion>
-<Accordion title="tls.caRef">
- This block defines the reference to the CA certificate to use for connecting
- to the Infisical instance with SSL/TLS.
-</Accordion>
+ <Accordion title="tls.caRef">
+ This block defines the reference to the CA certificate to use for connecting
+ to the Infisical instance with SSL/TLS.
+ </Accordion>
-<Accordion title="tls.caRef.secretName">
- The name of the Kubernetes secret containing the CA certificate to use for
- connecting to the Infisical instance with SSL/TLS.
-</Accordion>
+ <Accordion title="tls.caRef.secretName">
+ The name of the Kubernetes secret containing the CA certificate to use for
+ connecting to the Infisical instance with SSL/TLS.
+ </Accordion>
-<Accordion title="tls.caRef.secretNamespace">
- The namespace of the Kubernetes secret containing the CA certificate to use
- for connecting to the Infisical instance with SSL/TLS.
-</Accordion>
+ <Accordion title="tls.caRef.secretNamespace">
+ The namespace of the Kubernetes secret containing the CA certificate to use
+ for connecting to the Infisical instance with SSL/TLS.
+ </Accordion>
-<Accordion title="tls.caRef.key">
- The name of the key in the Kubernetes secret which contains the value of the
- CA certificate to use for connecting to the Infisical instance with SSL/TLS.
+ <Accordion title="tls.caRef.key">
+ The name of the key in the Kubernetes secret which contains the value of the
+ CA certificate to use for connecting to the Infisical instance with SSL/TLS.
+ </Accordion>
</Accordion>
-### Authentication methods
-
-To retrieve the requested secrets, the operator must first authenticate with Infisical.
-The list of available authentication methods are shown below.
-
-<Accordion title="authentication"></Accordion>
+<Accordion title="authentication">
+ This block defines the method that will be used to authenticate with Infisical
+ so that secrets can be fetched
-<Accordion title="authentication.universalAuth">
+ <Accordion title="authentication.universalAuth">
The universal machine identity authentication method is used to authenticate with Infisical. The client ID and client secret needs to be stored in a Kubernetes secret. This block defines the reference to the name and namespace of secret that stores these credentials.
<Steps>
@@ -124,548 +196,519 @@ The list of available authentication methods are shown below.
</Steps>
-<Info>
- Make sure to also populate the `secretsScope` field with the project slug
- _`projectSlug`_, environment slug _`envSlug`_, and secrets path
- _`secretsPath`_ that you want to fetch secrets from. Please see the example
- below.
-</Info>
+ <Info>
+ Make sure to also populate the `secretsScope` field with the project slug
+ _`projectSlug`_, environment slug _`envSlug`_, and secrets path
+ _`secretsPath`_ that you want to fetch secrets from. Please see the example
+ below.
+ </Info>
-## Example
+ ## Example
-```yaml
-apiVersion: secrets.infisical.com/v1alpha1
-kind: InfisicalSecret
-metadata:
- name: infisicalsecret-sample-crd
-spec:
- authentication:
- universalAuth:
- secretsScope:
- projectSlug: <project-slug> # <-- project slug
- envSlug: <env-slug> # "dev", "staging", "prod", etc..
- secretsPath: "<secrets-path>" # Root is "/"
- credentialsRef:
- secretName: universal-auth-credentials # <-- name of the Kubernetes secret that stores our machine identity credentials
- secretNamespace: default # <-- namespace of the Kubernetes secret that stores our machine identity credentials
- ...
-```
+ ```yaml
+ apiVersion: secrets.infisical.com/v1alpha1
+ kind: InfisicalSecret
+ metadata:
+ name: infisicalsecret-sample-crd
+ spec:
+ authentication:
+ universalAuth:
+ secretsScope:
+ projectSlug: <project-slug> # <-- project slug
+ envSlug: <env-slug> # "dev", "staging", "prod", etc..
+ secretsPath: "<secrets-path>" # Root is "/"
+ credentialsRef:
+ secretName: universal-auth-credentials # <-- name of the Kubernetes secret that stores our machine identity credentials
+ secretNamespace: default # <-- namespace of the Kubernetes secret that stores our machine identity credentials
+ ...
+ ```
-</Accordion>
+ </Accordion>
-<Accordion title="authentication.kubernetesAuth">
- The Kubernetes machine identity authentication method is used to authenticate with Infisical. The identity ID is stored in a field in the InfisicalSecret resource. This authentication method can only be used within a Kubernetes environment.
+ <Accordion title="authentication.kubernetesAuth">
+ The Kubernetes machine identity authentication method is used to authenticate with Infisical. The identity ID is stored in a field in the InfisicalSecret resource. This authentication method can only be used within a Kubernetes environment.
- <Steps>
- <Step title="Obtaining the token reviewer JWT for Infisical">
- 1.1. Start by creating a service account in your Kubernetes cluster that will be used by Infisical to authenticate with the Kubernetes API Server.
-
- ```yaml infisical-service-account.yaml
- apiVersion: v1
- kind: ServiceAccount
- metadata:
- name: infisical-auth
- namespace: default
-
- ```
-
- ```
- kubectl apply -f infisical-service-account.yaml
- ```
-
- 1.2. Bind the service account to the `system:auth-delegator` cluster role. As described [here](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#other-component-roles), this role allows delegated authentication and authorization checks, specifically for Infisical to access the [TokenReview API](https://kubernetes.io/docs/reference/kubernetes-api/authentication-resources/token-review-v1/). You can apply the following configuration file:
-
- ```yaml cluster-role-binding.yaml
- apiVersion: rbac.authorization.k8s.io/v1
- kind: ClusterRoleBinding
- metadata:
- name: role-tokenreview-binding
- namespace: default
- roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: system:auth-delegator
- subjects:
- - kind: ServiceAccount
+ <Steps>
+ <Step title="Obtaining the token reviewer JWT for Infisical">
+ 1.1. Start by creating a service account in your Kubernetes cluster that will be used by Infisical to authenticate with the Kubernetes API Server.
+
+ ```yaml infisical-service-account.yaml
+ apiVersion: v1
+ kind: ServiceAccount
+ metadata:
name: infisical-auth
namespace: default
- ```
- ```
- kubectl apply -f cluster-role-binding.yaml
- ```
+ ```
- 1.3. Next, create a long-lived service account JWT token (i.e. the token reviewer JWT token) for the service account using this configuration file for a new `Secret` resource:
+ ```
+ kubectl apply -f infisical-service-account.yaml
+ ```
- ```yaml service-account-token.yaml
- apiVersion: v1
- kind: Secret
- type: kubernetes.io/service-account-token
- metadata:
- name: infisical-auth-token
- annotations:
- kubernetes.io/service-account.name: "infisical-auth"
- ```
+ 1.2. Bind the service account to the `system:auth-delegator` cluster role. As described [here](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#other-component-roles), this role allows delegated authentication and authorization checks, specifically for Infisical to access the [TokenReview API](https://kubernetes.io/docs/reference/kubernetes-api/authentication-resources/token-review-v1/). You can apply the following configuration file:
+ ```yaml cluster-role-binding.yaml
+ apiVersion: rbac.authorization.k8s.io/v1
+ kind: ClusterRoleBinding
+ metadata:
+ name: role-tokenreview-binding
+ namespace: default
+ roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: ClusterRole
+ name: system:auth-delegator
+ subjects:
+ - kind: ServiceAccount
+ name: infisical-auth
+ namespace: default
+ ```
- ```
- kubectl apply -f service-account-token.yaml
- ```
-
- 1.4. Link the secret in step 1.3 to the service account in step 1.1:
+ ```
+ kubectl apply -f cluster-role-binding.yaml
+ ```
- ```bash
- kubectl patch serviceaccount infisical-auth -p '{"secrets": [{"name": "infisical-auth-token"}]}' -n default
- ```
+ 1.3. Next, create a long-lived service account JWT token (i.e. the token reviewer JWT token) for the service account using this configuration file for a new `Secret` resource:
- 1.5. Finally, retrieve the token reviewer JWT token from the secret.
+ ```yaml service-account-token.yaml
+ apiVersion: v1
+ kind: Secret
+ type: kubernetes.io/service-account-token
+ metadata:
+ name: infisical-auth-token
+ annotations:
+ kubernetes.io/service-account.name: "infisical-auth"
+ ```
- ```bash
- kubectl get secret infisical-auth-token -n default -o=jsonpath='{.data.token}' | base64 --decode
- ```
- Keep this JWT token handy as you will need it for the **Token Reviewer JWT** field when configuring the Kubernetes Auth authentication method for the identity in step 2.
+ ```
+ kubectl apply -f service-account-token.yaml
+ ```
- </Step>
+ 1.4. Link the secret in step 1.3 to the service account in step 1.1:
- <Step title="Creating an identity">
- To create an identity, head to your Organization Settings > Access Control > Machine Identities and press **Create identity**.
+ ```bash
+ kubectl patch serviceaccount infisical-auth -p '{"secrets": [{"name": "infisical-auth-token"}]}' -n default
+ ```
- ![identities organization](/images/platform/identities/identities-org.png)
+ 1.5. Finally, retrieve the token reviewer JWT token from the secret.
- When creating an identity, you specify an organization level [role](/documentation/platform/role-based-access-controls) for it to assume; you can configure roles in Organization Settings > Access Control > Organization Roles.
+ ```bash
+ kubectl get secret infisical-auth-token -n default -o=jsonpath='{.data.token}' | base64 --decode
+ ```
- ![identities organization create](/images/platform/identities/identities-org-create.png)
+ Keep this JWT token handy as you will need it for the **Token Reviewer JWT** field when configuring the Kubernetes Auth authentication method for the identity in step 2.
- Now input a few details for your new identity. Here's some guidance for each field:
+ </Step>
- - Name (required): A friendly name for the identity.
- - Role (required): A role from the **Organization Roles** tab for the identity to assume. The organization role assigned will determine what organization level resources this identity can have access to.
+ <Step title="Creating an identity">
+ To create an identity, head to your Organization Settings > Access Control > Machine Identities and press **Create identity**.
- Once you've created an identity, you'll be prompted to configure the authentication method for it. Here, select **Kubernetes Auth**.
+ ![identities organization](/images/platform/identities/identities-org.png)
- <Info>
- To learn more about each field of the Kubernetes native authentication method, see step 2 of [guide](/documentation/platform/identities/kubernetes-auth#guide).
- </Info>
+ When creating an identity, you specify an organization level [role](/documentation/platform/role-based-access-controls) for it to assume; you can configure roles in Organization Settings > Access Control > Organization Roles.
- ![identities organization create auth method](/images/platform/identities/identities-org-create-kubernetes-auth-method.png)
+ ![identities organization create](/images/platform/identities/identities-org-create.png)
+ Now input a few details for your new identity. Here's some guidance for each field:
- </Step>
- <Step title="Adding an identity to a project">
- To allow the operator to use the given identity to access secrets, you will need to add the identity to project(s) that you would like to grant it access to.
+ - Name (required): A friendly name for the identity.
+ - Role (required): A role from the **Organization Roles** tab for the identity to assume. The organization role assigned will determine what organization level resources this identity can have access to.
- To do this, head over to the project you want to add the identity to and go to Project Settings > Access Control > Machine Identities and press **Add identity**.
+ Once you've created an identity, you'll be prompted to configure the authentication method for it. Here, select **Kubernetes Auth**.
- Next, select the identity you want to add to the project and the project level role you want to allow it to assume. The project role assigned will determine what project level resources this identity can have access to.
+ <Info>
+ To learn more about each field of the Kubernetes native authentication method, see step 2 of [guide](/documentation/platform/identities/kubernetes-auth#guide).
+ </Info>
- ![identities project](/images/platform/identities/identities-project.png)
+ ![identities organization create auth method](/images/platform/identities/identities-org-create-kubernetes-auth-method.png)
- ![identities project create](/images/platform/identities/identities-project-create.png)
- </Step>
- <Step title="Add your identity ID & service account to your InfisicalSecret resource">
- Once you have created your machine identity and added it to your project(s), you will need to add the identity ID to your InfisicalSecret resource.
- In the `authentication.kubernetesAuth.identityId` field, add the identity ID of the machine identity you created.
- See the example below for more details.
- </Step>
- <Step title="Add your Kubernetes service account token to the InfisicalSecret resource">
- Add the service account details from the previous steps under `authentication.kubernetesAuth.serviceAccountRef`.
- Here you will need to enter the name and namespace of the service account.
- The example below shows a complete InfisicalSecret resource with all required fields defined.
- </Step>
+ </Step>
+ <Step title="Adding an identity to a project">
+ To allow the operator to use the given identity to access secrets, you will need to add the identity to project(s) that you would like to grant it access to.
- </Steps>
+ To do this, head over to the project you want to add the identity to and go to Project Settings > Access Control > Machine Identities and press **Add identity**.
-<Info>
- Make sure to also populate the `secretsScope` field with the project slug
- _`projectSlug`_, environment slug _`envSlug`_, and secrets path
- _`secretsPath`_ that you want to fetch secrets from. Please see the example
- below.
-</Info>
+ Next, select the identity you want to add to the project and the project level role you want to allow it to assume. The project role assigned will determine what project level resources this identity can have access to.
-## Example
+ ![identities project](/images/platform/identities/identities-project.png)
-```yaml example-kubernetes-auth.yaml
-apiVersion: secrets.infisical.com/v1alpha1
-kind: InfisicalSecret
-metadata:
- name: infisicalsecret-sample-crd
-spec:
- authentication:
- kubernetesAuth:
- identityId: <machine-identity-id>
- serviceAccountRef:
- name: <service-account-name>
- namespace: <service-account-namespace>
-
- # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
- secretsScope:
- projectSlug: your-project-slug
- envSlug: prod
- secretsPath: "/path"
- recursive: true
- ...
-```
+ ![identities project create](/images/platform/identities/identities-project-create.png)
-</Accordion>
+ </Step>
+ <Step title="Add your identity ID & service account to your InfisicalSecret resource">
+ Once you have created your machine identity and added it to your project(s), you will need to add the identity ID to your InfisicalSecret resource.
+ In the `authentication.kubernetesAuth.identityId` field, add the identity ID of the machine identity you created.
+ See the example below for more details.
+ </Step>
+ <Step title="Add your Kubernetes service account token to the InfisicalSecret resource">
+ Add the service account details from the previous steps under `authentication.kubernetesAuth.serviceAccountRef`.
+ Here you will need to enter the name and namespace of the service account.
+ The example below shows a complete InfisicalSecret resource with all required fields defined.
+ </Step>
-<Accordion title="authentication.awsIamAuth">
- The AWS IAM machine identity authentication method is used to authenticate with Infisical. The identity ID is stored in a field in the InfisicalSecret resource. This authentication method can only be used within an AWS environment like an EC2 or a Lambda function.
+ </Steps>
- <Steps>
- <Step title="Create a machine identity">
- You need to create a machine identity, and give it access to the project(s) you want to interact with. You can [read more about AWS machine identities here](/documentation/platform/identities/aws-auth).
- </Step>
- <Step title="Add your identity ID to your InfisicalSecret resource">
- Once you have created your machine identity and added it to your project(s), you will need to add the identity ID to your InfisicalSecret resource. In the `authentication.awsIamAuth.identityId` field, add the identity ID of the machine identity you created. See the example below for more details.
- </Step>
+ <Info>
+ Make sure to also populate the `secretsScope` field with the project slug
+ _`projectSlug`_, environment slug _`envSlug`_, and secrets path
+ _`secretsPath`_ that you want to fetch secrets from. Please see the example
+ below.
+ </Info>
- </Steps>
+ ## Example
-<Info>
- Make sure to also populate the `secretsScope` field with the project slug
- _`projectSlug`_, environment slug _`envSlug`_, and secrets path
- _`secretsPath`_ that you want to fetch secrets from. Please see the example
- below.
-</Info>
+ ```yaml example-kubernetes-auth.yaml
+ apiVersion: secrets.infisical.com/v1alpha1
+ kind: InfisicalSecret
+ metadata:
+ name: infisicalsecret-sample-crd
+ spec:
+ authentication:
+ kubernetesAuth:
+ identityId: <machine-identity-id>
+ serviceAccountRef:
+ name: <service-account-name>
+ namespace: <service-account-namespace>
-## Example
+ # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
+ secretsScope:
+ projectSlug: your-project-slug
+ envSlug: prod
+ secretsPath: "/path"
+ recursive: true
+ ...
+ ```
-```yaml example-aws-iam-auth.yaml
-apiVersion: secrets.infisical.com/v1alpha1
-kind: InfisicalSecret
-metadata:
- name: infisicalsecret-sample-crd
-spec:
- authentication:
- awsIamAuth:
- identityId: <your-machine-identity-id>
-
- # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
- secretsScope:
- projectSlug: your-project-slug
- envSlug: prod
- secretsPath: "/path"
- recursive: true
- ...
-```
+ </Accordion>
-</Accordion>
+ <Accordion title="authentication.awsIamAuth">
+ The AWS IAM machine identity authentication method is used to authenticate with Infisical. The identity ID is stored in a field in the InfisicalSecret resource. This authentication method can only be used within an AWS environment like an EC2 or a Lambda function.
+
+ <Steps>
+ <Step title="Create a machine identity">
+ You need to create a machine identity, and give it access to the project(s) you want to interact with. You can [read more about AWS machine identities here](/documentation/platform/identities/aws-auth).
+ </Step>
+ <Step title="Add your identity ID to your InfisicalSecret resource">
+ Once you have created your machine identity and added it to your project(s), you will need to add the identity ID to your InfisicalSecret resource. In the `authentication.awsIamAuth.identityId` field, add the identity ID of the machine identity you created. See the example below for more details.
+ </Step>
+
+ </Steps>
+
+ <Info>
+ Make sure to also populate the `secretsScope` field with the project slug
+ _`projectSlug`_, environment slug _`envSlug`_, and secrets path
+ _`secretsPath`_ that you want to fetch secrets from. Please see the example
+ below.
+ </Info>
+
+ ## Example
+
+ ```yaml example-aws-iam-auth.yaml
+ apiVersion: secrets.infisical.com/v1alpha1
+ kind: InfisicalSecret
+ metadata:
+ name: infisicalsecret-sample-crd
+ spec:
+ authentication:
+ awsIamAuth:
+ identityId: <your-machine-identity-id>
+
+ # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
+ secretsScope:
+ projectSlug: your-project-slug
+ envSlug: prod
+ secretsPath: "/path"
+ recursive: true
+ ...
+ ```
-<Accordion title="authentication.azureAuth">
- The Azure machine identity authentication method is used to authenticate with Infisical. The identity ID is stored in a field in the InfisicalSecret resource. This authentication method can only be used within an Azure environment.
+ </Accordion>
- <Steps>
- <Step title="Create a machine identity">
- You need to create a machine identity, and give it access to the project(s) you want to interact with. You can [read more about Azure machine identities here](/documentation/platform/identities/azure-auth).
- </Step>
- <Step title="Add your identity ID to your InfisicalSecret resource">
- Once you have created your machine identity and added it to your project(s), you will need to add the identity ID to your InfisicalSecret resource. In the `authentication.azureAuth.identityId` field, add the identity ID of the machine identity you created. See the example below for more details.
- </Step>
+ <Accordion title="authentication.azureAuth">
+ The Azure machine identity authentication method is used to authenticate with Infisical. The identity ID is stored in a field in the InfisicalSecret resource. This authentication method can only be used within an Azure environment.
+
+ <Steps>
+ <Step title="Create a machine identity">
+ You need to create a machine identity, and give it access to the project(s) you want to interact with. You can [read more about Azure machine identities here](/documentation/platform/identities/azure-auth).
+ </Step>
+ <Step title="Add your identity ID to your InfisicalSecret resource">
+ Once you have created your machine identity and added it to your project(s), you will need to add the identity ID to your InfisicalSecret resource. In the `authentication.azureAuth.identityId` field, add the identity ID of the machine identity you created. See the example below for more details.
+ </Step>
+
+ </Steps>
+
+ <Info>
+ Make sure to also populate the `secretsScope` field with the project slug
+ _`projectSlug`_, environment slug _`envSlug`_, and secrets path
+ _`secretsPath`_ that you want to fetch secrets from. Please see the example
+ below.
+ </Info>
+
+ ## Example
+
+ ```yaml example-azure-auth.yaml
+ apiVersion: secrets.infisical.com/v1alpha1
+ kind: InfisicalSecret
+ metadata:
+ name: infisicalsecret-sample-crd
+ spec:
+ authentication:
+ azureAuth:
+ identityId: <your-machine-identity-id>
+
+ # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
+ secretsScope:
+ projectSlug: your-project-slug
+ envSlug: prod
+ secretsPath: "/path"
+ recursive: true
+ ...
+ ```
- </Steps>
+ </Accordion>
-<Info>
- Make sure to also populate the `secretsScope` field with the project slug
- _`projectSlug`_, environment slug _`envSlug`_, and secrets path
- _`secretsPath`_ that you want to fetch secrets from. Please see the example
- below.
-</Info>
+ <Accordion title="authentication.gcpIdTokenAuth">
+ The GCP ID Token machine identity authentication method is used to authenticate with Infisical. The identity ID is stored in a field in the InfisicalSecret resource. This authentication method can only be used within GCP environments.
+
+ <Steps>
+ <Step title="Create a machine identity">
+ You need to create a machine identity, and give it access to the project(s) you want to interact with. You can [read more about GCP machine identities here](/documentation/platform/identities/gcp-auth).
+ </Step>
+ <Step title="Add your identity ID to your InfisicalSecret resource">
+ Once you have created your machine identity and added it to your project(s), you will need to add the identity ID to your InfisicalSecret resource. In the `authentication.gcpIdTokenAuth.identityId` field, add the identity ID of the machine identity you created. See the example below for more details.
+ </Step>
+
+ </Steps>
+
+ <Info>
+ Make sure to also populate the `secretsScope` field with the project slug
+ _`projectSlug`_, environment slug _`envSlug`_, and secrets path
+ _`secretsPath`_ that you want to fetch secrets from. Please see the example
+ below.
+ </Info>
+
+ ## Example
+
+ ```yaml example-gcp-id-token-auth.yaml
+ apiVersion: secrets.infisical.com/v1alpha1
+ kind: InfisicalSecret
+ metadata:
+ name: infisicalsecret-sample-crd
+ spec:
+ authentication:
+ gcpIdTokenAuth:
+ identityId: <your-machine-identity-id>
+
+ # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
+ secretsScope:
+ projectSlug: your-project-slug
+ envSlug: prod
+ secretsPath: "/path"
+ recursive: true
+ ...
+ ```
-## Example
+ </Accordion>
-```yaml example-azure-auth.yaml
-apiVersion: secrets.infisical.com/v1alpha1
-kind: InfisicalSecret
-metadata:
- name: infisicalsecret-sample-crd
-spec:
- authentication:
- azureAuth:
- identityId: <your-machine-identity-id>
-
- # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
- secretsScope:
- projectSlug: your-project-slug
- envSlug: prod
- secretsPath: "/path"
- recursive: true
- ...
-```
+ <Accordion title="authentication.gcpIamAuth">
+ The GCP IAM machine identity authentication method is used to authenticate with Infisical. The identity ID is stored in a field in the InfisicalSecret resource. This authentication method can only be used both within and outside GCP environments.
+
+ <Steps>
+ <Step title="Create a machine identity">
+ You need to create a machine identity, and give it access to the project(s) you want to interact with. You can [read more about GCP machine identities here](/documentation/platform/identities/gcp-auth).
+ </Step>
+ <Step title="Add your identity ID and service account token path to your InfisicalSecret resource">
+ Once you have created your machine identity and added it to your project(s), you will need to add the identity ID to your InfisicalSecret resource. In the `authentication.gcpIamAuth.identityId` field, add the identity ID of the machine identity you created.
+ You'll also need to add the service account key file path to your InfisicalSecret resource. In the `authentication.gcpIamAuth.serviceAccountKeyFilePath` field, add the path to your service account key file path. Please see the example below for more details.
+ </Step>
+
+ </Steps>
+
+ <Info>
+ Make sure to also populate the `secretsScope` field with the project slug
+ _`projectSlug`_, environment slug _`envSlug`_, and secrets path
+ _`secretsPath`_ that you want to fetch secrets from. Please see the example
+ below.
+ </Info>
+
+ ## Example
+
+ ```yaml example-gcp-id-token-auth.yaml
+ apiVersion: secrets.infisical.com/v1alpha1
+ kind: InfisicalSecret
+ metadata:
+ name: infisicalsecret-sample-crd
+ spec:
+ authentication:
+ gcpIamAuth:
+ identityId: <your-machine-identity-id>
+ serviceAccountKeyFilePath: "/path/to-service-account-key-file-path.json"
+
+ # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
+ secretsScope:
+ projectSlug: your-project-slug
+ envSlug: prod
+ secretsPath: "/path"
+ recursive: true
+ ...
+ ```
-</Accordion>
+ </Accordion>
-<Accordion title="authentication.gcpIdTokenAuth">
- The GCP ID Token machine identity authentication method is used to authenticate with Infisical. The identity ID is stored in a field in the InfisicalSecret resource. This authentication method can only be used within GCP environments.
+ <Accordion title="authentication.serviceToken">
- <Steps>
- <Step title="Create a machine identity">
- You need to create a machine identity, and give it access to the project(s) you want to interact with. You can [read more about GCP machine identities here](/documentation/platform/identities/gcp-auth).
- </Step>
- <Step title="Add your identity ID to your InfisicalSecret resource">
- Once you have created your machine identity and added it to your project(s), you will need to add the identity ID to your InfisicalSecret resource. In the `authentication.gcpIdTokenAuth.identityId` field, add the identity ID of the machine identity you created. See the example below for more details.
- </Step>
+ The service token required to authenticate with Infisical needs to be stored in a Kubernetes secret. This block defines the reference to the name and namespace of secret that stores this service token.
+ Follow the instructions below to create and store the service token in a Kubernetes secrets and reference it in your CRD.
- </Steps>
+ #### 1. Generate service token
-<Info>
- Make sure to also populate the `secretsScope` field with the project slug
- _`projectSlug`_, environment slug _`envSlug`_, and secrets path
- _`secretsPath`_ that you want to fetch secrets from. Please see the example
- below.
-</Info>
+ You can generate a [service token](../../documentation/platform/token) for an Infisical project by heading over to the Infisical dashboard then to Project Settings.
-## Example
+ #### 2. Create Kubernetes secret containing service token
-```yaml example-gcp-id-token-auth.yaml
-apiVersion: secrets.infisical.com/v1alpha1
-kind: InfisicalSecret
-metadata:
- name: infisicalsecret-sample-crd
-spec:
- authentication:
- gcpIdTokenAuth:
- identityId: <your-machine-identity-id>
-
- # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
- secretsScope:
- projectSlug: your-project-slug
- envSlug: prod
- secretsPath: "/path"
- recursive: true
- ...
-```
+ Once you have generated the service token, you will need to create a Kubernetes secret containing the service token you generated.
+ To quickly create a Kubernetes secret containing the generated service token, you can run the command below. Make sure you replace `<your-service-token-here>` with your service token.
-</Accordion>
+ ```bash
+ kubectl create secret generic service-token --from-literal=infisicalToken="<your-service-token-here>"
+ ```
-<Accordion title="authentication.gcpIamAuth">
- The GCP IAM machine identity authentication method is used to authenticate with Infisical. The identity ID is stored in a field in the InfisicalSecret resource. This authentication method can only be used both within and outside GCP environments.
+ #### 3. Add reference for the Kubernetes secret containing service token
- <Steps>
- <Step title="Create a machine identity">
- You need to create a machine identity, and give it access to the project(s) you want to interact with. You can [read more about GCP machine identities here](/documentation/platform/identities/gcp-auth).
- </Step>
- <Step title="Add your identity ID and service account token path to your InfisicalSecret resource">
- Once you have created your machine identity and added it to your project(s), you will need to add the identity ID to your InfisicalSecret resource. In the `authentication.gcpIamAuth.identityId` field, add the identity ID of the machine identity you created.
- You'll also need to add the service account key file path to your InfisicalSecret resource. In the `authentication.gcpIamAuth.serviceAccountKeyFilePath` field, add the path to your service account key file path. Please see the example below for more details.
- </Step>
+ Once the secret is created, add the name and namespace of the secret that was just created under `authentication.serviceToken.serviceTokenSecretReference` field in the InfisicalSecret resource.
- </Steps>
+ {" "}
-<Info>
- Make sure to also populate the `secretsScope` field with the project slug
- _`projectSlug`_, environment slug _`envSlug`_, and secrets path
- _`secretsPath`_ that you want to fetch secrets from. Please see the example
- below.
-</Info>
+ <Info>
+ Make sure to also populate the `secretsScope` field with the, environment slug
+ _`envSlug`_, and secrets path _`secretsPath`_ that you want to fetch secrets
+ from. Please see the example below.
+ </Info>
-## Example
+ ## Example
-```yaml example-gcp-id-token-auth.yaml
-apiVersion: secrets.infisical.com/v1alpha1
-kind: InfisicalSecret
-metadata:
- name: infisicalsecret-sample-crd
-spec:
- authentication:
- gcpIamAuth:
- identityId: <your-machine-identity-id>
- serviceAccountKeyFilePath: "/path/to-service-account-key-file-path.json"
-
- # secretsScope is identical to the secrets scope in the universalAuth field in this sample.
- secretsScope:
- projectSlug: your-project-slug
- envSlug: prod
- secretsPath: "/path"
- recursive: true
- ...
-```
+ ```yaml
+ apiVersion: secrets.infisical.com/v1alpha1
+ kind: InfisicalSecret
+ metadata:
+ name: infisicalsecret-sample-crd
+ spec:
+ authentication:
+ serviceToken:
+ serviceTokenSecretReference:
+ secretName: service-token # <-- name of the Kubernetes secret that stores our service token
+ secretNamespace: option # <-- namespace of the Kubernetes secret that stores our service token
+ secretsScope:
+ envSlug: <env-slug> # "dev", "staging", "prod", etc..
+ secretsPath: <secrets-path> # Root is "/"
+ ...
+ ```
+ </Accordion>
</Accordion>
-<Accordion title="authentication.serviceToken">
-
-The service token required to authenticate with Infisical needs to be stored in a Kubernetes secret. This block defines the reference to the name and namespace of secret that stores this service token.
-Follow the instructions below to create and store the service token in a Kubernetes secrets and reference it in your CRD.
-
-#### 1. Generate service token
-
-You can generate a [service token](../../documentation/platform/token) for an Infisical project by heading over to the Infisical dashboard then to Project Settings.
-
-#### 2. Create Kubernetes secret containing service token
-
-Once you have generated the service token, you will need to create a Kubernetes secret containing the service token you generated.
-To quickly create a Kubernetes secret containing the generated service token, you can run the command below. Make sure you replace `<your-service-token-here>` with your service token.
+<Accordion title="managedSecretReferences">
+The `managedSecretReferences` field is used to define the target location(s) for storing secrets retrieved from an Infisical project.
+This field requires specifying both the name and namespace of the Kubernetes secret that will hold these secrets.
+The Infisical operator will automatically create the Kubernetes secret with the specified name/namespace and keep it continuously updated.
-```bash
-kubectl create secret generic service-token --from-literal=infisicalToken="<your-service-token-here>"
-```
-
-#### 3. Add reference for the Kubernetes secret containing service token
-
-Once the secret is created, add the name and namespace of the secret that was just created under `authentication.serviceToken.serviceTokenSecretReference` field in the InfisicalSecret resource.
-
-{" "}
-
-<Info>
- Make sure to also populate the `secretsScope` field with the, environment slug
- _`envSlug`_, and secrets path _`secretsPath`_ that you want to fetch secrets
- from. Please see the example below.
-</Info>
-
-## Example
+The `managedSecretReferences` field is an array of objects. Below you can see the structure of the `managedSecretReferences` object.
+Example using a single managed secret reference:
```yaml
-apiVersion: secrets.infisical.com/v1alpha1
-kind: InfisicalSecret
-metadata:
- name: infisicalsecret-sample-crd
-spec:
- authentication:
- serviceToken:
- serviceTokenSecretReference:
- secretName: service-token # <-- name of the Kubernetes secret that stores our service token
- secretNamespace: option # <-- namespace of the Kubernetes secret that stores our service token
- secretsScope:
- envSlug: <env-slug> # "dev", "staging", "prod", etc..
- secretsPath: <secrets-path> # Root is "/"
- ...
+managedSecretReferences:
+ - secretName: managed-secret
+ secretNamespace: default
+ creationPolicy: "Orphan" ## Owner | Orphan
+ # template:
+ # includeAllSecrets: true
+ # data:
+ # CUSTOM_KEY: "{{ .KEY.SecretPath }} {{ .KEY.Value }}"
+ # secretType: kubernetes.io/dockerconfigjson
```
-</Accordion>
-
-### Operator managed secrets
-
-The managed secret properties specify where to store the secrets retrieved from your Infisical project.
-This includes defining the name and namespace of the Kubernetes secret that will hold these secrets.
-The Infisical operator will automatically create the Kubernetes secret in the specified name/namespace and ensure it stays up-to-date.
-
-<Accordion title="managedSecretReference">
-</Accordion>
-<Accordion title="managedSecretReference.secretName">
-The name of the managed Kubernetes secret to be created
-</Accordion>
-<Accordion title="managedSecretReference.secretNamespace">
-The namespace of the managed Kubernetes secret to be created.
-</Accordion>
-<Accordion title="managedSecretReference.secretType">
-Override the default Opaque type for managed secrets with this field. Useful for creating kubernetes.io/dockerconfigjson secrets.
-</Accordion>
-<Accordion title="managedSecretReference.creationPolicy">
-Creation polices allow you to control whether or not owner references should be added to the managed Kubernetes secret that is generated by the Infisical operator.
-This is useful for tools such as ArgoCD, where every resource requires an owner reference; otherwise, it will be pruned automatically.
-
-#### Available options
-
-- `Orphan` (default)
-- `Owner`
-
-<Tip>
- When creation policy is set to `Owner`, the `InfisicalSecret` CRD must be in
- the same namespace as where the managed kubernetes secret.
-</Tip>
-
-</Accordion>
-
-### Manged secret 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.
-
-<Accordion title="managedSecretReference.template">
-</Accordion>
-<Accordion title="managedSecretReference.template.includeAllSecrets">
- This property controls what secrets are included in your managed secret when using templates.
- When set to `true`, all secrets fetched from your Infisical project will be added into your managed Kubernetes secret resource.
- **Use this option when you would like to sync all secrets from Infisical to Kubernetes but want to template a subset of them.**
-
-When set to `false`, only secrets defined in the `managedSecretReference.template.data` field of the template will be included in the managed secret.
-Use this option when you would like to sync **only** a subset of secrets from Infisical to Kubernetes.
-
-</Accordion>
-<Accordion title="managedSecretReference.template.data">
-Define secret keys and their corresponding templates.
-Each data value uses a Golang template with access to all secrets retrieved from the specified scope.
+ Note: The managed secret be should be created in the same namespace as the deployment that will use it.
+ <Accordion title="managedSecretReferences.[index].secretName">
+ The name of the managed Kubernetes secret to be created
+ </Accordion>
+ <Accordion title="managedSecretReferences.[index].secretNamespace">
+ The namespace of the managed Kubernetes secret to be created.
+ </Accordion>
+ <Accordion title="managedSecretReferences.[index].secretType">
+ Override the default Opaque type for managed secrets with this field. Useful for creating `kubernetes.io/dockerconfigjson` secrets.
+ </Accordion>
+ <Accordion title="managedSecretReferences.[index].template">
+ Templates enable you to transform data from Infisical before storing it as a Kubernetes Secret.
+ </Accordion>
+ <Accordion title="managedSecretReferences.[index].template.includeAllSecrets">
+ When set to true, this option injects all secrets retrieved from Infisical into your configuration.
+ Secrets defined in the template will override the automatically injected secrets.
+ </Accordion>
+ <Accordion title="managedSecretReferences.[index].template.data">
+ Define secret keys and their corresponding templates.
+ Each data value uses a Golang template with access to all secrets retrieved from the specified scope.
-Secrets are structured as follows:
+ Secrets are structured as follows:
-```golang
-type TemplateSecret struct {
- Value string `json:"value"`
- SecretPath string `json:"secretPath"`
-}
-```
+ ```golang
+ type TemplateSecret struct {
+ Value string `json:"value"`
+ SecretPath string `json:"secretPath"`
+ }
+ ```
-#### Example template configuration:
+ #### Example template configuration:
-```yaml
-managedSecretReference:
- secretName: managed-secret
- secretNamespace: default
- template:
- includeAllSecrets: true
- data:
- # Create new secret key that doesn't exist in your Infisical project using values of other secrets
- NEW_KEY: "{{ .DB_PASSWORD.Value }}"
- # Override an existing secret key in Infisical project with a new value using values of other secrets
- API_URL: "https://api.{{.COMPANY_NAME.Value}}.{{.REGION.Value}}.com"
-```
+ ```golang
+ managedSecretReferences:
+ - secretName: managed-secret
+ secretNamespace: default
+ template:
+ includeAllSecrets: true
+ data:
+ NEW_KEY: "{{ .KEY1.SecretPath }} {{ .KEY1.Value }}"
+ ```
-For this example, let's assume the following secrets exist in your Infisical project:
+ When you run the following command:
-```
-DB_PASSWORD = "secret123"
-COMPANY_NAME = "acme"
-REGION = "us-east-1"
-API_URL = "old-url" # This will be overridden
-```
+ ```bash
+ kubectl get secret managed-secret -o jsonpath='{.data}'
+ ```
-The resulting managed Kubernetes secret will then contain:
+ You'll receive Kubernetes secrets output that includes the NEW_KEY:
-```
-# Original secrets (from includeAllSecrets: true)
-DB_PASSWORD = "secret123"
-COMPANY_NAME = "acme"
-REGION = "us-east-1"
-
-# New and overridden templated secrets
-NEW_KEY = "secret123" # New secret created from template
-API_URL = "https://api.acme.us-east-1.com" # Existing secret overridden by template
-```
+ ```bash
+ {... "KEY":"d29ybGQ=","NEW_KEY":"LyBoZWxsbw=="}
+ ```
-To help transform your secrets further, the operator provides a set of built-in functions that you can use in your templates.
+ When you set `includeAllSecrets` as `false` the Kubernetes secrets outputs will be:
-### Available templating functions
+ ```bash
+ {"NEW_KEY":"LyBoZWxsbw=="}
+ ```
-<Accordion title="decodeBase64ToBytes">
- **Function name**: decodeBase64ToBytes
+ </Accordion>
+ <Accordion title="managedSecretReferences.[index].creationPolicy">
+ Creation polices allow you to control whether or not owner references should be added to the managed Kubernetes secret that is generated by the Infisical operator.
+ This is useful for tools such as ArgoCD, where every resource requires an owner reference; otherwise, it will be pruned automatically.
-**Description**:
-Given a base64 encoded string, this function will decodes the base64-encoded string.
-This function is useful when your secrets are already stored as base64 encoded value in Infisical.
+ #### Available options
-**Returns**: The decoded base64 string as bytes.
+ - `Orphan` (default)
+ - `Owner`
-**Example**:
-The example below assumes that the `BINARY_KEY_BASE64` secret is stored as a base64 encoded value in Infisical.
-The resulting managed secret will contain the decoded value of `BINARY_KEY_BASE64`.
+ <Tip>
+ When creation policy is set to `Owner`, the `InfisicalSecret` CRD must be in
+ the same namespace as where the managed kubernetes secret.
+ </Tip>
-```yaml
-managedSecretReference:
-secretName: managed-secret
-secretNamespace: default
-template:
- includeAllSecrets: true
- data:
- BINARY_KEY: "{{ decodeBase64ToBytes .BINARY_KEY_BASE64.Value }}"
-```
+ </Accordion>
-</Accordion>
</Accordion>
-## Applying CRD
+### Apply the InfisicalSecret CRD to your cluster
Once you have configured the InfisicalSecret CRD with the required fields, you can apply it to your cluster.
After applying, you should notice that the managed secret has been created in the desired namespace your specified.
@@ -674,6 +717,8 @@ After applying, you should notice that the managed secret has been created in th
kubectl apply -f example-infisical-secret-crd.yaml
```
+### Verify managed secret creation
+
To verify that the operator has successfully created the managed secret, you can check the secrets in the namespace that was specified.
```bash
@@ -688,7 +733,7 @@ kubectl get secrets -n <namespace of managed secret>
## Using managed secret in your deployment
-To make use of the managed secret created by the operator into your deployment can be achieved through several methods.
+Incorporating the managed secret created by the operator into your deployment can be achieved through several methods.
Here, we will highlight three of the most common ways to utilize it. Learn more about Kubernetes secrets [here](https://kubernetes.io/docs/concepts/configuration/secret/)
<Accordion title="envFrom">
@@ -913,7 +958,7 @@ spec:
..
authentication:
...
- managedSecretReference:
+ managedSecretReferences:
...
```
@@ -934,4 +979,4 @@ metadata:
type: Opaque
```
-</Accordion>
+</Accordion>
\ No newline at end of file
diff --git a/k8-operator/config/samples/crd/infisicalsecret/infisicalSecretCrd.yaml b/k8-operator/config/samples/crd/infisicalsecret/infisicalSecretCrd.yaml
index 43ec5a7e40..108b86e783 100644
--- a/k8-operator/config/samples/crd/infisicalsecret/infisicalSecretCrd.yaml
+++ b/k8-operator/config/samples/crd/infisicalsecret/infisicalSecretCrd.yaml
@@ -97,11 +97,11 @@ spec:
secretsPath: "/path"
recursive: true
- managedSecretReference:
- secretName: managed-secret
- secretNamespace: default
- creationPolicy: "Orphan" ## Owner | Orphan
- # secretType: kubernetes.io/dockerconfigjson
+ managedSecretReferences:
+ - secretName: managed-secret
+ secretNamespace: default
+ creationPolicy: "Orphan" ## Owner | Orphan
+ # secretType: kubernetes.io/dockerconfigjson
# # To be depreciated soon
# tokenSecretReference: