The source code for the operator is stored in the
$ cd $GOPATH/src/wordpress $ ls
The folder contains all the files required to run an operator like the configurations, API files, controllers, reconciliation files, main files, etc. All these files contain information about the operator and it's runtime characteristics, such as the CRUD logic, reconciliation frequency, etc. These files can be classified in four sections:
Controllers and Reconciler.
CRAFT creates these files when you create an operator. This saves you a few weeks of effort to write and connect your operator.
These files are used to build the operator:
- go.mod : A Go module for the project that lists all the dependencies.
- Makefile : File makes targets for building and deploying the controller and reconciler.
- PROJECT : Kubebuilder metadata for scaffolding new components.
- DockerFile : File with instructions on running the operator. Specifies the docker entrypoint for the operator.
The launch configurations are in the config/ directory. It holds the CustomResourceDefinitions, RBAC configuration, and WebhookConfigurations. Each folder in config/ contains a refactored part of the launch configuration.
config/defaultcontains a Kustomize base for launching the controller with standard configurations.
config/managercan be used to launch controllers as pods in the cluster
config/rbaccontains permissions required to run your controllers under their own service account.
The basic entry point for the operator is in the main.go file. This file can be used to:
- Set up flags for metrics.
- Initialise all the controller parameters, including the reconciliation frequency and the parameters we received from controller.json and resource.json
- Instantiate a manager to keep track of all the running controllers and clients to the API server.
- Run a manager that runs all of the controllers and keeps track of them until it receives a shutdown signal when it stops all of the controllers.