CNPA practice question 13 of 15

Which IaC approach ensures Kubernetes infrastructure maintains its desired state automatically?

Full set: 85 questions
Answer options
A: Declarative Correct answer
B: Imperative
C: Hybrid
D: Manual
Correct Answer:
A. Declarative
Explanation

The declarative approach is fundamental to Kubernetes' design for Infrastructure as Code (IaC). In this model, a user defines the desired state of the system in a manifest file (e.g., a YAML file describing a Deployment with three replicas). The Kubernetes control plane then continuously works to match the cluster's actual state to this desired state. This is achieved through a reconciliation loop, where controllers monitor resources and automatically take corrective action—such as restarting a failed pod or scaling a service—to enforce the declared configuration. This ensures the infrastructure self-heals and maintains its intended state without direct, step-by-step commands.

Why Incorrect

B. Imperative: This approach specifies explicit commands to reach a state. It does not inherently provide the continuous, automatic reconciliation needed to maintain that state if a deviation occurs.
C. Hybrid: This is not a standard, fundamental IaC paradigm. The automatic state maintenance described is a specific and core characteristic of the declarative model, not a hybrid one.
D. Manual: This is the opposite of IaC and automation. It relies on direct human intervention for configuration and lacks any mechanism for automatic state maintenance.

References

1. Kubernetes Official Documentation

"Declarative Management of Kubernetes Objects Using Configuration Files": This document explicitly contrasts declarative and imperative approaches

stating

"When you use the declarative approach

you work with Kubernetes object configuration files stored in source control. [...] The Kubernetes control plane will automatically... make and keep the Kubernetes cluster's state the same as the state that you declared."

Source: Kubernetes Authors. (n.d.). Declarative Management of Kubernetes Objects Using Configuration Files. Kubernetes Documentation. Retrieved from https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/

2. Kubernetes Official Documentation

"Controllers": This page explains the core mechanism behind the declarative model. "In Kubernetes

controllers are control loops that watch the state of your cluster

then make or request changes where needed. Each controller tries to move the current cluster state closer to the desired state."

Source: Kubernetes Authors. (n.d.). Controllers. Kubernetes Documentation. Retrieved from https://kubernetes.io/docs/concepts/architecture/controller/

3. University of California

Berkeley

EECS Courseware (CS 194-24): Lecture materials on Cloud Native Systems often describe this principle. For instance

lectures on Kubernetes architecture emphasize that users "declare the desired state of the world" and the system's controllers are responsible for the "reconciliation loop" that makes it a reality.

Source: Joseph

A. D.

& Stoica

I. (2021). Lecture 10: Kubernetes. CS 194-24: Cloud Native Systems. University of California

Berkeley. (Specific course materials often detail the declarative nature of Kubernetes controllers).

Scroll to Top