Skip to main content

AlmaForge Kubernetes Access Guide

Connect Kubernetes clusters to AlmaForge for SSO-backed access through kubectl. Users authenticate through your corporate identity provider and receive short-lived credentials tied to mapped Kubernetes identities. The in-cluster agent brokers traffic to the Kubernetes API server using native Kubernetes impersonation headers, keeping API servers off the public internet while Kubernetes RBAC continues to enforce permissions.

Connecting target clusters

This guide shows how to connect target Kubernetes clusters to AlmaForge using the in-cluster agent Helm chart (almaforge-agent). To deploy the main control plane instead, see Cluster on Kubernetes (almaforge chart).

  • Unified access across all clusters. Manage EKS, GKE, AKS, and self-hosted clusters through one private, audited access plane instead of maintaining fragmented cloud IAM roles and VPN endpoints.
  • SSO mapped to Kubernetes RBAC. Map IdP groups directly to Kubernetes users and groups. kubectl obtains short-lived credentials via an exec credential plugin with no static kubeconfigs or permanent admin tokens to rotate.
  • Keep existing tools. Engineers continue using kubectl, k9s, Helm, and IDEs without workflow changes. alma kube login sets up the native kubeconfig context transparently.
  • Full audit trail and session replay. Structured audit logs capture every API request with the user's verified SSO identity. Interactive kubectl exec and attach sessions are recorded for live observation and playback.

Architecture​

Kubernetes access consists of three components:

  1. AlmaForge Control Plane (almad): The Auth and Proxy services running on Kubernetes or Linux. Terminates user sessions, validates SSO claims, issues short-lived certificates, and manages cluster state.
  2. In-Cluster Agent (almaforge-agent Helm chart): A 2-replica StatefulSet running inside the target Kubernetes cluster. It dials outbound to the Proxy Service over a persistent TLS reverse tunnel and forwards incoming user requests to the in-cluster Kubernetes API server using impersonation headers (Impersonate-User, Impersonate-Group).
  3. Workstation Client (alma and kubectl): Engineers log in via the CLI, select a target cluster with alma kube login, and interact with the cluster using standard kubectl commands.

In-cluster agent topology

Prerequisites​

AlmaForge Control Plane​

  • A running AlmaForge control plane with Proxy Service reachable at almaforge.example.com:443. See Cluster on Kubernetes.
  • An SSO connector configured on the control plane (e.g. Okta, Google, Microsoft, GitHub). See Single Sign-On.
  • An operator account with permissions to issue tokens (admin preset role).

Target Kubernetes Cluster​

  • Target Kubernetes cluster running version 1.24 or later (EKS, GKE, AKS, or self-hosted).
  • Network egress allowing outbound TCP/443 connections from agent pods to your AlmaForge Proxy endpoint.

Operator Workstation​

  • kubectl 1.24+ configured with administrative access to the target cluster.
  • Helm 3.12+ installed.
  • The alma CLI installed and logged in to your control plane. See Install the CLI.

In-cluster agent​

The recommended deployment runs the agent inside the target Kubernetes cluster using the official almaforge/almaforge-agent Helm chart.

Step 1. Issue a join token (run on your control plane workstation)​

Run this command from your workstation logged in to the AlmaForge control plane:

Terminal
alma login --proxy=[your-almaforge-host]:443alma create token --services=kubernetes,app,database --format=text

The command outputs the join credentials on two separate lines:

text
[client-id]
[client-secret]
  • Line 1 is the Client ID (ALMA_CLIENT_ID).
  • Line 2 is the Client Secret (ALMA_CLIENT_SECRET).

Save these values. You will pass them to the target cluster in Step 2.

Secretless Workload Identity

To connect clusters using cloud-native IAM instead of static tokens, see Workload Identity Join Options for Kubernetes, AWS IRSA, GCP, or Azure AD Workload Identity.

Step 2. Install the agent with Helm (run against the target Kubernetes cluster)​

Switch your kubectl context to the target Kubernetes cluster you want to connect:

Terminal
kubectl config use-context [your-target-cluster-context]

Add the Helm repository and install the almaforge-agent chart using the credentials from Step 1:

Terminal
helm repo add almaforge https://get.almaforge.com/helmhelm repo update almaforgehelm upgrade --install almaforge-agent almaforge/almaforge-agent \    --namespace almaforge --create-namespace \    --set env.ALMA_PROXY=[your-almaforge-host]:443 \    --set env.ALMA_CLIENT_ID=[client-id] \    --set env.ALMA_CLIENT_SECRET=[client-secret] \    --set clusterName=prod-cluster \    --set labels.env=prod \    --wait

