GoogleContainerTools/skaffold · error
instantiating default kubectl deployer: %w
Error message
instantiating default kubectl deployer: %w
What it means
Wraps any error returned when Skaffold constructs its default kubectl deployer during `skaffold apply`/`deploy` fallback. kubectl.NewDeployer fails if the kubectl deploy config or its flags are invalid (e.g. bad kube-context values, invalid flags). The inner error identifies the concrete problem.
Source
Thrown at pkg/skaffold/runner/deployer.go:297
}
if currentDefaultNamespace != nil {
if defaultNamespace != nil && *defaultNamespace != *currentDefaultNamespace {
return nil, fmt.Errorf("found multiple namespaces in skaffold.yaml (not supported in `skaffold apply`): %s, %s", *defaultNamespace, *currentDefaultNamespace)
}
defaultNamespace = currentDefaultNamespace
}
}
if kFlags == nil {
kFlags = &latest.KubectlFlags{}
}
k := &latest.KubectlDeploy{
Flags: *kFlags,
DefaultNamespace: defaultNamespace,
}
dCtx := &deployerCtx{runCtx, latest.DeployConfig{StatusCheck: statusCheck, KubeContext: kubeContext, DeployType: latest.DeployType{KubectlDeploy: k}}}
defaultDeployer, err := kubectl.NewDeployer(dCtx, labeller, k, runCtx.Artifacts(), "", selectors)
if err != nil {
return nil, fmt.Errorf("instantiating default kubectl deployer: %w", err)
}
return defaultDeployer, nil
}
func validateKubectlFlags(flags *latest.KubectlFlags, additional latest.KubectlFlags) error {
errStr := "conflicting sets of kubectl deploy flags not supported in `skaffold apply` (flag: %s)"
if additional.DisableValidation != flags.DisableValidation {
return fmt.Errorf(errStr, strconv.FormatBool(additional.DisableValidation))
}
for _, flag := range additional.Apply {
if !stringslice.Contains(flags.Apply, flag) {
return fmt.Errorf(errStr, flag)
}
}
for _, flag := range additional.Delete {
if !stringslice.Contains(flags.Delete, flag) {
return fmt.Errorf(errStr, flag)
}View on GitHub (pinned to a1189de023)
Solutions
- Read the inner `%w` error to identify the concrete constructor failure
- Fix the deploy.kubectl section of skaffold.yaml (flags, kube-context)
- Run `skaffold config list` / `kubectl config get-contexts` to verify the kube-context exists
- Upgrade or match the Skaffold version used to author the config
Example fix
// before
deploy:
kubectl:
flags:
apply: ["--unknown-flag"]
// after
deploy:
kubectl:
flags:
apply: ["--server-side"] Defensive patterns
Strategy: validation
Validate before calling
// pre-check kubectl deploy config before apply
const k = cfg.deploy?.kubectl
if (k?.flags?.apply || k?.flags?.delete || k?.flags?.global) {
for (const f of [...(k.flags.apply||[]), ...(k.flags.delete||[]), ...(k.flags.global||[])])
if (!f.startsWith('--')) throw new Error(`invalid kubectl flag: ${f}`)
}
if (k?.kubeContext && !knownContexts.includes(k.kubeContext)) throw new Error(`unknown kube-context: ${k.kubeContext}`) Type guard
function hasValidKubectlConfig(c) {
return c != null && typeof c === 'object' &&
(c.kubectl == null || typeof c.kubectl === 'object')
} Try / catch
deployer, err := kubectl.NewDeployer(dCtx, labeller, k, artifacts, "", selectors)
if err != nil {
log.Errorf("kubectl deployer init failed: %v", err)
return fmt.Errorf("check deploy.kubectl config: %w", err)
} Prevention
- Validate skaffold.yaml with `skaffold verify`/lint before apply
- Keep kubectl flags minimal and documented in skaffold.yaml
- Pin Skaffold version in CI to match config schema
When it happens
Trigger: getDefaultDeployer calls kubectl.NewDeployer with the parsed kubectl deploy config and flag selectors; any non-nil error from that constructor (invalid kubeContext, malformed flags, artifact issues) is wrapped here.
Common situations: Invalid `deploy.kubectl.flags` in skaffold.yaml; unsupported/renamed kubectl flag; corrupted kubeconfig referenced by the kube-context; running `skaffold apply` on a config last written by a different Skaffold version.
Related errors
- INSPECT_PROFILE_NOT_FOUND_ERR
- kubectl version 1.12.0 or greater is recommended for use wit
- cannot resolve active Kubernetes context - multiple contexts
- filename not specified
- getting run context: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/50ace644abb99bba.
Report an issue: GitHub.