Skip to content

Instantly share code, notes, and snippets.

@mumoshu
Forked from h3poteto/setup.sh
Last active August 22, 2022 09:58
Show Gist options
  • Save mumoshu/1e497707f0dc31576e213b2ca1e52d97 to your computer and use it in GitHub Desktop.
Save mumoshu/1e497707f0dc31576e213b2ca1e52d97 to your computer and use it in GitHub Desktop.
Setup Kubernetes using kubeadm. In case you provided a wrong control-plane node address, run `sudo kubeadm reset` and try again.
#!/bin/bash
set -e
if [ $# -ne 1 ]; then
echo "controle-plane-endpoint is required" 1>&2
exit 1
fi
CONTROLE_PLANE_ENDPOINT=$1
set -x
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo rm /etc/containerd/config.toml || :
sudo systemctl restart containerd
sudo kubeadm init --control-plane-endpoint $CONTROLE_PLANE_ENDPOINT
mkdir -p ~/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
curl https://get.helm.sh/helm-v3.9.1-linux-amd64.tar.gz -o helm.tar.gz
tar -xvf helm.tar.gz
sudo mv linux-amd64/helm /usr/local/bin/helm
helm repo add cilium https://helm.cilium.io/
helm install cilium cilium/cilium --version 1.12.0 --namespace kube-system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment