Kubectl Security Review: Protecting Your Kubernetes Cluster
A single misconfigured kubectl command can tear a hole in your cluster’s defenses. That’s why a proper kubectl security review is not optional—it’s critical. Attackers look for weak RBAC rules, exposed kubeconfigs, and over-privileged service accounts. If you don’t check them, they will.
A kubectl security review starts with a full audit of your configuration and access controls. Pull down the current RBAC policies with:
kubectl get clusterrolebindings --all-namespaces -o yaml
Review every binding. Strip cluster-wide privileges from accounts that do not need them. Replace cluster-admin with narrow, namespace-specific roles.
Next, check your kubeconfig files. Are they stored in plaintext? Do they contain long-lived access tokens? Use short-lived credentials and rotate them often. Remove unused contexts from ~/.kube/config to cut attack surface.
Run kubectl auth can-i --list for each service account and user. This reveals the exact verbs and resources available. If you find the ability to create pods with arbitrary images or mount host paths, tighten the policies immediately.
Inspect secrets. Even if they are base64-encoded, they are not encrypted. Enable secrets encryption at rest on the API server and limit which roles can get or list them.
Finally, monitor kubectl usage. Audit logs in the API server can show which commands were run, from where, and by whom. Send these logs to a secure, centralized store and review them for anomalies.
Security reviews must be repeatable and automated. Integrate kubectl checks into CI/CD pipelines, and enforce them before deploying changes.
Your cluster’s integrity depends on catching weak points before they are exploited. Run a kubectl security review, fix the gaps, and keep it ongoing.
See how hoop.dev makes secure access control and full command auditing simple—deploy and get it running in minutes.