coins-demo/contrib/firstboot.sh

45 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/bash
2020-07-31 13:32:43 +00:00
bootflag='/.manufactured'
2020-07-31 11:33:22 +00:00
groot='/opt/coins-demo'
k8sDemoWA () {
2020-07-31 15:04:12 +00:00
printf "\033c"
2020-07-31 11:33:22 +00:00
echo 'Disabling swap space...'
sync && swapoff -a && sed -i '/ swap / s/^/#/' /etc/fstab
2020-07-31 15:04:12 +00:00
export KUBECONFIG=/root/.kube/config
2020-07-31 11:33:22 +00:00
}
2020-07-31 14:44:43 +00:00
k8sDeploy () {
2020-07-31 11:33:22 +00:00
echo 'Installing K8s...'
cd ${groot}/contrib/ansible && \
ansible-playbook bootstrap-node.yml && \
ansible-playbook init-cluster.yml
2020-08-01 15:03:57 +00:00
# Sometimes it's still not ready on this stage, let's check it just to be sure
2020-08-01 14:33:34 +00:00
while true ; do
2020-08-01 15:03:57 +00:00
echo "Waiting for node up..."
2020-08-01 14:33:34 +00:00
result=$(kubectl get nodes|awk '{print $2}'| tail -1| grep -nE '^Ready')
if [ -z "$result" ] ; then
break
fi
2020-08-01 15:03:57 +00:00
sleep 10
2020-08-01 14:33:34 +00:00
done
}
2020-08-01 15:03:57 +00:00
InstallRegistry () {
echo ToDo
}
2020-08-01 14:33:34 +00:00
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
2020-07-31 11:33:22 +00:00
}
2020-07-31 13:32:43 +00:00
if [ ! -f ${bootflag} ]; then
touch ${bootflag}
k8sDemoWA;
2020-07-31 14:44:43 +00:00
k8sDeploy;
2020-08-01 14:33:34 +00:00
InstallIngress;
2020-08-01 15:03:57 +00:00
InstallRegistry
2020-07-31 13:32:43 +00:00
fi