πŸ”’ Cloud & Kubernetes Track

Kubernetes Hardening

Secure a production Kubernetes cluster using industry-standard benchmarks, Pod Security Standards, and defense-in-depth strategies.

⏱️ 8-12 hours 🎯 Intermediate πŸ’Ό Portfolio Ready

πŸ“‹ Project Overview

Security isn't a feature you add at the endβ€”it's foundational. In this project, you'll harden a Kubernetes cluster from the ground up, implementing controls that real enterprises use to protect production workloads.

You'll apply the CIS Kubernetes Benchmark, configure RBAC with least privilege, enforce Pod Security Standards, and implement network segmentation using Network Policies.

βœ… Prerequisites

Required Knowledge

  • β€’ Kubernetes basics (Pods, Deployments, Services)
  • β€’ YAML configuration
  • β€’ Basic Linux security concepts
  • β€’ kubectl command proficiency

Tools Needed

  • β€’ Kubernetes cluster (kind/minikube)
  • β€’ kubectl CLI
  • β€’ kube-bench (security scanner)
  • β€’ OPA Gatekeeper (optional)

🎯 What You'll Learn

πŸ”

RBAC Mastery

Design least-privilege access controls using Roles and RoleBindings

πŸ›‘οΈ

Pod Security

Enforce security contexts and Pod Security Standards

🌐

Network Segmentation

Implement default-deny Network Policies

πŸ“Š

Security Auditing

Use kube-bench to validate CIS compliance

πŸ”¨ Implementation Guide

Step 1: CIS Benchmark Baseline

Run kube-bench to identify security gaps

kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml kubectl logs -f job/kube-bench

Step 2: Enable RBAC & Remove Default Permissions

Create a read-only ClusterRole for developers

apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: developer-read-only rules: - apiGroups: ["", "apps"] resources: ["pods", "services", "deployments"] verbs: ["get", "list", "watch"]

Step 3: Pod Security Standards

Enforce "restricted" profile on production namespaces

kubectl label namespace production \\ pod-security.kubernetes.io/enforce=restricted

Step 4: Network Policies (Default-Deny)

Block all ingress traffic by default, then allow explicitly

apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: default-deny-ingress namespace: production spec: podSelector: {} policyTypes: - Ingress

πŸ“¦ Deliverables

  • βœ“ kube-bench report showing >80% compliance with CIS benchmark
  • βœ“ RBAC configuration with 3+ roles (admin, developer, viewer)
  • βœ“ Network Policy manifests for production namespace
  • βœ“ Documentation explaining security controls implemented

πŸ“š Resources