-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster1-setup.sh
86 lines (62 loc) · 3.65 KB
/
cluster1-setup.sh
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
#!/bin/bash
####### This section must be run only on the Master node#########################################################################################
#Initialize the cluster
sudo kubeadm init
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
#*******************************************************************************************************************************************************
#************************************************************Join worker nodes***************************************************************************
#sudo kubeadm join
#**************************************************************
#*********************************************************Install Cilium********************************************************************
#Install cilium
curl -L --remote-name-all https://github.com/cilium/cilium-cli/releases/latest/download/cilium-linux-amd64.tar.gz{,.sha256sum}
sha256sum --check cilium-linux-amd64.tar.gz.sha256sum
sudo tar xzvfC cilium-linux-amd64.tar.gz /usr/local/bin
rm cilium-linux-amd64.tar.gz{,.sha256sum}
#Setup Helm repository
helm repo add cilium https://helm.cilium.io/
#helm uninstall cilium -n kube-system #To uninstall cilium
#*******************************************************************************************************************************************************
#*********************************************************Add cluster contexts**********************************************************
# Edit $HOME/.kube/config to add both clusters information as in the example config file
sudo kubectl config --kubeconfig=config set-context cluster1-cntx --cluster=cluster1 --user=cluster1-admin
#To switch cluster context
kubectl config --kubeconfig=config use-context cluster1-cntx
sudo kubectl config get-contexts
export KUBECONFIG=~/.kube/config
#Make sure there are no spaces after "\" on each line!
#This topped working
helm install cilium cilium/cilium --version 1.11.2 \
--namespace kube-system \
--set cluster.name=cluster1 \
--set cluster.id=1 \
--set ipam.operator.clusterPoolIPv4PodCIDR="172.0.0.0/16"
#****************************************************************Verify Cluster Installation and install "Hubble"******************************************
#Veriy thal all PODS and nodes are ready. You may need to reboot if things are not healthy after a few minutes.
kubectl -n kube-system get pods -l k8s-app=cilium -o wide
kubectl get pods -n kube-system -o wide
kubectl get nodes -o wide
#Validate that Cilium installation
cilium status --wait
#***If cilium and cluster is healty, enable "Hubble"
#Enable hubble. Make sure there are no spaces after "\"
helm upgrade cilium cilium/cilium --version 1.11.2 \
--namespace kube-system \
--reuse-values \
--set hubble.relay.enabled=true \
--set hubble.enabled=true
kubectl get secret -n kube-system -o wide | grep cilium-ca
cilium hubble enable --create-ca
kubectl get secret -n kube-system -o wide | grep cilium-ca
#In order to access the observability data collected by Hubble, install the Hubble CL
export HUBBLE_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/hubble/master/stable.txt)
curl -L --remote-name-all https://github.com/cilium/hubble/releases/download/$HUBBLE_VERSION/hubble-linux-amd64.tar.gz{,.sha256sum}
sha256sum --check hubble-linux-amd64.tar.gz.sha256sum
sudo tar xzvfC hubble-linux-amd64.tar.gz /usr/local/bin
rm hubble-linux-amd64.tar.gz{,.sha256sum}
#In order to access the Hubble API, create a port forward to the Hubble service from your local machine
cilium hubble port-forward&
hubble status
hubble observe