azure/setup-kubectl
Install a specific version of kubectl on the runner.
What it does
azure/setup-kubectl installs the requested kubectl version on the runner so later steps can run kubectl commands against any cluster.
It only installs the binary, cluster credentials (kubeconfig) come from a separate step such as azure/aks-set-context, aws eks update-kubeconfig, or gcloud container clusters get-credentials.
Usage
steps:
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: azure/setup-kubectl@v5
with:
version: v1.30.0
- run: |
az aks get-credentials --resource-group my-rg --name my-cluster
kubectl get podsInputs
| Input | Description | Default | Required |
|---|---|---|---|
version | Version of kubectl (latest or a semantic version like v1.30.0). | latest | Yes |
Outputs
| Output | Description |
|---|---|
kubectl-path | Path to the cached kubectl binary. |
Notes
Pin version to the minor version of your cluster (kubectl supports one minor version of skew in either direction) instead of latest.
Common errors
The connection to the server localhost:8080 was refusedfrom kubectl means no kubeconfig was configured, the install succeeded, but you skipped the cluster-credentials step.- An invalid
versionstring fails the download; uselatestor a full semantic version likev1.30.0.
Security and pinning
- Pin the action to a commit SHA and pin
versionfor reproducible builds. - Prefer OIDC-based cloud logins (azure/login federated credentials, configure-aws-credentials role assumption) over long-lived kubeconfig files stored as secrets.