The operator was created following the steps documented under the operator-sdk user-guide.
The steps specific to the wavefront operator are captured here:
-
Install the operator-sdk
-
Create a new wavefront-operator project:
$ cd $HOME/dev
$ operator-sdk new wavefront-operator --repo=github.com/wavefronthq/wavefront-operator
$ cd wavefront-operator
- Add a new CRD for the collector:
$ operator-sdk add api --api-version=wavefront.com/v1alpha1 --kind=WavefrontCollector
-
Manually modify the spec and status at
/pkg/apis/wavefront/v1alpha1/wavefrontcollector_types.go
Runoperator-sdk generate k8s
after modifying the spec and status. -
Run
operator-sdk generate openapi
to update the OpenAPIValidation section in the CRD. This updates the CRD based on latest spec / status mentioned in/pkg/apis/wavefront/v1alpha1/wavefrontcollector_types.go
-
Add a new controller for the collector
operator-sdk add controller --api-version=wavefront.com/v1alpha1 --kind=WavefrontCollector
Flesh out the controller logic as relevant to the CRD.
- Build the docker image:
operator-sdk build ${REPO_NAME}/wavefront-operator:latest
- Deploy the operator:
$ ka -f deploy/crds/wavefront_v1alpha1_wavefrontcollector_crd.yaml
$ ka -f deploy/service_account.yaml
$ ka -f deploy/role.yaml
$ ka -f deploy/role_binding.yaml
$ ka -f deploy/operator.yaml
- Now deploying a wavefrontcollector CR should create pods for the collector:
ka -f deploy/crds/wavefront_v1alpha1_wavefrontcollector_cr.yaml