Files
swaphb 3b1ca2a468
Kube-bench CIS scan / Scan ephemeral K3s cluster (push) Failing after 1m21s
emit clean kube-bench JSON report
2026-08-11 19:00:11 -04:00

77 lines
2.2 KiB
YAML

apiVersion: batch/v1
kind: Job
metadata:
name: kube-bench
namespace: kube-bench
labels:
app.kubernetes.io/name: kube-bench
app.kubernetes.io/part-of: kubernetes-security-baseline
spec:
backoffLimit: 0
template:
metadata:
labels:
app.kubernetes.io/name: kube-bench
spec:
# The K3s CIS profile checks host processes and node configuration.
hostPID: true
nodeSelector:
node-role.kubernetes.io/control-plane: "true"
tolerations:
- operator: Exists
restartPolicy: Never
containers:
- name: kube-bench
image: docker.io/aquasec/kube-bench:v0.16.0
command:
- /bin/sh
- -c
- |
set +e
kube-bench run \
--benchmark k3s-cis-1.7 \
--skip 1.4.1,1.4.2 \
--exit-code 0 \
--json \
>/tmp/kube-bench.json 2>/tmp/kube-bench.stderr
scan_rc=$?
cat /tmp/kube-bench.json
if [ "$scan_rc" -ne 0 ]; then
cat /tmp/kube-bench.stderr >&2
fi
exit "$scan_rc"
securityContext:
privileged: true
volumeMounts:
- name: etc-rancher-k3s
mountPath: /etc/rancher/k3s
readOnly: true
- name: var-lib-rancher-k3s
mountPath: /var/lib/rancher/k3s
readOnly: true
- name: var-lib-kubelet
mountPath: /var/lib/kubelet
readOnly: true
- name: var-lib-cni
mountPath: /var/lib/cni
readOnly: true
- name: etc-cni-netd
mountPath: /etc/cni/net.d
readOnly: true
volumes:
- name: etc-rancher-k3s
hostPath:
path: /etc/rancher/k3s
- name: var-lib-rancher-k3s
hostPath:
path: /var/lib/rancher/k3s
- name: var-lib-kubelet
hostPath:
path: /var/lib/kubelet
- name: var-lib-cni
hostPath:
path: /var/lib/cni
- name: etc-cni-netd
hostPath:
path: /etc/cni/net.d