Skip to content

Commit 4863e1d

Browse files
authored
Merge pull request #41 from appuio/feat/lieutenant-api-vault
Read Vault address and login method from Lieutenant API
2 parents 4afb97c + 39cf665 commit 4863e1d

6 files changed

Lines changed: 32 additions & 19 deletions

File tree

workflows/cloudscale/decommission-steps.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ spells:
66
- name: vault_address
77
description: |-
88
Address of the Vault server associated with the Lieutenant API to store cluster secrets.
9-
10-
https://vault-prod.syn.vshn.net/ for production clusters.
11-
https://vault-int.syn.vshn.net/ for test clusters.
9+
- name: vault_login_method
1210
- name: commodore_cluster_id
1311
- name: commodore_tenant_id
1412
outputs:
@@ -19,7 +17,7 @@ spells:
1917
run: |
2018
set -euo pipefail
2119
export VAULT_ADDR=${INPUT_vault_address}
22-
vault login -method=oidc
20+
vault login -method=${INPUT_vault_login_method}
2321
2422
token=$(vault kv get -format=json \
2523
"clusters/kv/${INPUT_commodore_tenant_id}/${INPUT_commodore_cluster_id}/cloudscale" | \
@@ -257,6 +255,7 @@ spells:
257255
inputs:
258256
- name: cloudscale_token
259257
- name: vault_address
258+
- name: vault_login_method
260259
- name: commodore_cluster_id
261260
- name: commodore_api_url
262261
- name: backup_deletion_confirmation
@@ -293,7 +292,7 @@ spells:
293292
git archive --remote "${REPO_URL}" master | tar -xC catalog
294293
295294
export VAULT_ADDR=${INPUT_vault_address}
296-
vault login -method=oidc
295+
vault login -method=${INPUT_vault_login_method}
297296
298297
# extract restic credentials from catalog and vault
299298
restic_repo=s3:$(yq -o=json 'select(.kind == "Schedule")| .spec.backend.s3 | .endpoint + "/" + .bucket' catalog/manifests/cluster-backup/10_object.yaml | tr -d '"')

workflows/cloudscale/init-steps.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ spells:
7373
- name: vault_address
7474
description: |-
7575
Address of the Vault server associated with the Lieutenant API to store cluster secrets.
76-
77-
https://vault-prod.syn.vshn.net/ for production clusters.
76+
- name: vault_login_method
7877
- name: commodore_cluster_id
7978
- name: commodore_tenant_id
8079
- name: bucket_user
@@ -89,7 +88,7 @@ spells:
8988
set -euo pipefail
9089
9190
export VAULT_ADDR=${INPUT_vault_address}
92-
vault login -method=oidc
91+
vault login -method=${INPUT_vault_login_method}
9392
9493
# Set the cloudscale.ch access secrets
9594
vault kv put clusters/kv/${INPUT_commodore_tenant_id}/${INPUT_commodore_cluster_id}/cloudscale \
@@ -198,6 +197,7 @@ spells:
198197
- name: base_domain
199198
- name: cluster_domain
200199
- name: vault_address
200+
- name: vault_login_method
201201
- name: redhat_pull_secret
202202
- name: csp_region
203203
- name: bucket_user
@@ -214,7 +214,7 @@ spells:
214214
}
215215
216216
export VAULT_ADDR="${INPUT_vault_address}"
217-
vault login -method=oidc
217+
vault login -method="${INPUT_vault_login_method}"
218218
219219
ssh_private_key="$(pwd)/ssh_${INPUT_commodore_cluster_id}"
220220
ssh_public_key="${ssh_private_key}.pub"
@@ -821,14 +821,15 @@ spells:
821821
inputs:
822822
- name: commodore_api_url
823823
- name: vault_address
824+
- name: vault_login_method
824825
- name: kubeconfig_path
825826
run: |
826827
set -euo pipefail
827828
export COMMODORE_API_URL="${INPUT_commodore_api_url}"
828829
export KUBECONFIG="${INPUT_kubeconfig_path}"
829830
830831
export VAULT_ADDR=${INPUT_vault_address}
831-
vault login -method=oidc
832+
vault login -method=${INPUT_vault_login_method}
832833
833834
echo '# Applying cert-manager ... #'
834835
kubectl apply -f catalog/manifests/cert-manager/00_namespace.yaml

workflows/exoscale/decommission-steps.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ spells:
199199
- name: exoscale_key
200200
- name: exoscale_secret
201201
- name: vault_address
202+
- name: vault_login_method
202203
- name: commodore_cluster_id
203204
- name: commodore_api_url
204205
- name: backup_deletion_confirmation
@@ -238,7 +239,7 @@ spells:
238239
git archive --remote "${REPO_URL}" master | tar -xC catalog
239240
240241
export VAULT_ADDR=${INPUT_vault_address}
241-
vault login -method=oidc
242+
vault login -method=${INPUT_vault_login_method}
242243
243244
# extract restic credentials from catalog and vault
244245
restic_repo=s3:$(yq -o=json 'select(.kind == "Schedule")| .spec.backend.s3 | .endpoint + "/" + .bucket' catalog/manifests/cluster-backup/10_object.yaml | tr -d '"')

