Skip to content

GitHub Action for setting context (retrieving Kubeconfig) before interacting with Kubernetes cluster

License

Notifications You must be signed in to change notification settings

Azure/aks-set-context

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Repository files navigation

Azure Kubernetes Service set context

Used for setting the target AKS cluster context which will be used by other actions like azure/k8s-deploy, azure/k8s-create-secret etc. or run any kubectl commands.

uses: azure/aks-set-context@v1
    with:
        creds: '${{ secrets.AZURE_CREDENTIALS }}' # Azure credentials
        resource-group: '<resource group name>'
        cluster-name: '<cluster name>'
    id: login

Refer to the action metadata file for details about all the inputs https://github.com/Azure/aks-set-context/blob/master/action.yml

Azure credentials

Run az ad sp create-for-rbac --sdk-auth to generate an Azure Active Directory service principals. For more details refer to: az ad sp create-for-rbac

{
  "clientId": "<client id>",
  "clientSecret": "<client secret>",
  "subscriptionId": "<subscription id>",
  "tenantId": "<tenant id>",
  "activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
  "resourceManagerEndpointUrl": "https://management.azure.com/",
  "activeDirectoryGraphResourceId": "https://graph.windows.net/",
  "sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
  "galleryEndpointUrl": "https://gallery.azure.com/",
  "managementEndpointUrl": "https://management.core.windows.net/"
}

Using secret

Now add the json output as a secret in the GitHub repository. In the above example the secret name is AZURE_CREDENTIALS and it can be used in the workflow by using the following syntax:

creds: '${{ secrets.AZURE_CREDENTIALS }}'

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

About

GitHub Action for setting context (retrieving Kubeconfig) before interacting with Kubernetes cluster

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 31