-
-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support azure cli as well #48
Comments
After did the research, I gave up the idea. Azure CLI is a python package, but Microsoft develop team doesn't care of the package size (familar, right?). If I installed it in our reference the discussion at Azure/azure-cli#19591 (comment) |
So what's the better way to deploy a kubernetes application in Azure? We need az cli to get credential for AKS, but install Azure CLI takes extra 1.3GB space currently, that's not suitable for a image to run in Pipeline
|
If the only thing you need is |
This was reconstructed from my command history, so it's untested in this particular form, but I was able to get the Kubernetes config back. I don't know if you have to URI-escape the password, but it works if you do. az ad sp create-for-rbac --name "manual login to AKS test SP" -o json > sp.json
APP_ID=$(jq .appId sp.json)
APP_PASS=$(jq ".password | @uri" sp.json)
TENANT_ID=$(jq .tenant sp.json)
CLUSTER_ID=subscriptions/$SUBSCRIPTION_ID/resourceGroups/$CLUSTER_RESOURCE_GROUP/providers/Microsoft.ContainerService/managedClusters/$CLUSTER_NAME
az role assignment create \
--role "Azure Kubernetes Service Cluster User Role" \
--scope /$CLUSTER_ID \
--assignee $APP_ID
token=$(
curl -X POST -d "grant_type=client_credentials&client_id=$APP_ID&client_secret=$APP_PASS&resource=https%3A%2F%2Fmanagement.azure.com%2F"
https://login.microsoftonline.com/$TENANT_ID/oauth2/token
| jq -r .access_token)
curl -s -X POST -d "" -H "Authorization:Bearer $token" \
https://management.azure.com/$CLUSTER_ID/listClusterUserCredential\?api-version\=2022-10-02-preview \
| jq -r '.kubeconfigs[0].value' \
| base64 -d \
> $HOME/.kube/config.testme |
support azure cli as well in this image to cover Azure AKS in automation pipeline as well
Azure CLI doesn't work as AWS, sometimes you need install extra extensions for managing some services. In this image, I will only install the basic Azure CLI to save the image size.
If you want to manage extra extensions for your pipepline, please add the command in your pipeline tasks
The text was updated successfully, but these errors were encountered: