Ansible playbook to install a Kubernetes cluster
The Ansible Kubernetes Playbook is an early version to install HA Kubernetes cluster in the following operating systems.
Note: Currently the playbook can only install a single master Kuberentes cluster on Red Hat Linux, Red Hat CentOS Linux machines, Ubuntu and Debian it is in progress for the Windows Operating Systems.
To run the playbook, the following are the prerequisites before even we run the playbook,
Follow the below steps to set up and configure the environment to run the installation playbook,
To configure the hosts in the playbook, clone the Ansible Kubernetes Playbook repository.
Once the servers are provisioned, add the following information in the hosts file,
[masternodes]
master.hostname/IP
[workernodes]
worker1.hostname/IP
worker2.hostname/IP
After the Hosts Configuration, add the following in the hosts file to run playbook with a specific user,
Ansible Kubernetes Playbook can configure Kubernetes CNI plugin with either Flannel, Calico or Canal in the hosts file,CNI_network_type= flannel|calico|canal
Flannel is a straightforward plugin that configures a layer 3 IPv4 overlay network. Flannel uses Docker bridge for the Pods to communicate within the same host, while pods on different hosts communicate using flanneld with a default VXLAN by encapsulating the traffic in UDP packets to route to the appropriate destination.
Calico is most flexible and popular Kubernetes CNI plugin that configures a layer 3 network that uses the BGP(border gateway protocol) routing protocol to route packets between hosts by eliminating an extra layer of encapsulation. Calico is more easy for conventional debugging standard debugging tools when there is a network problem. Calico can also integrate with a service mesh like, Istio to provide extra security and control over the network policy.
Canal is a mix of Calico and Flannel, which means Canal configures a layer 3 IPv4 overlay network from Flannel and the network policy capabilities layered from Calico, which is also the right way for teams to experiment.
Once all the configurations are in the right place, run the following command to install Kubernetes,
ansible-playbook main.yml
Keeping time constraint in mind while retrying the playbook, add the --skip-tags=common-tasks
to skip the tasks of the common packages.
Sit back and relax for the playbook to finish with no errors !!!
Note: This playbook is tested on Red Hat Linux, CentOS Linux servers, Ubuntu and Debian Operating Systems.