Getting started with Operator SDK for Helm-based Operators
To demonstrate the basics of setting up and running an Helm-based Operator using tools and libraries provided by the Operator SDK, Operator developers can build an example Helm-based Operator for Nginx and deploy it to a cluster.
Logged into an OKD 4.7 cluster with
oc
with an account that hascluster-admin
permissionsTo allow the cluster pull the image, the repository where you push your image must be set as public, or you must configure an image pull secret.
You can build and deploy a simple Helm-based Operator for Nginx by using the Operator SDK.
Procedure
Create a project.
Change into the project directory:
Run the
operator-sdk init
command with thehelm
plug-in to initialize the project:--plugins=helm
Create an API.
Create a simple Nginx API:
This API uses the built-in Helm chart boilerplate from the
helm create
command.Build and push the Operator image.
Use the default
Makefile
targets to build and push your Operator. SetIMG
with a pull spec for your image that uses a registry you can push to:$ make docker-build docker-push IMG=<registry>/<user>/<image_name>:<tag>
Run the Operator.
-
Deploy the project to the cluster. Set
IMG
to the image that you pushed:
-
Create a sample custom resource (CR).
Create a sample CR:
$ oc apply -f config/samples/demo_v1_nginx.yaml \
Watch for the CR to reconcile the Operator:
Clean up.
Run the following command to clean up the resources that have been created as part of this procedure:
$ make undeploy
- See for a more in-depth walkthrough on building a Helm-based Operator.