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

4/27/2020

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?

-- Ani
kubernetes

2 Answers

4/27/2020

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.

-- coderanger
Source: StackOverflow

4/27/2020

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

-- Tummala Dhanvi
Source: StackOverflow