Editing Kubernetes Pods and Deployments: A Practical Guide

Jiadong Chen
2 min read5 days ago

As a Kubernetes administrator or developer, you’ll often need to modify your running workloads. However, there are some important limitations and best practices you should be aware of. In this guide, we’ll explore the ins and outs of editing Pods and Deployments in Kubernetes.

Pod Editing: Understanding the Limitations

First, let’s address a crucial point: Pods have strict limitations on what can be edited after creation. You can only modify the following specifications in an existing Pod:

  • spec.containers[*].image
  • spec.initContainers[*].image
  • spec.activeDeadlineSeconds
  • spec.tolerations

This means you cannot directly edit things like environment variables, service accounts, or resource limits in a running Pod. However, don’t worry — there are workarounds!

Two Approaches to Pod Modification

Method 1: The Edit-and-Recreate Approach

  1. First, attempt to edit the Pod directly:
kubectl edit pod <pod name>

This opens the Pod specification in the vi editor. When you try to save changes to non-editable…

--

--

Jiadong Chen

Microsoft MVP, MCT | Azure Certified Solutions Architect & Cybersecurity Architect Expert | Member of .NET Foundation | Packt Author