H is for Harre.

harre.dev

Today-I-Learned

Today I learned - kubectl replace

Here’s one for your toolbox, but use with care. Say you have an app running on kubernetes in a pod and you spot something you want to change. This is one way to get it done.

For the example, I spun up an nginx server called webapp.

The command to edit a resource running on kubernetes is kubectl edit <thing> <name>. So here goes:

kubectl edit pod webapp

You’ll see a whole bunch of yaml that represents the pods definition. In what editor will depend on what you’ve set as your default editor for any kubectl related business. (See: KUBE_EDITOR environment variable).