forked from IBM/container-service-getting-started-wt
-
Notifications
You must be signed in to change notification settings - Fork 6
/
deploy.sh
executable file
·88 lines (74 loc) · 2.77 KB
/
deploy.sh
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
echo "Create Demo Application"
IP_ADDR=$(ibmcloud ks workers $CLUSTER_NAME | grep normal | awk '{ print $2 }')
if [ -z $IP_ADDR ]; then
echo "$CLUSTER_NAME not created or workers not ready"
exit 1
fi
echo -e "Configuring vars"
exp=$(ibmcloud ks cluster-config $CLUSTER_NAME | grep export)
if [ $? -ne 0 ]; then
echo "Cluster $CLUSTER_NAME not created or not ready."
exit 1
fi
eval "$exp"
echo -e "Setting up Stage 3 Watson Deployment yml"
cd Stage3/
# curl --silent "https://raw.githubusercontent.com/IBM/container-service-getting-started-wt/master/Stage3/watson-deployment.yml" > watson-deployment.yml
#
## WILL NEED FOR LOADBALANCER ###
# #Find the line that has the comment about the load balancer and add the nodeport def after this
# let NU=$(awk '/^ # type: LoadBalancer/{ print NR; exit }' guestbook.yml)+3
# NU=$NU\i
# sed -i "$NU\ \ type: NodePort" guestbook.yml #For OSX: brew install gnu-sed; replace sed references with gsed
echo -e "Deleting previous version of Watson Deployment if it exists"
kubectl delete --ignore-not-found=true -f watson-deployment.yml
echo -e "Unbinding previous version of Watson Tone Analyzer if it exists"
ibmcloud service list | grep tone
if [ $? -eq 0 ]; then
ibmcloud ks cluster-service-unbind $CLUSTER_NAME default tone
fi
echo -e "Deleting previous Watson Tone Analyzer instance if it exists"
ibmcloud service delete tone -f
echo -e "Creating new instance of Watson Tone Analyzer named tone..."
ibmcloud service create tone_analyzer standard tone
echo -e "Binding Watson Tone Service to Cluster and Pod"
ibmcloud ks cluster-service-bind $CLUSTER_NAME default tone
echo -e "Building Watson and Watson-talk images..."
cd watson/
docker build -t registry.ng.bluemix.net/contbot/watson . &> buildout.txt
if [ $? -ne 0 ]; then
echo "Could not create the watson image for the build"
cat buildout.txt
exit 1
fi
docker push registry.ng.bluemix.net/contbot/watson
if [ $? -ne 0 ]; then
echo "Could not push the watson image for the build"
exit 1
fi
cd ..
cd watson-talk/
docker build -t registry.ng.bluemix.net/contbot/watson-talk . &> buildout.txt
if [ $? -ne 0 ]; then
echo "Could not create the watson-talk image for the build"
cat buildout.txt
exit 1
fi
docker push registry.ng.bluemix.net/contbot/watson-talk
if [ $? -ne 0 ] ; then
echo "Could not push the watson image for the build"
exit 1
fi
echo -e "Injecting image namespace into deployment yamls"
cd ..
sed -i "s/<namespace>/${BLUEMIX_NAMESPACE}/" watson-deployment.yml
if [ $? -ne 0 ] ; then
echo "Could not inject image namespace into deployment yaml"
exit 1
fi
echo -e "Creating pods"
kubectl create -f watson-deployment.yml
PORT=$(kubectl get services | grep watson-service | sed 's/.*:\([0-9]*\).*/\1/g')
echo ""
echo "View the watson talk service at http://$IP_ADDR:$PORT"