Alternatively, maintain configuration in a version-controlled values file:

agent-values.yaml:

examples/kubernetes/in-cluster-agent/agent-values.yaml
# Helm values for an in-cluster AlmaForge agent (Kubernetes, App, and Database services).
# Issue a join token on the AlmaForge control plane first:
# alma create token --services=kubernetes --format=text
env:
ALMA_PROXY: 'almaforge.example.com:443'
# Pass credentials via env, or comment out and use tokenSecret below for GitOps:
ALMA_CLIENT_ID: '[client-id]'
ALMA_CLIENT_SECRET: '[client-secret]'

# For GitOps (Vault, ExternalSecrets, SealedSecrets), load credentials from a Secret:
# tokenSecret:
# name: almaforge-agent-token
# clientIdKey: ALMA_CLIENT_ID
# clientSecretKey: ALMA_CLIENT_SECRET

# Registers this Kubernetes cluster as a target in AlmaForge.
clusterName: prod-cluster
labels:
env: prod

# RBAC configuration for the agent and impersonated users:
rbac:
# User access bindings deployed alongside the agent to grant permissions
# to impersonated AlmaForge groups or users:
bindings:
- name: almaforge-developers
roleRef:
kind: ClusterRole
name: view
subjects:
- kind: Group
name: developers
Terminal
helm upgrade --install almaforge-agent almaforge/almaforge-agent \    --namespace almaforge --create-namespace \    -f agent-values.yaml --wait

See the Helm Values Reference for every supported configuration option.

Step 3. Verify agent registration​

On the target cluster, verify that the agent pods are running:

Terminal
kubectl -n almaforge get pods -l app.kubernetes.io/component=agentNAME                READY   STATUS    RESTARTS   AGEalmaforge-agent-0   1/1     Running   0          45salmaforge-agent-1   1/1     Running   0          38s

On your control plane workstation, confirm the cluster has registered:

Terminal
alma get kubeCluster      Labels     Version------------ ---------- -------prod-cluster env=prod   2026.2.30

Configure RBAC & SSO mappings​

Access to Kubernetes clusters is governed by two layers:

  1. AlmaForge Role: Controls which clusters a user can access and which Kubernetes users and groups the agent will impersonate.
  2. Kubernetes RBAC: Native ClusterRole, Role, ClusterRoleBinding, and RoleBinding resources inside the target cluster that determine what those impersonated identities can do.

Step 1. Define an AlmaForge Role​

Create an AlmaForge role that grants access to clusters matching env: prod and maps the engineer into the developers Kubernetes group:

kube-access.yaml:

examples/kubernetes/roles/kube-access.yaml
apiVersion: almaforge.com/v1
kind: Role
metadata:
name: kube-access
spec:
allow:
kubernetesLabels:
env: prod
kubernetesResources:
- kind: pod
namespace: 'app-*'
name: '*'
verbs: ['get', 'list', 'watch']
kubernetesGroups:
- developers
kubernetesUsers:
- '{{external.email}}'

Apply the role to the control plane:

Terminal
alma apply -f kube-access.yaml

Key fields in spec.allow:

  • kubernetesLabels: Label selector matching the target cluster's labels (or clusterName).
  • kubernetesGroups: The Kubernetes RBAC groups the agent impersonates when forwarding requests.
  • kubernetesUsers: The Kubernetes username impersonated (supports template variables like {{external.email}}).
  • kubernetesResources: Optional API-level filter restricting specific verbs, namespaces, and resources.

To grant cluster-admin access to trusted platform engineers, map to system:masters:

YAML
apiVersion: almaforge.com/v1
kind: Role
metadata:
name: kube-admin
spec:
allow:
kubernetesLabels:
env: '*'
kubernetesGroups:
- system:masters

Step 2. Provision Kubernetes bindings​

Grant permissions to the impersonated group inside the target Kubernetes cluster. You can provision bindings directly via the agent's Helm values (rbac.bindings), or apply them manually with kubectl.

Configure rbac.bindings in your agent-values.yaml so user bindings are version-controlled and deployed with the agent:

YAML
rbac:
bindings:
- name: almaforge-developers
roleRef:
kind: ClusterRole
name: view
subjects:
- kind: Group
name: developers

