Provisioning a Kubernetes cluster using an Ansible playbook

In order to provision a Kubernetes cluster using an Ansible playbook, follow these steps: 

  1. Edit the hosts.ini file and replace the master and node IP addresses with your node IPs where you want Kubernetes to be configured:
$ cd src/chapter1/ansible/ && vim hosts.ini
  1. The hosts.ini file should look as follows:
[master]
192.168.1.10
[node]
192.168.1.[11:13]
[kube-cluster:children]
master
node
  1. Edit the groups_vars/all.yml file to customize your configuration. The following is an example of how to do this:
kube_version: v1.14.0
token: b0f7b8.8d1767876297d85c
init_opts: ""
kubeadm_opts: ""
service_cidr: "10.96.0.0/12"
pod_network_cidr: "10.244.0.0/16"
calico_etcd_service: "10.96.232.136"
network: calico
network_interface: ""
enable_dashboard: yes
insecure_registries: []
systemd_dir: /lib/systemd/system
system_env_dir: /etc/sysconfig
network_dir: /etc/kubernetes/network
kubeadmin_config: /etc/kubernetes/admin.conf
kube_addon_dir: /etc/kubernetes/addon
  1. Run the site.yaml playbook to create your cluster:
$ ansible-playbook site.yaml

Your cluster will be deployed based on your configuration.