Add install kubernetes scripts
Change-Id: Ib956dc170fa5b9dbd73cc6f99c96b445f889c7e3
This commit is contained in:
parent
83f4c3287c
commit
9bee573989
@ -1,7 +1,7 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Master install script"
|
||||
|
||||
wget https://raw.githubusercontent.com/alijawadfahs/scripts/main/nebulous/install-kube-u22-wg.sh && chmod +x ./install-kube-u22-wg.sh && ./install-kube-u22-wg.sh
|
||||
wget https://opendev.org/nebulous/sal-scripts/raw/branch/master/k8s/install-kube-u22-wg.sh && chmod +x ./install-kube-u22-wg.sh && ./install-kube-u22-wg.sh
|
||||
|
||||
echo "Installing Helm..."
|
||||
sudo -H -u ubuntu bash -c ' curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && chmod 700 get_helm.sh && ./get_helm.sh'
|
||||
|
@ -1,2 +1,2 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Master post-install script"
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Master pre-install script\n"
|
||||
|
||||
sudo hostnamectl set-hostname "$variables_PA_JOB_NAME"
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Master start script"
|
||||
WIREGUARD_VPN_IP=`ip a | grep wg | grep inet | awk '{print $2}' | cut -d'/' -f1`;
|
||||
echo "WIREGUARD_VPN_IP=$WIREGUARD_VPN_IP";
|
||||
|
@ -1,2 +1,2 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Master stop script"
|
||||
|
@ -1,2 +1,2 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Master update script"
|
||||
|
@ -1,3 +1,3 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Worker install script"
|
||||
wget https://raw.githubusercontent.com/alijawadfahs/scripts/main/nebulous/install-kube-u22-wg.sh && chmod +x ./install-kube-u22-wg.sh && ./install-kube-u22-wg.sh
|
||||
wget https://opendev.org/nebulous/sal-scripts/raw/branch/master/k8s/install-kube-u22-wg.sh && chmod +x ./install-kube-u22-wg.sh && ./install-kube-u22-wg.sh
|
||||
|
@ -1,2 +1,2 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "worker post-install script"
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Worker pre-install script"
|
||||
sudo hostnamectl set-hostname "$variables_PA_JOB_NAME"
|
||||
sudo -H -u ubuntu bash -c 'wget https://opendev.org/nebulous/sal-scripts/raw/branch/master/onm/nm-bootstrap-script.sh && chmod +x nm-bootstrap-script.sh'
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Worker start script"
|
||||
sudo kubeadm reset --force
|
||||
echo $variables_kubeCommand
|
||||
sudo $variables_kubeCommand
|
||||
|
@ -1,2 +1,2 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Worker stop script"
|
||||
|
@ -1,2 +1,2 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Worker update script"
|
||||
|
@ -1,11 +1,12 @@
|
||||
#!/bin/bash
|
||||
echo "Master install script"
|
||||
|
||||
wget https://raw.githubusercontent.com/alijawadfahs/scripts/main/nebulous/install-kube-u22.sh && chmod +x ./install-kube-u22.sh && ./install-kube-u22.sh
|
||||
wget https://opendev.org/nebulous/sal-scripts/raw/branch/master/k8s/install-kube-u22.sh && chmod +x ./install-kube-u22.sh && ./install-kube-u22.sh
|
||||
|
||||
echo "Installing Helm..."
|
||||
sudo -H -u ubuntu bash -c ' curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && chmod 700 get_helm.sh && ./get_helm.sh'
|
||||
# Add KubeVela Helm repository and update
|
||||
|
||||
# Add KubeVela Helm repository and update
|
||||
echo "Installing Kubevela..."
|
||||
sudo -H -u ubuntu bash -c 'curl -fsSl https://kubevela.io/script/install.sh | bash'
|
||||
echo "Configuration complete."
|
||||
|
@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
echo "Worker install script"
|
||||
wget https://raw.githubusercontent.com/alijawadfahs/scripts/main/nebulous/install-kube-u22.sh && chmod +x ./install-kube-u22.sh && ./install-kube-u22.sh
|
||||
wget https://opendev.org/nebulous/sal-scripts/raw/branch/master/k8s/install-kube-u22.sh && chmod +x ./install-kube-u22.sh && ./install-kube-u22.sh
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
echo "Worker start script"
|
||||
sudo kubeadm reset --force
|
||||
echo $variables_kubeCommand
|
||||
sudo $variables_kubeCommand
|
||||
|
134
k8s/install-kube-u22.sh
Normal file
134
k8s/install-kube-u22.sh
Normal file
@ -0,0 +1,134 @@
|
||||
#!/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
|
||||
|
||||
|
||||
# Set up the script variables
|
||||
STARTTIME=$(date +%s)
|
||||
PID=$(echo $$)
|
||||
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
|
||||
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."
|
||||
}
|
||||
|
||||
|
||||
# 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
|
||||
sudo unattended-upgrade -d
|
||||
|
||||
# Check for lock
|
||||
Check_lock
|
||||
|
||||
# Install curl
|
||||
log_print INFO "Installing curl"
|
||||
sudo apt-get install -y curl || { log_print ERROR "curl installation failed!"; exit $EXITCODE; }
|
||||
|
||||
# Install Docker
|
||||
log_print INFO "Installing Docker"
|
||||
sudo apt-get install -y docker.io
|
||||
sudo systemctl enable docker
|
||||
sudo systemctl status docker
|
||||
sudo systemctl start docker
|
||||
|
||||
sudo docker -v || { log_print ERROR "Docker installation failed!"; exit $EXITCODE; }
|
||||
|
||||
|
||||
|
||||
# Adding Kubernetes Repo
|
||||
log_print INFO "Adding Kubernetes Repo"
|
||||
sudo mkdir -p /etc/apt/keyrings
|
||||
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.26/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
||||
|
||||
# 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; }
|
||||
sudo apt-get update
|
||||
|
||||
# Check for lock
|
||||
Check_lock
|
||||
|
||||
# Install Kubernetes
|
||||
log_print INFO "Installing Kubernetes"
|
||||
sudo apt-get install -y kubeadm=1.26.15-1.1 --allow-downgrades || { log_print ERROR "kubeadm installation failed!"; exit $EXITCODE; }
|
||||
sudo apt-get install -y kubelet=1.26.15-1.1 --allow-downgrades || { log_print ERROR "kubectl installation failed!"; exit $EXITCODE; }
|
||||
sudo apt-get install -y kubectl=1.26.15-1.1 --allow-downgrades || { log_print ERROR "kubelet installation failed!"; exit $EXITCODE; }
|
||||
|
||||
|
||||
# Hoding upgrades for Kubernetes software (versions to updated manually)
|
||||
sudo apt-mark hold kubeadm kubelet kubectl
|
||||
|
||||
# Checking for the installiation versions
|
||||
|
||||
sudo mkdir /etc/containerd
|
||||
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
|
||||
|
||||
|
||||
log_print INFO "Checking Kubernetes versions"
|
||||
|
||||
kubeadm version || { log_print ERROR "kubeadm installation failed!"; exit $EXITCODE; }
|
||||
kubectl version
|
||||
if [ $? -gt 1 ]
|
||||
then
|
||||
log_print ERROR "kubectl installation failed!"; exit $EXITCODE;
|
||||
fi
|
||||
kubelet --version || { log_print ERROR "kubelet installation failed!"; exit $EXITCODE; }
|
||||
|
||||
|
||||
# Turn off the swap momery
|
||||
if [ `grep Swap /proc/meminfo | grep SwapTotal: | cut -d" " -f14` == "0" ];
|
||||
then
|
||||
log_print INFO "The swap memory is Off"
|
||||
else
|
||||
sudo swapoff –a || { log_print ERROR "swap memory can't be turned off "; exit $EXITCODE; }
|
||||
fi
|
||||
|
||||
|
||||
# Declare configuration done successfully
|
||||
ENDTIME=$(date +%s)
|
||||
ELAPSED=$(( ENDTIME - STARTTIME ))
|
||||
log_print INFO "Configuration done successfully in $ELAPSED seconds "
|
||||
|
Loading…
x
Reference in New Issue
Block a user