I'm new with both Python and YAML (great with Javascript and JSON) and I need to construct a subset of a YAML file. In particular, I want to generate a .yaml file that can be used to create a new deployment in openshift/kubernetes, gleaning the needed information from running pods/deployments. The YAML file will have separate sections for PVCs, Service, and Deployment.
I need to eliminate things like status, and a lot of the metadata that is generated when new pvcs, services, and deployments are created. The steps I want to use are:
It seems like an easy thing to do, but with my scarce experience with both Python and YAML, I can't seem to get it right. I can't even traverse all of the nodes of the YAML document and print out the qualified node names.
Edit: I know which oc/kubectl commands I need to get the YAML I need, I just need some help on taking only certain sections from those files and generating a new document by inserting those extracted sections,
Does your python script run on environment that has kubectl? You can try to create python script which does things like -
P.S. These ideas might make things simple.