Created
March 15, 2024 20:15
-
-
Save ImIOImI/70f456b0f6d4c7e50a7941eaa222e9b6 to your computer and use it in GitHub Desktop.
Test Azure workload identity in a container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference https://blog.baeke.info/2022/05/18/quick-guide-to-kubernetes-workload-identity-on-aks/ | |
echo $AZURE_CLIENT_ID | |
echo $AZURE_TENANT_ID | |
echo $AZURE_FEDERATED_TOKEN_FILE | |
cat $AZURE_FEDERATED_TOKEN_FILE | |
echo $AZURE_AUTHORITY_HOST | |
# list the standard Kubernetes service account secrets | |
cd /var/run/secrets/kubernetes.io/serviceaccount | |
ls | |
# check the folder containing the AZURE_FEDERATED_TOKEN_FILE | |
cd /var/run/secrets/azure/tokens | |
ls | |
# you can use the AZURE_FEDERATED_TOKEN_FILE with the Azure CLI | |
# together with $AZURE_CLIENT_ID and $AZURE_TENANT_ID | |
# a password is not required since we are doing federated token exchange | |
echo "az login --federated-token \"$(cat ${AZURE_FEDERATED_TOKEN_FILE})\" \ | |
--service-principal -u ${AZURE_CLIENT_ID} -t ${AZURE_TENANT_ID}" | |
az login --federated-token "$(cat $AZURE_FEDERATED_TOKEN_FILE)" \ | |
--service-principal -u $AZURE_CLIENT_ID -t $AZURE_TENANT_ID | |
# list resource groups | |
az group list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment