Review kube-apiserver static token file authentication

Review static API token lifetime, revocation and storage, and use manageable authentication where needed.

Description

Static bearer tokens loaded through --token-auth-file do not expire automatically. An API server must restart to pick up changes to the token list.

Potential impact

A leaked token or file can grant access with the user’s permissions until revocation takes effect on every API server.

Remediation

Test replacement authentication and permissions first, such as OIDC for people and short-lived service account tokens for workloads. Migrate clients, remove the flag from each API server and restart it. Retire unused files and distributed copies. Verify that new credentials work and the old tokens are rejected.

Examples

The Kubernetes 1.6 excerpts remove only the static-token file option. This method remains supported. If you keep it, restrict file access and token privileges and plan how to revoke tokens across all API servers.

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: api-server
spec:
  containers:
    - name: kube-apiserver
      image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
      command:
        - "kube-apiserver"
      args:
        - "--token-auth-file=/path/to/any/file"

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: api-server
spec:
  containers:
    - name: kube-apiserver
      image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
      command:
        - "kube-apiserver"

References