Infisical PAM supports secure, just-in-time access to Kubernetes clusters. Your team can access Kubernetes clusters without sharing long-lived credentials, while maintaining a complete audit trail of who accessed what and when. There are two ways to authenticate: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.
- Service Account Token — you provide a static token that the Gateway injects into requests. Simple to set up, but the token is long-lived and stored in Infisical.
- Gateway — the Gateway uses its own pod identity and Kubernetes impersonation to act as a target service account. No tokens are stored in Infisical — you only provide a service account name and namespace.
How It Works
Service Account Token
When using a service account token, the Gateway forwards kubectl requests to the Kubernetes API server using the provided token.Gateway (Impersonation)
When using Gateway auth, the Gateway authenticates as itself using its own pod service account, then tells the Kubernetes API to treat the request as if it came from the target service account. No tokens are stored in Infisical. The Gateway reads its own pod token from the filesystem (auto-mounted by Kubernetes) and auto-discovers the Kubernetes API server from environment variables.Key Concepts
- Gateway: An Infisical Gateway deployed in your network that can reach the Kubernetes API server. The Gateway handles secure communication between users and your cluster.
- Service Account Token: A Kubernetes service account token that grants access to the cluster. This token is stored securely in Infisical and used by the Gateway to authenticate with the Kubernetes API.
-
Impersonation: A Kubernetes feature where one identity (the Gateway) can act on behalf of another (the target service account). The Gateway authenticates as itself and adds
Impersonate-Userheaders. Kubernetes checks if the Gateway has permission to impersonate the target, then applies the target’s RBAC rules. - Local Proxy: The Infisical CLI starts a local proxy on your machine that intercepts kubectl commands and routes them securely through the Gateway to your cluster.
- Session Tracking: All access sessions are logged, including when the session was created, who accessed the cluster, session duration, and when it ended.
Session Tracking
Infisical tracks:- When the session was created
- Who accessed which cluster
- Session duration
- All kubectl commands executed during the session
- When the session ended
Prerequisites
Before configuring Kubernetes access in Infisical PAM, you need:- Infisical Gateway - A Gateway deployed in your network with access to the Kubernetes API server
- Infisical CLI - The Infisical CLI installed on user machines
- Depending on your auth method:
- Service Account Token: A Kubernetes service account with appropriate RBAC permissions and a static token
- Gateway: The Gateway must be deployed inside the Kubernetes cluster as a pod, with a ClusterRole that allows impersonation of target service accounts
Create the PAM Resource
The PAM Resource represents the connection between Infisical and your Kubernetes cluster.Ensure Gateway is Running
Create the Resource in Infisical
- Navigate to your PAM project and go to the Resources tab
- Click Add Resource and select Kubernetes
- Enter a name for the resource (e.g.,
production-k8s,staging-cluster) - Enter the Kubernetes API Server URL - the URL to your Kubernetes API endpoint (e.g.
https://kubernetes.example.com:6443). If using Gateway auth with an in-cluster gateway, usehttps://kubernetes.default.svc.cluster.local. - Select the Gateway that has access to this cluster
- Configure SSL verification options if needed
https://kubernetes.default.svc.cluster.local, disable SSL verification here — the Gateway will use strict TLS with the in-cluster CA certificate during sessions.Set Up Authentication
Choose one of the two authentication methods below based on your setup.- Service Account Token
- Gateway (Impersonation)
Create a Service Account
Apply the Service Account
- A ServiceAccount named
infisical-pam-sain thekube-systemnamespace - A ClusterRoleBinding that grants the service account its permissions
- A Secret containing a static, non-expiring token for the service account
Create PAM Accounts
Once you have configured the PAM resource and set up authentication, create a PAM account to grant access.Navigate to Resource
Access Kubernetes Cluster
Once your resource and accounts are configured, users can request access through the Infisical CLI:Get the Access Command
- Navigate to the Resources tab in your PAM project and open the Kubernetes resource
- In the resource’s accounts section, find the account you want to access
- Click the Access button for that account
- Copy the provided CLI command
Run the Access Command
- Authenticate with Infisical
- Establish a secure connection through the Gateway
- Start a local proxy on your machine
- Configure kubectl to use the proxy
Use kubectl
kubectl commands as normal:FAQ
Which auth method should I use?
Which auth method should I use?
- Use Gateway if your Gateway is deployed as a pod inside the Kubernetes cluster. No tokens to create or manage — just enter a service account name and namespace.
- Use Service Account Token if your Gateway runs outside the cluster (e.g., on a separate VM) and only has network access to the Kubernetes API. You’ll need to create a service account token and paste it into Infisical.
Do I still need to enter a Kubernetes API URL when using Gateway auth?
Do I still need to enter a Kubernetes API URL when using Gateway auth?
https://kubernetes.default.svc.cluster.local. The Gateway auto-discovers the actual Kubernetes API address from its pod environment variables, so this URL isn’t used for the connection itself — but the field is still required when creating the resource.How does the Gateway find the Kubernetes API server?
How does the Gateway find the Kubernetes API server?
KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT_HTTPS environment variables that Kubernetes automatically sets in every pod. It ignores the URL configured on the resource and connects directly to the in-cluster API server.Do I need to configure SSL certificates for Gateway auth?
Do I need to configure SSL certificates for Gateway auth?
What happens if the Gateway can't impersonate a service account?
What happens if the Gateway can't impersonate a service account?
resourceNames list, the session fails. You don’t need to configure any allowlist in Infisical; just update the ClusterRole in your cluster.Can I use both auth methods on the same Kubernetes resource?
Can I use both auth methods on the same Kubernetes resource?
Does the Gateway need to run inside the Kubernetes cluster?
Does the Gateway need to run inside the Kubernetes cluster?