-
Notifications
You must be signed in to change notification settings - Fork 9
/
mkcluster
executable file
·66 lines (53 loc) · 1.96 KB
/
mkcluster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
source .demoscript
# SKIP=1
# Usage: mkcluster cluster-name
# Creates 3 worker-node cluster in IBM Cloud to be used for a Knative demo
set -e
ZONE=${ZONE:-dal13}
MACHINE=${MACHINE:-b2c.4x16}
WORKERS=${WORKERS:-3}
NAME=${1:-kndemo}
comment "Checking to see if the cluster '%{NAME}' already exists..."
if ibmcloud ks clusters | grep "^${NAME} .* normal " > /dev/null 2>&1 ; then
echo Cluster already exists
else
comment Creating ${NAME}
comment Get our VLAN info
doit ibmcloud ks vlans --zone $ZONE
PRI_VLAN=$(grep private out | sed "s/ .*//")
PUB_VLAN=$(grep public out | sed "s/ .*//")
comment Create the cluster
doit echo ibmcloud ks cluster-create --name ${NAME} --zone ${ZONE} \
--machine-type ${MACHINE} \
--workers ${WORKERS} --private-vlan ${PRI_VLAN} \
--public-vlan ${PUB_VLAN} \
--kube-version $(ibmcloud ks kube-versions -s | tail -1)
comment Wait for the cluster to be ready
while ! (ibmcloud ks clusters | tee tmpout | grep "^${NAME} " | grep " normal "); do
grep "^${NAME} " tmpout || true
sleep 30
done
rm tmpout
fi
comment Get the KUBECONFIG export to use
ibmcloud config --check-version false
doit ibmcloud ks cluster-config -s --export ${NAME}
config=$(cat out)
$(${config})
comment Checking for Knative
if ! kubectl get ns knative-serving > /dev/null 2>&1 ; then
comment "Install Knative (and Istio)"
doit ibmcloud ks cluster-addon-enable knative -y --cluster ${NAME}
comment "Wait until Knative is ready..."
wait "kubectl get ns | grep knative-serving"
comment "Knative namespace is there, now waiting for pods..."
wait "kubectl get pods -n knative-serving | grep controller"
wait ! "kubectl get pods --namespace knative-serving | \
grep -v Terminating | grep -v NAME | grep -v Running"
else
comment Knative is already installed
fi
comment Please run the following command to access the cluster:
echo ${config}
echo