Skip to content

kube-bench

60 commands

Checks whether a Kubernetes cluster is deployed securely by running the CIS Kubernetes Benchmark tests against nodes and control plane.

  • Kubernetes
  • CIS benchmark
  • hardening

Install kube-bench

brew install kube-bench

Basic Execution3

kube-bench

Runs the default CIS benchmark checks based on auto-detected Kubernetes version and node type.

kube-bench run

Explicitly triggers the run command to execute benchmarks using default settings.

kube-bench version

Displays the installed version of the kube-bench tool.

Target Selection7

kube-bench run --targets master

Executes security checks specifically designed for the Kubernetes master/control plane node.

kube-bench run --targets node

Executes security checks specifically designed for Kubernetes worker nodes.

kube-bench run --targets etcd

Runs checks specifically targeting the etcd data store configuration and security.

kube-bench run --targets policies

Runs checks aimed at validating Kubernetes policies and RBAC configurations.

kube-bench run --targets controlplane

Target alias often used interchangeably with master to check control plane components.

kube-bench run --targets master,node

Executes benchmark checks for both master and worker node roles simultaneously.

kube-bench run --targets master,etcd

Combines control plane and etcd checks in a single execution run.

Link

Output Formatting4

kube-bench run --json

Outputs the audit results in structured JSON format for parsing and automation.

Link
kube-bench run --junit

Outputs the audit results in JUnit XML format for CI/CD pipeline integration.

Link
kube-bench run --noremediations

Runs checks but suppresses the remediation suggestions in the output to reduce clutter.

Link
kube-bench run --noresults

Suppresses the detailed results output, useful when only interested in exit codes or logs.

Link

Specific Checks2

kube-bench run --check <ID>

Executes only the specific benchmark check identified by the provided ID.

Link
kube-bench run --check <ID_LIST>

Executes a comma-separated list of specific benchmark check IDs.

Link

Skipping Checks2

kube-bench run --skip <ID>

Runs all default checks except the specific ID provided.

Link
kube-bench run --skip <ID_LIST>

Runs all default checks while excluding the comma-separated list of IDs.

Link

Benchmark Versions5

kube-bench run --benchmark cis-1.5

Forces the usage of the legacy CIS Kubernetes Benchmark v1.5.

Link
kube-bench run --benchmark cis-1.6

Forces the usage of the CIS Kubernetes Benchmark v1.6.

Link
kube-bench run --benchmark cis-1.7

Forces the usage of the CIS Kubernetes Benchmark v1.7.

Link
kube-bench run --benchmark cis-1.20

Forces the usage of the CIS Kubernetes Benchmark v1.20.

Link
kube-bench run --benchmark cis-1.23

Forces the usage of the CIS Kubernetes Benchmark v1.23.

Link

Cloud Specific5

kube-bench run --benchmark eks-1.2.0

Runs the CIS benchmark specifically tailored for Amazon EKS v1.2.0.

Link
kube-bench run --benchmark gke-1.0

Runs the CIS benchmark specifically tailored for Google Kubernetes Engine (GKE).

Link
kube-bench run --benchmark aks-1.0

Runs the CIS benchmark specifically tailored for Azure Kubernetes Service (AKS).

Link
kube-bench run --benchmark rh-0.0.1

Runs the benchmark specifically tailored for Red Hat OpenShift environments.

Link
kube-bench run --benchmark ack-1.0

Runs the CIS benchmark specifically tailored for Alibaba Cloud Container Service.

Link

Version Override1

kube-bench run --version <K8S_VER>

Manually specifies the Kubernetes version to select the appropriate benchmark set.

Link

Configuration2

kube-bench run --config-dir <PATH>

Specifies a custom directory path to look for benchmark configuration files.

Link
kube-bench run --config <FILE>

Specifies a custom configuration file instead of the default config.yaml.

Link

Logging2

kube-bench run --log_level 1

Sets the logging verbosity to level 1 for basic info logging.

