Skip to content

Commit 6311021

Browse files
committed
fix: use correct mongo user password to instance config
SE-6524
1 parent 2bcaef0 commit 6311021

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

manifests/phd-mongodb-provision-template.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,12 @@ spec:
137137
#!/bin/sh
138138
set -e
139139
140+
NAMESPACE="{{workflow.parameters.namespace}}"
140141
DATABASE_NAME="{{workflow.parameters.database-name}}"
141142
USERNAME="{{workflow.parameters.username}}"
142143
PASSWORD="{{workflow.parameters.password}}"
143144
MONGODB_CLUSTER_ID="{{workflow.parameters.mongodb-cluster-id}}"
144-
K8s_API_BEARER_TOKEN="{{k8s-api-bearer-token}}"
145+
K8s_API_BEARER_TOKEN="{{workflow.parameters.k8s-api-bearer-token}}"
145146
146147
echo "Creating user via DigitalOcean API: $USERNAME for database $DATABASE_NAME"
147148
echo "The current password is $PASSWORD"
@@ -166,12 +167,16 @@ spec:
166167
167168
echo "Saving MongoDB user password to kubernetes secret"
168169
169-
echo "$K8s_API_BEARER_TOKEN"
170-
cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
171170
BASE64_ENCODED_PASSWORD=$(echo -n "$PASSWORD" | base64)
172-
echo "$BASE64_ENCODED_PASSWORD"
173171
174-
echo ""
172+
K8S_RESPONSE=$(curl -s -X POST \
173+
-H "Content-Type: application/json" \
174+
-H "Authorization: $K8s_API_BEARER_TOKEN" \
175+
--cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
176+
-d '{"apiVersion": "v1","kind": "Secret","metadata": {"name": "phd-mongodb-user-password","namespace": "$NAMESPACE"},"type": "Opaque","data": {"phd-mongodb-user-password": "$BASE64_ENCODED_PASSWORD"}}' \
177+
"https://kubernetes.default.svc/api/v1/namespaces/$NAMESPACE/secrets")
178+
179+
echo "MongoDB user password saved to kubernetes secret \"phd-mongodb-user-password\" in namespace $NAMESPACE"
175180
echo "MongoDB provisioning completed (DigitalOcean API)"
176181
177182

0 commit comments

Comments
 (0)