'Use go to read some seperate K8S YAML files (Deployment with 1 contianer in each pod) and combine to one deploy with pod contains all containers

I recently have to create a automation tool in Golang to handle some k8s tasks. One of them is to combine some Deployments definition in YAML file and manage all these seperated containers into one POD deploy. These legacy YAML defines Deployments is maintained by developers team so they should not be modified directly for some reason, thus my program needs to read them as template then do all the manipulation in runtime then deploy them use k8s apis(go-client maybe). I did some research and managed to parse YAML by using API

k8s.io/client-go/kubernetes/scheme => Codecs.UniversalDeserializer().Decode
k8s.io/apimachinery/pkg/util/yaml => NewYAMLOrJSONDecoder

But I'm kind of stuck from here. Any body might have done such before? What kind of API I should look at?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source