-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcis-kubelet.sh
14 lines (13 loc) · 974 Bytes
/
cis-kubelet.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
#cis-kubelet.sh
#total_fail=$(kube-bench run --targets node --version 1.15 --check 4.2.1,4.2.2 --json | jq .[].total_fail)
total_fail=$(docker run --pid=host -v /etc:/etc:ro -v /var:/var:ro -v $(which kubectl):/usr/local/mount-from-host/bin/kubectl -v ~/.kube:/.kube -e KUBECONFIG=/.kube/config -t docker.io/aquasec/kube-bench:latest run --targets node --version 1.20 --check 4.2.1,4.2.2 --json | jq '.Totals.total_fail')
fail_result=$(docker run --pid=host -v /etc:/etc:ro -v /var:/var:ro -v $(which kubectl):/usr/local/mount-from-host/bin/kubectl -v ~/.kube:/.kube -e KUBECONFIG=/.kube/config -t docker.io/aquasec/kube-bench:latest run --targets node --version 1.20 --check 4.2.1,4.2.2 )
if [[ "$total_fail" -ne 0 ]];
then
echo "CIS Benchmark Failed Kubelet while testing for 4.2.1, 4.2.2"
exit 1;
else
echo "CIS Benchmark Passed Kubelet for 4.2.1, 4.2.2"
echo $fail_result
fi;