In order to contribute on the nsm operator project make sure you have the minimal software requirements below:
-
GNU make (https://www.gnu.org/software/make/)
-
access to a Kubernetes 1.21+ cluster (for development it can be minikube or kind)
-
have both clients kubectl and oc
NOTE: the environment for Kubernetes or OpenShift need to be setup beforehand. It means that a kubeconfig file and/or proper cluster admin credentials must be in place and the Kubeapi-server endpoint must be accessible through the network. The projects make targets and commands will use that connection to communicate with the api, deploy and run all the resources.
This source code can be run basically in two ways:
1 - Running make run
, which executes go run behind the scenes and will rely on logs and error messages for debugging. With that the operator will run from the developer's machine and communicate externally with the Kubeapi-server endpoint.
2- By using the debug and run from VSCode. With the main.go file in focus you can hit F5 and trigger the VSCode debugger that has other features such as breakpoints and variable watches. For that you will need the golang extension installed in your environment. We do recommend to use VSCode but it's not mandatory. Any golang environment should work just fine. Check the VSCode debug page for more information.
First in the make file we need to setup two variables according to the needs:
IMG
- for the registry where the operator image will be stored. It needs to have all the path in the string plus the tag.
BUILDER
- is the container builder that can be podman or docker.
The project has a few make targets available for building:
make build
- Will generate a binary file under a bin directory with the controller, manager and all the added reconcilers and types involved. That's the operator itself.
make container-build
- Will generate the container image that runs the operator inside the cluster as a platform component.
make container-push
- Will push the operator
With the container image available in a registry and that registry edited in the makefile the make deploy
command can be run in order to deploy that container with all the necessary manifests to the cluster. From that point you should have your dev version running on a pod in the nsm namespace. Then follow the example on the README file to test with the other resources.