-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk8s-cluster-up.sh
More file actions
70 lines (54 loc) · 2.85 KB
/
k8s-cluster-up.sh
File metadata and controls
70 lines (54 loc) · 2.85 KB
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
#! /bin/bash
export guser=vagrant
sudo chmod 666 /var/run/docker.sock
sudo chmod 644 /etc/kubernetes/admin.conf
kubectl drain master --delete-emptydir-data --force --ignore-daemonsets && echo
sudo kubeadm reset -f && echo
# //reset CNI
sudo rm -rf /etc/cni/net.d
# //reset iptables
# //sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X
# //reset your system's IPVS tables
sudo apt install ipvsadm network-manager -y && echo
# sudo ipvsadm -C
sudo kubeadm init --pod-network-cidr=192.168.0.0/16 && echo
# sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --cri-socket=unix:///var/run/containerd/containerd.sock && echo
# //Follow above if use cri-dockerd
# sudo kubeadm init && echo
sudo chmod 666 /var/run/docker.sock
sudo chmod 644 /etc/kubernetes/admin.conf
# //Open Calico addon N/w Req Port.on M/w node
# sudo ufw allow 179/tcp (skip it)
# kubectl apply -f /home/$guser/calico.yaml && echo
# kubectl apply -f /home/$guser/tigera-operator.yaml && echo && kubectl apply -f /home/$guser/custom-resources.yaml && echo
# //For Weave-Net N/w addon port
# sudo ufw allow 6783/tcp && sudo ufw allow 6783,6784/udp && echo (skip it)
kubectl apply -f /home/$guser/weave-daemonset-k8s.yaml && echo
watch kubectl get ns,deploy,po,svc,ing,ep,sc -A -o wide && echo
# //Uncomment to test nginc Ex on master
# kubectl describe nodes master | grep -i taint && echo
# kubectl taint node master node-role.kubernetes.io/control-plane:NoSchedule- && echo
# kubectl describe nodes master | grep -i taint && echo
watch kubectl get deploy,po,svc -A -o wide && echo
kubectl apply -f /home/$guser/*/nginx-master.yml -f /home/$guser/*/env-config.yml -f /home/$guser/*/host-pv-pvc.yml && echo
watch kubectl get deploy,po,svc -A -o wide && echo
# //Set-up K8s dashboard
# kubectl describe nodes master | grep -i taint && echo
# kubectl taint node master node-role.kubernetes.io/control-plane:NoSchedule- && echo
# kubectl describe nodes master | grep -i taint && echo
kubectl apply -f /home/$guser/*/dashboard-recommended.yaml -f /home/$guser/*/dashboard-adminuser.yaml && echo
kubectl get svc -n kubernetes-dashboard kubernetes-dashboard && echo
kubectl edit svc -n kubernetes-dashboard kubernetes-dashboard && echo
# //as: NP/LB
kubectl taint node master node-role.kubernetes.io/control-plane:NoSchedule && echo
kubectl describe nodes master | grep -i taint && echo
# //Now we need to find the token we can use to log in. as:
kubectl -n kubernetes-dashboard create token admin-user >/home/$guser/k8s-bootstrap/dashboard-user.token && echo
kubectl get svc -A && echo
cat /home/$guser/k8s-bootstrap/dashboard-user.token && echo
# //using below we get hash of existing active tocken
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null |
openssl dgst -sha256 -hex | sed 's/^.* //'
echo
nmcli device
# //sudo systemctl reboot // manditory