Update the release:

Terminal
helm upgrade almaforge-agent almaforge/almaforge-agent \    --namespace almaforge -f agent-values.yaml

Step 3. Assign the role to users​

In your SSO connector (or Role assignment), map IdP groups or users to your AlmaForge roles. For example, map the Okta Engineering group to kube-access and Platform-Admins to kube-admin. See OIDC SSO Configuration.

Connect to Kubernetes​

Step 1. Log in with the CLI​

Sign in to AlmaForge from your workstation:

Terminal
alma login --proxy=[your-almaforge-host]:443

List the available clusters:

Terminal
alma get kubeCluster      Labels     Version------------ ---------- -------prod-cluster env=prod   2026.2.30

Step 2. Log in to the target cluster​

Generate credentials and set your active kubectl context:

Terminal
alma kube login prod-clusterLogged into Kubernetes cluster "prod-cluster".Try: kubectl get pods

alma kube login creates a context named [your-almaforge-host]-prod-cluster (with alias prod-cluster), switches your active kubectl context to it, and updates ~/.kube/config with an exec credential plugin stanza (kubeconfig-stanza.yaml) pointing to alma kube credentials. No static tokens or permanent certificates are stored on disk.

CLI in PATH

kubectl executes alma kube credentials automatically whenever you run a Kubernetes command. Ensure the alma binary is in your $PATH.

Step 3. Run native kubectl commands​

Interact with the cluster using standard Kubernetes tools:

Terminal
kubectl get namespaceskubectl get pods -n app-backendkubectl exec -it deploy/frontend -n app-backend -- shkubectl port-forward svc/postgres -n app-backend 5432:5432

Tools like k9s, Helm, and Lens work out of the box using the configured context.

Step 4. Switch between clusters​

To switch between multiple registered clusters:

Terminal
# Switch to another clusteralma kube login staging-cluster
# Or use standard kubectl context switchingkubectl config get-contextskubectl config use-context [your-almaforge-host]-prod-cluster

To configure all available clusters in your kubeconfig at once, run:

Terminal
alma kube login --all

Audit & session replay​

Every Kubernetes request proxied by AlmaForge is recorded and attributed to the operator's authenticated SSO identity:

  • Structured API Audit Events: Non-interactive requests (such as kubectl get, kubectl apply, or port-forwards) generate structured audit events capturing the authenticated user, target cluster, namespace, resource, and HTTP verb. See Audit Events Reference.
  • Interactive Terminal Recording: Sessions initiated via kubectl exec and kubectl attach record full terminal PTY input and output.

List recent session recordings:

Terminal
alma recording ls --last=1hID                                   Type  User               Cluster      Duration------------------------------------ ----- ------------------ ------------ --------d6f4b2a1-89ce-4a7b-a49e-11f8139e88d1 kube  alice@example.com  prod-cluster 4m12s

Play back an interactive session in your terminal:

Terminal
alma recording play d6f4b2a1-89ce-4a7b-a49e-11f8139e88d1

Advanced​

Namespace isolation and RBAC scoping​

The agent requires a cluster-scoped ClusterRole to perform native Kubernetes user and group impersonation (impersonate on users, groups, and serviceaccounts).

Multi-tenant isolation and namespace jailing are enforced within AlmaForge roles rather than by restricting the agent's ServiceAccount:

  • Map users to native Kubernetes groups or users that only possess permissions in specific namespaces.
  • Use AlmaForge role definitions to restrict which namespaces, resources, and verbs users can access.

If you manage Kubernetes RBAC out-of-band via GitOps, set rbac.create: false to disable automatic ClusterRole and ClusterRoleBinding provisioning.

Workload identity join options​

For production environments with supported cloud workload identity providers, agents can authenticate without static tokens:

The agent authenticates using IAM Roles for Service Accounts (IRSA):

kube-iam.yaml:

examples/kubernetes/tokens/kube-iam.yaml
apiVersion: almaforge.com/v1
kind: Token
metadata:
name: kube-agent
spec:
roles:
- system:kubernetes
aws:
allow:
- awsAccount: '123456789012'
awsARN: 'arn:aws:sts::123456789012:assumed-role/almaforge-agent/*'
Terminal
alma apply -f kube-iam.yaml

Set env.ALMA_JOIN_METHOD=aws and env.ALMA_CLIENT_ID=kube-iam during install.

Remote VM agent with kubeconfig​

