Implementing Security Best Practices
1. Implementing Network Segmentation
| Practice | Tool |
|---|---|
| Default deny | NetworkPolicy per namespace |
| L7 segmentation | Cilium / Istio AuthorizationPolicy |
| Egress control | Egress gateway, FQDN policies |
2. Enabling RBAC Authorization
kube-apiserver --authorization-mode=Node,RBAC
Note: Never grant
cluster-admin to humans broadly; use just-in-time elevation.3. Using Pod Security Standards
Apply restricted profile on all workload namespaces; reserve privileged for system namespaces only.
4. Scanning Container Images
| Tool | Use |
|---|---|
| Trivy | Vuln + SBOM + IaC |
| Grype | Anchore scanner |
| Snyk | SaaS scanner |
| Clair | Registry-side scan |
5. Enabling Secrets Encryption
apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
- resources: [secrets]
providers:
- aescbc: { keys: [{ name: key1, secret: BASE64_32_BYTE_KEY }] }
- identity: {}
| Provider | Detail |
|---|---|
| aescbc / aesgcm | Local key (rotate frequently) |
| kms v2 | External KMS (AWS KMS, GCP KMS, Vault) |
6. Using Admission Controllers
Enable NodeRestriction, PodSecurity, ResourceQuota, and policy engines (Kyverno, Gatekeeper) for org rules.
7. Enabling Audit Logging
apiVersion: audit.k8s.io/v1
kind: Policy
rules:
- level: Metadata
resources: [{ group: "", resources: [secrets, configmaps] }]
- level: RequestResponse
verbs: [delete, deletecollection]
- level: None
users: [system:kube-proxy]
8. Implementing mTLS
Cluster-wide mTLS via service mesh (Istio STRICT, Linkerd default). Identity from SPIFFE/SPIRE.
9. Rotating Certificates
See §42 — automate kubeadm cert renewal + kubelet auto-rotation; alert on expiry < 30 days.
10. Running CIS Benchmarks
kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml
kubectl logs job/kube-bench
11. Using Runtime Security
| Tool | Detail |
|---|---|
| Falco | eBPF/kernel syscall rules |
| Tetragon | eBPF observability + enforcement |
| Tracee | Aqua runtime tracing |
12. Implementing Supply Chain Security
| Practice | Tool |
|---|---|
| Sign images | Sigstore Cosign |
| Verify at admission | Kyverno verifyImages, Policy Controller |
| Generate SBOM | Syft, Trivy |
| Provenance | SLSA, in-toto attestations |
| Pin by digest | image: nginx@sha256:... |