2.3 KiB
Tower Operator
An Ansible Tower operator for Kubernetes built with Operator SDK and Ansible.
Testing
This Operator includes a Molecule-based test environment, which can be executed standalone in Docker (e.g. in CI or in a single Docker container anywhere), or inside any kind of Kubernetes cluster (e.g. Minikube).
You need to make sure you have Molecule installed before running the following commands. You can install Molecule with:
pip install 'molecule[docker]
Running molecule test sets up a clean environment, builds the operator, runs all configured tests on an example operator instance, then tears down the environment (at least in the case of Docker).
If you want to actively develop the operator, use molecule converge, which does everything but tear down the environment at the end.
Testing in Docker (standalone)
molecule test -s test-local
This environment is meant for headless testing (e.g. in a CI environment, or when making smaller changes which don't need to be verified through a web interface). It is difficult to test things like Tower's web UI or to connect other applications on your local machine to the services running inside the cluster, since it is inside a Docker container with no static IP address.
Testing in Minikube
minikube start --memory 6g --cpus 2
minikube addons enable ingress
molecule test -s test-minikube
Minikube is a more full-featured test environment running inside a full VM on your computer, with an assigned IP address. This makes it easier to test things like NodePort services and Ingress from outside the Kubernetes cluster (e.g. in a browser on your computer).
Once the operator is deployed, you can visit the Tower UI in your browser by following these steps:
- Make sure you have an entry like
IP_ADDRESS example-tower.testin your/etc/hostsfile. (Get the IP address withminikube ip.) - Visit
http://example-tower.test/in your browser.