Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
244 views
in Technique[技术] by (71.8m points)

kubernetes - K8s get back my yaml files from running cluster

Okay first let me say please don't judge. Believe me, I am kicking myself in the ass.

So I lost my hard disk on my laptop which held the Kubernetes yaml files that I ran against a Kubernetes Cloud cluster. I don't have the latest backup which is the problem.

does anyone know how to get just the yaml I ran against the K8s cloud server. I can get to the cluster and run kubectl get pod my-pod -o yaml but of course, it adds a lot of things. I am just looking for the yaml that I ran.

I am stressing here and have learned my lesson. Backup, Backup and verify Backup.

question from:https://stackoverflow.com/questions/65889833/k8s-get-back-my-yaml-files-from-running-cluster

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use this and extend it to your needs:

kubectl get [resource type] -n [namespace] [resource Name] -o yaml > [output.yaml]

The -o yaml will do the job

enter image description here

Note

You will get some extra information provided by your cloud providers like history, version, and more.


Lens

https://k8slens.dev/

You can use Lens which will allow you to view & edit your resources so you will be able to copy the YAML from it.enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...