workflows/exoscale/init-steps.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ spells:
231231
- name: vault_address
232232
description: |-
233233
Address of the Vault server associated with the Lieutenant API to store cluster secrets.
234-
235-
https://vault-prod.syn.vshn.net/ for production clusters.
234+
- name: vault_login_method
236235
- name: commodore_cluster_id
237236
- name: commodore_tenant_id
238237
- name: s3_key
@@ -249,7 +248,7 @@ spells:
249248
set -euo pipefail
250249
251250
export VAULT_ADDR=${INPUT_vault_address}
252-
vault login -method=oidc
251+
vault login -method=${INPUT_vault_login_method}
253252
254253
# Set the Exoscale object storage API key
255254
vault kv put clusters/kv/${INPUT_commodore_tenant_id}/${INPUT_commodore_cluster_id}/exoscale/storage_iam \
@@ -353,6 +352,7 @@ spells:
353352
- name: base_domain
354353
- name: cluster_domain
355354
- name: vault_address
355+
- name: vault_login_method
356356
- name: redhat_pull_secret
357357
- name: ccm_key
358358
- name: ccm_secret
@@ -370,7 +370,7 @@ spells:
370370
}
371371
372372
export VAULT_ADDR="${INPUT_vault_address}"
373-
vault login -method=oidc
373+
vault login -method="${INPUT_vault_login_method}"
374374
375375
ssh_private_key="$(pwd)/ssh_${INPUT_commodore_cluster_id}"
376376
ssh_public_key="${ssh_private_key}.pub"
@@ -895,6 +895,7 @@ spells:
895895
inputs:
896896
- name: commodore_api_url
897897
- name: vault_address
898+
- name: vault_login_method
898899
- name: kubeconfig_path
899900
run: |
900901
set -euo pipefail
@@ -903,7 +904,7 @@ spells:
903904
export KUBECONFIG="${INPUT_kubeconfig_path}"
904905
905906
export VAULT_ADDR=${INPUT_vault_address}
906-
vault login -method=oidc
907+
vault login -method=${INPUT_vault_login_method}
907908
908909
echo '# Applying cert-manager ... #'
909910
kubectl apply -f catalog/manifests/cert-manager/00_namespace.yaml

workflows/shared/decommission-steps.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ spells:
4949
during decommissioning.
5050
inputs:
5151
- name: vault_address
52+
- name: vault_login_method
5253
- name: commodore_cluster_id
5354
run: |
5455
set -euo pipefail
5556
export VAULT_ADDR=${INPUT_vault_address}
56-
vault login -method=oidc
57+
vault login -method=${INPUT_vault_login_method}
5758
OPSGENIE_KEY=$(vault kv get -format=json \
5859
clusters/kv/__shared__/__shared__/opsgenie/aldebaran | \
5960
jq -r '.data.data["heartbeat-password"]')
@@ -287,6 +288,7 @@ spells:
287288
- name: commodore_cluster_id
288289
- name: commodore_api_url
289290
- name: vault_address
291+
- name: vault_login_method
290292
- name: backup_deletion_confirmation
291293
run: |
292294
set -euo pipefail
@@ -308,7 +310,7 @@ spells:
308310
SECRET_KEY="$(yq -o=json 'select(.kind == "Secret" and .metadata.name == "objects-backup-s3-credentials") | .stringData.password' catalog/manifests/cluster-backup/10_object.yaml | cut -d: -f2)"
309311
310312
export VAULT_ADDR=${INPUT_vault_address}
311-
vault login -method=oidc
313+
vault login -method=${INPUT_vault_login_method}
312314
313315
for secret in $(find catalog/refs/ -type f \
314316
| sed -r -e 's#catalog/refs#clusters/kv#' -e 's#(.*)/.*#\1#' \
@@ -334,11 +336,12 @@ spells:
334336
This step deletes the cluster's OpsGenie heartbeat.
335337
inputs:
336338
- name: vault_address
339+
- name: vault_login_method
337340
- name: commodore_cluster_id
338341
run: |
339342
set -euo pipefail
340343
export VAULT_ADDR=${INPUT_vault_address}
341-
vault login -method=oidc
344+
vault login -method=${INPUT_vault_login_method}
342345
OPSGENIE_KEY=$(vault kv get -format=json \
343346
clusters/kv/__shared__/__shared__/opsgenie/aldebaran | \
344347
jq -r '.data.data["heartbeat-password"]')

workflows/shared/init-steps.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ spells:
3434
You might use the WebUI at https://control.vshn.net/syn/lieutenantapiendpoints to create and manage your clusters.
3535
outputs:
3636
- name: commodore_tenant_id
37+
- name: vault_address
38+
- name: vault_login_method
3739
- name: csp_region
3840
run: |
3941
set -euo pipefail
@@ -47,6 +49,12 @@ spells:
4749
region=$(curl -sH "Authorization: Bearer $(commodore fetch-token)" ${COMMODORE_API_URL}/clusters/${INPUT_commodore_cluster_id} | jq -r .facts.region)
4850
if test -z "$region" && test "$region" != "null" ; then { echo "❌ Failed to retrieve CSP region for cluster ID '$INPUT_commodore_cluster_id'."; exit 1; } ; else { echo "✅ Retrieved CSP region '$region' for cluster ID '$INPUT_commodore_cluster_id'."; } ; fi
4951
env -i "csp_region=$region" >> "$OUTPUT"
52+
53+
echo "Retrieving Vault address and login method..."
54+
vault_addr=$(curl -s "${COMMODORE_API_URL}" | jq -r '.vault.addr')
55+
env -i "vault_address=${vault_addr}" >> "$OUTPUT"
56+
vault_login_method=$(curl -s "${COMMODORE_API_URL}" | jq -r '.vault.loginMethod')
57+
env -i "vault_login_method=${vault_login_method}" >> "$OUTPUT"
5058
- match: And a Keycloak service
5159
description: |-
5260
In this step, you have to create a Keycloak service for the new cluster

0 commit comments

Comments
 (0)