Skip to content

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

extract kubernetes auth into shared snippet

Matheus Nogueiraa3a7b95ad1a2
diff --git a/docs/integrations/platforms/kubernetes/infisical-auth-crd.mdx b/docs/integrations/platforms/kubernetes/infisical-auth-crd.mdx
index c100c9e230..1f462775e6 100644
--- a/docs/integrations/platforms/kubernetes/infisical-auth-crd.mdx
+++ b/docs/integrations/platforms/kubernetes/infisical-auth-crd.mdx
@@ -4,6 +4,8 @@ title: "Using the InfisicalAuth CRD"
description: "Learn how to configure the InfisicalAuth CRD to define how the operator authenticates with Infisical."
---
+import KubernetesAuthOperatorSetup from "/snippets/documentation/platform/identities/kubernetes-auth-operator-setup.mdx";
+
## Overview
The **InfisicalAuth** CRD defines how the Infisical Operator authenticates with your Infisical instance. It encapsulates the machine identity authentication method and credentials. Once created, it can be referenced by multiple secret resources, so you only need to define authentication details once per identity.
@@ -26,239 +28,7 @@ Authenticates using a Kubernetes service account token. This is the recommended
[Read more about Kubernetes Auth](/documentation/platform/identities/kubernetes-auth).
-<Tabs>
- <Tab title="Short-lived service account tokens (Recommended)">
-<Steps>
- <Step title="Create a token reviewer service account">
- Create a reviewer service account in your Kubernetes cluster. Infisical uses this account to authenticate with the Kubernetes API Server through the TokenReview API.
-
- ```yaml infisical-reviewer-service-account.yaml
- apiVersion: v1
- kind: ServiceAccount
- metadata:
- name: infisical-token-reviewer
- namespace: default
- ```
-
- ```bash
- kubectl apply -f infisical-reviewer-service-account.yaml
- ```
- </Step>
-
- <Step title="Bind the reviewer service account">
- Bind the reviewer service account to the `system:auth-delegator` cluster role. This allows Infisical to perform delegated authentication checks against the TokenReview API.
-
- ```yaml infisical-reviewer-cluster-role-binding.yaml
- apiVersion: rbac.authorization.k8s.io/v1
- kind: ClusterRoleBinding
- metadata:
- name: infisical-token-reviewer-role-binding
- namespace: default
- roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: system:auth-delegator
- subjects:
- - kind: ServiceAccount
- name: infisical-token-reviewer
- namespace: default
- ```
-
- ```bash
- kubectl apply -f infisical-reviewer-cluster-role-binding.yaml
- ```
- </Step>
-
- <Step title="Create and retrieve the token reviewer JWT">
- Create a service account token secret for the reviewer service account:
-
- ```yaml service-account-reviewer-token.yaml
- apiVersion: v1
- kind: Secret
- type: kubernetes.io/service-account-token
- metadata:
- name: infisical-token-reviewer-token
- annotations:
- kubernetes.io/service-account.name: "infisical-token-reviewer"
- ```
-
- ```bash
- kubectl apply -f service-account-reviewer-token.yaml
- ```
-
- Link the secret to the reviewer service account:
-
- ```bash
- kubectl patch serviceaccount infisical-token-reviewer \
- -p '{"secrets": [{"name": "infisical-token-reviewer-token"}]}' \
- -n default
- ```
-
- Retrieve the token reviewer JWT:
-
- ```bash
- kubectl get secret infisical-token-reviewer-token \
- -n default \
- -o=jsonpath='{.data.token}' | base64 --decode
- ```
-
- Keep this JWT token handy. You will need it for the **Token Reviewer JWT** field when configuring Kubernetes Auth on the machine identity in Infisical.
- </Step>
-
- <Step title="Create and configure a machine identity">
- Follow the [Kubernetes Auth guide](/documentation/platform/identities/kubernetes-auth#guide) to create a machine identity, configure its **Kubernetes Auth** authentication method, and add it to the projects it should access.
-
- Use the token reviewer JWT from the previous step when filling the **Token Reviewer JWT** field.
- </Step>
-
- <Step title="Create the service account used for authentication">
- Create the Kubernetes service account that the operator will use to authenticate with Infisical. The operator creates short-lived tokens for this service account automatically.
-
- ```yaml infisical-service-account.yaml
- apiVersion: v1
- kind: ServiceAccount
- metadata:
- name: infisical-service-account
- namespace: default
- ```
-
- ```bash
- kubectl apply -f infisical-service-account.yaml
- ```
- </Step>
-</Steps>
- </Tab>
- <Tab title="Manual long-lived service account tokens">
- Manual long-lived service account tokens are created as Kubernetes secrets and remain valid until deleted or rotated. In most cases, use short-lived service account tokens instead because they are easier to operate and reduce the lifetime of exposed credentials.
-
- <Steps>
- <Step title="Create a token reviewer service account">
- Create a reviewer service account in your Kubernetes cluster. Infisical uses this account to authenticate with the Kubernetes API Server through the TokenReview API.
-
- ```yaml infisical-reviewer-service-account.yaml
- apiVersion: v1
- kind: ServiceAccount
- metadata:
- name: infisical-token-reviewer
- namespace: default
- ```
-
- ```bash
- kubectl apply -f infisical-reviewer-service-account.yaml
- ```
- </Step>
-
- <Step title="Bind the reviewer service account">
- Bind the reviewer service account to the `system:auth-delegator` cluster role. This allows Infisical to perform delegated authentication checks against the TokenReview API.
-
- ```yaml infisical-reviewer-cluster-role-binding.yaml
- apiVersion: rbac.authorization.k8s.io/v1
- kind: ClusterRoleBinding
- metadata:
- name: infisical-token-reviewer-role-binding
- namespace: default
- roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: system:auth-delegator
- subjects:
- - kind: ServiceAccount
- name: infisical-token-reviewer
- namespace: default
- ```
-
- ```bash
- kubectl apply -f infisical-reviewer-cluster-role-binding.yaml
- ```
- </Step>
-
- <Step title="Create and retrieve the token reviewer JWT">
- Create a service account token secret for the reviewer service account:
-
- ```yaml service-account-reviewer-token.yaml
- apiVersion: v1
- kind: Secret
- type: kubernetes.io/service-account-token
- metadata:
- name: infisical-token-reviewer-token
- annotations:
- kubernetes.io/service-account.name: "infisical-token-reviewer"
- ```
-
- ```bash
- kubectl apply -f service-account-reviewer-token.yaml
- ```
-
- Link the secret to the reviewer service account:
-
- ```bash
- kubectl patch serviceaccount infisical-token-reviewer \
- -p '{"secrets": [{"name": "infisical-token-reviewer-token"}]}' \
- -n default
- ```
-
- Retrieve the token reviewer JWT:
-
- ```bash
- kubectl get secret infisical-token-reviewer-token \
- -n default \
- -o=jsonpath='{.data.token}' | base64 --decode
- ```
-
- Keep this JWT token handy. You will need it for the **Token Reviewer JWT** field when configuring Kubernetes Auth on the machine identity in Infisical.
- </Step>
-
- <Step title="Create and configure a machine identity">
- Follow the [Kubernetes Auth guide](/documentation/platform/identities/kubernetes-auth#guide) to create a machine identity, configure its **Kubernetes Auth** authentication method, and add it to the projects it should access.
-
- Use the token reviewer JWT from the previous step when filling the **Token Reviewer JWT** field.
- </Step>
-
- <Step title="Create the service account used for authentication">
- Create the Kubernetes service account that the operator will use to authenticate with Infisical.
-
- ```yaml infisical-service-account.yaml
- apiVersion: v1
- kind: ServiceAccount
- metadata:
- name: infisical-service-account
- namespace: default
- ```
-
- ```bash
- kubectl apply -f infisical-service-account.yaml
- ```
- </Step>
-
- <Step title="Create a long-lived token for the service account">
- Create a service account token secret for the service account used to authenticate with Infisical:
-
- ```yaml infisical-service-account-token.yaml
- apiVersion: v1
- kind: Secret
- type: kubernetes.io/service-account-token
- metadata:
- name: infisical-service-account-token
- namespace: default
- annotations:
- kubernetes.io/service-account.name: "infisical-service-account"
- ```
-
- ```bash
- kubectl apply -f infisical-service-account-token.yaml
- ```
-
- Patch the service account with the newly created service account token:
-
- ```bash
- kubectl patch serviceaccount infisical-service-account \
- -p '{"secrets": [{"name": "infisical-service-account-token"}]}' \
- -n default
- ```
- </Step>
- </Steps>
- </Tab>
-</Tabs>
+<KubernetesAuthOperatorSetup />
| Field | Required | Description |
| ------------------------------ | -------- | --------------------------------------------------------- |
diff --git a/docs/integrations/platforms/kubernetes/infisical-secret-crd.mdx b/docs/integrations/platforms/kubernetes/infisical-secret-crd.mdx
index 8092203421..60d7d0f698 100644
--- a/docs/integrations/platforms/kubernetes/infisical-secret-crd.mdx
+++ b/docs/integrations/platforms/kubernetes/infisical-secret-crd.mdx
@@ -5,6 +5,7 @@ description: "Learn how to use the InfisicalSecret CRD to fetch secrets from Inf
---
import KubernetesOperatorTemplatingHelpers from "/snippets/kubernetes-operator-templating-helpers.mdx";
+import KubernetesAuthOperatorSetup from "/snippets/documentation/platform/identities/kubernetes-auth-operator-setup.mdx";
<Warning>
The `InfisicalSecret` CRD is deprecated and will be removed in a future release.
@@ -216,157 +217,24 @@ spec:
<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.
- <Tabs>
- <Tab title="Short-lived service account tokens (Recommended)">
- Short-lived service account tokens are automatically created by the operator and are valid only for a short period of time. This is the recommended approach for using Kubernetes auth in the Infisical Secrets Operator.
+ <KubernetesAuthOperatorSetup />
- <Steps>
- <Step title="Obtaining the token reviewer JWT for Infisical">
- **1.1.** Start by creating a reviewer service account in your Kubernetes cluster that will be used by Infisical to authenticate with the Kubernetes API Server.
+ Once you have set up the Kubernetes Auth prerequisites above, add the identity ID and service account details to your InfisicalSecret resource.
+ In the `authentication.kubernetesAuth.identityId` field, add the identity ID of the machine identity you created.
+ Under `authentication.kubernetesAuth.serviceAccountRef`, enter the name and namespace of the service account.
- ```yaml infisical-reviewer-service-account.yaml
- apiVersion: v1
- kind: ServiceAccount
- metadata:
- name: infisical-token-reviewer
- namespace: default
+ If using short-lived tokens, set `authentication.kubernetesAuth.autoCreateServiceAccountToken` to `true`.
- ```
+ <Info>
+ Make sure to also populate the `secretsScope` field with the project slug
+ _`projectSlug`_, or project ID _`projectId`_, environment slug _`envSlug`_, and secrets path
+ _`secretsPath`_ that you want to fetch secrets from. Please see the examples
+ below.
- ```bash
- kubectl apply -f infisical-reviewer-service-account.yaml
- ```
-
- **1.2.** Bind the reviewer 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 infisical-reviewer-cluster-role-binding.yaml
- apiVersion: rbac.authorization.k8s.io/v1
- kind: ClusterRoleBinding
- metadata:
- name: infisical-token-reviewer-role-binding
- namespace: default
- roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: system:auth-delegator
- subjects:
- - kind: ServiceAccount
- name: infisical-token-reviewer
- namespace: default
- ```
-
- ```bash
- kubectl apply -f infisical-reviewer-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:
-
- ```yaml service-account-reviewer-token.yaml
- apiVersion: v1
- kind: Secret
- type: kubernetes.io/service-account-token
- metadata:
- name: infisical-token-reviewer-token
- annotations:
- kubernetes.io/service-account.name: "infisical-token-reviewer"
- ```
-
-
- ```bash
- kubectl apply -f service-account-reviewer-token.yaml
- ```
-
- **1.4.** Link the secret in step 1.3 to the service account in step 1.1:
-
- ```bash
- kubectl patch serviceaccount infisical-token-reviewer -p '{"secrets": [{"name": "infisical-token-reviewer-token"}]}' -n default
- ```
-
- **1.5.** Finally, retrieve the token reviewer JWT token from the secret.
-
- ```bash
- kubectl get secret infisical-token-reviewer-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.
- </Step>
-
- <Step title="Creating an identity">
- To create an identity, head to your Organization Settings > Access Control > Identities and press **Create identity**.
-
- ![identities organization](/images/platform/identities/identities-org.png)
-
- When creating an identity, you specify an organization level [role](/documentation/platform/access-controls/role-based-access-controls) for it to assume; you can configure roles in Organization Settings > Access Control > Organization Roles.
-
- ![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:
-
- - 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.
-
- Once you've created an identity, you'll be prompted to configure the authentication method for it. Here, select **Kubernetes Auth**.
-
- <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 organization create auth method](/images/platform/identities/identities-org-create-kubernetes-auth-method.png)
-
-
- </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.
-
- 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**.
-
- 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.
-
- ![identities project](/images/platform/identities/identities-project.png)
-
- ![identities project create](/images/platform/identities/identities-project-create.png)
-
- </Step>
-
- <Step title="Create a new Kubernetes service account to authenticate with Infisical">
- You have already created the reviewer service account in step **1.1**. Now, create a new Kubernetes service account that will be used to authenticate with Infisical.
- This service account will create short-lived tokens that will be used to authenticate with Infisical. The operator itself will handle the creation of these tokens automatically.
-
- ```yaml infisical-service-account.yaml
- kind: ServiceAccount
- apiVersion: v1
- metadata:
- name: infisical-service-account
- ```
-
- ```bash
- kubectl apply -f infisical-service-account.yaml -n default
- ```
-
- </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.
- Make sure you set `authentication.kubernetesAuth.autoCreateServiceAccountToken` to `true` to automatically create short-lived service account tokens for the service account.
- </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
+ Please note that you can only use either `projectSlug` or `projectId` in the `secretsScope` field.
+ </Info>
+ <Accordion title="Example with short-lived tokens">
```yaml example-kubernetes-auth.yaml
apiVersion: secrets.infisical.com/v1alpha1
kind: InfisicalSecret
@@ -392,180 +260,9 @@ spec:
recursive: true
...
```
+ </Accordion>
- </Tab>
- <Tab title="Manual long-lived service account tokens">
- Manual long-lived service account tokens are manually created by the user and are valid indefinitely unless deleted or rotated. In most cases, you should be using the automatic short-lived service account tokens as they are more secure and easier to use.
- <Steps>
- <Step title="Obtaining the token reviewer JWT for Infisical">
- **1.1.** Start by creating a reviewer service account in your Kubernetes cluster that will be used by Infisical to authenticate with the Kubernetes API Server.
-
- ```yaml infisical-reviewer-service-account.yaml
- apiVersion: v1
- kind: ServiceAccount
- metadata:
- name: infisical-token-reviewer
- namespace: default
-
- ```
-
- ```bash
- kubectl apply -f infisical-reviewer-service-account.yaml
- ```
-
- **1.2.** Bind the reviewer 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 infisical-reviewer-cluster-role-binding.yaml
- apiVersion: rbac.authorization.k8s.io/v1
- kind: ClusterRoleBinding
- metadata:
- name: infisical-token-reviewer-role-binding
- namespace: default
- roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: system:auth-delegator
- subjects:
- - kind: ServiceAccount
- name: infisical-token-reviewer
- namespace: default
- ```
-
- ```bash
- kubectl apply -f infisical-reviewer-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:
-
- ```yaml service-account-reviewer-token.yaml
- apiVersion: v1
- kind: Secret
- type: kubernetes.io/service-account-token
- metadata:
- name: infisical-token-reviewer-token
- annotations:
- kubernetes.io/service-account.name: "infisical-token-reviewer"
- ```
-
-
- ```bash
- kubectl apply -f service-account-reviewer-token.yaml
- ```
-
- **1.4.** Link the secret in step 1.3 to the service account in step 1.1:
-
- ```bash
- kubectl patch serviceaccount infisical-token-reviewer -p '{"secrets": [{"name": "infisical-token-reviewer-token"}]}' -n default
- ```
-
- **1.5.** Finally, retrieve the token reviewer JWT token from the secret.
-
- ```bash
- kubectl get secret infisical-token-reviewer-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.
- </Step>
-
- <Step title="Creating an identity">
- To create an identity, head to your Organization Settings > Access Control > Identities and press **Create identity**.
-
- ![identities organization](/images/platform/identities/identities-org.png)
-
- When creating an identity, you specify an organization level [role](/documentation/platform/access-controls/role-based-access-controls) for it to assume; you can configure roles in Organization Settings > Access Control > Organization Roles.
-
- ![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:
-
- - 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.
-
- Once you've created an identity, you'll be prompted to configure the authentication method for it. Here, select **Kubernetes Auth**.
-
- <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 organization create auth method](/images/platform/identities/identities-org-create-kubernetes-auth-method.png)
-
-
- </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.
-
- 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**.
-
- 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.
-
- ![identities project](/images/platform/identities/identities-project.png)
-
- ![identities project create](/images/platform/identities/identities-project-create.png)
-
- </Step>
-
- <Step title="Create a new Kubernetes service account to authenticate with Infisical">
- You have already created the reviewer service account in step **1.1**. Now, create a new Kubernetes service account that will be used to authenticate with Infisical.
-
- ```yaml infisical-service-account.yaml
- kind: ServiceAccount
- apiVersion: v1
- metadata:
- name: infisical-service-account
- ```
-
- ```bash
- kubectl apply -f infisical-service-account.yaml -n default
- ```
- </Step>
-
- <Step title="Create a service account token for the Kubernetes service account">
- Create a service account token for the newly created Kubernetes service account from the previous step.
-
- ```yaml infisical-service-account-token.yaml
- apiVersion: v1
- kind: Secret
- type: kubernetes.io/service-account-token
- metadata:
- name: infisical-service-account-token
- annotations:
- kubernetes.io/service-account.name: "infisical-service-account"
- ```
-
- ```bash
- kubectl apply -f infisical-service-account-token.yaml -n default
- ```
-
- Patch the service account with the newly created service account token.
-
- ```bash
- kubectl patch serviceaccount infisical-service-account -p '{"secrets": [{"name": "infisical-service-account-token"}]}' -n default
- ```
- </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>
- </Steps>
-
- <Info>
- Make sure to also populate the `secretsScope` field with the project slug
- _`projectSlug`_, or project ID _`projectId`_, environment slug _`envSlug`_, and secrets path
- _`secretsPath`_ that you want to fetch secrets from. Please see the example
- below.
-
- Please note that you can only use either `projectSlug` or `projectId` in the `secretsScope` field.
- </Info>
-
- ## Example
-
+ <Accordion title="Example with long-lived tokens">
```yaml example-kubernetes-auth.yaml
apiVersion: secrets.infisical.com/v1alpha1
kind: InfisicalSecret
@@ -588,9 +285,7 @@ spec:
recursive: true
...
```
-
- </Tab>
-</Tabs>
+ </Accordion>
</Accordion>
diff --git a/docs/snippets/documentation/platform/identities/kubernetes-auth-operator-setup.mdx b/docs/snippets/documentation/platform/identities/kubernetes-auth-operator-setup.mdx
new file mode 100644
index 0000000000..3ea4dfaf69
--- /dev/null
+++ b/docs/snippets/documentation/platform/identities/kubernetes-auth-operator-setup.mdx
@@ -0,0 +1,347 @@
+<Accordion title="Short-lived service account tokens (Recommended)">
+<Steps>
+ <Step title="Create a token reviewer service account">
+ Create a reviewer service account in your Kubernetes cluster. Infisical uses this account to authenticate with the Kubernetes API Server through the TokenReview API.
+
+ ```yaml infisical-reviewer-service-account.yaml
+ apiVersion: v1
+ kind: ServiceAccount
+ metadata:
+ name: infisical-token-reviewer
+ namespace: default
+ ```
+
+ ```bash
+ kubectl apply -f infisical-reviewer-service-account.yaml
+ ```
+ </Step>
+
+ <Step title="Bind the reviewer service account">
+ Bind the reviewer service account to the `system:auth-delegator` cluster role. This allows Infisical to perform delegated authentication checks against the TokenReview API.
+
+ ```yaml infisical-reviewer-cluster-role-binding.yaml
+ apiVersion: rbac.authorization.k8s.io/v1
+ kind: ClusterRoleBinding
+ metadata:
+ name: infisical-token-reviewer-role-binding
+ namespace: default
+ roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: ClusterRole
+ name: system:auth-delegator
+ subjects:
+ - kind: ServiceAccount
+ name: infisical-token-reviewer
+ namespace: default
+ ```
+
+ ```bash
+ kubectl apply -f infisical-reviewer-cluster-role-binding.yaml
+ ```
+ </Step>
+
+ <Step title="Create and retrieve the token reviewer JWT">
+ Create a service account token secret for the reviewer service account:
+
+ ```yaml service-account-reviewer-token.yaml
+ apiVersion: v1
+ kind: Secret
+ type: kubernetes.io/service-account-token
+ metadata:
+ name: infisical-token-reviewer-token
+ annotations:
+ kubernetes.io/service-account.name: "infisical-token-reviewer"
+ ```
+
+ ```bash
+ kubectl apply -f service-account-reviewer-token.yaml
+ ```
+
+ Link the secret to the reviewer service account:
+
+ ```bash
+ kubectl patch serviceaccount infisical-token-reviewer \
+ -p '{"secrets": [{"name": "infisical-token-reviewer-token"}]}' \
+ -n default
+ ```
+
+ Retrieve the token reviewer JWT:
+
+ ```bash
+ kubectl get secret infisical-token-reviewer-token \
+ -n default \
+ -o=jsonpath='{.data.token}' | base64 --decode
+ ```
+
+ Keep this JWT token handy. You will need it for the **Token Reviewer JWT** field when configuring Kubernetes Auth on the machine identity in Infisical.
+ </Step>
+
+ <Step title="Create a machine identity">
+ To create an identity, head to your Organization Settings > Access Control > Identities and press **Create identity**.
+
+ ![identities organization](/images/platform/identities/identities-org.png)
+
+ When creating an identity, you specify an organization level [role](/documentation/platform/access-controls/role-based-access-controls) for it to assume; you can configure roles in Organization Settings > Access Control > Organization Roles.
+
+ ![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:
+
+ - 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.
+
+ Once you've created an identity, you'll be prompted to configure the authentication method for it. Here, select **Kubernetes Auth**.
+
+ Use the token reviewer JWT from the previous step when filling the **Token Reviewer JWT** field.
+
+ <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 organization create auth method](/images/platform/identities/identities-org-create-kubernetes-auth-method.png)
+ </Step>
+
+ <Step title="Add the 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.
+
+ 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**.
+
+ 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.
+
+ ![identities project](/images/platform/identities/identities-project.png)
+
+ ![identities project create](/images/platform/identities/identities-project-create.png)
+ </Step>
+
+ <Step title="Create the service account used for authentication">
+ Create the Kubernetes service account that the operator will use to authenticate with Infisical. The operator creates short-lived tokens for this service account automatically.
+
+ ```yaml infisical-service-account.yaml
+ apiVersion: v1
+ kind: ServiceAccount
+ metadata:
+ name: infisical-service-account
+ namespace: default
+ ```
+
+ ```bash
+ kubectl apply -f infisical-service-account.yaml
+ ```
+ </Step>
+</Steps>
+</Accordion>
+<Accordion title="Manual long-lived service account tokens">
+ Manual long-lived service account tokens are created as Kubernetes secrets and remain valid until deleted or rotated. In most cases, use short-lived service account tokens instead because they are easier to operate and reduce the lifetime of exposed credentials.
+
+ <Steps>
+ <Step title="Create a token reviewer service account">
+ Create a reviewer service account in your Kubernetes cluster. Infisical uses this account to authenticate with the Kubernetes API Server through the TokenReview API.
+
+ ```yaml infisical-reviewer-service-account.yaml
+ apiVersion: v1
+ kind: ServiceAccount
+ metadata:
+ name: infisical-token-reviewer
+ namespace: default
+ ```
+
+ ```bash
+ kubectl apply -f infisical-reviewer-service-account.yaml
+ ```
+ </Step>
+
+ <Step title="Bind the reviewer service account">
+ Bind the reviewer service account to the `system:auth-delegator` cluster role. This allows Infisical to perform delegated authentication checks against the TokenReview API.
+
+ ```yaml infisical-reviewer-cluster-role-binding.yaml
+ apiVersion: rbac.authorization.k8s.io/v1
+ kind: ClusterRoleBinding
+ metadata:
+ name: infisical-token-reviewer-role-binding
+ namespace: default
+ roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: ClusterRole
+ name: system:auth-delegator
+ subjects:
+ - kind: ServiceAccount
+ name: infisical-token-reviewer
+ namespace: default
+ ```
+
+ ```bash
+ kubectl apply -f infisical-reviewer-cluster-role-binding.yaml
+ ```
+ </Step>
+
+ <Step title="Create and retrieve the token reviewer JWT">
+ Create a service account token secret for the reviewer service account:
+
+ ```yaml service-account-reviewer-token.yaml
+ apiVersion: v1
+ kind: Secret
+ type: kubernetes.io/service-account-token
+ metadata:
+ name: infisical-token-reviewer-token
+ annotations:
+ kubernetes.io/service-account.name: "infisical-token-reviewer"
+ ```
+
+ ```bash
+ kubectl apply -f service-account-reviewer-token.yaml
+ ```
+
+ Link the secret to the reviewer service account:
+
+ ```bash
+ kubectl patch serviceaccount infisical-token-reviewer \
+ -p '{"secrets": [{"name": "infisical-token-reviewer-token"}]}' \
+ -n default
+ ```
+
+ Retrieve the token reviewer JWT:
+
+ ```bash
+ kubectl get secret infisical-token-reviewer-token \
+ -n default \
+ -o=jsonpath='{.data.token}' | base64 --decode
+ ```
+
+ Keep this JWT token handy. You will need it for the **Token Reviewer JWT** field when configuring Kubernetes Auth on the machine identity in Infisical.
+ </Step>
+
+ <Step title="Create a machine identity">
+ To create an identity, head to your Organization Settings > Access Control > Identities and press **Create identity**.
+
+ ![identities organization](/images/platform/identities/identities-org.png)
+
+ When creating an identity, you specify an organization level [role](/documentation/platform/access-controls/role-based-access-controls) for it to assume; you can configure roles in Organization Settings > Access Control > Organization Roles.
+
+ ![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:
+
+ - 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.
+
+ Once you've created an identity, you'll be prompted to configure the authentication method for it. Here, select **Kubernetes Auth**.
+
+ Use the token reviewer JWT from the previous step when filling the **Token Reviewer JWT** field.
+
+ <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 organization create auth method](/images/platform/identities/identities-org-create-kubernetes-auth-method.png)
+ </Step>
+
+ <Step title="Add the 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.
+
+ 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**.
+
+ 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.
+
+ ![identities project](/images/platform/identities/identities-project.png)
+
+ ![identities project create](/images/platform/identities/identities-project-create.png)
+ </Step>
+
+ <Step title="Create the service account used for authentication">
+ Create the Kubernetes service account that the operator will use to authenticate with Infisical.
+
+ ```yaml infisical-service-account.yaml
+ apiVersion: v1
+ kind: ServiceAccount
+ metadata:
+ name: infisical-service-account
+ namespace: default
+ ```
+
+ ```bash
+ kubectl apply -f infisical-service-account.yaml
+ ```
+ </Step>
+
+ <Step title="Create a long-lived token for the service account">
+ Create a service account token secret for the service account used to authenticate with Infisical:
+
+ ```yaml infisical-service-account-token.yaml
+ apiVersion: v1
+ kind: Secret
+ type: kubernetes.io/service-account-token
+ metadata:
+ name: infisical-service-account-token
+ namespace: default
+ annotations:
+ kubernetes.io/service-account.name: "infisical-service-account"
+ ```
+
+ ```bash
+ kubectl apply -f infisical-service-account-token.yaml
+ ```
+
+ Patch the service account with the newly created service account token:
+
+ ```bash
+ kubectl patch serviceaccount infisical-service-account \
+ -p '{"secrets": [{"name": "infisical-service-account-token"}]}' \
+ -n default
+ ```
+ </Step>
+ </Steps>
+</Accordion>
+<Accordion title="Use Gateway as Reviewer">
+ <Note>
+ **When to use this option**: Choose this approach when you have a gateway deployed in your Kubernetes Cluster and wish to eliminate long-lived tokens. This approach simplifies Infisical Kubernetes Auth configuration, and only one service account will need to have the elevated `system:auth-delegator` ClusterRole binding.
+ </Note>
+
+ <Info>
+ **Note:** Gateway is a paid feature. - **Infisical Cloud users:** Gateway is
+ available under the **Enterprise Tier**. - **Self-Hosted Infisical:** Please
+ contact [[email protected]](mailto:[email protected]) to purchase an
+ enterprise license.
+ </Info>
+
+ <Steps>
+ <Step title="Deploying a gateway">
+ To deploy a gateway in your Kubernetes cluster, follow our [Gateway deployment guide using Helm](/documentation/platform/gateways/gateway-deployment).
+ </Step>
+
+ <Step title="Grant the gateway the system:auth-delegator ClusterRole binding">
+ To grant the gateway the `system:auth-delegator` ClusterRole binding, you can use the following command:
+
+ ```yaml gateway-role-binding.yaml
+ apiVersion: rbac.authorization.k8s.io/v1
+ kind: ClusterRoleBinding
+ metadata:
+ name: infisical-token-reviewer-role-binding
+ namespace: default # Replace with your namespace if not default
+ roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: ClusterRole
+ name: system:auth-delegator
+ subjects:
+ - kind: ServiceAccount
+ name: infisical-gateway # The name of the gateway service account
+ namespace: default # Replace with your namespace if not default
+ ```
+
+ ```bash
+ kubectl apply -f gateway-role-binding.yaml
+ ```
+
+ <Tip>
+ The gateway service account name is `infisical-gateway` by default if deployed using Helm.
+ </Tip>
+ </Step>
+
+ <Step title="Configure the Kubernetes Auth authentication method for the identity">
+ To configure your Kubernetes Auth method to use the gateway as the token reviewer, set the `Review Method` to "Gateway as Reviewer", and select the gateway you want to use as the token reviewer.
+
+ You can select either an individual gateway or a **Gateway Pool** for automatic failover. When a pool is selected, the platform routes through a healthy gateway at request time. See [Gateway Pools](/documentation/platform/gateways/gateway-pools) for more details.
+
+ ![identities organization create kubernetes auth method](/images/platform/identities/identities-kubernetes-auth-gateway-as-reviewer.png)
+ </Step>
+ </Steps>
+</Accordion>