Workload Identity Controller
The Workload Identity Controller binds a Kubernetes service account to Thalassa Cloud IAM. A pod can then exchange a projected JWT for a Thalassa bearer token. See Workload identity for Kubernetes.
Warning
This controller is experimental (v1beta1). The API and the behaviour may change.
The controller creates the Thalassa service account, the federated identity, and the IAM policy binding. It does not create the cluster OIDC identity provider. Thalassa Cloud creates that provider for a managed cluster. The provider label is kubernetes_cluster_id=<cluster identity>. For any other cluster, create the identity provider before you install the controller.
Where it runs
| Topology | Reconciler | Webhook |
|---|---|---|
| Thalassa-managed Kubernetes | Thalassa Cloud runs it. You do not install it. | You install it in the cluster. |
| Self-managed | You install it in the cluster. | You install it in the cluster. |
The chart default enables the controller and leaves the webhook disabled. Install the controller when the cluster does not already run the reconciler. The webhook always runs in the workload cluster, because admission must call an in-cluster Service.
The same container image is used for both Deployments. Each Deployment has its own service account and RBAC.
Custom resource
The API group is iam.thalassa.cloud/v1beta1. The kind is WorkloadIdentityBinding. Fields sit at the root of the object, in the same way as a RoleBinding. They do not sit under spec.
| Field | Purpose |
|---|---|
serviceAccountName | Kubernetes service account in the same namespace. |
policyRef | Thalassa IAM policy to bind. Prefer a stable policy identity. |
roleRef | Organisation role. Use this only when a policy is not available. |
scopes | API scopes on the federated identity. The default is openid when you omit the field. |
identityConfigMap | When true, the controller also writes a ConfigMap. |
deleteResources | When true, deleting the binding deletes the Thalassa resources. |
The JWT subject is system:serviceaccount:<namespace>:<name>. The projected token audience for exchange is https://api.thalassa.cloud.
Limit workloadidentitybindings write access to platform or GitOps identities. Application teams can own service accounts without permission to grant cloud IAM.
The API rejects a binding that has neither policyRef nor roleRef. It also rejects a wildcard (*). Optional controller allowlists can restrict the policies and roles a binding may reference.
Before you install the reconciler
- A cluster identity provider. See Cluster identity provider.
- Helm 3 and permission to pull charts from
oci://ghcr.io/thalassa-cloud/charts/. - The
tcloudCLI. - cert-manager, when you enable the webhook with the default TLS settings.
The controller calls the Thalassa API as its own service account. The bootstrap example binds iam:FullAccess. That policy can create service accounts, federated identities, and IAM bindings. The federated identity needs the scopes api:read and api:write. Those scopes are the bootstrap default.
| API area | Access |
|---|---|
| Service accounts | list, create, delete |
| Federated identities | list, create, update, delete |
| Federated identity providers | list |
| IAM policies and bindings | get and list policies; list, create, and delete bindings |
| Organisation roles and bindings | only when a binding uses roleRef |
Install the reconciler
Skip this section on a Thalassa-managed cluster that already runs the reconciler. Install the webhook only.
export ORG_ID="<organisation-id>"
export CLUSTER_ID="<cluster-id>"
tcloud iam workload-identity-federation bootstrap kubernetes \
--cluster "$CLUSTER_ID" \
--namespace thalassa-system \
--service-account thalassa-workload-identity-controller \
--policy iam:FullAccessCopy the Thalassa service account ID from the command output. Replace <version> with the chart release you want to run.
export CONTROLLER_THALASSA_SA_ID="<thalassa-service-account-id>"
helm upgrade --install thalassa-workload-identity-controller-crds \
oci://ghcr.io/thalassa-cloud/charts/thalassa-workload-identity-controller-crds:<version> \
--namespace thalassa-system --create-namespace
helm upgrade --install thalassa-workload-identity-controller \
oci://ghcr.io/thalassa-cloud/charts/thalassa-workload-identity-controller:<version> \
--namespace thalassa-system --create-namespace \
--set thalassa.organisation="$ORG_ID" \
--set thalassa.clusterIdentity="$CLUSTER_ID" \
--set thalassa.serviceAccountId="$CONTROLLER_THALASSA_SA_ID"Set thalassa.project when policy bindings must use a project. Leave it empty to use organisation-root policies.
To run the controller and the webhook together, also set webhook.enabled=true. The webhook default failurePolicy is Ignore, so pods still start when the webhook is unavailable. Set webhook.failurePolicy=Fail when the cluster must reject pods that the webhook cannot mutate. Use more than one webhook replica with that setting.
Webhook-only values for a managed cluster disable the controller, enable the webhook, set two replicas, and set failurePolicy to Fail. That overlay is values-webhook-only.yaml in the source repository.
Without cert-manager, provide a TLS Secret with tls.crt and tls.key, and set webhook.certManager.enabled=false and webhook.tls.secretName.
Bind a workload
apiVersion: v1
kind: ServiceAccount
metadata:
name: app
namespace: default
---
apiVersion: iam.thalassa.cloud/v1beta1
kind: WorkloadIdentityBinding
metadata:
name: app
namespace: default
serviceAccountName: app
policyRef: prometheus:RemoteWriteFullAccessThe binding is ready when status.phase is Ready and the Ready condition is True. Status includes serviceAccountID, organisationID, policyID, and federatedIdentityID.
When the binding is ready, the controller annotates the Kubernetes service account:
| Annotation | When it is set |
|---|---|
thalassa.cloud/wif.organisation-id | Always |
thalassa.cloud/wif.service-account-id | Always |
thalassa.cloud/wif.project-id | When the controller has a project |
How a pod receives the identifiers
Token exchange needs the organisation ID, the Thalassa service account ID, and the projected JWT.
Webhook
Enable the webhook. Label the pod with thalassa.cloud/wif.use: "true". This value is a label. The webhook objectSelector does not read an annotation.
The webhook adds these environment variables when the service account annotations exist:
| Variable | Value |
|---|---|
THALASSA_ORGANISATION_ID | From the service account annotation |
THALASSA_SERVICE_ACCOUNT_ID | From the service account annotation |
THALASSA_PROJECT_ID | When the annotation exists |
THALASSA_SUBJECT_TOKEN_FILE | /var/run/secrets/thalassa/token |
The webhook also mounts the projected token.
ConfigMap
Set identityConfigMap: true on the binding, or set controller.enableIdentityConfigMap=true to do this for every ready binding. The controller creates a ConfigMap named wif-<serviceAccountName> with the keys organisation-id, service-account-id, and, when set, project-id. Mount that ConfigMap next to the projected token.
Turning the flag off does not delete an existing ConfigMap. Deleting the binding deletes ConfigMaps that the binding owns.
Explicit configuration
Copy the IDs from the binding status or the service account annotations into the workload configuration. Mount only the projected JWT.
Related documentation
- Workload identity for Kubernetes — Manual federation for one service account
- OIDC workload identity — Token exchange and identity providers
tcloud iam workload-identity-federation bootstrap kubernetes— Command reference- Workload Identity Controller source — Chart values and examples