When the agent cannot run as a pod inside the target cluster (for example, on isolated edge infrastructure or when managing multiple external clusters from a centralized bastion VM), install almad on a Linux VM and point it to the target cluster using a kubeconfig.

Files for this deployment pattern:

  1. Target Cluster RBAC: Create a dedicated namespace and service account with impersonation permissions:
  2. Kubeconfig Template: Generate a kubeconfig for the agent service account on the VM:
  3. Environment Configuration: Configure /etc/almaforge/almad.env on the agent VM:
    • Template: almad.env
    • Set ALMA_KUBERNETES_SERVICE=true and ALMA_KUBECONFIG=/etc/almaforge/kubeconfig.yaml.
  4. Register the Target: Register the cluster with the control plane:

Isolated kubeconfig files​

To keep work contexts separate without modifying your default ~/.kube/config, specify an independent kubeconfig file:

Terminal
alma kube login prod-cluster --kubeconfig=~/.kube/prod.yamlKUBECONFIG=~/.kube/prod.yaml kubectl get pods

Operations​

Upgrades​

Upgrade the in-cluster agent using Helm. Leave image.tag unset so the agent version tracks the chart version:

Terminal
helm repo update almaforgehelm upgrade almaforge-agent almaforge/almaforge-agent \    --namespace almaforge -f agent-values.yaml --version [new-version] --wait

Because the chart runs two replicas by default with a PodDisruptionBudget, one replica updates while the other keeps serving without interrupting active traffic.

If an upgrade fails or misbehaves, roll back to the previous Helm revision:

Terminal
helm -n almaforge rollback almaforge-agent --wait

Uninstallation​

To remove the in-cluster agent from the target cluster:

Terminal
helm -n almaforge uninstall almaforge-agent

This removes the StatefulSet, ServiceAccount, ClusterRole, ClusterRoleBinding, Role, and NetworkPolicy. To wipe persistent process identity Secrets as well:

Terminal
kubectl -n almaforge delete secret almaforge-agent-0-state almaforge-agent-1-state

Troubleshooting​

alma get kube shows nothing​

  1. Confirm agent pods are running:
    Terminal
    kubectl -n almaforge get pods -l app.kubernetes.io/component=agent
  2. Inspect agent startup logs:
    Terminal
    kubectl -n almaforge logs statefulset/almaforge-agent
    Look for Joining the cluster or token authentication errors. If using a static token, confirm the token has not expired (alma get token).

kubectl fails with impersonate: user "..." cannot impersonate​

The agent pod's ServiceAccount lacks RBAC permission to impersonate the target group or user. Verify that the chart's ClusterRole and ClusterRoleBinding were created:

Terminal
kubectl get clusterrole almaforge-almaforge-agentkubectl get clusterrolebinding almaforge-almaforge-agent

kubectl commands return forbidden​

AlmaForge successfully authenticated the user and forwarded the request, but the target cluster's native RBAC denied the operation:

  1. Inspect the groups mapped in the user's role:
    Terminal
    alma status
  2. Confirm the target cluster has a binding for those exact groups:
    Terminal
    kubectl get clusterrolebindings -o yaml | grep -B 5 -A 10 "name: developers"

GKE Autopilot: cannot impersonate "system:masters"​

GKE Autopilot blocks impersonation of the built-in system:masters group. Create a custom administrative group in your AlmaForge role (e.g. cluster-admin-group) and bind it to the cluster-admin ClusterRole in Kubernetes:

gke-autopilot-cluster-admin.yaml:

examples/kubernetes/bindings/gke-autopilot-cluster-admin.yaml
# Workaround for GKE Autopilot, which blocks impersonation of the
# built-in `system:masters` group at admission. Bind a regular group
# to `cluster-admin` and reference it from the AlmaForge Role's
# kubernetesGroups instead.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: almaforge-cluster-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: Group
name: almaforge-cluster-admin
apiGroup: rbac.authorization.k8s.io

Agent fails with x509: certificate signed by unknown authority​

If your AlmaForge control plane uses an internal enterprise CA or private certificates, the agent container will not trust the proxy endpoint by default. Supply your root CA bundle via a ConfigMap (e.g. distributed by trust-manager) or Secret:

Terminal
helm upgrade almaforge-agent almaforge/almaforge-agent \    --namespace almaforge \    --set tls.caConfigMapName=internal-ca \    --set tls.caKey=ca.crt \    -f agent-values.yaml

References​