The Operator SDK project is a really cool framework to help you build Kubernetes operators. I’ve been really intrigued about the Ansible style operators as they seem to offer a great deal of convenience.
When developing and debugging operators it is really useful to be able to run them locally without needing to install an image in a registry somewhere. I’ve been trying to get an ansible based operator working with the operator-sdk in local mode and struggling with the upstream instructions.
This is what finally worked for me in Fedora 30 after:
- make sure ansible is installed
- install the following packages through
python3-ansible-runner python3-psutil python3-openshift
- install the http runner for ansible with the following command:
pip3 install --user ansible-runner-http
- make a symbolic link for
/usr/bin/python3. i still don’t understand this one, but for some reason when i run the ansible operator it tries to run python2 even though it knows where the python3 binary is located.
- you will most likely need to have a
cluster-adminrole if you are running on OpenShift
After all this I was able to run
operator-sdk up local and my operator was
running fine. Now on to the debugging ;)
Update 31 July 2019
One more thing to keep in mind when you are running local operators. The
watches.yaml file will be set to look for things in
/opt/ansible/, so I
needed to make a symlink from
/opt/ansible to the root of my project
directory. You could also just change the watches file.