Pregunta de Kubernetes #019e3a4f
Which Kubernetes resource uses immutable: true boolean field?
Deployment
Pod
ConfigMap
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
immutablefield is a top-level field in the ConfigMap spec. When set totrue, any attempt to modify the ConfigMap's data (e.g., viakubectl editorkubectl 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
immutablefield. 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
immutablefield. 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
immutablefield. 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
immutablefield. Deployments are designed to manage changes through rolling updates, not immutability. - Pod: Does not have an
immutablefield. Pods are immutable in the sense that their spec cannot be changed after creation, but they do not have a booleanimmutablefield. - ReplicaSet: Does not have an
immutablefield. 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.