Skip to content

Commit

Permalink
fix k8s setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
mhewedy committed May 25, 2020
1 parent b458c95 commit 2b96fc9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
25 changes: 16 additions & 9 deletions etc/samples-provision/k8s/master.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# HW requirements: 2 CPUS 2 RAM
# OS: Ubuntu focal

#should change to $(lsb_release -cs) but it appears it is not working on focal yet
docker_ubuntu_release=bionic
k8s_version=1.18.0

# Set hostname and disable swap
sudo hostnamectl set-hostname "$(hostname -I | awk '{print $1}')"
sudo swapoff -a && sudo sed -i '/ swap / s/^/#/' /etc/fstab
Expand All @@ -20,27 +24,30 @@ sudo netplan apply
############# start k8s installation

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$docker_ubuntu_release \
stable"
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

sudo apt-get update -y
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu kubelet=1.13.5-00 kubeadm=1.13.5-00 kubectl=1.13.5-00
sudo apt-get update
sudo apt-get install -y \
containerd.io=1.2.13-1 \
docker-ce=5:19.03.8~3-0~ubuntu-$docker_ubuntu_release \
docker-ce-cli=5:19.03.8~3-0~ubuntu-$docker_ubuntu_release
sudo apt-get install -y kubelet=$k8s_version-00 kubeadm=$k8s_version-00 kubectl=$k8s_version-00
sudo apt-mark hold docker-ce kubelet kubeadm kubectl

echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

####### configure kubeadm

sudo kubeadm init --pod-network-cidr=10.244.0.0/16 &> ~/kubeadm.log
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 &>~/kubeadm.log
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown "$(id -u):$(id -g)" $HOME/.kube/config
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml


23 changes: 16 additions & 7 deletions etc/samples-provision/k8s/worker.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# HW requirements: 2 CPUS 2 RAM
# HW requirements: 1 CPUS 2 RAM
# OS: Ubuntu focal

#should change to $(lsb_release -cs) but it appears it is not working on focal yet
docker_ubuntu_release=bionic
k8s_version=1.18.0

# Set hostname and disable swap
sudo hostnamectl set-hostname "$(hostname -I | awk '{print $1}')"
sudo swapoff -a && sudo sed -i '/ swap / s/^/#/' /etc/fstab
Expand All @@ -20,16 +24,21 @@ sudo netplan apply
############# start k8s installation

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$docker_ubuntu_release \
stable"
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

sudo apt-get update -y
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu kubelet=1.13.5-00 kubeadm=1.13.5-00 kubectl=1.13.5-00
sudo apt-get update
sudo apt-get install -y \
containerd.io=1.2.13-1 \
docker-ce=5:19.03.8~3-0~ubuntu-$docker_ubuntu_release \
docker-ce-cli=5:19.03.8~3-0~ubuntu-$docker_ubuntu_release
sudo apt-get install -y kubelet=$k8s_version-00 kubeadm=$k8s_version-00 kubectl=$k8s_version-00
sudo apt-mark hold docker-ce kubelet kubeadm kubectl

echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf
Expand Down

0 comments on commit 2b96fc9

Please sign in to comment.