- Access to a supported version of an Openshift cluster
- Red Hat OpenShift Local can be used if the monitoring stack is enabled.
- A cluster can also be provisioned here
- A clone of koku-metrics-operator
- Go 1.13 or greater
- Openshift-CLI (preferably a version that matches your Openshift cluster version)
- kubebuilder
- kubectl
- kustomize (before installing this separately, check that it was not already installed along with kubectl)
- Docker Desktop
- quay.io account
-
Log into your OCP cluster from a terminal, create an
koku-metrics-operator
namespace, and switch to the new namespace:$ oc login --token=<token> --server=<server> $ oc new-project koku-metrics-operator
-
Build the manager binary:
$ make build
-
Register the CRD with the Kubernetes apiserver:
$ make install
-
Deploy the ServiceAccount:
$ oc apply -f testing/sa.yaml
-
The
token
andservice-ca.crt
need to be copied from one of the createdkoku-metrics-manager-role-token-*
secrets. A make command exists to help:$ make get-token-and-cert
This will place the token
and service-ca.crt
in the testing
directory. To place these files somewhere else, you can also use the command like this:
```
$ SECRET_ABSPATH=/absolute/path/to/local/secrets make get-token-and-cert
```
-
Deploy the operator
make run ENABLE_WEBHOOKS=false SECRET_ABSPATH=/absolute/path/to/local/secrets
At this point, you will see the operator spin up in your terminal. After a few seconds, you should see something similar to the following output:
2020-10-21T09:31:37.195-0400 INFO controller-runtime.controller Starting workers {"controller": "kokumetricsconfig", "worker count": 1}
The operator is running but is not doing any work. We need to create a CR.
-
Deploy a CR. For local development, use basic authentication. The following creates the appropriate authentication spec within the CR.
username
andpassword
correspond to the username (not email address) and password for the account you want to use at console.redhat.com:$ make deploy-local-cr AUTH=basic USER=<username> PASS=<password>
This command uses the CR defined in
config/samples/koku-metrics-cfg_v1beta1_kokumetricsconfig.yaml
, adds an external prometheus route, disables TLS verification for the prometheus route, adds the authentication spec, and creates a CR intesting/koku-metrics-cfg_v1beta1_kokumetricsconfig.yaml
. The command then deploys this CR to the cluster.After this CR has been created in the cluster, reconciliation will begin.
Running
make deploy-local-cr
as-is will create the external prometheus route, disable TLS verification for prometheus, and use token authentication for console.redhat.com. -
To continue development, make code changes. To apply those changes, stop the operator, and redeploy it. If changes are made to the api, the CRD needs to be re-registered, and the operator re-deployed.