GitHub Action for setting context (retrieving Kubeconfig) before interacting with Kubernetes cluster
Перейти к файлу
Oliver King 3db6e9a567
Update README with kubelogin clarity fixes
2022-06-21 09:14:19 -04:00
.github refactor (#45) 2022-02-04 14:09:43 -05:00
src export prior to converting kubeconfig (#67) 2022-06-13 14:51:08 -04: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 with kubelogin clarity fixes 2022-06-21 09:14:19 -04:00
SECURITY.md Initial commit 2019-09-03 23:07:01 -07:00
action.yml updated action with node16 (#68) 2022-06-16 13:18:43 -04:00
jest.config.js Added L0 tests. 2021-03-23 14:39:14 +05:30
package-lock.json Bump ansi-regex from 4.1.0 to 4.1.1 (#60) 2022-05-16 13:56:14 -04:00
package.json Switch to using az (adds OIDC) (#48) 2022-02-08 09:28:00 -05:00
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 and azure/k8s-create-secret. Any kubectl commands (in script) can also be run subsequently in the workflow.

You must run Azure/login before this action.

Action inputs

Action inputs Description
resource-group
(Required)
Resource group containing the AKS cluster
cluster-name
(Required)
Name of the AKS cluster
subscription Subscription tied to AKS cluster
admin Get cluster admin credentials. Values: true or false
use-kubelogin Allows non-admin users to use the Action via kubelogin

Example

- uses: azure/login@v1
  with:
    client-id: ${{ secrets.AZURE_CLIENT_ID }}
    tenant-id: ${{ secrets.AZURE_TENANT_ID }}
    subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- uses: azure/aks-set-context@v2
  with:
    resource-group: "<resource group name>"
    cluster-name: "<cluster name>"

Service Principal Authentication

- uses: azure/login@v1
  with:
    creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: azure/aks-set-context@v2
  with:
    resource-group: "<resource group name>"
    cluster-name: "<cluster name>"

Non-Admin User Example

If you are executing this Action as a non-admin user, you need to toggle the optional use-kubelogin Action input to true for it to work. To run this Action as a non-admin user, you must also install kubelogin before running this action.

- uses: azure/login@v1 # you can also use the Service Principal with secrets strategy
  with:
    client-id: ${{ secrets.AZURE_CLIENT_ID }}
    tenant-id: ${{ secrets.AZURE_TENANT_ID }}
    subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
    
- name: Set up kubelogin
  run: |
    curl -LO https://github.com/Azure/kubelogin/releases/download/v0.0.9/kubelogin-linux-amd64.zip
    sudo unzip -j kubelogin-linux-amd64.zip -d /usr/local/bin
    rm -f kubelogin-linux-amd64.zip
    kubelogin --version
              
- uses: azure/aks-set-context@v2
  with:
    resource-group: "<resource group name>"
    cluster-name: "<cluster name>"
    admin: "false"
    use-kubelogin: "true"

kubelogin is at the core of the non-admin user scenario. For more information on kubelogin, refer to the documentation here.

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.