Skip to content

Commit 522fe9a

Browse files
authored
capz: use provider-agnostic bastion resolution (#520)
this commit fixes the resolution of the bastion endpoint by querying the cluster resource managed by CAPI to resolve the API server endpoint.
1 parent 08d27bb commit 522fe9a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

capz/run-capz-e2e.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,22 @@ create_cluster(){
264264
log "cluster creation complete"
265265
fi
266266

267+
log "wait for "${CLUSTER_NAME}" cluster to stabilize"
268+
timeout --foreground 300 bash -c "until kubectl get --raw /version --request-timeout 5s > /dev/null 2>&1; do sleep 3; done"
269+
270+
CLUSTER_JSON=$(kubectl get cluster "${CLUSTER_NAME}" -n default -o json || true)
271+
if [[ -z "${CLUSTER_JSON}" ]]; then
272+
log "ERROR: failed to get cluster "${CLUSTER_NAME}" in namespace default"
273+
exit 1
274+
fi
275+
BASTION_ADDRESS=$(echo "${CLUSTER_JSON}" | jq -r '.spec.controlPlaneEndpoint.host // empty')
276+
if [[ -z "${BASTION_ADDRESS}" ]]; then
277+
log "ERROR: bastion address lookup failed for cluster"
278+
echo "${CLUSTER_JSON}"
279+
exit 1
280+
fi
267281
# set the SSH bastion that can be used to SSH into nodes
268-
KUBE_SSH_BASTION=$(kubectl get azurecluster -o json | jq '.items[0].spec.networkSpec.apiServerLB.frontendIPs[0].publicIP.dnsName' | tr -d \"):22
269-
export KUBE_SSH_BASTION
282+
export KUBE_SSH_BASTION="${BASTION_ADDRESS}:22"
270283
KUBE_SSH_USER=capi
271284
export KUBE_SSH_USER
272285
log "bastion info: $KUBE_SSH_USER@$KUBE_SSH_BASTION"
@@ -282,7 +295,7 @@ create_cluster(){
282295
apply_workload_configuraiton(){
283296
log "wait for cluster to stabilize"
284297
timeout --foreground 300 bash -c "until kubectl get --raw /version --request-timeout 5s > /dev/null 2>&1; do sleep 3; done"
285-
298+
286299
log "installing calico"
287300
"$TOOLS_BIN_DIR"/helm repo add projectcalico https://docs.tigera.io/calico/charts
288301
kubectl create ns calico-system

0 commit comments

Comments
 (0)