Ansible role for docker & kubernetes on a Debian host
-
install
Will install docker and kubernetes. Do this to bootstrap all nodes.
-
init_kubernetes_master
Will initialize a kubernetes master. Only use when initially setting up a cluster.
-
generate_kubernetes_join_command
Run against master. Will copy a join command to local machine. Use join_kubernetes_cluster afterwards to join nodes to your kubernetes cluster.
-
join_kubernetes_cluster
Will use join command created by generate_kubernetes_join_command to join an existing kubernetes cluster.
-
init_single_node_cluster
May be used after init_kubernetes_master to create a single node cluster.
-
kubernetes_version
Install specific version of kubernetes. Show available versions:
curl -s https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages | grep Version | awk '{print $2}'
-
control_plane_endpoint
The kuberenetes api endpoint. This address is used by all nodes to communicate with the api. In a high availability cluster this is normaly set to a load balancer, which distribute incoming requests across all master nodes. In newer versions of kubernetes this may also be a DNS name. For a single node test cluster a possible value could be
localhost
for example.
Instead of using the playbook like shown below, you can also adapt the playbook. Check Ansible documentation.
Either install a single node
ansible-playbook playbook.yml -i <your-servers-dns-or-ip>, --tag install
or a bunch of nodes.
ansible-playbook playbook.yml -i <your-servers-dns-or-ip>,<your-servers-dns-or-ip>,<your-servers-dns-or-ip> --tag install
Instead of using the masters ip for kubernetes api queries, you should think about using a load balancer like suggested in the kubernetes documentation. This is especially relevent for multi-master clusters. Single node-clusters for development don't need this.
ansible-playbook playbook.yml -i <your-servers-dns-or-ip>, --tag init_kubernetes_master --extra-vars "control_plane_endpoint=<your-loadbalancer-or-dns>"
The control plane could also be a DNS name.
ansible-playbook playbook.yml -i <your-servers-dns-or-ip>, --tag install,init_kubernetes_master,init_single_node_cluster, --extra-vars "control_plane_endpoint=localhost"