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.
version v2.9.0+
Ansible Runner version v1.1.0+
version v1.0.0+
OpenShift Python client version v0.11.2+
Logged into an OKD 4.8 cluster with
oc
with an account that hascluster-admin
permissions
You can build and deploy a simple Ansible-based Operator for Memcached by using the Operator SDK.
Procedure
Create an API.
Create a simple Memcached API:
-
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/cache_v1_memcached.yaml \
-n memcached-operator-system
Watch for the CR to reconcile the Operator:
$ oc logs deployment.apps/memcached-operator-controller-manager \
-c manager \
Example output
-
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.