{"record":{"id":"5ef7ea951403cfb9","repo":"GoogleContainerTools/skaffold","slug":"cannot-resolve-active-kubernetes-context-multipl","errorCode":null,"errorMessage":"cannot resolve active Kubernetes context - multiple contexts configured in skaffold.yaml","messagePattern":"cannot resolve active Kubernetes context - multiple contexts configured in skaffold\\.yaml","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/runner/deployer.go","lineNumber":244,"sourceCode":"  - deploy.Kubectl.Flags\n  - deploy.Kubectl.DefaultNamespace\n\nFor a multi-config project, we do not currently support resolving conflicts between differing sets of this deploy configuration.\nTherefore, in this function we do implicit validation of the provided configuration, and fail if any conflict cannot be resolved.\n*/\nfunc getDefaultDeployer(runCtx *runcontext.RunContext, labeller *label.DefaultLabeller, selectors []manifest.GroupKindSelector) (deploy.Deployer, error) {\n\tdeployCfgs := runCtx.DeployConfigs()\n\n\tvar kFlags *latest.KubectlFlags\n\tvar logPrefix string\n\tvar defaultNamespace *string\n\tvar kubeContext string\n\tstatusCheckTimeout := -1\n\tvar statusCheck *bool\n\tfor _, d := range deployCfgs {\n\t\tif d.KubeContext != \"\" {\n\t\t\tif kubeContext != \"\" && kubeContext != d.KubeContext {\n\t\t\t\treturn nil, errors.New(\"cannot resolve active Kubernetes context - multiple contexts configured in skaffold.yaml\")\n\t\t\t}\n\t\t\tkubeContext = d.KubeContext\n\t\t}\n\t\tif d.StatusCheck != nil {\n\t\t\tif statusCheck == nil {\n\t\t\t\tstatusCheck = d.StatusCheck\n\t\t\t} else if statusCheck != d.StatusCheck {\n\t\t\t\t// if we get conflicting values for status check from different skaffold configs, we turn status check off\n\t\t\t\tstatusCheck = util.Ptr(false)\n\t\t\t}\n\t\t}\n\t\tif d.StatusCheckDeadlineSeconds != 0 && d.StatusCheckDeadlineSeconds != int(status.DefaultStatusCheckDeadline.Seconds()) {\n\t\t\tif statusCheckTimeout != -1 && statusCheckTimeout != d.StatusCheckDeadlineSeconds {\n\t\t\t\treturn nil, fmt.Errorf(\"found multiple status check timeouts in skaffold.yaml (not supported in `skaffold apply`): %d, %d\", statusCheckTimeout, d.StatusCheckDeadlineSeconds)\n\t\t\t}\n\t\t\tstatusCheckTimeout = d.StatusCheckDeadlineSeconds\n\t\t}\n\t\tif d.Logs.Prefix != \"\" {","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/runner/deployer.go#L226-L262","documentation":" getDefaultDeployer iterates all deploy configs in skaffold.yaml and collects a single active Kubernetes context. If two or more deploy configs declare different `kubeContext` values, no single deployer context can be chosen and this error is returned. Skaffold requires all deployers in a run to target the same cluster context.","triggerScenarios":"Running any command that builds a deployer (GetDeployer / Dev / Deploy) with a skaffold.yaml containing multiple deploy configs (e.g. kubectl + helm) where each sets a different `deploy.kubeContext`.","commonSituations":"Developers combining a kubectl deploy stanza and a helm deploy stanza in one skaffold.yaml but pointing them at different clusters (e.g. `minikube` vs `gke_project_us-central1`), often after copy-pasting configs from different projects.","solutions":["Set the same `kubeContext` value on every deploy config in skaffold.yaml (or remove kubeContext from all of them to use kubectl's current context).","Remove the redundant deploy config that points at the wrong cluster.","Use the `--kube-context` CLI flag on a single-context config instead of hardcoding contexts in the file."],"exampleFix":"// before\ndeploy:\n  kubectl:\n    kubeContext: minikube\n  helm:\n    kubeContext: gke_my-project_us-central1-c_my-cluster\n// after\ndeploy:\n  kubectl: {}\n  helm: {}\n# or set the same kubeContext on both","handlingStrategy":"validation","validationCode":"yq e '.deploy | (.kubectl.kubeContext // \"\") , (.helm.kubeContext // \"\")' skaffold.yaml | sort -u | wc -l\n# must be <= 1 (ignoring empty) before running skaffold","typeGuard":"func singleKubeContext(cfgs []*latest.DeployConfig) (string, bool) {\n\tvar ctx string\n\tfor _, d := range cfgs {\n\t\tif d.KubeContext == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif ctx != \"\" && ctx != d.KubeContext {\n\t\t\treturn \"\", false\n\t\t}\n\t\tctx = d.KubeContext\n\t}\n\treturn ctx, true\n}","tryCatchPattern":null,"preventionTips":["Omit kubeContext from skaffold.yaml and rely on `kubectl config current-context` or the `--kube-context` flag.","Lint skaffold.yaml in CI to assert at most one distinct kubeContext across all deploy configs.","When adding a new deploy stanza, copy from an existing one to keep context fields consistent."],"tags":["kubernetes","config","skaffold"],"backgroundTag":"ambiguous-kubernetes-context","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}