Kubernetes (K8s) (50 Qs)•Part 3: Advanced Internals, Scale & Production Security (Senior / Lead)
Hardening Kubernetes Workloads with Kyverno and Open Policy Agent (OPA) Gatekeeper.
senior LevelMost AskedCode ExampleSecurity & AuthKubernetes
In Simple Words: Enforcing corporate security policies at API admission time using validating webhooks:
- Kyverno Policy Example: Enforcing Read-Only Root Filesystem:
If any developer or CI/CD script submits a pod YAML withoutyaml
apiVersion: kyverno.io/v1 kind: ClusterPolicy metadata: name: require-ro-rootfs spec: validationFailureAction: Enforce rules: - name: validate-ro-rootfs match: resources: kinds: [Pod] validate: message: "Root filesystem must be read-only!" pattern: spec: containers: - securityContext: readOnlyRootFilesystem: truereadOnlyRootFilesystem: true, the API server rejects the request immediately.