Skip to main content
InterviewHubPRO
Section Overview
Q35

Question 35 of 50

Part 3: Advanced Internals, Scale & Production Security (Senior / Lead)

70%
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:
    yaml
    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: true
    
    If any developer or CI/CD script submits a pod YAML without readOnlyRootFilesystem: true, the API server rejects the request immediately.