forked from rsundara/cp4i-datapower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·162 lines (131 loc) · 4.24 KB
/
install.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
echo
echo "Install IBM DataPower Service"
echo
# Set the project
PROJECT=cp4i
# Define the location of the directories
CONFIG_DIR=../drouter/config
LOCAL_DIR=../drouter/local
USRCERTS_DIR=../drouter/secure/usrcerts
MANIFESTS_DIR=../manifests
# Set the instance name
DP_SERVICE_NAME=dp-demo-dev
if [ ! -z "$SERVICE_NAME" ]; then
DP_SERVICE_NAME=$SERVICE_NAME;
fi;
# Set the limits for resources
LIMITS_CPU=4
LIMITS_MEMORY=8Gi
# In case of production, it can be set to "3"
REPLICA_COUNT=1
if [ "$PRODUCTION" = "true" ]; then
REPLICA_COUNT=3;
fi;
#
# Compute revised datapowerservice.yaml
#
sed "s/PARM_DP_SERVICE_NAME/$DP_SERVICE_NAME/g" $MANIFESTS_DIR/datapowerservice-template.yaml > $MANIFESTS_DIR/datapowerservice_revised_1.yaml
sed "s/PARM_REPLICA_COUNT/$REPLICA_COUNT/g" $MANIFESTS_DIR/datapowerservice_revised_1.yaml > $MANIFESTS_DIR/datapowerservice_revised_2.yaml
sed "s/PARM_LIMITS_CPU/$LIMITS_CPU/g" $MANIFESTS_DIR/datapowerservice_revised_2.yaml > $MANIFESTS_DIR/datapowerservice_revised_3.yaml
sed "s/PARM_LIMITS_MEMORY/$LIMITS_MEMORY/g" $MANIFESTS_DIR/datapowerservice_revised_3.yaml > $MANIFESTS_DIR/datapowerservice.yaml
rm $MANIFESTS_DIR/datapowerservice_revised_1.yaml
rm $MANIFESTS_DIR/datapowerservice_revised_2.yaml
rm $MANIFESTS_DIR/datapowerservice_revised_3.yaml
echo
echo Contents of $MANIFESTS_DIR/datapowerservice.yaml
echo
cat $MANIFESTS_DIR/datapowerservice.yaml
echo
echo
#
# Compute revised service.yaml
#
DATAPOWER_INSTANCE_NAME=$PROJECT-$DP_SERVICE_NAME
sed "s/PARM_DATAPOWER_INSTANCE_NAME/$DATAPOWER_INSTANCE_NAME/g" $MANIFESTS_DIR/service-template.yaml > $MANIFESTS_DIR/service.yaml
echo
echo Contents of $MANIFESTS_DIR/service.yaml
echo
cat $MANIFESTS_DIR/service.yaml
echo
echo
#
# Compute revised admin-route.yaml
#
# Set the instance name
OCP_DOMAIN_SUFFIX=$DOMAIN_SUFFIX
if [ -z "$OCP_DOMAIN_SUFFIX" ]; then
OCP_DOMAIN_SUFFIX=$(oc get dns cluster -o yaml | grep baseDomain: | awk -F' ' '{print $2 }')
fi;
echo
echo Domain suffix is $OCP_DOMAIN_SUFFIX TEST
echo
OCP_DOMAIN_SUFFIX=mycluster-wdc04-b-807030-97f2cdaea86b0f55496562172dc793b6-0000.us-east.containers.appdomain.cloud
DP_ADMIN_HOST_NAME=dp-admin.$OCP_DOMAIN_SUFFIX
sed "s/PARM_DP_ADMIN_HOST_NAME/$DP_ADMIN_HOST_NAME/g" $MANIFESTS_DIR/admin-route-template.yaml > $MANIFESTS_DIR/admin-route.yaml
echo
echo Contents of $MANIFESTS_DIR/admin-route.yaml
echo
cat $MANIFESTS_DIR/admin-route.yaml
echo
#
# Compute revised app-route.yaml
#
DP_DEMO_HOST_NAME=dp-demo.$OCP_DOMAIN_SUFFIX
sed "s/PARM_DP_DEMO_HOST_NAME/$DP_DEMO_HOST_NAME/g" $MANIFESTS_DIR/app-route-template.yaml > $MANIFESTS_DIR/app-route.yaml
echo
echo Contents of $MANIFESTS_DIR/app-route.yaml
echo
cat $MANIFESTS_DIR/app-route.yaml
echo
# Create tar file of contents of local directory of IDP application domain
tar --directory=$LOCAL_DIR/IDP -czvf idp-local.tar.gz .
#
# Create config maps
#
echo
echo Create configMap objects to store application domain configurations
echo
oc delete configmap web-mgmt
oc apply -f $MANIFESTS_DIR/web-mgmt-configmap.yaml
oc delete configmap idp-config
oc create configmap idp-config --from-file=$CONFIG_DIR/IDP/IDP.cfg
oc delete configmap idp-local
oc create configmap idp-local --from-file=./idp-local.tar.gz
#
# Create secrets
#
echo
echo Create secrets to store the certificates
echo
oc delete secret idp-privkey
oc create secret generic idp-privkey --from-file=$USRCERTS_DIR/IDP/IDP-privkey.pem
oc delete secret idp-sscert
oc create secret generic idp-sscert --from-file=$USRCERTS_DIR/IDP/IDP-sscert.pem
oc delete secret admin-credentials
oc apply -f $MANIFESTS_DIR/admin-credentials.yaml
#
# Create service and routes
#
echo
echo Create service and routes
echo
oc apply -f $MANIFESTS_DIR/service.yaml
oc apply -f $MANIFESTS_DIR/admin-route.yaml
oc apply -f $MANIFESTS_DIR/app-route.yaml
#
# Create datapowerservice
#
echo
echo Create DataPower service
echo
oc apply -f $MANIFESTS_DIR/datapowerservice.yaml
# Perform cleanup of the temp files created
rm ./idp-local.tar.gz
rm $MANIFESTS_DIR/datapowerservice.yaml
rm $MANIFESTS_DIR/service.yaml
rm $MANIFESTS_DIR/admin-route.yaml
rm $MANIFESTS_DIR/app-route.yaml
echo
echo "Install of IBM DataPower Service is now complete"
echo