Skip to main content
Pulumi logo Pulumi logo
  1. Docs
  2. Infrastructure AI
  3. Pulumi Agents
  4. Integrations
  5. Cloud CLI integrations
  6. Connect Kubernetes

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-stacks ESC provider to read the kubeconfig from an EKS, AKS, or GKE stack output, then write it to a temporary file through files.KUBECONFIG. The connection reads the kubeconfig from the stack output when the environment is opened.
    • Static kubeconfig. Set the kubeconfig contents in files.KUBECONFIG for 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):

    1. Open your organization’s Agent settings > Integrations > CLI tools.
    2. Under Available, choose Kubernetes and select Connect.
    3. Enter a Name and select the ESC environment that supplies the credentials.
    4. In Notes (optional), describe when the agent should use this connection.
    5. 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.

      The infrastructure platform for humans and agents.