-
Notifications
You must be signed in to change notification settings - Fork 198
/
Copy pathKubernetesInstallation.txt
executable file
·105 lines (63 loc) · 2.95 KB
/
KubernetesInstallation.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
For Amazon Linux 2 systems
Launch 2 amazon linux 2 machines
1 master and 1 slaves
On both master and slave nodes :
sudo su
yum install docker -y
systemctl enable docker && systemctl start docker
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
EOF
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
setenforce 0
### install kubelet, kubeadm and kubectl; start kubelet daemon
### Do it on both master as welll as worker nodes
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
systemctl enable kubelet && systemctl start kubelet
### On master node initialize the cluster
sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --ignore-preflight-errors=NumCPU
# sudo kubeadm init --pod-network-cidr=192.168.0.0/16 #Do this only if proper CPU cores are available
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=/etc/kubernetes/kubelet.conf
## On Worker nodes, Switch to the root mode
Copy kubeadm join command from output of "kubeadm init on master node"
<kubeadm join command copies from master node>
## Clone a repository to get YAML files for Calico networking
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
## For calico networking: apply on master node only
sudo kubectl apply -f etcd.yaml
sudo kubectl apply -f rbac.yaml
sudo kubectl apply -f calico.yaml
Take a pause of 2 minutes and see if the nodes are ready; run it on master node
kubectl get nodes
watch system pods
kubectl get pods --all-namespaces
on all the worker nodes do
mkdir -p $HOME/.kube
export KUBECONFIG=/etc/kubernetes/kubelet.conf
###############################################################################################################
Further references
Install ubuntu
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04
Install Kubernetes
https://linuxconfig.org/how-to-install-kubernetes-on-ubuntu-18-04-bionic-beaver-linux
Add - --ignore-preflight-errors=NumCPU to init
3.12.166.213 /172.31.7.109 - kmaster
52.14.195.98 /172.31.8.20 - kwroker1
3.15.17.173 /172.31.13.104 - kworker2
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
e.g. of join command
kubeadm join 172.31.7.109:6443 --token 2kw97g.1nwh56i5s67trju6 --discovery-token-ca-cert-hash sha256:a139c46d5228f7ab2c4ef08c52bee036d1ef2a873ac10a163073d503796fe23b