Search code examples
kubernetesyamlkubectl

find which yaml file was used for the any kubernetes resource?


How to find, that which yaml file was used for the deployment of any kubernetes resource.

I checked "kubectl describe", it doesn't list the same, is there anyway to know.

use case:

I want to update the yaml and redeploy, one option, I guess is to generate the yaml from running resource, update and redeploy.

any suggestions ?


Solution

  • To get yaml for your k8s application deployment.

    Use this

    kubectl get deploy my-deployment -o yaml --export
     OR
    kubectl get pod my-pod -o yaml --export
     OR
    kubectl get svc my-svc -o yaml --export
    

    Editing is also simple.

    kubectl get deploy my-deployment -o yaml --export > my-deployment.yml
    <Edit the my-deployment.yml file and kubectl apply -f my-deployment.yml>
    
    OR 
    
    kubectl edit deployment my-deployment
    

    Hope this helps.