-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·197 lines (162 loc) · 4.17 KB
/
entrypoint.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
set -e
if [ "$1" = 'apiserver' ]; then
if [ -z "$WORKBENCH_NAME" ]; then
WORKBENCH_NAME="Labs Workbench"
fi
if [ -z "$ETCD_ADDR" ]; then
ETCD_ADDR="localhost:4001"
fi
if [ -z "$KUBERNETES_ADDR" ]; then
KUBERNETES_ADDR="https://localhost:6443"
fi
if [ -z "$CORS_ORIGIN_ADDR" ]; then
CORS_ORIGIN_ADDR="http://localhost"
fi
if [ -z "$PREFIX" ]; then
PREFIX="/api/"
fi
if [ -z "$TIMEOUT" ]; then
TIMEOUT="30"
fi
if [ -z "$INGRESS" ]; then
INGRESS="NodePort"
fi
if [ -z "$HOME_PVC_SUFFIX" ]; then
HOME_PVC_SUFFIX="-home"
fi
if [ -z "$PVC_STORAGE_CLASS" ]; then
PVC_STORAGE_CLASS="nfs"
fi
if [ -z "$SHARED_VOLUME_PATH" ]; then
SHARED_VOLUME_PATH="/shared"
fi
if [ -z "$SHARED_VOLUME_NAME" ]; then
SHARED_VOLUME_NAME="shared"
fi
if [ -z "$SHARED_VOLUME_READ_ONLY" ]; then
SHARED_VOLUME_READ_ONLY="false"
fi
if [ -z "$SMTP_HOST" ]; then
SMTP_HOST="smtp.ncsa.illinois.edu"
fi
if [ -z "$SMTP_PORT" ]; then
SMTP_PORT=25
fi
if [ -z "$SMTP_TLS" ]; then
SMTP_TLS=true
fi
if [ -z "$SUPPORT_EMAIL" ]; then
SUPPORT_EMAIL="[email protected]"
fi
if [ -z "$SUPPORT_FORUM" ]; then
SUPPORT_FORUM="https://groups.google.com/forum/#!forum/ndslabs"
fi
if [ -z "$SUPPORT_CHAT" ]; then
SUPPORT_CHAT="https://gitter.im/nds-org/ndslabs"
fi
if [ -z "$ADMIN_PASSWORD" ]; then
ADMIN_PASSWORD=`strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'`
fi
if [ -z "$REQUIRE_APPROVAL" ]; then
REQUIRE_APPROVAL="true"
fi
if [ -z "$MAX_MESSAGES" ]; then
MAX_MESSAGES=100
fi
if [ -z "$INACTIVITY_TIMEOUT" ]; then
INACTIVITY_TIMEOUT=480
fi
if [ -z "$TOKEN_PATH" ]; then
TOKEN_PATH="/run/secrets/kubernetes.io/serviceaccount/token"
fi
if [ -z "$SIGNIN_URL" ]; then
SIGNIN_URL="$CORS_ORIGIN_ADDR/login/#/",
fi
if [ -z "$AUTH_URL" ]; then
AUTH_URL="$CORS_ORIGIN_ADDR/cauth/auth"
fi
cat << EOF > /apiserver.json
{
"port": "30001",
"adminPort": "30002",
"origin": "$CORS_ORIGIN_ADDR",
"timeout": $TIMEOUT,
"requireApproval": $REQUIRE_APPROVAL,
"domain" : "$DOMAIN",
"prefix" : "$PREFIX",
"ingress": "$INGRESS",
"username": "admin",
"password": "admin",
"homePvcSuffix": "$HOME_PVC_SUFFIX",
"name": "$WORKBENCH_NAME",
"dataProviderURL": "$DATA_PROVIDER_URL",
"authSignInURL": "$SIGNIN_URL",
"authURL": "$AUTH_URL",
"support": {
"email": "$SUPPORT_EMAIL",
"forum": "$SUPPORT_FORUM",
"chat": "$SUPPORT_CHAT"
},
"defaultLimits": {
"cpuMax": 2000,
"cpuDefault": 1000,
"memMax": 8196,
"memDefault": 100,
"storageDefault": 10,
"inactiveTimeout": $INACTIVITY_TIMEOUT
},
"etcd": {
"address": "$ETCD_ADDR",
"maxMessages": $MAX_MESSAGES
},
"kubernetes": {
"address": "$KUBERNETES_ADDR",
"username": "admin",
"password": "admin",
"tokenPath": "$TOKEN_PATH",
"nodeSelectorName": "$NODE_SELECTOR_NAME",
"nodeSelectorValue": "$NODE_SELECTOR_VALUE",
"pvcStorageClass": "$PVC_STORAGE_CLASS"
},
"email": {
"host": "$SMTP_HOST",
"port": $SMTP_PORT,
"tls": $SMTP_TLS
},
"certmgr": {
"clusterIssuer": "$TLS_CLUSTER_ISSUER",
"issuer": "$TLS_ISSUER"
},
"specs": {
"path": "/specs"
},
"volumes": [
{
"name": "$SHARED_VOLUME_NAME",
"path": "$SHARED_VOLUME_PATH",
"readOnly": $SHARED_VOLUME_READ_ONLY
}
]
}
EOF
if [ -z "$SPEC_GIT_REPO" ]; then
SPEC_GIT_REPO=https://github.com/nds-org/ndslabs-specs
fi
if [ -z "$SPEC_GIT_BRANCH" ]; then
SPEC_GIT_BRANCH=master
fi
git clone -b $SPEC_GIT_BRANCH $SPEC_GIT_REPO /specs
echo "Cloned $SPEC_GIT_BRANCH $SPEC_GIT_REPO"
echo $ADMIN_PASSWORD > /password.txt
umask 0
if [ -z "$TEST" ]; then
apiserver -conf /apiserver.json --logtostderr=true -v=1 -passwd $ADMIN_PASSWORD
else
echo "Running binary with test/coverage instrumentation"
echo "Writing output to $VOLUME_PATH/coverage.out"
apiserver -test.coverprofile=$VOLUME_PATH/coverage.out -test.v -test.run=TestRunMain
fi
else
exec "$@"
fi