Link
kube-bench run --log_level 2

Sets the logging verbosity to level 2 for more detailed debug information.

Link

Advanced Workflow4

kube-bench run --targets master --json --noremediations

Runs master checks outputting pure JSON without remediation text for cleaner data ingestion.

Link
kube-bench run --targets node --junit --skip <ID>

Runs node checks, skips a known false positive, and outputs JUnit XML for CI pipelines.

Link
kube-bench run --targets etcd --check <ID_LIST> --json

Audits specific etcd configurations and outputs the result in JSON.

Link
kube-bench run --benchmark cis-1.23 --targets master

Forces a specific modern CIS benchmark version on the master node regardless of detection.

Link

Containerized Execution1

kube-bench run --targets node --version <VER>

Typical command used inside a Job definition to audit the node hosting the pod.

Link

File Output2

kube-bench run --json > report.json

Standard shell redirection to save JSON audit results to a file for later analysis.

Link
kube-bench run --junit > junit.xml

Standard shell redirection to save JUnit XML results to a file for Jenkins/GitLab.

Link

Performance Tuning1

kube-bench run --v 0

Runs with minimal verbosity, reducing IO overhead during execution.

Link

Blue Team Validation1

kube-bench run --check <CRITICAL_IDS>

Rapidly validates the state of specific critical control plane configurations during an incident.

Link

Compliance Audit1

kube-bench run --targets master,node,etcd --json

Full cluster compliance sweep outputting a comprehensive JSON report.

Link

Custom Config1

kube-bench run --config-dir cfg/ --benchmark <CUSTOM>

Runs a custom-defined benchmark suite located in a specific directory.

Link

Specific Check Group1

kube-bench run --check 1.1

Runs all sub-checks under section 1.1 (e.g., API Server configuration).

Link

Environment Override1

kube-bench run --version <OLD_VER>

Simulates an audit for an older Kubernetes version to test legacy compliance rules.

Link

EKS Analysis1

kube-bench run --benchmark eks-1.2.0 --targets node

Validates worker node security posture specifically against EKS standards.

Link

GKE Analysis1

kube-bench run --benchmark gke-1.0 --targets node

Validates worker node security posture specifically against GKE standards.

Link

Combined Filter1

kube-bench run --targets master --skip <FAILING_IDS>

Runs master checks while ignoring known failing controls that are accepted risks.

Link

DevOps Pipeline1

kube-bench run --targets node --json --noremediations > result.json

Optimized command for automated pipeline jobs to capture node status silently.

Link

Interactive Debug1

kube-bench run --log_level 2 --check <ID>

High verbosity run on a single check to troubleshoot why a specific audit is failing.

Link

Post-Incident1

kube-bench run --targets policies --json

Audits RBAC and ServiceAccount policies specifically to detect permission drifts.

Link

Legacy Support1

kube-bench run --benchmark cis-1.4

Runs very old benchmark definitions for maintaining legacy system audits.

Link

Control Plane Only1

kube-bench run --targets controlplane --json

Focuses strictly on the control plane components for managed service validations.

Link

Automated Parsing1

kube-bench run --json --noresults

Generates JSON structure without human-readable summaries, maximizing parsing speed.

Link

Full System Audit1

kube-bench run --targets master,node,etcd,policies

Maximum coverage command targeting every available component and policy.

Link

Specific Benchmark Path1

kube-bench run --config-dir /opt/kube-bench/cfg

Directs kube-bench to load configuration from a non-standard system location.

Link

CI/CD Gate1

kube-bench run --junit --targets master --skip <FLAKY>

Production gate check outputting JUnit, ignoring flaky tests to prevent build failures.

Link

Quick Sanity Check1

kube-bench run --check 1.1.1,1.1.2,1.1.3

Runs only the first three API server checks as a quick health signal.

Link

Documentation Generation1

kube-bench run --json > current_audit.json

Snapshots the current security posture to a JSON file for documentation and comparison.

Link