Connect Kubernetes
Connect a Kubernetes cluster so an agent can run kubectl commands against it. Pulumi ESC supplies the kubeconfig whenever the agent runs kubectl.
Choose the cluster identity
Use a Kubernetes identity with only the RBAC permissions the agent needs, such as read access to the namespaces it investigates. Before you connect a kubeconfig, check which identity it authenticates as and what that identity’s RBAC roles allow. See Connected credentials for guidance on scoping credentials.
Prepare an ESC environment
The Kubernetes Cluster Access guide walks through both options:
- Stack-output kubeconfig (recommended for Pulumi-managed clusters). Use the
pulumi-stacksESC provider to read the kubeconfig from an EKS, AKS, or GKE stack output, then write it to a temporary file throughfiles.KUBECONFIG. The connection reads the kubeconfig from the stack output when the environment is opened. - Static kubeconfig. Set the kubeconfig contents in
files.KUBECONFIGfor clusters not managed by a Pulumi program.
If the kubeconfig runs an authentication command, supply the credentials that command needs in the same ESC environment. For example, Amazon EKS uses aws eks get-token, so an EKS connection also needs AWS credentials for an identity with access to the cluster.
The agent’s Pulumi Cloud role needs permission to open the environment before ESC can supply the kubeconfig to kubectl. For a Neo task, the user who runs it needs that permission instead.
Connect the environment
To connect the environment, you need permission to manage organization integrations (org_integrations:update):
- Open your organization’s Agent settings > Integrations > CLI tools.
- Under Available, choose Kubernetes and select Connect.
- Enter a Name and select the ESC environment that supplies the credentials.
- In Notes (optional), describe when the agent should use this connection.
- Select Connect.
For example, name the connection production-k8s-investigation and include the cluster name in its notes, so the agent knows which cluster the connection reaches.
Use the connection
Include the connection name, cluster, and target resources in the assignment.