Skip to content
Snippets Groups Projects
Commit a3d58620 authored by Nico Benjamin Pögel's avatar Nico Benjamin Pögel
Browse files

changed the install script to work for root users and other users.

parent fc285590
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ git clone https://gitlab.reutlingen-university.de/poegel/microservice-architectu ...@@ -28,7 +28,7 @@ git clone https://gitlab.reutlingen-university.de/poegel/microservice-architectu
### Installation with the script ### Installation with the script
There are a few ways to install the architecture on a new server. The first one is the easiest, by simply running the [install_msa.sh](install_msa.sh) script. On Linux you can do that with the following command: There are a few ways to install the architecture on a new server. The first one is the easiest, by simply running the [install_msa.sh](install_msa.sh) script. On Linux you can do that with the following command:
``` ```
bash install_msa.sh sudo bash install_msa.sh
``` ```
This script installs all the tools necessary to run the architecture on your Ubuntu server. After that, the base microservice architecture is ready for use and you can start implementing your own applications. This script installs all the tools necessary to run the architecture on your Ubuntu server. After that, the base microservice architecture is ready for use and you can start implementing your own applications.
......
#Save directory of the script in variable #Save directory of the script in variable
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
USER_HOME=$(getent passwd ${SUDO_USER:-$USER} | cut -d: -f6)
ORIGINAL_USER=${SUDO_USER:-$USER}
#Download and install K3s, then create a single node cluster #Download and install K3s, then create a single node cluster
curl -sfL https://get.k3s.io | sh - curl -sfL https://get.k3s.io | sh -
#Wait for availability of Traefik-CRDs in the cluster
counter=0
retries=15
sleeptime=10
while [ $counter -le $retries ]
do
((counter++))
kubectl get ingressroute
if [ $? -eq 0 ]; then
break
else
if [ $counter -eq $retries ]; then
echo CRDs are not yet available, please install helm-chart manually
exit 1
fi
echo CRDs not yet ready, retrying in $sleeptime seconds. \(Try $counter/$retries\)
sleep $sleeptime
fi
done
#Edit K3s service environment variable file to change access permission to k3s.yaml if not root
if [ $ORIGINAL_USER != 'root' ]; then
echo User not root, changing access permission for k3s.yaml
sudo echo K3S_KUBECONFIG_MODE=\"644\" >> /etc/systemd/system/k3s.service.env
sudo systemctl restart k3s
fi
#Download Linkerd and install onto cluster #Download Linkerd and install onto cluster
linkerd version linkerd version
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo Linkerd already installed echo Linkerd already installed
else else
curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sh curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sudo -u $ORIGINAL_USER sh
fi fi
export PATH=$PATH:/root/.linkerd2/bin export PATH=$PATH:$USER_HOME/.linkerd2/bin
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
linkerd install --crds | kubectl apply -f - linkerd install --crds | kubectl apply -f -
...@@ -30,14 +59,14 @@ else ...@@ -30,14 +59,14 @@ else
sudo apt-get install helm sudo apt-get install helm
fi fi
#Wait for availability of CRDs in the cluster #Wait for availability of Linkerd-CRDs in the cluster
counter=1 counter=0
retries=10 retries=10
sleeptime=10 sleeptime=10
while [ $counter -le $retries ] while [ $counter -le $retries ]
do do
((counter++)) ((counter++))
kubectl get ingressroute kubectl get serviceprofiles
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
break break
else else
...@@ -45,7 +74,7 @@ do ...@@ -45,7 +74,7 @@ do
echo CRDs are not yet available, please install helm-chart manually echo CRDs are not yet available, please install helm-chart manually
exit 1 exit 1
fi fi
echo CRDs not yet ready, retrying in $sleeptime seconds echo CRDs not yet ready, retrying in $sleeptime seconds. \(Try $counter/$retries\)
sleep $sleeptime sleep $sleeptime
fi fi
done done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment