Getting started with Operator SDK for Ansible-based Operators

    To demonstrate the basics of setting up and running an Ansible-based Operator using tools and libraries provided by the Operator SDK, Operator developers can build an example Ansible-based Operator for Memcached, a distributed key-value store, and deploy it to a cluster.

    You can build and deploy a simple Ansible-based Operator for Memcached by using the Operator SDK.

    Procedure

    1. Create an API.

      Create a simple Memcached API:

    2. 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>
    3. Run the Operator.

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

    4. Create a sample custom resource (CR).

      1. Create a sample CR:

        1. $ oc apply -f config/samples/cache_v1_memcached.yaml \
        2. -n memcached-operator-system
      2. Watch for the CR to reconcile the Operator:

        1. $ oc logs deployment.apps/memcached-operator-controller-manager \
        2. -c manager \

        Example output

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

      • See for a more in-depth walkthrough on building an Ansible-based Operator.