Skip to content

Commit

Permalink
Export env vars needed for SSH access
Browse files Browse the repository at this point in the history
Export environment variables needed for SSH access into nodes
needed for running tests that required SSH access:
- hack/util.sh: rename SSH_KEY_FILE to AZURE_SSH_KEY and export it
- scripts/ci-entrypoint.sh: setup the bastion and user env vars
  • Loading branch information
aravindhp authored and k8s-infra-cherrypick-robot committed Nov 18, 2023
1 parent 34b9813 commit 853fc91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ capz::util::generate_ssh_key() {
AZURE_SSH_PUBLIC_KEY_FILE=${AZURE_SSH_PUBLIC_KEY_FILE:-""}
if [ -z "${AZURE_SSH_PUBLIC_KEY_FILE}" ]; then
echo "generating sshkey for e2e"
SSH_KEY_FILE=.sshkey
rm -f "${SSH_KEY_FILE}" 2>/dev/null
ssh-keygen -t rsa -b 2048 -f "${SSH_KEY_FILE}" -N '' 1>/dev/null
AZURE_SSH_PUBLIC_KEY_FILE="${SSH_KEY_FILE}.pub"
AZURE_SSH_KEY=.sshkey
rm -f "${AZURE_SSH_KEY}" 2>/dev/null
ssh-keygen -t rsa -b 2048 -f "${AZURE_SSH_KEY}" -N '' 1>/dev/null
AZURE_SSH_PUBLIC_KEY_FILE="${AZURE_SSH_KEY}.pub"
# This is needed to run tests that required SSH access to nodes
export AZURE_SSH_KEY
fi
AZURE_SSH_PUBLIC_KEY_B64=$(base64 < "${AZURE_SSH_PUBLIC_KEY_FILE}" | tr -d '\r\n')
export AZURE_SSH_PUBLIC_KEY_B64
Expand Down
6 changes: 6 additions & 0 deletions scripts/ci-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ create_cluster() {
echo "Unable to find kubeconfig for kind mgmt cluster ${KIND_CLUSTER_NAME}"
exit 1
fi

# set the SSH bastion and user that can be used to SSH into nodes
KUBE_SSH_BASTION=$(${KUBECTL} get azurecluster -o json | jq '.items[0].spec.networkSpec.apiServerLB.frontendIPs[0].publicIP.dnsName' | tr -d \"):22
export KUBE_SSH_BASTION
KUBE_SSH_USER=capi
export KUBE_SSH_USER
}

# get_cidrs derives the CIDR from the Cluster's '.spec.clusterNetwork.pods.cidrBlocks' metadata
Expand Down

0 comments on commit 853fc91

Please sign in to comment.