
Kubespray – Kubernetes Cluster Setup - rahulwagh17
https://jhooq.com/kubespray-12-steps-for-installing-a-production-ready-kubernetes-cluster/
======
rahulwagh17
Step 1. Setup vagrant

Step 2: Update /etc/hosts on all the nodes vagrant@amaster:~$ sudo vi
/etc/hosts 100.0.0.1 amaster.jhooq.com amaster 100.0.0.2 kmaster.jhooq.com
kmaster 100.0.0.3 kworker.jhooq.com kworker

Step 3: Generate SSH key for ansible vagrant@amaster:~$ ssh-keygen -t rsa

Step 4: Copy SSH key to other nodes vagrant@amaster:~$ ssh-copy-id 100.0.0.2
vagrant@amaster:~$ ssh-copy-id 100.0.0.3

Step 5: Install python3-pip vagrant@amaster:~$ sudo apt install python3-pip

Step 6: Clone the kubespray git repo vagrant@amaster:~$ git clone
[https://github.com/kubernetes-
sigs/kubespray.git](https://github.com/kubernetes-sigs/kubespray.git)

Step 7: Install kubespray package vagrant@amaster:~/kubespray$ sudo pip3
install -r requirements.txt

Step 8: Copy inventory file to current users vagrant@amaster:~/kubespray$ cp
-rfp inventory/sample inventory/mycluster

Step 9: Prepare host.yml for kubespray vagrant@amaster:~/kubespray$ declare -a
IPS=(100.0.0.2 100.0.0.3)

vagrant@amaster:~/kubespray$ CONFIG_FILE=inventory/mycluster/hosts.yml python3
contrib/inventory_builder/inventory.py ${IPS[@]}

Step 10: Run the ansible-playbook on ansible node ansible-playbook -i
inventory/mycluster/hosts.yml --become --become-user=root cluster.yml

Step 11: Install kubectl on kubernetes master vagrant@node1:~$ curl -LO
[https://storage.googleapis.com/kubernetes-
release/release/`c...](https://storage.googleapis.com/kubernetes-
release/release/`curl) -s [https://storage.googleapis.com/kubernetes-
release/release/st...](https://storage.googleapis.com/kubernetes-
release/release/stable.txt`/bin/linux/amd64/kubectl)

vagrant@node1:~$ sudo cp /etc/kubernetes/admin.conf /home/vagrant/config
vagrant@node1:~$ mkdir .kube vagrant@node1:~$ mv config .kube/
vagrant@node1:~$ sudo chown $(id -u):$(id -g ) $HOME/.kube/config

Step 12: Verify the kubernetes nodes vagrant@node1:~$ kubectl get nodes NAME
STATUS ROLES AGE VERSION node1 Ready master 13m v1.18.2 node2 Ready master 13m
v1.18.2

