code/single-node-kubernetes/setup-master.sh

70 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
VERSION=1.29.2
kubeadm config images pull --kubernetes-version $VERSION
kubeadm init --kubernetes-version $VERSION
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
echo "Waiting until cluster available..."
while ! kubectl get nodes >& /dev/null
do
echo .
sleep 1
done
#kubectl taint node master1 node-role.kubernetes.io/control-plane-
echo '
. /etc/bash_completion
. <( kubectl completion bash )
. <( kubectl completion bash | sed 's/kubectl/k/g' )
alias k=kubectl
' >> ~/.bashrc
echo "Waiting for kube-proxy..."
while ! kubectl get pods -n kube-system | grep kube-proxy | grep Running >& /dev/null
do
echo .
sleep 1
done
echo "Installing network plugin..."
while ! kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml >& /dev/null
do
echo .
sleep 1
done
echo "Waiting until coredns is running..."
while ! kubectl get pods -n kube-system | grep coredns | grep Running >& /dev/null
do
echo .
sleep 1
done
kubectl taint node "$HOSTNAME" node-role.kubernetes.io/control-plane-
echo "Installing OPA gatekeeper"
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper/v3.15.0/deploy/gatekeeper.yaml
kubectl scale -n gatekeeper-system deployment gatekeeper-controller-manager --replicas 1
echo "Done setting up master"
exit 0
curl https://raw.githubusercontent.com/projectcalico/calico/v3.27.2/manifests/calico.yaml -O
while ! kubectl apply -f calico.yaml
do
sleep 1
done