Skip to content

Commit

Permalink
update install_k3s.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Jaehyun Nam <[email protected]>
  • Loading branch information
nam-jaehyun committed May 23, 2022
1 parent 12d3610 commit a5c8630
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions contribution/k3s/install_k3s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@

# create a single-node K3s cluster
if [ -x "$(command -v docker)" ]; then # docker
CGROUP_SYSTEMD=$(docker info 2> /dev/null | grep -i cgroup | grep systemd | wc -l)
if [ $CGROUP_SYSTEMD == 1 ]; then
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik --docker --kubelet-arg cgroup-driver=systemd" sh -
[[ $? != 0 ]] && echo "Failed to install k3s" && exit 1
else # cgroupfs
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik --docker" sh -
[[ $? != 0 ]] && echo "Failed to install k3s" && exit 1
fi
CGROUP_SYSTEMD=$(docker info 2> /dev/null | grep -i cgroup | grep systemd | wc -l)
if [ $CGROUP_SYSTEMD == 1 ]; then
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik --docker --kubelet-arg cgroup-driver=systemd" sh -
[[ $? != 0 ]] && echo "Failed to install k3s" && exit 1
else # cgroupfs
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik --docker" sh -
[[ $? != 0 ]] && echo "Failed to install k3s" && exit 1
fi
else # containerd
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik" sh -
[[ $? != 0 ]] && echo "Failed to install k3s" && exit 1
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik" sh -
[[ $? != 0 ]] && echo "Failed to install k3s" && exit 1
fi

if [[ $(hostname) = kubearmor-dev* ]]; then
mkdir -p /home/vagrant/.kube
sudo cp /etc/rancher/k3s/k3s.yaml /home/vagrant/.kube/config
sudo chown -R vagrant:vagrant /home/vagrant/.kube
else
KUBEDIR=$HOME/.kube
KUBECONFIG=$KUBEDIR/config
KUBEDIR=$HOME/.kube
KUBECONFIG=$KUBEDIR/config
[[ ! -d $KUBEDIR ]] && mkdir $KUBEDIR
if [ -f $KUBECONFIG ]; then
echo "Found $KUBECONFIG already in place ... backing it up to $KUBECONFIG.backup"
cp $KUBECONFIG $KUBECONFIG.backup
fi
sudo cp /etc/rancher/k3s/k3s.yaml $KUBECONFIG
if [ -f $KUBECONFIG ]; then
echo "Found $KUBECONFIG already in place ... backing it up to $KUBECONFIG.backup"
cp $KUBECONFIG $KUBECONFIG.backup
fi
sudo cp /etc/rancher/k3s/k3s.yaml $KUBECONFIG
sudo chown $USER:$USER $KUBECONFIG
fi

Expand All @@ -38,10 +38,10 @@ sleep 15

for (( ; ; ))
do
status=$(kubectl get pods -A -o jsonpath={.items[*].status.phase})
[[ $(echo $status | grep -v Running | wc -l) -eq 0 ]] && break
echo "wait for initialization"
sleep 1
status=$(kubectl get pods -A -o jsonpath={.items[*].status.phase})
[[ $(echo $status | grep -v Running | wc -l) -eq 0 ]] && break
echo "wait for initialization"
sleep 1
done

kubectl get pods -A

0 comments on commit a5c8630

Please sign in to comment.