-
Notifications
You must be signed in to change notification settings - Fork 9
/
config-init.sh
54 lines (45 loc) · 1.78 KB
/
config-init.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
mkdir /data/docker/RO-crates -p
mkdir /data/docker/user-data/shared -p
mkdir /data/docker/tmp-images -p
mkdir /data/docker/tmp -p
mkdir /data/docker/workflows/tmp-workflows -p
mkdir /data/docker/workflows-svg -p
mkdir /data/docker/archived_workflows -p
mkdir /data/docker/profiles -p
touch /data/containerized
mkdir /root/.kube/
chmod 777 /data/docker -R
## Create a kubeconfig file in order for www-data to be able to run kubectl commands
KUBECFG_FILE_NAME="/root/.kube/config"
SECRETS_FOLDER="/run/secrets/kubernetes.io/serviceaccount"
SERVICE_ACCOUNT_NAME="schema-kubectl"
NAMESPACE=$(cat ${SECRETS_FOLDER}/namespace)
CLUSTER_NAME="schema-cluster"
ENDPOINT=$CLUSTER_ENDPOINT
CERTAUTH=${SECRETS_FOLDER}/ca.crt
USER_TOKEN=$(cat ${SECRETS_FOLDER}/token)
# Set up the config
echo -e "\\nPreparing k8s-${SERVICE_ACCOUNT_NAME}-${NAMESPACE}-conf"
echo -n "Setting a cluster entry in kubeconfig..."
kubectl config set-cluster "${CLUSTER_NAME}" \
--kubeconfig="${KUBECFG_FILE_NAME}" \
--server="${ENDPOINT}" \
--certificate-authority="${SECRETS_FOLDER}/ca.crt" \
--embed-certs=true
echo -n "Setting token credentials entry in kubeconfig..."
kubectl config set-credentials \
"${SERVICE_ACCOUNT_NAME}-${NAMESPACE}-${CLUSTER_NAME}" \
--kubeconfig="${KUBECFG_FILE_NAME}" \
--token="${USER_TOKEN}"
echo -n "Setting a context entry in kubeconfig..."
kubectl config set-context \
"${SERVICE_ACCOUNT_NAME}-${NAMESPACE}-${CLUSTER_NAME}" \
--kubeconfig="${KUBECFG_FILE_NAME}" \
--cluster="${CLUSTER_NAME}" \
--user="${SERVICE_ACCOUNT_NAME}-${NAMESPACE}-${CLUSTER_NAME}" \
--namespace="${NAMESPACE}"
echo -n "Setting the current-context in the kubeconfig file..."
kubectl config use-context "${SERVICE_ACCOUNT_NAME}-${NAMESPACE}-${CLUSTER_NAME}" \
--kubeconfig="${KUBECFG_FILE_NAME}"
# Run the main apache process
apache2-foreground