Skaffold "context not found" (--kube-context) in CI
Skaffold can pin a deploy to a named kube-context via skaffold.yaml or --kube-context. If that context name is not in the runner's kubeconfig, Skaffold refuses to deploy because it cannot select the cluster.
What this error means
A deploy fails with "context X does not exist" or "getting kubernetes client: context ... not found", even though a kubeconfig is present.
getting kubernetes client: context "gke_my-project_us-central1_my-cluster" does not existCommon causes
The context name differs on the runner
A hardcoded local context name does not match the context that the CI kubeconfig actually defines.
The config activates a context CI never created
skaffold.yaml pins deploy.kubeContext to a context that only exists on a developer machine.
How to fix it
Pass the real context or let it default
- List available contexts with
kubectl config get-contexts. - Pass the matching name with
--kube-context, or remove the pin so the current context is used. - Re-run the deploy.
kubectl config get-contexts
skaffold deploy --kube-context="$(kubectl config current-context)" --build-artifacts=build.jsonDo not hardcode a local context in skaffold.yaml
Move the context choice to a CI profile, or omit it so the runner's current context applies.
profiles:
- name: ci
deploy:
kubeContext: ""How to prevent it
- Avoid pinning a machine-specific kube-context in skaffold.yaml.
- Rename the CI context to match, or pass it explicitly.
- Select the deploy context in a CI profile.