Check Pod immutability

Learn how to edit a live Pod and how to specify resource requests and resource limits for each container in a Pod.

Pods as immutable objects

Pods are designed as immutable objects, meaning we shouldn’t change them after deployment.

Immutability applies at two levels:

  • Object immutability (the Pod)

  • App immutability (containers)

Kubernetes handles object immutability by preventing changes to a running Pod’s configuration. However, Kubernetes can’t always prevent us from changing the app and filesystem in containers. We’re responsible for ensuring containers and their apps are stateless and immutable.

The following example uses kubectl edit to edit a live Pod object. Try and change any of these attributes:

  • Pod name

  • Container name

  • Container port

  • Resource requests and limits

Playground

Use the following terminal to execute the commands.

Get hands-on with 1400+ tech skills courses.