Last active
December 3, 2023 19:46
-
-
Save random-robbie/0d8c929f9dccc13351123fd18fbc28a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Disable swap | |
sudo swapoff -a | |
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab | |
# Update system | |
sudo apt update && sudo apt upgrade -y | |
# Install dependencies | |
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common | |
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf | |
overlay | |
br_netfilter | |
EOF | |
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf | |
net.bridge.bridge-nf-call-iptables = 1 | |
net.bridge.bridge-nf-call-ip6tables = 1 | |
net.ipv4.ip_forward = 1 | |
EOF | |
sudo sysctl --system | |
sudo modprobe overlay | |
sudo modprobe br_netfilter | |
# Add Docker's official GPG key | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
# Add Docker repository | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
# Update the package database with the Docker packages from the newly added repo | |
sudo apt update | |
# Install Docker from the official Docker repository | |
sudo apt install -y containerd.io | |
sudo mkdir -p /etc/containerd | |
sudo containerd config default | sudo tee /etc/containerd/config.toml | |
sudo sed -i 's/ SystemdCgroup = false/ SystemdCgroup = true/' /etc/containerd/config.toml | |
sudo systemctl restart containerd | |
# Start and enable Docker service | |
sudo systemctl start docker | |
sudo systemctl enable docker | |
# Install kubeadm, kubelet, and kubectl | |
sudo apt update | |
sudo apt install -y kubelet kubeadm kubectl | |
sudo apt-mark hold kubelet kubeadm kubectl | |
# Initialize the cluster | |
sudo kubeadm config images pull | |
sudo kubeadm init --control-plane-endpoint=k8s-master.k8s.lan --pod-network-cidr=192.168.0.0/16 | |
# Set up kubeconfig for the current user | |
mkdir -p $HOME/.kube | |
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
sudo chown $(id -u):$(id -g) $HOME/.kube/config | |
# Install a pod network add-on (Calico in this example) | |
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml | |
# Install Helm | |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | |
chmod 700 get_helm.sh | |
./get_helm.sh | |
# Install etcd using Helm | |
helm repo add bitnami https://charts.bitnami.com/bitnami | |
kubectl create ns etcd | |
helm install etcd bitnami/etcd -n etcd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment