parent
b45c73de9b
commit
0815a8096d
@ -0,0 +1,32 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then |
||||||
|
echo "This script should be run as root. Aborting..." > /dev/stderr |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
echo "Initializing kubernetes.." |
||||||
|
kubeadm init |
||||||
|
|
||||||
|
# This if statement evaulates if the script is launched using sudo AND not |
||||||
|
# a `sudo su` logged user |
||||||
|
if [ -n "$SUDO_USER" ] && [ "$SUDO_COMMAND" != "/usr/bin/su" ]; then |
||||||
|
SUDO_HOME=$(su -c "echo \$HOME" "$SUDO_USER") |
||||||
|
echo "Adding kubernetes config to this user home folder (useful for non-root users)..." |
||||||
|
su -c "mkdir -p $SUDO_HOME/.kube" "$SUDO_USER" |
||||||
|
cp -i /etc/kubernetes/admin.conf "$SUDO_HOME/.kube/config" |
||||||
|
chown "$SUDO_UID":"$SUDO_GID" "$SUDO_HOME/.kube/config" |
||||||
|
# This last one thanks to: |
||||||
|
# https://stackoverflow.com/questions/53814150/how-to-setup-a-2-node-kubernetes-cluster-in-custom-environment |
||||||
|
|
||||||
|
su -c "echo \"export KUBECONFIG=$SUDO_HOME/.kube/config\" | tee -a $SUDO_HOME/.profile" "$SUDO_USER" |
||||||
|
else |
||||||
|
echo "Adding kubernetes config to this user home folder (useful for non-root users)..." |
||||||
|
mkdir -p "$HOME/.kube" |
||||||
|
cp -i /etc/kubernetes/admin.conf "$HOME/.kube/config" |
||||||
|
chown "$(id -u)":"$(id -g)" "$HOME/.kube/config" |
||||||
|
# This last one thanks to: |
||||||
|
# https://stackoverflow.com/questions/53814150/how-to-setup-a-2-node-kubernetes-cluster-in-custom-environment |
||||||
|
|
||||||
|
echo "export KUBECONFIG=$HOME/.kube/config" | tee -a ~/.profile |
||||||
|
fi |
@ -0,0 +1,19 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then |
||||||
|
echo "This script should be run as root. Aborting..." > /dev/stderr |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
echo "Updating apt package index..." |
||||||
|
apt-get update > /dev/null |
||||||
|
|
||||||
|
echo "Installing snapd..." |
||||||
|
apt-get -q -y -o Dpkg::Use-Pty=0 install \ |
||||||
|
snapd |
||||||
|
|
||||||
|
echo "Installing core..." |
||||||
|
snap install core |
||||||
|
|
||||||
|
echo "Installing microk8s..." |
||||||
|
snap install microk8s --classic |
Loading…
Reference in new issue