简体   繁体   English

Kubectl找到yaml位置

[英]Kubectl finding yaml location

So I know how to check the yaml file of my service and deployment which is 所以我知道如何检查我的服务和部署的yaml文件

$ 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 如果有帮助,我正在使用minikube

I would highly recommend you to change .yaml files and apply the resource again. 强烈建议您更改.yaml文件并再次应用该资源。

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

Why would you want to modify YAML's on the fly? 你为什么要动态修改YAML? 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. 可以用来查看YAML defn,你可以看到文件内容。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM