Editing a kubernetes resource on the fly:

To be able to edit the configuration of a kubernetes resource  ( pods, services, ... ), we use the below command:


For pods for example, we will use the below command:


For a service for example, we will use the below command:


The above commands open a Yaml file of the resource in the editor mentioned in the environment variable "
KUBE_EDITOR".
We could then modify the resource and save the changes.

To change the default editor to "emacs" for example, we use the below command: 


Editing the Yaml configuration file "manually":

We have a pod named "nginx-pod" for example with the below Yaml file:


We create the pod using the below command:


Then we could edit the Yaml file directly using the below commands:


The above command "outputs" the Yaml configuration file of the "nginx-pod" to the "modified-pod.yaml" file.

After editing the Yaml file "modified-pod.yaml", we could apply the changes using the below command:


Brando Sabatini and Ikbal C ©. Powered by Blogger.