From fc52ad58595d27a38993e3bcb37b6d23e84f708c Mon Sep 17 00:00:00 2001 From: Ankica Barisic <156663621+ankicabarisic@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:07:00 +0100 Subject: [PATCH] kubernetes key update (#106) (cherry picked from commit b5066e1d336b55541c4e7af7e1dff8c40ec06e4d) --- .../bootstrap-scripts/install-kube-u22-wg.sh | 40 ++++++++--------- docker/bootstrap-scripts/install-kube-u22.sh | 45 +++++++++---------- 2 files changed, 40 insertions(+), 45 deletions(-) diff --git a/docker/bootstrap-scripts/install-kube-u22-wg.sh b/docker/bootstrap-scripts/install-kube-u22-wg.sh index 426bc4a..62c3132 100644 --- a/docker/bootstrap-scripts/install-kube-u22-wg.sh +++ b/docker/bootstrap-scripts/install-kube-u22-wg.sh @@ -1,9 +1,8 @@ #!/bin/bash -# This bash script is designed to prepare and install docker and Kubernetes for Ubuntu 22.04. -# If an error occur, the script will exit with the value of the PID to point at the logfile. -# Author: Ali Jawad FAHS, Activeeon - +# This bash script is designed to prepare and install docker and Kubernetes v1.26 for Ubuntu 22.04. +# If an error occurs, the script will exit with the value of the PID to point at the logfile. +# Author: Ali Jawad FAHS, Ankica Barisic, Activeeon # Set up the script variables STARTTIME=$(date +%s) @@ -12,46 +11,43 @@ EXITCODE=$PID DATE=$(date) LOGFILE="/var/log/kube-install.$PID.log" - # Set up the logging for the script sudo touch $LOGFILE sudo chown $USER:$USER $LOGFILE - # All the output of this shell script is redirected to the LOGFILE exec 3>&1 4>&2 trap 'exec 2>&4 1>&3' 0 1 2 3 exec 1>$LOGFILE 2>&1 -# A function to print a message to the stdout as well as as the LOGFILE +# A function to print a message to the stdout as well as the LOGFILE log_print(){ level=$1 Message=$2 echo "$level [$(date)]: $Message" echo "$level [$(date)]: $Message" >&3 } + # A function to check for the apt lock Check_lock() { -i=0 -log_print INFO "Checking for apt lock" -while [ `ps aux | grep [l]ock_is_held | wc -l` != 0 ]; do - echo "Lock_is_held $i" - ps aux | grep [l]ock_is_held - sleep 10 - ((i=i+10)); -done -log_print INFO "Exited the while loop, time spent: $i" -echo "ps aux | grep apt" -ps aux | grep apt -log_print INFO "Waiting for lock task ended properly." + i=0 + log_print INFO "Checking for apt lock" + while [ "$(ps aux | grep [l]ock_is_held | wc -l)" != "0" ]; do + echo "Lock_is_held $i" + ps aux | grep [l]ock_is_held + sleep 10 + ((i=i+10)) + done + log_print INFO "Exited the while loop, time spent: $i" + echo "ps aux | grep apt" + ps aux | grep apt + log_print INFO "Waiting for lock task ended properly." } - # Start the Configuration log_print INFO "Configuration started!" log_print INFO "Logs are saved at: $LOGFILE" - # Update the package list log_print INFO "Updating the package list." sudo apt-get update @@ -94,7 +90,7 @@ echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs. # Check for lock Check_lock -curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.26/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg || { log_print ERROR "Kubernetes repo can't be added!"; exit $EXITCODE; } +curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg || { log_print ERROR "Kubernetes repo can't be added!"; exit $EXITCODE; } sudo apt-get update # Check for lock diff --git a/docker/bootstrap-scripts/install-kube-u22.sh b/docker/bootstrap-scripts/install-kube-u22.sh index 8a33e88..78c1475 100644 --- a/docker/bootstrap-scripts/install-kube-u22.sh +++ b/docker/bootstrap-scripts/install-kube-u22.sh @@ -1,9 +1,8 @@ #!/bin/bash -# This bash script is designed to prepare and install docker and Kubernetes for Ubuntu 22.04. -# If an error occur, the script will exit with the value of the PID to point at the logfile. -# Author: Ali Jawad FAHS, Activeeon - +# This bash script is designed to prepare and install docker and Kubernetes v1.26 for Ubuntu 22.04. +# If an error occurs, the script will exit with the value of the PID to point at the logfile. +# Author: Ali Jawad FAHS, Ankica Barisic, Activeeon # Set up the script variables STARTTIME=$(date +%s) @@ -12,46 +11,43 @@ EXITCODE=$PID DATE=$(date) LOGFILE="/var/log/kube-install.$PID.log" - # Set up the logging for the script sudo touch $LOGFILE sudo chown $USER:$USER $LOGFILE - # All the output of this shell script is redirected to the LOGFILE exec 3>&1 4>&2 trap 'exec 2>&4 1>&3' 0 1 2 3 exec 1>$LOGFILE 2>&1 -# A function to print a message to the stdout as well as as the LOGFILE +# A function to print a message to the stdout as well as the LOGFILE log_print(){ level=$1 Message=$2 echo "$level [$(date)]: $Message" echo "$level [$(date)]: $Message" >&3 } + # A function to check for the apt lock Check_lock() { -i=0 -log_print INFO "Checking for apt lock" -while [ `ps aux | grep [l]ock_is_held | wc -l` != 0 ]; do - echo "Lock_is_held $i" - ps aux | grep [l]ock_is_held - sleep 10 - ((i=i+10)); -done -log_print INFO "Exited the while loop, time spent: $i" -echo "ps aux | grep apt" -ps aux | grep apt -log_print INFO "Waiting for lock task ended properly." + i=0 + log_print INFO "Checking for apt lock" + while [ "$(ps aux | grep [l]ock_is_held | wc -l)" != "0" ]; do + echo "Lock_is_held $i" + ps aux | grep [l]ock_is_held + sleep 10 + ((i=i+10)) + done + log_print INFO "Exited the while loop, time spent: $i" + echo "ps aux | grep apt" + ps aux | grep apt + log_print INFO "Waiting for lock task ended properly." } - # Start the Configuration log_print INFO "Configuration started!" log_print INFO "Logs are saved at: $LOGFILE" - # Update the package list log_print INFO "Updating the package list." sudo apt-get update @@ -73,7 +69,9 @@ sudo systemctl start docker sudo docker -v || { log_print ERROR "Docker installation failed!"; exit $EXITCODE; } - +# Add the Kubernetes GPG key +# log_print INFO "Adding Kubernetes GPG key" +#curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg || { log_print ERROR "Failed to add new Kubernetes GPG key"; exit $EXITCODE; } # Adding Kubernetes Repo log_print INFO "Adding Kubernetes Repo" @@ -82,7 +80,8 @@ echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs. # Check for lock Check_lock -curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.26/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg || { log_print ERROR "Kubernetes repo can't be added!"; exit $EXITCODE; } +# curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.26/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg || { log_print ERROR "Kubernetes repo can't be added!"; exit $EXITCODE; } +curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg || { log_print ERROR "Kubernetes repo can't be added!"; exit $EXITCODE; } sudo apt-get update # Check for lock