@@ -10,6 +10,11 @@ echo "-------------Disabling swap-------------"
1010swapoff -a
1111sed -i ' / swap / s/^\(.*\)$/#\1/g' /etc/fstab
1212
13+ # Install Dependencies
14+ echo " -------------Installing Required Packages-------------"
15+ apt-get update -y
16+ apt-get install -y curl wget gpg apt-transport-https ca-certificates
17+
1318# Install Containerd
1419echo " -------------Installing Containerd-------------"
1520wget https://github.com/containerd/containerd/releases/download/v1.7.4/containerd-1.7.4-linux-amd64.tar.gz
@@ -66,14 +71,13 @@ sysctl net.bridge.bridge-nf-call-iptables net.bridge.bridge-nf-call-ip6tables ne
6671modprobe br_netfilter
6772sysctl -p /etc/sysctl.conf
6873
69- # Install kubectl, kubelet and kubeadm
70- echo " -------------Installing Kubectl, Kubelet and Kubeadm-------------"
71- apt-get update && sudo apt-get install -y apt-transport-https curl
72- curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
73-
74- cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
75- deb https://apt.kubernetes.io/ kubernetes-xenial main
76- EOF
74+ # Check if the key file already exists
75+ if [ ! -f /etc/apt/keyrings/kubernetes-apt-keyring.gpg ]; then
76+ # Download the key if it doesn't exist
77+ curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
78+ # Add the Kubernetes repository to the sources list
79+ 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
80+ fi
7781
7882apt update -y
7983apt install -y kubelet kubeadm kubectl
0 commit comments