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.

    • OpenShift CLI () v4.7+ installed

    • Logged into an OKD 4.7 cluster with oc with an account that has cluster-admin permissions

    • To 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

    1. Create a project.

      1. Change into the project directory:

        1. Run the operator-sdk init command with the helm plug-in to initialize the project:

          1. --plugins=helm
      2. Create an API.

        Create a simple Nginx API:

        This API uses the built-in Helm chart boilerplate from the helm create command.

      3. Build and push the Operator image.

        Use the default Makefile targets to build and push your Operator. Set IMG with a pull spec for your image that uses a registry you can push to:

        1. $ make docker-build docker-push IMG=<registry>/<user>/<image_name>:<tag>
      4. Run the Operator.

        1. Deploy the project to the cluster. Set IMG to the image that you pushed:

      5. Create a sample custom resource (CR).

        1. Create a sample CR:

          1. $ oc apply -f config/samples/demo_v1_nginx.yaml \
        2. Watch for the CR to reconcile the Operator:

      6. Clean up.

        Run the following command to clean up the resources that have been created as part of this procedure:

        1. $ make undeploy
      • See for a more in-depth walkthrough on building a Helm-based Operator.