Skip to main content

One post tagged with "kube-scanning-tests"

View All Tags

ยท 2 min read

Introduction#

Create your Kube scanning test, for your custom plugin in against running kubernetes cluster. Here we are using the Kube-bench tool that checks the Kubernetes cluster is deployed securely by running the necessary checks documented in the CIS Kubernetes Benchmark.

Build gradle configuration for kube scanner#

deployIntegrationServer {    kubeScanner {        awsRegion = 'eu-west-1'         logOutput = true        kubeBenchTagVersion = "v0.6.5"        command = ["-v", "3", "logtostrerr"]    } }
NameTypeDefault ValueDescription
awsRegionOptionalBy default it will read from config [~/.aws/config] file.
logOutputOptionalfalseTo Log the command and output executed while running the test.
kubeBenchTagVersionOptionallatestBy default it will use the latest main branch.
commandOptional["kube-bench", "run", "--targets", "node","--benchmark", "eks-1.0"]List of command for running the test.

Under the hood#

Great, we now have the setup done. Let's figure out how it works.

How to scan the kubernetes cluster which is running on AWS (EKS)?#

  • By Running the below command, we can scan the Kubernetes cluster which is configured as current-context in ~/.kube/config.
./gradlew clean kubeScanning
  • Firstly, it will clone the kube-bench repo with a tag to build/kube-scanning/kube-bench folder. As in the below illustration:

kube-bench-repo

  • Next, execute the steps for AWS-EKS-Cluster
    • Create the repository in AWS ECR
    • Take docker build of kube-bench with tag
    • Push the created image to AWS ECR
    • Update the job-eks.yaml with the latest image which we generate in a previous step and run the job.

kube-bench-aws-eks-command

  • Once the above command execution is completed, we can find the report in build/kube-scanning/report folder, like the below sample log.

    kube-bench-aws-eks-report

info

note