2beb148ddc
Bumps the actions group with 6 updates in the / directory: | Package | From | To | | --- | --- | --- | | [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) | `1.10.1` | `1.11.1` | | [@kubernetes/client-node](https://github.com/kubernetes-client/javascript) | `0.21.0` | `0.22.0` | | [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) | `29.5.12` | `29.5.13` | | [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `22.5.4` | `22.7.4` | | [@vercel/ncc](https://github.com/vercel/ncc) | `0.38.1` | `0.38.2` | | [typescript](https://github.com/microsoft/TypeScript) | `5.5.4` | `5.6.2` | Updates `@actions/core` from 1.10.1 to 1.11.1 - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) Updates `@kubernetes/client-node` from 0.21.0 to 0.22.0 - [Release notes](https://github.com/kubernetes-client/javascript/releases) - [Changelog](https://github.com/kubernetes-client/javascript/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes-client/javascript/compare/0.21.0...0.22.0) Updates `@types/jest` from 29.5.12 to 29.5.13 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) Updates `@types/node` from 22.5.4 to 22.7.4 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Updates `@vercel/ncc` from 0.38.1 to 0.38.2 - [Release notes](https://github.com/vercel/ncc/releases) - [Commits](https://github.com/vercel/ncc/compare/0.38.1...0.38.2) Updates `typescript` from 5.5.4 to 5.6.2 - [Release notes](https://github.com/microsoft/TypeScript/releases) - [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml) - [Commits](https://github.com/microsoft/TypeScript/compare/v5.5.4...v5.6.2) --- updated-dependencies: - dependency-name: "@actions/core" dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: "@kubernetes/client-node" dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: "@types/jest" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: actions - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: actions - dependency-name: "@vercel/ncc" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: actions - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor dependency-group: actions ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
---|---|---|
.github | ||
src | ||
tests | ||
.gitignore | ||
.prettierignore | ||
.prettierrc.json | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
LICENSE | ||
README.md | ||
SECURITY.md | ||
action.yml | ||
jest.config.js | ||
package-lock.json | ||
package.json | ||
tsconfig.json |
README.md
Kubernetes set context
This action can be used to set cluster context before other actions like azure/k8s-deploy
and azure/k8s-create-secret
. It should also be used before kubectl
commands (in script) are run subsequently in the workflow.
It is a requirement to use azure/login
in your workflow before using this action when using the service-account
or service-principal
methods.
There are three approaches for specifying the deployment target:
- Kubeconfig file provided as input to the action
- Service account approach where the secret associated with the service account is provided as input to the action
- Service principal approach (only applicable for arc cluster) where service principal provided with 'creds' is used as input to action
In all these approaches it is recommended to store these contents (kubeconfig file content or secret content) in a secret.
Refer to the action metadata file for details about inputs. Note that different inputs are required for different method and cluster types. Use the below examples as a reference.
Example usage
Kubeconfig approach
- uses: azure/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: <your kubeconfig>
context: <context name> # current-context from kubeconfig is used as default
Please note that the input requires the contents of the kubeconfig file, and not its path.
Following are the ways to fetch kubeconfig file onto your local development machine so that the same can be used in the action input shown above.
Azure Kubernetes Service cluster
az aks get-credentials --name
--resource-group
[--admin]
[--file]
[--overwrite-existing]
[--subscription]
Further details can be found in az aks get-credentials documentation.
Generic Kubernetes cluster
Please refer to documentation on fetching kubeconfig for any generic K8s cluster
Service account approach
- uses: azure/k8s-set-context@v4
with:
method: service-account
k8s-url: <URL of the cluster's API server>
k8s-secret: <secret associated with the service account>
For fetching Server URL, execute the following command on your shell:
kubectl config view --minify -o 'jsonpath={.clusters[0].cluster.server}'
For fetching Secret object required to connect and authenticate with the cluster, the following sequence of commands need to be run:
kubectl get serviceAccounts <service-account-name> -n <namespace> -o 'jsonpath={.secrets[*].name}'
kubectl get secret <service-account-secret-name> -n <namespace> -o yaml
Service account approach for arc cluster
- uses: azure/k8s-set-context@v4
with:
method: service-account
cluster-type: arc
cluster-name: <cluster-name>
resource-group: <resource-group>
token: '${{ secrets.SA_TOKEN }}'
Service principal approach for arc cluster
- uses: azure/k8s-set-context@v4
with:
method: service-principal
cluster-type: arc
cluster-name: <cluster-name>
resource-group: <resource-group>
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.