Kubernetes
medium

Pregunta de Kubernetes #019e3a4f

Enunciado de la Pregunta
Kubernetes
#kubernetes
#configmap
#immutable
Medio

Which Kubernetes resource uses immutable: true boolean field?

A

Deployment

B

Pod

C

ConfigMap

Correcto
D

ReplicaSet

Explicación Oficial / Explicaciones de la Comunidad

The immutable: true boolean field is a feature of the ConfigMap resource in Kubernetes. When set to true, it prevents updates to the ConfigMap's data after creation. This is useful for ensuring configuration stability and avoiding unintended changes that could affect running pods. The field is not available for Deployment, Pod, or ReplicaSet resources.

How it Works

  • ConfigMap: The immutable field is a top-level field in the ConfigMap spec. When set to true, any attempt to modify the ConfigMap's data (e.g., via kubectl edit or kubectl apply) will be rejected. This ensures that the configuration remains constant, which is particularly beneficial for production environments where configuration changes should be deliberate and controlled.
  • Deployment: Manages replica sets and rolling updates; it does not have an immutable field. Immutability is not a concept applied to Deployments, as they are designed to be updated.
  • Pod: The smallest deployable unit; it does not have an immutable field. Pods are ephemeral and can be replaced, but their configuration is not locked.
  • ReplicaSet: Ensures a specified number of pod replicas are running; it does not have an immutable field. Like Deployments, ReplicaSets are meant to be updated.

Why the Correct Value is Right

The ConfigMap resource is the only one among the options that supports the immutable: true field. This field was introduced in Kubernetes 1.21 (alpha) and became stable in 1.24. It is a security and reliability feature that prevents accidental or unauthorized changes to configuration data.

Why the Incorrect Values are Wrong

  • Deployment: Does not have an immutable field. Deployments are designed to manage changes through rolling updates, not immutability.
  • Pod: Does not have an immutable field. Pods are immutable in the sense that their spec cannot be changed after creation, but they do not have a boolean immutable field.
  • ReplicaSet: Does not have an immutable field. It is a lower-level resource that is typically managed by a Deployment and does not support immutability.

In summary, the immutable: true field is exclusive to ConfigMap (and also Secret, though not listed here) to lock configuration data from modifications.