coins-demo/contrib/firstboot.sh
2020-08-01 17:03:57 +02:00

44 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
bootflag='/.manufactured'
groot='/opt/coins-demo'
k8sDemoWA () {
printf "\033c"
echo 'Disabling swap space...'
sync && swapoff -a && sed -i '/ swap / s/^/#/' /etc/fstab
export KUBECONFIG=/root/.kube/config
}
k8sDeploy () {
echo 'Installing K8s...'
cd ${groot}/contrib/ansible && \
ansible-playbook bootstrap-node.yml && \
ansible-playbook init-cluster.yml
# Sometimes it's still not ready on this stage, let's check it just to be sure
while true ; do
echo "Waiting for node up..."
result=$(kubectl get nodes|awk '{print $2}'| tail -1| grep -nE '^Ready')
if [ -z "$result" ] ; then
break
fi
sleep 10
done
}
InstallRegistry () {
echo ToDo
}
InstallIngress () {
# Allow scheduling on our master node
kubectl taint nodes k8s-demo node-role.kubernetes.io/master-
# Installing Ingress
helm repo add nginx-stable https://helm.nginx.com/stable && \
helm repo update && \
helm install nginx-stable/nginx-ingress --namespace kube-system --generate-name --set rbac.create=true
}
if [ ! -f ${bootflag} ]; then
touch ${bootflag}
k8sDemoWA;
k8sDeploy;
InstallIngress;
InstallRegistry
fi