Skip to main content

More Info:

Explicitly set a service account public key file for service accounts on the apiserver

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS Kubernetes

Triage and Remediation

Remediation

Manual Steps

  1. On every control plane node, back up the current API server manifest:
  2. Ensure a service account public key file exists on the node (example path used below); if you already have a specific key file, skip this generation and use that path instead:
  3. Edit the API server pod specification file on the control plane node:
    In the spec.containers[0].command list, add (or update) the argument so there is a line like:
    Ensure the path matches the actual public key file you intend to use.
  4. If the public key file is not already available inside the kube-apiserver container, add/ensure a hostPath volume and volumeMount in the same manifest so the file is accessible:
    Save and exit the editor. Editing this static pod manifest will cause the kubelet to automatically restart the kube-apiserver pod.
  5. Wait for the kube-apiserver pod to restart and become Running:
    (If crictl is not available, use the node’s container runtime CLI to confirm the kube-apiserver container is running.)
  6. Verify that the kube-apiserver process is now using the --service-account-key-file argument with the correct path:
kubectl cannot be used to configure the API server’s --service-account-key-file flag because it is set in the static pod manifest on each control plane node. To remediate this finding, edit /etc/kubernetes/manifests/kube-apiserver.yaml directly on every control plane node as described in the Manual Steps section.

Additional Reading: