-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
218 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
#!/bin/bash | ||
echo "Master install script" | ||
|
||
wget https://raw.githubusercontent.com/eu-nebulous/sal-scripts/main/k8s/install-kube-u22-wg.sh && chmod +x ./install-kube-u22-wg.sh && ./install-kube-u22-wg.sh | ||
K3S_DEP_PATH=$HOME/k3s | ||
|
||
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 | ||
|
||
sudo -H -u ubuntu bash -c 'curl -fsSl https://kubevela.io/script/install.sh | bash' | ||
echo "Configuration complete." | ||
echo "Installing K3s Server" | ||
sudo -H -u ubuntu bash -c 'wget -P $K3S_DEP_PATH https://raw.githubusercontent.com/eu-nebulous/sal-scripts/dev/k3s/install-kube-k3s-server-u22-wg.sh && chmod +x $K3S_DEP_PATH/install-kube-k3s-server-u22-wg.sh && $K3S_DEP_PATH/install-kube-k3s-server-u22-wg.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
#!/bin/bash | ||
echo "Worker install script" | ||
wget https://raw.githubusercontent.com/eu-nebulous/sal-scripts/main/k8s/install-kube-u22-wg.sh && chmod +x ./install-kube-u22-wg.sh && ./install-kube-u22-wg.sh | ||
|
||
echo "Installing K3s Agent" | ||
K3S_DEP_PATH=$HOME/k3s | ||
|
||
sudo -H -u ubuntu bash -c 'wget -P $K3S_DEP_PATH https://raw.githubusercontent.com/eu-nebulous/sal-scripts/dev/k3s/install-kube-k3s-agent-u22-wg.sh && chmod +x $K3S_DEP_PATH/install-kube-k3s-agent-u22-wg.sh && $K3S_DEP_PATH/install-kube-k3s-agent-u22-wg.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
#!/bin/bash | ||
echo "Worker pre-install script" | ||
|
||
echo "Setting hostname\n" | ||
sudo hostnamectl set-hostname "$variables_PA_JOB_NAME" | ||
|
||
echo "Create K3s Dependencies folder\n" | ||
K3S_DEP_PATH=$HOME/k3s | ||
mkdir -p $K3S_DEP_PATH | ||
|
||
echo "Setting Wireguard Interface\n" | ||
sudo -H -u ubuntu bash -c 'wget https://raw.githubusercontent.com/eu-nebulous/overlay-network-manager/main/network-manager/bootstrap-agent-scripts/onm/onm-bootstrap.sh && chmod +x onm-bootstrap.sh' | ||
sudo -H -u ubuntu bash -c "./onm-bootstrap.sh 'CREATE' $APPLICATION_ID $ONM_URL $PUBLIC_IP $SSH_PORT"; | ||
echo "" | ||
echo "" | ||
sleep 60 | ||
|
||
WIREGUARD_VPN_IP=`ip a | grep wg | grep inet | awk '{print $2}' | cut -d'/' -f1`; | ||
echo "WIREGUARD_VPN_IP= $WIREGUARD_VPN_IP"; | ||
|
||
echo "Executing k3s-preinstall script\n" | ||
sudo -H -u ubuntu bash -c 'wget -P $K3S_DEP_PATH https://raw.githubusercontent.com/eu-nebulous/sal-scripts/dev/k3s/preinstall-kube-k3s-u22.sh && chmod +x $K3S_DEP_PATH/preinstall-kube-k3s-u22.sh && $K3S_DEP_PATH/preinstall-kube-k3s-u22.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
#!/bin/bash | ||
echo "Worker start script" | ||
sudo kubeadm reset --force | ||
echo $variables_kubeCommand | ||
sudo $variables_kubeCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Set up the script variables | ||
STARTTIME=$(date +%s) | ||
PID=$(echo $$) | ||
EXITCODE=$PID | ||
DATE=$(date) | ||
LOGFILE="/var/log/install-kube-k3s-agent-u22-wg.$PID.log" | ||
|
||
# Set up the logging for the script | ||
sudo touch $LOGFILE | ||
sudo chown $USER:$USER $LOGFILE | ||
|
||
WIREGUARD_SERVER=192.168.55.1 | ||
NODE_TOKEN=${APPLICATION_ID} | ||
K3S_VERSION=v1.26.15+k3s1 | ||
|
||
# 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 | ||
} | ||
|
||
log_print INFO "Installing k3s agent" | ||
WIREGUARD_VPN_IP=`ip a | grep wg | grep inet | awk '{print $2}' | cut -d'/' -f1` | ||
|
||
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=${K3S_VERSION} K3S_URL="https://${WIREGUARD_SERVER}:6443" K3S_TOKEN=${NODE_TOKEN} INSTALL_K3S_EXEC="--node-ip $WIREGUARD_VPN_IP" sh - | ||
|
||
# Declare configuration done successfully | ||
ENDTIME=$(date +%s) | ||
ELAPSED=$(( ENDTIME - STARTTIME )) | ||
log_print INFO "Configuration done successfully in $ELAPSED seconds " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
# Set up the script variables | ||
STARTTIME=$(date +%s) | ||
PID=$(echo $$) | ||
EXITCODE=$PID | ||
DATE=$(date) | ||
LOGFILE="/var/log/install-kube-k3s-server-u22-wg.$PID.log" | ||
|
||
# Set up the logging for the script | ||
sudo touch $LOGFILE | ||
sudo chown $USER:$USER $LOGFILE | ||
|
||
# Variables | ||
K3S_DEP_PATH=$HOME/k3s | ||
CILIUM_VERSION=1.15.5 | ||
POD_CIDR=10.244.0.0/16 | ||
K3S_VERSION=v1.26.15+k3s1 | ||
|
||
# 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 | ||
} | ||
|
||
log_print INFO "Installing k3s server" | ||
WIREGUARD_VPN_IP=`ip a | grep wg | grep inet | awk '{print $2}' | cut -d'/' -f1` | ||
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=${K3S_VERSION} INSTALL_K3S_EXEC="--cluster-cidr ${POD_CIDR} --token ${APPLICATION_ID} --flannel-backend=none --disable-network-policy --bind-address ${WIREGUARD_VPN_IP} --node-ip ${WIREGUARD_VPN_IP} --write-kubeconfig-mode 644" sh - | ||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml | ||
|
||
log_print INFO "Setting NODE_TOKEN environmental variable (default expiry 1d)" | ||
NODE_TOKEN=$(sudo cat /var/lib/rancher/k3s/server/token) | ||
log_print INFO "NODE_TOKEN: ${NODE_TOKEN}" | ||
|
||
log_print INFO "Installing Helm..." | ||
curl -fsSL -o $K3S_DEP_PATH/get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && chmod 700 $K3S_DEP_PATH/get_helm.sh && $K3S_DEP_PATH/get_helm.sh | ||
|
||
log_print INFO "Adding Cilium Repo" | ||
# Add Cilium Helm Repo | ||
helm repo add cilium https://helm.cilium.io/ | ||
helm repo update | ||
|
||
log_print INFO "Installing Cilium" | ||
# Install Cilium with Wireguard parameters | ||
helm install cilium cilium/cilium \ | ||
--version $CILIUM_VERSION \ | ||
--namespace kube-system \ | ||
--set ipam.mode=cluster-pool \ | ||
--set ipam.operator.clusterPoolIPv4PodCIDRList=$POD_CIDR \ | ||
--set encryption.enabled=true \ | ||
--set encryption.type=wireguard | ||
|
||
# Declare configuration done successfully | ||
ENDTIME=$(date +%s) | ||
ELAPSED=$(( ENDTIME - STARTTIME )) | ||
log_print INFO "Configuration done successfully in $ELAPSED seconds " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
|
||
# This bash script is designed to prepare and install Kubernetes K3s Distribution for Ubuntu 22.04. | ||
# If an error occur, the script will exit with the value of the PID to point at the logfile. | ||
|
||
# Set up the script variables | ||
STARTTIME=$(date +%s) | ||
PID=$(echo $$) | ||
EXITCODE=$PID | ||
DATE=$(date) | ||
LOGFILE="/var/log/preinstall-kube-k3s-u22.$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" | ||
|
||
# Check for lock | ||
Check_lock | ||
|
||
# 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; } | ||
|
||
# Turn off the swap memory | ||
log_print INFO "Turning swap off...." | ||
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 "Temporary swap memory can't be turned off "; exit $EXITCODE; } | ||
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab || { log_print ERROR "swap memory can't be turned off "; exit $EXI | ||
TCODE; } | ||
log_print INFO "Swap turned off!" | ||
fi | ||
|
||
# Declare configuration done successfully | ||
ENDTIME=$(date +%s) | ||
ELAPSED=$(( ENDTIME - STARTTIME )) | ||
log_print INFO "Configuration done successfully in $ELAPSED seconds " |