Skip to content
Latchkey

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.

skaffold
getting kubernetes client: context "gke_my-project_us-central1_my-cluster" does not exist

Common 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

  1. List available contexts with kubectl config get-contexts.
  2. Pass the matching name with --kube-context, or remove the pin so the current context is used.
  3. Re-run the deploy.
Terminal
kubectl config get-contexts
skaffold deploy --kube-context="$(kubectl config current-context)" --build-artifacts=build.json

Do 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.

skaffold.yaml
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.

Frequently asked questions

What causes ""context ... does not exist""?
A hardcoded local context name does not match the context that the CI kubeconfig actually defines.
How do I fix "context ... does not exist"?
Pass the real context or let it default

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card