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.
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.
kubectlobtains 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 loginsets 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 execandattachsessions are recorded for live observation and playback.
Architecture
Kubernetes access consists of three components:
- 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. - In-Cluster Agent (
almaforge-agentHelm 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). - Workstation Client (
almaandkubectl): Engineers log in via the CLI, select a target cluster withalma kube login, and interact with the cluster using standardkubectlcommands.
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 (
adminpreset 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
kubectl1.24+ configured with administrative access to the target cluster.- Helm 3.12+ installed.
- The
almaCLI 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:
alma login --proxy=[your-almaforge-host]:443alma create token --services=kubernetes,app,database --format=textThe command outputs the join credentials on two separate lines:
[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.
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:
kubectl config use-context [your-target-cluster-context]Add the Helm repository and install the almaforge-agent chart using the credentials from Step 1:
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 \ --waitAlternatively, maintain configuration in a version-controlled values file:
# 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
helm upgrade --install almaforge-agent almaforge/almaforge-agent \ --namespace almaforge --create-namespace \ -f agent-values.yaml --waitSee 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:
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 38sOn your control plane workstation, confirm the cluster has registered:
alma get kubeCluster Labels Version------------ ---------- -------prod-cluster env=prod 2026.2.30Configure RBAC & SSO mappings
Access to Kubernetes clusters is governed by two layers:
- AlmaForge Role: Controls which clusters a user can access and which Kubernetes users and groups the agent will impersonate.
- Kubernetes RBAC: Native
ClusterRole,Role,ClusterRoleBinding, andRoleBindingresources 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:
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:
alma apply -f kube-access.yamlKey fields in spec.allow:
kubernetesLabels: Label selector matching the target cluster'slabels(orclusterName).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:
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.
- Via Helm Values (Recommended)
- Via kubectl
Configure rbac.bindings in your agent-values.yaml so user bindings are version-controlled
and deployed with the agent:
rbac:
bindings:
- name: almaforge-developers
roleRef:
kind: ClusterRole
name: view
subjects:
- kind: Group
name: developers
Update the release:
helm upgrade almaforge-agent almaforge/almaforge-agent \ --namespace almaforge -f agent-values.yamlApply a native ClusterRoleBinding directly to the target cluster:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: almaforge-developers
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view
subjects:
- kind: Group
name: developers
apiGroup: rbac.authorization.k8s.io
kubectl apply -f developers-binding.yamlStep 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:
alma login --proxy=[your-almaforge-host]:443List the available clusters:
alma get kubeCluster Labels Version------------ ---------- -------prod-cluster env=prod 2026.2.30Step 2. Log in to the target cluster
Generate credentials and set your active kubectl context:
alma kube login prod-clusterLogged into Kubernetes cluster "prod-cluster".Try: kubectl get podsalma 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.
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:
kubectl get namespaceskubectl get pods -n app-backendkubectl exec -it deploy/frontend -n app-backend -- shkubectl port-forward svc/postgres -n app-backend 5432:5432Tools 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:
# Switch to another clusteralma kube login staging-cluster
# Or use standard kubectl context switchingkubectl config get-contextskubectl config use-context [your-almaforge-host]-prod-clusterTo configure all available clusters in your kubeconfig at once, run:
alma kube login --allAudit & 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 execandkubectl attachrecord full terminal PTY input and output.
List recent session recordings:
alma recording ls --last=1hID Type User Cluster Duration------------------------------------ ----- ------------------ ------------ --------d6f4b2a1-89ce-4a7b-a49e-11f8139e88d1 kube alice@example.com prod-cluster 4m12sPlay back an interactive session in your terminal:
alma recording play d6f4b2a1-89ce-4a7b-a49e-11f8139e88d1Advanced
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:
- AWS IAM (EKS)
- GCP (GKE)
- Azure (AKS)
- Kubernetes (Same Cluster)
The agent authenticates using IAM Roles for Service Accounts (IRSA):
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/*'
alma apply -f kube-iam.yamlSet env.ALMA_JOIN_METHOD=aws and env.ALMA_CLIENT_ID=kube-iam during install.
The agent authenticates via GKE Workload Identity:
apiVersion: almaforge.com/v1
kind: Token
metadata:
name: kube-agent
spec:
roles:
- system:kubernetes
gcp:
allow:
- projectIDs:
- 'my-project'
serviceAccounts:
- 'agent@my-project.iam.gserviceaccount.com'
alma apply -f kube-gcp.yamlSet env.ALMA_JOIN_METHOD=gcp and env.ALMA_CLIENT_ID=kube-gcp during install.
The agent authenticates via Azure AD Workload Identity:
apiVersion: almaforge.com/v1
kind: Token
metadata:
name: kube-agent
spec:
roles:
- system:kubernetes
azure:
allow:
- subscription: '11111111-1111-1111-1111-111111111111'
resourceGroups:
- 'aks-rg'
alma apply -f kube-azure.yamlSet env.ALMA_JOIN_METHOD=azure and env.ALMA_CLIENT_ID=kube-azure during install.
When the agent and control plane share a cluster or TokenReview API, the agent
authenticates via its in-cluster ServiceAccount token:
alma apply -f - <<EOFapiVersion: almaforge.com/v1kind: Tokenmetadata: name: kube-agentspec: services: [kubernetes, app, database] joinMethod: kubernetes kubernetes: type: in_cluster allow: - serviceAccount: "almaforge:almaforge-agent"EOFSet env.ALMA_JOIN_METHOD=kubernetes and env.ALMA_CLIENT_ID=kube-agent 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:
- Target Cluster RBAC: Create a dedicated namespace and service account with
impersonation permissions:
- Apply
01-namespace.yaml - Apply
02-rbac.yaml
- Apply
- Kubeconfig Template: Generate a kubeconfig for the agent service account on the VM:
- Template:
03-kubeconfig.yaml
- Template:
- Environment Configuration: Configure
/etc/almaforge/almad.envon the agent VM:- Template:
almad.env - Set
ALMA_KUBERNETES_SERVICE=trueandALMA_KUBECONFIG=/etc/almaforge/kubeconfig.yaml.
- Template:
- Register the Target: Register the cluster with the control plane:
- Manifest:
kubernetestarget.yaml - Apply with
alma apply -f kubernetestarget.yaml.
- Manifest:
Isolated kubeconfig files
To keep work contexts separate without modifying your default ~/.kube/config,
specify an independent kubeconfig file:
alma kube login prod-cluster --kubeconfig=~/.kube/prod.yamlKUBECONFIG=~/.kube/prod.yaml kubectl get podsOperations
Upgrades
Upgrade the in-cluster agent using Helm. Leave image.tag unset so the agent
version tracks the chart version:
helm repo update almaforgehelm upgrade almaforge-agent almaforge/almaforge-agent \ --namespace almaforge -f agent-values.yaml --version [new-version] --waitBecause 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:
helm -n almaforge rollback almaforge-agent --waitUninstallation
To remove the in-cluster agent from the target cluster:
helm -n almaforge uninstall almaforge-agentThis removes the StatefulSet, ServiceAccount, ClusterRole, ClusterRoleBinding, Role, and NetworkPolicy. To wipe persistent process identity Secrets as well:
kubectl -n almaforge delete secret almaforge-agent-0-state almaforge-agent-1-stateTroubleshooting
alma get kube shows nothing
- Confirm agent pods are running:
kubectl -n almaforge get pods -l app.kubernetes.io/component=agent - Inspect agent startup logs:
Look for
kubectl -n almaforge logs statefulset/almaforge-agentJoining the clusteror 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:
kubectl get clusterrole almaforge-almaforge-agentkubectl get clusterrolebinding almaforge-almaforge-agentkubectl commands return forbidden
AlmaForge successfully authenticated the user and forwarded the request, but the target cluster's native RBAC denied the operation:
- Inspect the groups mapped in the user's role:
alma status - Confirm the target cluster has a binding for those exact groups:
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:
# 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:
helm upgrade almaforge-agent almaforge/almaforge-agent \ --namespace almaforge \ --set tls.caConfigMapName=internal-ca \ --set tls.caKey=ca.crt \ -f agent-values.yamlReferences
- Helm Values Reference: Complete values
documentation for the
almaforge-agentchart. - Declarative Configuration: Schema reference
for
KubernetesTarget,Role, andToken. - Workload Identity: Detailed setup for in-cluster, AWS IAM, GCP, and Azure join methods.
- RBAC Reference: Complete documentation on role templates, deny rules, and dynamic trait mapping.
- Audit & Recording: Event types, retention, and compliance policies.