Dev1ce
Dev1ce

Reputation: 5944

How to view the manifest file used to create a Kubenetes resource?

I have K8s deployed on an EC2 based cluster,
There is an application running in the deployment, and I am trying to figure out the manifest files that were used to create the resources,
There were deployment, service and ingress files used to create the App setup.

I tried the following command, but I'm not sure if it's the correct one as it's also returning a lot of unusual data like lastTransitionTime, lastUpdateTime and status-

kubectl get deployment -o yaml

What is the correct command to view the manifest yaml files of an existing deployed resource?

Upvotes: 1

Views: 12601

Answers (3)

John Karasev
John Karasev

Reputation: 331

KUBE_EDITOR="cat" kubectl edit secrets rook-ceph-mon -o yaml -n rook-ceph 2>/dev/null >user.yaml

Upvotes: -1

Tummala Dhanvi
Tummala Dhanvi

Reputation: 3380

You can try using the --export flag, but it is deprecated and may not work perfectly.

kubectl get deployment -o yaml --export

Refer: https://github.com/kubernetes/kubernetes/pull/73787

Upvotes: 2

coderanger
coderanger

Reputation: 54211

There is no specific way to do that. You should store your source files in source control like any other code. Think of it like decompiling, you can do it, but what you get back is not the same as what you put in. That said, check for the last-applied annotation, if you use kubectl apply that would have a JSON version of a more original-ish manifest, but again probably with some defaulted fields.

Upvotes: 3

Related Questions