Ensure the --service-account-key-file argument is set appropriately

Error: The --service-account-key-file argument is not set appropriately

Bridgecrew Policy ID: BC_K8S_73
Checkov Check ID: CKV_K8S_97
Severity: MEDIUM

The --service-account-key-file argument is not set appropriately

Description

Explicitly set a service account public key file for service accounts on the apiserver.
By default, if no --service-account-key-file is specified to the apiserver, it uses the private key from the TLS serving certificate to verify service account tokens. To ensure that the keys for service account tokens could be rotated as needed, a separate public/private key pair should be used for signing service account tokens. Hence, the public key should be specified to the apiserver with --service-account-key-file.

Fix - Buildtime

Kubernetes

  • Kind: Pod
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    component: kube-apiserver
    tier: control-plane
  name: kube-apiserver
  namespace: kube-system
spec:
  containers:
  - command:
+   - kube-apiserver
+   - --service-account-key-file=/keys/key.pem
    image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
    ...