Due to the complex chains of dependencies on the Ansible k8s module, testing this container requires mocking up part of a full build.
While you can test with a full Docker Hub build and a complete site deploy, this can have a lot of turn around to solve individual issues. Instead, it's better to touch on the main components of a deploy.
To test:
- Build the container as normal.
- Open the
test-playbook.yml.example
file. - Run the container interactively.
- Using
vim
, copy the contents of the example playbook into the container. - Edit the new file, replacing the Digital Ocean API key, cluster name, and cluster namespace.
- Use
ansible-playbook
to deploy the contents. - If successful, delete the resulting secret,
auth-test-delete-later
in your kubernetes cluster in the provided namespace.
Even if the container builds successfully, that's not assurance that the above test will past. Python links libraries (modules) at runtime, meaning some errors aren't exposed until attempting to test.
To troubleshoot the container:
- Comment out the final
USER
statement in the Dockerfile. This will force the container to be built as root. - Repeat the testing procedure as stated above. It doesn't need root to operate, but it does give us full access to the container to install whatever we need.
- When the problem is found, update the Dockerfile. Uncomment the
USER
line. - Rebuild the container.
- Rerun the test.