# Token for a Kubernetes agent running in a different cluster from
# Auth. Auth cannot call TokenReview on the remote cluster, so it
# verifies the agent's ServiceAccount JWT against a JWKS that the
# remote cluster's apiserver publishes at /openid/v1/jwks.
apiVersion: almaforge.com/v1
kind: Token
metadata:
  name: remote-kube-agent # Agent ALMA_CLIENT_ID value.
spec:
  roles:
    - system:kubernetes # Allow joining Kubernetes agents.
  kubernetes:
    type: static_jwks # Verify ServiceAccount JWTs against the pinned JWKS below.
    staticJWKS:
      # Fetch from the remote cluster's apiserver:
      #   kubectl --context=<remote> get --raw /openid/v1/jwks
      # Replace this placeholder with the value that command returns.
      jwks: |
        {"keys":[{"use":"sig","kty":"RSA","kid":"replace-me","alg":"RS256","n":"replace-me","e":"AQAB"}]}
    allow:
      - serviceAccount: almaforge:agent # namespace:name of the joining ServiceAccount.
