Skip to content

Commit

Permalink
initial stub for falling back to curl when az login --identity fails
Browse files Browse the repository at this point in the history
  • Loading branch information
nawazkh committed Sep 5, 2024
1 parent 3bf7e50 commit bafa6ab
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 43 deletions.
26 changes: 20 additions & 6 deletions templates/test/ci/cluster-template-prow-ci-version-dual-stack.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 20 additions & 6 deletions templates/test/ci/cluster-template-prow-ci-version-ipv6.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 20 additions & 6 deletions templates/test/ci/cluster-template-prow-ci-version.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,26 @@
set -o errexit
[[ $(id -u) != 0 ]] && SUDO="sudo" || SUDO=""
echo "Use OOT credential provider"
mkdir -p /var/lib/kubelet/credential-provider
curl --retry 10 --retry-delay 5 -w "response status code is %{http_code}" -Lo /var/lib/kubelet/credential-provider/acr-credential-provider "https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/${AZURE_BLOB_CONTAINER_NAME}/${IMAGE_TAG_ACR_CREDENTIAL_PROVIDER}/azure-acr-credential-provider"
chmod 755 /var/lib/kubelet/credential-provider/acr-credential-provider
curl --retry 10 --retry-delay 5 -w "response status code is %{http_code}" -Lo /var/lib/kubelet/credential-provider-config.yaml "https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/${AZURE_BLOB_CONTAINER_NAME}/${IMAGE_TAG_ACR_CREDENTIAL_PROVIDER}/credential-provider-config.yaml"
chmod 644 /var/lib/kubelet/credential-provider-config.yaml
# Run the az login command with managed identity
output=$(az login --identity 2>&1)
status=$?
if [ $status -eq 0 ]; then
echo "Logged in Azure with managed identity"
az login --identity
echo "Use OOT credential provider"
mkdir -p /var/lib/kubelet/credential-provider
az storage blob download --blob-url "https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/${AZURE_BLOB_CONTAINER_NAME}/${IMAGE_TAG_ACR_CREDENTIAL_PROVIDER}/azure-acr-credential-provider" -f /var/lib/kubelet/credential-provider/acr-credential-provider --auth-mode login
chmod 755 /var/lib/kubelet/credential-provider/acr-credential-provider
az storage blob download --blob-url "https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/${AZURE_BLOB_CONTAINER_NAME}/${IMAGE_TAG_ACR_CREDENTIAL_PROVIDER}/credential-provider-config.yaml" -f /var/lib/kubelet/credential-provider-config.yaml --auth-mode login
chmod 644 /var/lib/kubelet/credential-provider-config.yaml
else
echo "Using curl to download the OOT credential provider"
mkdir -p /var/lib/kubelet/credential-provider
curl --retry 10 --retry-delay 5 -w "response status code is %{http_code}" -Lo /var/lib/kubelet/credential-provider/acr-credential-provider "https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/${AZURE_BLOB_CONTAINER_NAME}/${IMAGE_TAG_ACR_CREDENTIAL_PROVIDER}/azure-acr-credential-provider"
chmod 755 /var/lib/kubelet/credential-provider/acr-credential-provider
curl --retry 10 --retry-delay 5 -w "response status code is %{http_code}" -Lo /var/lib/kubelet/credential-provider-config.yaml "https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/${AZURE_BLOB_CONTAINER_NAME}/${IMAGE_TAG_ACR_CREDENTIAL_PROVIDER}/credential-provider-config.yaml"
chmod 644 /var/lib/kubelet/credential-provider-config.yaml
fi
path: /tmp/oot-cred-provider.sh
owner: "root:root"
permissions: "0744"
Expand All @@ -37,4 +51,4 @@
- op: add
path: /spec/kubeadmConfigSpec/joinConfiguration/nodeRegistration/kubeletExtraArgs/image-credential-provider-config
value:
/var/lib/kubelet/credential-provider-config.yaml
/var/lib/kubelet/credential-provider-config.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bafa6ab

Please sign in to comment.