{"id":452,"date":"2025-10-29T11:39:00","date_gmt":"2025-10-29T11:39:00","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=452"},"modified":"2025-10-29T11:39:00","modified_gmt":"2025-10-29T11:39:00","slug":"kube-bench-guide","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=452","title":{"rendered":"Kube-Bench: Kubernetes CIS Benchmarking Tool [Guide]"},"content":{"rendered":"<p>In this blog, you will learn about kube-bench and how to run Kubernetes CIS benchmarks against a cluster using kube-bench.<\/p>\n<p>When managing Kubernetes clusters for production use cases, security and compliance are crucial factors to consider. The clusters need to be securely configured to minimize the attack surface. <\/p>\n<p>Additionally, every organization might have audit requirements for systems to be compliant with security standards.<\/p>\n<h2 id=\"what-is-the-cis-kubernetes-benchmark\">What is the <strong>CIS Kubernetes benchmark<\/strong>?<\/h2>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-text\">CIS Benchmark is the product of a community consensus process and consists of secure configuration guidelines developed for Kubernetes<\/p>\n<p>cisecurity.org<\/p><\/div>\n<\/div>\n<p>Kubernetes CIS benchmarks cover security guidelines &amp; recommendations for the following<\/p>\n<ol>\n<li><strong>Control Plane Components<\/strong>: Control plane node configurations &amp; component recommendations.<\/li>\n<li><strong>Worker Nodes:<\/strong> Worker node configurations and Kubelet.<\/li>\n<li><strong>Policies: <\/strong>RBAC, service accounts, Pod security standards, CNI and network policies, Secret Management, etc.<\/li>\n<\/ol>\n<p>The following image shows the example list of CIS guidelines for the Kubernetes API server.<\/p>\n<figure class=\"kg-card kg-image-card kg-card-hascaption\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-8-44.png\" class=\"kg-image\" alt=\"kube-bench Kubernetes CIS benchmarks\" loading=\"lazy\" width=\"645\" height=\"603\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-8-44.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-8-44.png 645w\"><figcaption><span style=\"white-space: pre-wrap;\">Click to view in HD<\/span><\/figcaption><\/figure>\n<h2 id=\"what-is-kube-bench\">What is Kube-bench?<\/h2>\n<p>Kube-bench is an open-source tool to assess the security of Kubernetes clusters by running checks against the Center for Internet Security <a href=\"https:\/\/www.cisecurity.org\/benchmark\/kubernetes?ref=devopscube.com\" rel=\"noreferrer noopener\">(CIS) Kubernetes benchmark.<\/a> It was developed in <strong>GoLang<\/strong> by <a href=\"https:\/\/www.aquasec.com\/?ref=devopscube.com\" rel=\"noreferrer noopener\">Aqua Security<\/a>, a provider of cloud-native security solutions.<\/p>\n<p>Kube-bench can help with the following.<\/p>\n<ol>\n<li><strong>Cluster hardening:<\/strong> Kube-bench automates the process of checking the cluster configuration as per the security guidelines outlined in CIS benchmarks.<\/li>\n<li><strong>Policy Enforcement:<\/strong> Kube-bech checks for RBAC configuration to ensure the necessary least privileges are applied to service accounts, users, etc. it also checks for pod security standards and secret management.<\/li>\n<li><strong>Network segmentation:<\/strong> Kube-bench checks for CNI and its support for network policy to ensure that network policies are defined for all namespaces.<\/li>\n<\/ol>\n<p>When it comes to the use of kube-bench by organizations, a <a href=\"https:\/\/developers.redhat.com\/e-books\/2022-state-kubernetes-security-report?ref=devopscube.com\" rel=\"noreferrer noopener\">security survey<\/a> conducted by Red Hat found that 24% of the respondents use it.<\/p>\n<figure class=\"kg-card kg-image-card kg-card-hascaption\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-2-50.png\" class=\"kg-image\" alt=\"Kube-bench usage by organizations\" loading=\"lazy\" width=\"608\" height=\"371\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-2-50.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-2-50.png 608w\"><figcaption><span style=\"white-space: pre-wrap;\">Image Source: redhat.com<\/span><\/figcaption><\/figure>\n<p>You can run kube-bench checks against a cluster in two ways.<\/p>\n<ol>\n<li>From the command line using kube-bench CLI<\/li>\n<li>Run inside a pod<\/li>\n<\/ol>\n<p>Let&#8217;s look at both options.<\/p>\n<h2 id=\"running-kube-bench-from-command-line\">Running  Kube-bench From Command Line<\/h2>\n<p>If you are preparing for <a href=\"https:\/\/devopscube.com\/cks-exam-guide-tips\/\">CKS certification<\/a>, running kube-bench from the command line is one of the important tasks.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note:<\/strong><\/b> This method will only work if you have access to the control plane node. If you are utilizing a managed Kubernetes service, you can run kube-bench as a pod, as explained in the following section.<\/div>\n<\/div>\n<p><strong>Step 1:<\/strong> Log in to the control plane(master) node and create a kube-bench directory<\/p>\n<pre><code class=\"language-bash\">sudo mkdir -p \/opt\/kube-bench<\/code><\/pre>\n<p><strong>Step 2: <\/strong>Go to the <a href=\"https:\/\/github.com\/aquasecurity\/kube-bench\/releases?ref=devopscube.com\" rel=\"noreferrer noopener\">kube-bench releases<\/a> page and choose the latest Linux binary link.<\/p>\n<pre><code class=\"language-bash\">curl -L https:\/\/github.com\/aquasecurity\/kube-bench\/releases\/download\/v0.13.0\/kube-bench_0.13.0_linux_amd64.tar.gz -o \/opt\/kube-bench.tar.gz<\/code><\/pre>\n<p><strong>Step 3:<\/strong> Untar the binary to <strong><code>\/opt\/kube-bench <\/code><\/strong>folder<\/p>\n<pre><code class=\"language-bash\">tar -xvf kube-bench.tar.gz -C \/opt\/kube-bench<\/code><\/pre>\n<p>If you check the <strong><code>\/opt\/kube-bench<\/code><\/strong> directory, You will see the <strong><code>kube-bench<\/code><\/strong> executable and <strong><code>cfg<\/code><\/strong> folder that contains the benchmark variations for different versions and versions of managed kubernetes services <strong>GKE, EKS, AKS, etc<\/strong> as shown in the following tree structure.<\/p>\n<pre><code class=\"language-bash\">vagrant@master-node:~$ tree\n.\n\u251c\u2500\u2500 cfg\n\u2502   \u251c\u2500\u2500 ack-1.0\n\u2502   \u2502   \u251c\u2500\u2500 config.yaml\n\u2502   \u2502   \u251c\u2500\u2500 controlplane.yaml\n\u2502   \u2502   \u251c\u2500\u2500 etcd.yaml\n\u2502   \u2502   \u251c\u2500\u2500 managedservices.yaml\n\u2502   \u2502   \u251c\u2500\u2500 master.yaml\n\u2502   \u2502   \u251c\u2500\u2500 node.yaml\n\u2502   \u2502   \u2514\u2500\u2500 policies.yaml\n\u2502   \u251c\u2500\u2500 aks-1.0\n\u2502   \u2502   \u251c\u2500\u2500 config.yaml\n\u2502   \u2502   \u251c\u2500\u2500 controlplane.yaml\n\u2502   \u2502   \u251c\u2500\u2500 managedservices.yaml\n\u2502   \u2502   \u251c\u2500\u2500 master.yaml\n\u2502   \u2502   \u251c\u2500\u2500 node.yaml\n\u2502   \u2502   \u2514\u2500\u2500 policies.yaml\n\u2502   \u251c\u2500\u2500 cis-1.6-k3s\n\u2502   \u2502   \u251c\u2500\u2500 config.yaml\n\u2502   \u2502   \u251c\u2500\u2500 controlplane.yaml\n\u2502   \u2502   \u251c\u2500\u2500 etcd.yaml\n\u2502   \u2502   \u251c\u2500\u2500 master.yaml\n\u2502   \u2502   \u251c\u2500\u2500 node.yaml\n\u2502   \u2502   \u2514\u2500\u2500 policies.yaml\n\u2502   \u251c\u2500\u2500 config.yaml\n\u2502   \u251c\u2500\u2500 eks-stig-kubernetes-v1r6\n\u2502   \u2502   \u251c\u2500\u2500 config.yaml\n\u2502   \u2502   \u251c\u2500\u2500 controlplane.yaml\n\u2502   \u2502   \u251c\u2500\u2500 managedservices.yaml\n\u2502   \u2502   \u251c\u2500\u2500 master.yaml\n\u2502   \u2502   \u251c\u2500\u2500 node.yaml\n\u2502   \u2502   \u2514\u2500\u2500 policies.yaml\n\u2502   \u251c\u2500\u2500 gke-1.2.0\n\u2502   \u2502   \u251c\u2500\u2500 config.yaml\n\u2502   \u2502   \u251c\u2500\u2500 controlplane.yaml\n\u2502   \u2502   \u251c\u2500\u2500 managedservices.yaml\n\u2502   \u2502   \u251c\u2500\u2500 master.yaml\n\u2502   \u2502   \u251c\u2500\u2500 node.yaml\n\u2502   \u2502   \u2514\u2500\u2500 policies.yaml\n\u2502   \u2514\u2500\u2500 rh-1.0\n\u2502       \u251c\u2500\u2500 config.yaml\n\u2502       \u251c\u2500\u2500 controlplane.yaml\n\u2502       \u251c\u2500\u2500 etcd.yaml\n\u2502       \u251c\u2500\u2500 master.yaml\n\u2502       \u251c\u2500\u2500 node.yaml\n\u2502       \u2514\u2500\u2500 policies.yaml\n\u251c\u2500\u2500 kube-bench<\/code><\/pre>\n<p><strong>Step 4:<\/strong> Move the kube-bench executable to the <strong><code>\/usr\/local\/bin<\/code><\/strong> directory that is part of the system PATH<\/p>\n<pre><code class=\"language-bash\">sudo mv \/opt\/kube-bench\/kube-bench \/usr\/local\/bin\/<\/code><\/pre>\n<p>Now you can execute <code>kube-bench<\/code> from any system location.<\/p>\n<p><strong>Step 4:<\/strong> Let&#8217;s run the benchmark checks using <strong>kube-bench<\/strong> executable. We will be using the generic <strong>config.yaml<\/strong> to run the benchmarks using the following command. You have to run the command as sudo.<\/p>\n<pre><code class=\"language-bash\">sudo kube-bench --config-dir \/opt\/kube-bench\/cfg --config \/opt\/kube-bench\/cfg\/config.yaml<\/code><\/pre>\n<p>The above command will run the benchmarks checks and creates the summary of checks, remediation, and summary as shown below.<\/p>\n<pre><code class=\"language-bash\"># Checks Example\n[INFO] 1 Control Plane Security Configuration\n[INFO] 1.1 Control Plane Node Configuration Files\n[PASS] 1.1.1 Ensure that the API server pod specification file permissions are set to 644 or more restrictive (Automated)\n[PASS] 1.1.2 Ensure that the API server pod specification file ownership is set to root:root (Automated)\n\n# Remediations Example\n== Remediations master ==\n1.1.9 Run the below command (based on the file location on your system) on the control plane node.\nFor example, chmod 600 &lt;path\/to\/cni\/files&gt;\n1.1.12 On the etcd server node, get the etcd data directory, passed as an argument --data-dir,\nfrom the command 'ps -ef | grep etcd'.\n\n# Summary Example\n== Summary master ==\n41 checks PASS\n9 checks FAIL\n11 checks WARN\n0 checks INFO<\/code><\/pre>\n<p>If you want the report in a separate file, you can direct the output to a file as shown below.<\/p>\n<pre><code class=\"language-bash\">sudo kube-bench --config-dir \/opt\/kube-bench\/cfg --config \/opt\/kube-bench\/cfg\/config.yaml &gt; kube-bench.report<\/code><\/pre>\n<figure class=\"kg-card kg-image-card kg-card-hascaption\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-6-41.png\" class=\"kg-image\" alt=\"kube-bench CIS benchmark scan report\" loading=\"lazy\" width=\"1118\" height=\"749\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-6-41.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/image-6-41.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-6-41.png 1118w\" sizes=\"auto, (min-width: 720px) 720px\"><figcaption><span style=\"white-space: pre-wrap;\">Click to view in HD<\/span><\/figcaption><\/figure>\n<h3 id=\"installing-kube-bench-from-package\">Installing Kube-bench From Package<\/h3>\n<p>You can also install and run kube-bench using Linux packages. On the releases page, you will find both <strong><code>.deb<\/code><\/strong> and <strong><code>.rpm<\/code><\/strong> packages.<\/p>\n<p>For example, to install on Debian\/Ubuntu systems, you can execute the following commands.<\/p>\n<pre><code class=\"language-bash\">curl -L https:\/\/github.com\/aquasecurity\/kube-bench\/releases\/download\/v0.13.0\/kube-bench_0.13.0_linux_amd64.deb\n\nsudo dpkg -i  kube-bench.deb<\/code><\/pre>\n<p>After the installation, you can find the kube-bench cfg folder in the <strong><code>\/etc\/kube-bench\/<\/code><\/strong> directory.<\/p>\n<p>Also, you can run the kube-bench checks without providing the config directory parameters as we did in the binary installation. By default, <strong><code>kube-bench<\/code><\/strong> refers the <strong><code>\/etc\/kube-bench\/cfg<\/code><\/strong> directory.<\/p>\n<p>To run the checks execute the following command.<\/p>\n<pre><code class=\"language-bash\">sudo kube-bench<\/code><\/pre>\n<h2 id=\"running-kube-bench-in-a-pod\">Running  Kube-bench In a Pod<\/h2>\n<p>Another method to run <strong><code>kube-bench<\/code> <\/strong>is by deploying it as a <a href=\"https:\/\/devopscube.com\/create-kubernetes-jobs-cron-jobs\/\"><strong>Kubernetes job<\/strong><\/a><strong> pod<\/strong>. This method is particularly useful for running CIS benchmarks on managed Kubernetes clusters where root access to the control plane or worker nodes is not available.<\/p>\n<pre><code class=\"language-bash\">kubectl apply -f https:\/\/raw.githubusercontent.com\/aquasecurity\/kube-bench\/main\/job.yaml<\/code><\/pre>\n<p>Or if you want to modify the YAML, you can download it to a file and then apply it<\/p>\n<pre><code class=\"language-bash\">curl https:\/\/raw.githubusercontent.com\/aquasecurity\/kube-bench\/main\/job.yaml &gt; job.yaml<\/code><\/pre>\n<pre><code class=\"language-bash\">kubectl apply -f job.yaml<\/code><\/pre>\n<p>Then kube-bench report will be available in the pod logs. First List the pod<\/p>\n<pre><code class=\"language-bash\">kubectl get pods<\/code><\/pre>\n<p>Now use the pod name to get the logs. Replace <code>kube-bench-4j2bs<\/code> with your pod name.<\/p>\n<pre><code class=\"language-bash\">kubectl logs kube-bench-4j2bs<\/code><\/pre>\n<p>You can also export the kube-bench log to a file<\/p>\n<pre><code class=\"language-bash\">kubectl logs kube-bench-4j2bs &gt; kube-bench.report<\/code><\/pre>\n<h2 id=\"kube-bench-possible-errors\">Kube-bench Possible Errors<\/h2>\n<pre><code>unable to determine benchmark version: config file is missing 'version_mapping' sectio<\/code><\/pre>\n<p>If you run the <strong><code>kube-bench<\/code><\/strong> command without providing the <strong><code>--config-dir<\/code><\/strong> and <strong><code>--config<\/code><\/strong>  parameters, you will get the above error.<\/p>\n<h2 id=\"kube-bench-for-managed-kubernetes-clusters-gke-eks-aks-etc\">Kube-bench for Managed Kubernetes Clusters (GKE, EKS, AKS etc)<\/h2>\n<p>If you look at managed Kubernetes services like GKE, EKS, or AKS, you don&#8217;t get access to the control plane node to install the kube-bench utility.<\/p>\n<p>All managed kubernetes services follow the shared responsibility model where the Cloud providers take care of control plane availability and security and the user needs to take care of security in terms of users, policies, etc.<\/p>\n<p>Also, when you deploy the pod, it gets scheduled on a node and Kube-bench figures out that only kubelet is running on that node and it runs the checks accordingly. Meaning, it runs the tests for worker nodes. If you schedule the pod to be in the control plane, it runs all the checks required for the control plane.<\/p>\n<h2 id=\"kube-bench-alternatives\">kube-bench Alternatives<\/h2>\n<p>If you are looking for open-source alternatives for kube-bench to run CIS benchmarks, you can look at the following two tools.<\/p>\n<ol>\n<li>Checkov<\/li>\n<li>KubeScape<\/li>\n<\/ol>\n<h2 id=\"summary\">Summary<\/h2>\n<p>Kube-bench helps in verifying that your Kubernetes cluster is configured according to the recommendations from the Center for Internet Security (CIS).<\/p>\n<p>To comply with the organization&#8217;s security policies and audit requirements, you can run kube-bench to check and remediate security issues in the cluster.<\/p>\n<p>If you are learning kubernetes, check out the comprehensive <a href=\"https:\/\/devopscube.com\/kubernetes-tutorials-beginners\/\">kubernetes tutorials<\/a>.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/kube-bench-guide\/\" target=\"_blank\" rel=\"noopener noreferrer\">Kube-Bench: Kubernetes CIS Benchmarking Tool [Guide] \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/kube-bench-guide\/<\/p>\n","protected":false},"author":1,"featured_media":453,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-452","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=452"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/452\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/453"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}