Skip to content

Commit

Permalink
Safe k3s scripts execution (#43)
Browse files Browse the repository at this point in the history
* Update MASTER_INSTALL_SCRIPT.sh

Specify the output file of wget to prevent it creating multiple versions

* Update MASTER_INSTALL_SCRIPT.sh

* Update MASTER_PRE_INSTALL_SCRIPT.sh

Specify destination file for wget command to avoid versioning

* Update MASTER_PRE_INSTALL_SCRIPT.sh

Get dev version of onm-bootstrap.sh

* Update MASTER_PRE_INSTALL_SCRIPT.sh

Wait for WIREGUARD_IP

* Update MASTER_START_SCRIPT.sh

Assume yes for vela install command questions

* Update MASTER_START_SCRIPT.sh

delete secret docker-registry before creating it

* Update WORKER_INSTALL_SCRIPT.sh

specify  wget output file to avoid versioning

* Update WORKER_PRE_INSTALL_SCRIPT.sh

Wait for WIREGUARD_VPN_IP
Specify wget output file to avoid versioning

* Update MASTER_PRE_INSTALL_SCRIPT.sh

Wait WIREGUARD_VPN_IP to be set
Remove 60 seconds delay

* Update WORKER_PRE_INSTALL_SCRIPT.sh
  • Loading branch information
robert-sanfeliu authored Dec 2, 2024
1 parent 4e76765 commit 4f8924f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion installation-scripts-onm/MASTER_INSTALL_SCRIPT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ echo "Master install script"
K3S_DEP_PATH=$HOME/k3s

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 $APPLICATION_ID"
sudo -H -u ubuntu bash -c "wget https://raw.githubusercontent.com/eu-nebulous/sal-scripts/dev/k3s/install-kube-k3s-server-u22-wg.sh -O ${K3S_DEP_PATH}/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 $APPLICATION_ID"
18 changes: 13 additions & 5 deletions installation-scripts-onm/MASTER_PRE_INSTALL_SCRIPT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ 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 'wget https://raw.githubusercontent.com/eu-nebulous/overlay-network-manager/dev/network-manager/bootstrap-agent-scripts/onm/onm-bootstrap.sh -O 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";

while true; do
WIREGUARD_VPN_IP=$(ip a | grep wg | grep inet | awk '{print $2}' | cut -d'/' -f1)
if [[ -n "$WIREGUARD_VPN_IP" ]]; then
echo "WIREGUARD_VPN_IP is set to $WIREGUARD_VPN_IP"
break
fi
echo "Waiting for WIREGUARD_VPN_IP to be set..."
sleep 2
done


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"
sudo -H -u ubuntu bash -c "wget https://raw.githubusercontent.com/eu-nebulous/sal-scripts/dev/k3s/preinstall-kube-k3s-u22.sh -O ${K3S_DEP_PATH}/preinstall-kube-k3s-u22.sh && chmod +x $K3S_DEP_PATH/preinstall-kube-k3s-u22.sh && $K3S_DEP_PATH/preinstall-kube-k3s-u22.sh"
3 changes: 2 additions & 1 deletion installation-scripts-onm/MASTER_START_SCRIPT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo "Configuration complete."

echo "Setting KubeVela..."
$dau bash -c 'helm repo add kubevela https://kubevela.github.io/charts && helm repo update'
$dau bash -c 'vela install --version 1.9.11'
$dau bash -c 'vela install -y --version 1.9.11'

$dau bash -c 'helm repo add nebulous https://eu-nebulous.github.io/helm-charts/'

Expand All @@ -22,6 +22,7 @@ $dau bash -c 'helm repo add netdata https://netdata.github.io/helmchart/'
$dau bash -c 'helm repo update'

echo "Login to docker registry"
$dau bash -c "kubectl delete secret docker-registry regcred --ignore-not-found"
$dau bash -c "kubectl create secret docker-registry regcred --docker-server=$PRIVATE_DOCKER_REGISTRY_SERVER --docker-username=$PRIVATE_DOCKER_REGISTRY_USERNAME --docker-password=$PRIVATE_DOCKER_REGISTRY_PASSWORD --docker-email=$PRIVATE_DOCKER_REGISTRY_EMAIL"

echo "Starting EMS"
Expand Down
2 changes: 1 addition & 1 deletion installation-scripts-onm/WORKER_INSTALL_SCRIPT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ echo "Worker install script"
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 $APPLICATION_ID"
sudo -H -u ubuntu bash -c "wget https://raw.githubusercontent.com/eu-nebulous/sal-scripts/dev/k3s/install-kube-k3s-agent-u22-wg.sh -O ${K3S_DEP_PATH}/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 $APPLICATION_ID"
17 changes: 12 additions & 5 deletions installation-scripts-onm/WORKER_PRE_INSTALL_SCRIPT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ 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 'wget https://raw.githubusercontent.com/eu-nebulous/overlay-network-manager/main/network-manager/bootstrap-agent-scripts/onm/onm-bootstrap.sh -O 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";
while true; do
WIREGUARD_VPN_IP=$(ip a | grep wg | grep inet | awk '{print $2}' | cut -d'/' -f1)
if [[ -n "$WIREGUARD_VPN_IP" ]]; then
echo "WIREGUARD_VPN_IP is set to $WIREGUARD_VPN_IP"
break
fi
echo "Waiting for WIREGUARD_VPN_IP to be set..."
sleep 2
done


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"
sudo -H -u ubuntu bash -c "wget https://raw.githubusercontent.com/eu-nebulous/sal-scripts/dev/k3s/preinstall-kube-k3s-u22.sh -O ${K3S_DEP_PATH}/preinstall-kube-k3s-u22.sh && chmod +x $K3S_DEP_PATH/preinstall-kube-k3s-u22.sh && $K3S_DEP_PATH/preinstall-kube-k3s-u22.sh"

0 comments on commit 4f8924f

Please sign in to comment.