# Token for an in-cluster Kubernetes agent.
# The agent proves identity with its mounted ServiceAccount JWT.
apiVersion: almaforge.com/v1
kind: Token
metadata:
  name: kube-agent # Agent ALMA_CLIENT_ID value.
spec:
  roles:
    # Grant only the system roles the agent actually runs. An unused
    # role widens the trust boundary for no gain.
    - system:kubernetes # Allow joining Kubernetes agents.
    - system:app # Allow joining Application agents.
    - system:database # Allow joining Database agents.
  kubernetes:
    # Validation backend.
    #   in_cluster  - Auth calls the local TokenReview API. Use this
    #                 when Auth runs in the same Kubernetes cluster
    #                 as the joining agent. Default.
    #   static_jwks - Auth verifies the JWT against a pinned issuer
    #                 JWKS configured under spec.kubernetes.staticJWKS.
    #                 Use this when the agent runs in a different
    #                 Kubernetes cluster that Auth cannot reach.
    type: in_cluster
    allow:
      - serviceAccount: almaforge:agent # namespace:name of the joining ServiceAccount.
