Skip to content

Commit 8602282

Browse files
authored
Merge pull request #67 from akhiljns/k8sFix
updating versions of k8s provisioning vms to newest versions
2 parents 1ada806 + 640bda3 commit 8602282

2 files changed

Lines changed: 57 additions & 53 deletions

File tree

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
1-
# HW requirements: 2 CPUS 2 RAM
1+
# HW requirements: 2 CPUS 2G RAM
22
# OS: Ubuntu focal
33
set -ex
44

5-
#should be $(lsb_release -cs) but it appears it is not working on focal yet
6-
docker_ubuntu_release=bionic
7-
k8s_version=1.18.0
8-
95
# Set hostname and disable swap
106
sudo hostnamectl set-hostname "$(hostname -I | awk '{print $1}')"
117
echo "export PS1=\"\[\e[1;35m\]\u\[\033[m\]@\[\e[1;92m\]$(hostname -I | awk '{print $1}')\[\033[m\]:\w \$ \"" >>~/.bashrc
128

139
sudo swapoff -a && sudo sed -i 's/\/swap/#\/swap/g' /etc/fstab
1410

1511
## Fix IP Addr
16-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
1712
sudo add-apt-repository ppa:rmescandon/yq -y
1813
sudo apt-get update -y
1914
sudo apt-get install yq -y
20-
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.dhcp4 false
21-
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.addresses[+] "$(hostname -I | awk '{print $1}')/24"
22-
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.gateway4 "$(hostname -I | cut -d "." -f 1-3).1"
23-
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.8.8
24-
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.4.4
15+
16+
# Create a new empty file (assuming the desired filename is 00-installer-config.yaml)
17+
sudo touch /etc/netplan/00-installer-config.yaml
18+
19+
sudo yq eval '.network.ethernets.enp0s3.dhcp4 = false' -i /etc/netplan/00-installer-config.yaml
20+
sudo yq eval ".network.ethernets.enp0s3.addresses += [\"$(hostname -I | awk '{print $1}')/24\"]" -i /etc/netplan/00-installer-config.yaml
21+
sudo yq eval ".network.ethernets.enp0s3.gateway4 = \"$(hostname -I | cut -d '.' -f 1-3).1\"" -i /etc/netplan/00-installer-config.yaml
22+
sudo yq eval '.network.ethernets.enp0s3.nameservers.addresses += ["8.8.8.8"]' -i /etc/netplan/00-installer-config.yaml
23+
sudo yq eval '.network.ethernets.enp0s3.nameservers.addresses += ["8.8.4.4"]' -i /etc/netplan/00-installer-config.yaml
24+
2525
sudo netplan apply
2626
sleep 1
27+
2728
############# install docker & k8s
2829

30+
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
31+
32+
sudo mkdir -p -m 755 /etc/apt/keyrings
33+
34+
35+
# Add Kubernetes APT repository
36+
37+
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
38+
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
39+
2940
## install docker, kubelet, kubeadm and kubectl
30-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
31-
sudo add-apt-repository \
32-
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
33-
$docker_ubuntu_release \
34-
stable"
35-
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
36-
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
37-
deb https://apt.kubernetes.io/ kubernetes-xenial main
38-
EOF
3941

42+
# Update to the latest Docker version
4043
sudo apt-get update
41-
sudo apt-get install -y \
42-
containerd.io=1.2.13-1 \
43-
docker-ce=5:19.03.8~3-0~ubuntu-$docker_ubuntu_release \
44-
docker-ce-cli=5:19.03.8~3-0~ubuntu-$docker_ubuntu_release
45-
sudo apt-get install -y kubelet=$k8s_version-00 kubeadm=$k8s_version-00 kubectl=$k8s_version-00
46-
sudo apt-mark hold docker-ce kubelet kubeadm kubectl
44+
sudo apt-get install -y docker.io
45+
46+
# Update to the latest Kubernetes version
47+
sudo apt-get install -y kubelet kubeadm kubectl
48+
sudo apt-mark hold kubelet kubeadm kubectl
4749

