GitHub Action for setting context (retrieving Kubeconfig) before interacting with Kubernetes cluster
Перейти к файлу
Oliver King 0d17dff9ee
refactor (#45)
* refactor
2022-02-04 14:09:43 -05:00
.github refactor (#45) 2022-02-04 14:09:43 -05:00
src refactor (#45) 2022-02-04 14:09:43 -05:00
.gitignore refactor (#45) 2022-02-04 14:09:43 -05:00
CODE_OF_CONDUCT.md Initial commit 2019-09-03 23:06:58 -07:00
LICENSE Initial commit 2019-09-03 23:06:59 -07:00
README.md Update README.md 2020-12-29 09:34:10 +05:30
SECURITY.md Initial commit 2019-09-03 23:07:01 -07:00
action.yml refactor (#45) 2022-02-04 14:09:43 -05:00
jest.config.js Added L0 tests. 2021-03-23 14:39:14 +05:30
package-lock.json Refactor action and update ownership (#42) 2022-01-03 16:32:30 -05:00
package.json Added trigger for L2 tests and compiled typescript (#28) 2021-03-31 17:22:13 +05:30
tsconfig.json refactor (#45) 2022-02-04 14:09:43 -05:00

README.md

Azure Kubernetes Service set context

This action can be used to set cluster context before other actions like azure/k8s-deploy, azure/k8s-create-secret or any kubectl commands (in script) can be run subsequently in the workflow.

Refer to starter templates to deploy to any Kubernetes cluster on-premise or any cloud including Azure Kubernetes service.

Action inputs

Action inputs Description
creds
Credentials
(Required) Credentials required to authenticate with Azure. Steps to obtain these credentials are provided below
resource-group
Resource group
(Required) Resource group containing the AKS cluster
cluster-name
Cluster name
(Required) Name of the AKS cluster

Example

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

To fetch the credentials required to authenticate with Azure, run the following command:

az ad sp create-for-rbac --sdk-auth

For more details on this command, refer to service principal documentation

This generates a service principal and the output of the above command will be in the following format:

{
  "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/"
}

Add the json output as a secret (let's say with the name AZURE_CREDENTIALS) in the GitHub repository. The example YAML snippet given above showcases how this secret is referenced in the action for specifying the credentials as input to the action.

aks-set-context GitHub Actions is supported for the Azure public cloud as well as Azure government clouds ('AzureUSGovernment' or 'AzureChinaCloud'). Before running this action, login to the respective Azure Cloud using Azure Login by setting appropriate value for the environment parameter.

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.