Skip to main content
InterviewHubPRO
Section Overview
Q26

Question 26 of 50

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

52%
Kubernetes (K8s) (50 Qs)•Part 3: Advanced Internals, Scale & Production Security (Senior / Lead)

Custom Resource Definitions (CRDs) and the Operator Pattern.

senior LevelCode ExampleSecurity & Auth

In Simple Words:

  • CRD (Custom Resource Definition): Extends the Kubernetes API with custom schema objects (e.g., PostgresCluster, KafkaTopic).
  • Operator Pattern: Combines a CRD with a custom Controller running an infinite Reconcile Loop written in Go (using controller-runtime or Kubebuilder):
    go
    func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
        // 1. Fetch current live state
        // 2. Fetch desired state from CRD manifest
        // 3. Perform automated operations (provision cloud disk, take DB snapshot, failover leader)
        // 4. Update CRD status
        return ctrl.Result{RequeueAfter: time.Minute}, nil
    }
    
    Encapsulates human domain expertise (database backup, replication, cluster failover) into automated code.