☸️Kubernetes Static Security Testing Labs

🎯 Objective

Use tools like kube-score, kubescape, and checkov to statically analyze Kubernetes manifests for security and compliance issues.


🧰 Prerequisites

  • Kubernetes manifest files (YAML)

  • Tools: kube-score, kubescape, checkov

  • A system with internet access


🔹 Lab 1: Create a Sample Kubernetes Deployment

# insecure-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: insecure-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: insecure
  template:
    metadata:
      labels:
        app: insecure
    spec:
      containers:
      - name: app
        image: nginx:latest
        ports:
        - containerPort: 80

🔹 Lab 2: Install and Use kube-score

Install:

Run against manifest:

✅ Detects missing readOnlyRootFilesystem, runAsNonRoot, and more.


🔹 Lab 3: Install and Use kubescape

Install:

Run:

✅ Scans manifest against NSA, MITRE, and custom frameworks.


🔹 Lab 4: Install and Use checkov

Install:

Run:

✅ Reports insecure configurations, missing security context, and risky settings.


🔹 Lab 5: Automate in CI/CD

GitHub Actions Example:


✅ Wrap-Up

  • ✅ Used kube-score, kubescape, and checkov to statically analyze workloads

  • ✅ Identified common misconfigurations before deployment

  • ✅ Integrated security checks into CI pipelines


Last updated