This is an ansible playbook that deploys docker and a single-node kubernetes cluster on a remote host and deploys and smaple application on it.
For the roles we use the ones from user geerlingguy from github:
dockerrole: https://github.com/geerlingguy/ansible-role-docker.gitkubernetesrole: https://github.com/geerlingguy/ansible-role-kubernetes.git
The custom role (deploy role) does the following:
- Installs the python dependencies for
k8sanddocker_imageansible modules - Pulls the code from github and build a docker image
- Deploys the pods on kubernetes as a replica set of 2
- deploys a service with the nodeport configuration (uses round-robin load balancing by default)
The app is accessible via http://YOUR_SERVER_IP:30080
To run the playbook, get the code:
git clone https://github.com/ravenolf/soramitsu-test-ansible --recursive
cd soramitsu-test-ansibleAdd the private key as keys/id_ansible_rsa or remove this line from ansible.cfg if you want to use your host private key:
private_key_file = keys/id_rsa_ansibleChange the host on hosts.ini.
Run the playbook:
ansible-playbook main.ymlVariables can be changed in main.yml