Kubectl finding yaml location

1/28/2019

So I know how to check the yaml file of my service and deployment which is

$ kubectl get service/helloworld -o yaml
$ kubectl get deployment/helloworld -o yaml

How do I find these files so I could edit them?

I am using minikube if that helps

-- edmamerto
kubernetes
minikube

2 Answers

1/28/2019

I would highly recommend you to change .yaml files and apply the resource again.

But if you want for some reason do that on the fly, you can go with:

$ kubectl edit service/helloworld -o yaml
$ kubectl edit deployment/helloworld -o yaml
-- Ivan Aracki
Source: StackOverflow

1/28/2019

Why would you want to modify YAML's on the fly? This is prone to errors. If you have any version control in place, you should use that in the first place and build and deploy the artifacts the usual way.

kubectl get deploy deploymentname -o yaml --export

can be used to see the YAML defn alternatively, you can see the file contents. Alternatively, you can also try...

for n in $(kubectl get -o=name pvc,configmap,serviceaccount,secret,ingress,service,deployment,statefulset,hpa,job,cronjob)
 do
   mkdir -p $(dirname $n)
   kubectl get -o=yaml --export $n > $n.yaml
 done
-- Raunak Jhawar
Source: StackOverflow