Skip to content

Workload Identity

Service accounts#

Every pod runs as a ServiceAccount, the identity it uses towards the Kubernetes API. Most applications never call the Kubernetes API, so the cluster mounts no API token into pods by default.

When a workload needs API access#

Controllers, operators and some agents need to read or write Kubernetes objects:

  1. Install the application with a Flux HelmRelease. Its chart may bring a Role and RoleBinding for the application's ServiceAccount in the same namespace.
  2. Label the ServiceAccount so the token is mounted:

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: my-operator
      labels:
        k7e.tech/automount-service-account-token: "true"
    

The Role can grant at most the developer rights plus Role, RoleBinding and Lease in that namespace. Cluster-wide permissions are not possible; contact kloudease Support if you need them.

Inspecting your workload's identity#

# Which ServiceAccount does a pod use?
kubectl get pod <pod-name> -n <namespace> -o jsonpath='{.spec.serviceAccountName}'