Working with other required resources
Besides the CRD, our Operator will be responsible for managing a number of other cluster resources as well. Right now, this is the nginx Deployment that will be created as our Operand, as well as a ServiceAccount, Role, and RoleBinding for the Operator. What we need to understand is how the Operator will know the definition of those resources.
Somewhere, the resources need to be written as Kubernetes cluster objects. Just as you would create a Deployment by hand (for example, with kubectl create -f
), the definitions of necessary resources can be packaged with the Operator code in a couple of different ways. This can be done easily with templates if you are creating your Operator with Helm or Ansible, but for Operators written in Go, we need to consider our options.
One way to package these resources so that the Operator can create them is by defining them directly in the Operator's code. All Kubernetes objects are based on corresponding...