4850
echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf
4951
sudo sysctl -p
@@ -75,4 +77,4 @@ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
7577
sudo chown "$(id -u):$(id -g)" $HOME/.kube/config
7678

7779
## install flannel network
78-
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/485649719be5a21b0fe7e44f699f7acbb66137fa/Documentation/kube-flannel.yml
80+
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

‎etc/samples-provision/k8s/worker.sh‎

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
1-
# HW requirements: 1 CPUS 2 RAM
1+
# HW requirements: 1 CPUS 2G RAM
22
# OS: Ubuntu focal
33
set -ex
44

5-
#should be $(lsb_release -cs) but it appears it is not working on focal yet
6-
docker_ubuntu_release=bionic
7-
k8s_version=1.18.0
8-
95
# Set hostname and disable swap
106
sudo hostnamectl set-hostname "$(hostname -I | awk '{print $1}')"
117
echo "export PS1=\"\[\e[1;35m\]\u\[\033[m\]@\[\e[1;92m\]$(hostname -I | awk '{print $1}')\[\033[m\]:\w \$ \"" >>~/.bashrc
128

139
sudo swapoff -a && sudo sed -i 's/\/swap/#\/swap/g' /etc/fstab
1410

1511
## Fix IP Addr
16-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
1712
sudo add-apt-repository ppa:rmescandon/yq -y
1813
sudo apt-get update -y
1914
sudo apt-get install yq -y
20-
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.dhcp4 false
21-
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.addresses[+] "$(hostname -I | awk '{print $1}')/24"
22-
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.gateway4 "$(hostname -I | cut -d "." -f 1-3).1"
23-
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.8.8
24-
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.4.4
15+
16+
# Create a new empty file (assuming the desired filename is 00-installer-config.yaml)
17+
sudo touch /etc/netplan/00-installer-config.yaml
18+
19+
sudo yq eval '.network.ethernets.enp0s3.dhcp4 = false' -i /etc/netplan/00-installer-config.yaml
20+
sudo yq eval ".network.ethernets.enp0s3.addresses += [\"$(hostname -I | awk '{print $1}')/24\"]" -i /etc/netplan/00-installer-config.yaml
21+
sudo yq eval ".network.ethernets.enp0s3.gateway4 = \"$(hostname -I | cut -d '.' -f 1-3).1\"" -i /etc/netplan/00-installer-config.yaml
22+
sudo yq eval '.network.ethernets.enp0s3.nameservers.addresses += ["8.8.8.8"]' -i /etc/netplan/00-installer-config.yaml
23+
sudo yq eval '.network.ethernets.enp0s3.nameservers.addresses += ["8.8.4.4"]' -i /etc/netplan/00-installer-config.yaml
24+
2525
sudo netplan apply
2626
sleep 1
27+
2728
############# install docker & k8s
2829

30+
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
31+
32+
sudo mkdir -p -m 755 /etc/apt/keyrings
33+
34+
35+
# Add Kubernetes APT repository
36+
37+
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
38+
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
39+
2940
## install docker, kubelet, kubeadm and kubectl
30-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
31-
sudo add-apt-repository \
32-
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
33-
$docker_ubuntu_release \
34-
stable"
35-
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
36-
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
37-
deb https://apt.kubernetes.io/ kubernetes-xenial main
38-
EOF
3941

42+
# Update to the latest Docker version
4043
sudo apt-get update
41-
sudo apt-get install -y \
42-
containerd.io=1.2.13-1 \
43-
docker-ce=5:19.03.8~3-0~ubuntu-$docker_ubuntu_release \
44-
docker-ce-cli=5:19.03.8~3-0~ubuntu-$docker_ubuntu_release
45-
sudo apt-get install -y kubelet=$k8s_version-00 kubeadm=$k8s_version-00 kubectl=$k8s_version-00
46-
sudo apt-mark hold docker-ce kubelet kubeadm kubectl
44+
sudo apt-get install -y docker.io
45+
46+
# Update to the latest Kubernetes version
47+
sudo apt-get install -y kubelet kubeadm kubectl
48+
sudo apt-mark hold kubelet kubeadm kubectl
4749

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

0 commit comments

Comments
 (0)