Build a Kubernetes cluster using Vagrant, Ansible with kubeadm.
System requirements:
- Deployment environment must have Ansible
2.4.0+ - Master and nodes must have passwordless SSH access
Add the system information gathered above into a file called hosts.ini. For example:
[master]
10.10.10.11
[node]
10.10.10.[12:13]
[kube-cluster:children]
master
node
Before continuing, edit group_vars/all.yml to your specified configuration.
For example, I choose to run flannel instead of calico, and thus:
# Network implementation('flannel', 'calico')
network: flannelNote: Depending on your setup, you may need to modify cni_opts to an available network interface. By default, kubeadm-ansible uses eth1. Your default interface may be eth0.
After going through the setup, run the site.yaml playbook:
$ ansible-playbook site.yamlDownload the admin.conf from the master node:
$ scp k8s@k8s-master:/etc/kubernetes/admin.conf .Verify cluster is fully running using kubectl:
$ export KUBECONFIG=~/admin.conf
$ kubectl get node
NAME STATUS AGE VERSION
k8s-master1 Ready 22m v1.6.3
k8s-node1 Ready 20m v1.6.3
k8s-node2 Ready 20m v1.6.3
$ kubectl get po -n kube-system
NAME READY STATUS RESTARTS AGE
etcd-k8s-master1 1/1 Running 0 23m
...Finally, reset all kubeadm installed state using reset-site.yaml playbook:
$ ansible-playbook reset-site.yaml