I am trying my hands on creating my own kubernetes operator by following this link. In the Reconcile function, I need to create multiple Deployments and each will vary in some attributes (like name for e.g.) and the configuration is huge. Instead of creating the deployment by using appsv1.Deployment and creating each attributes within it (like below code), is there a way wherein I can provide a yaml template file and read this file to obtain the appsv1.Deployment object?
dep := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: customName,
Namespace: m.Namespace,
},
Spec: appsv1.DeploymentSpec{
Strategy: appsv1.DeploymentStrategy{
Type: "RollingUpdate",
},
... and so on
Instead of above, can something like below possible with some handy util functions?
dep := utils.parseYaml(deploymentYamlFile)