GoogleContainerTools/skaffold · error
kubectl create: %w
Error message
kubectl create: %w
What it means
The kubectl deployer uses `kubectl create --dry-run=client -o yaml` (ReadManifests) to materialize manifests with defaults (including namespace) before deploying. If the create command fails — including on a retry without the --namespace flag — this readManifestErr is returned. Usually the failure is a bad kubeconfig, unreachable cluster for validation, or unsupported flag combination.
Source
Thrown at pkg/skaffold/deploy/kubectl/cli.go:227
dryRun += "=client"
}
args := c.args([]string{dryRun, "-oyaml"}, list...)
if c.Flags.DisableValidation {
args = append(args, "--validate=false")
}
argsWithoutNamespace := args
if ns := util.ParseNamespaceFromFlags(c.Flags.Apply); ns != "" {
args = append(args, "-n", ns)
}
buf, err := c.RunOut(ctx, "create", args...)
if err != nil {
// try running again without the `--namespace` flag
buf, err = c.RunOutWithoutNamespace(ctx, "create", argsWithoutNamespace...)
if err != nil {
return nil, readManifestErr(fmt.Errorf("kubectl create: %w", err))
}
}
var manifestList manifest.ManifestList
manifestList.Append(buf)
return manifestList, nil
}
func (c *CLI) args(commandFlags []string, additionalArgs ...string) []string {
args := make([]string, 0, len(c.Flags.Global)+len(commandFlags)+len(additionalArgs))
args = append(args, c.Flags.Global...)
args = append(args, commandFlags...)
args = append(args, additionalArgs...)
return args
}View on GitHub (pinned to a1189de023)
Solutions
- Read the wrapped root cause; run the equivalent `kubectl create --dry-run=client -o yaml -f <manifest>` manually to see the full message.
- Upgrade kubectl to a recent version matching your cluster (client dry-run features).
- Fix kubeconfig: ensure the current context has a valid namespace or set one explicitly.
- Verify all manifest paths referenced by the deploy config exist.
Example fix
// before $ skaffold deploy # kubectl create fails: no namespace in context // after kubectl config set-context --current --namespace=default $ skaffold deploy
Defensive patterns
Strategy: validation
Validate before calling
// Ensure context and namespace resolve before reading manifests
ctxName, _ := exec.Command("kubectl", "config", "current-context").Output()
ns, _ := exec.Command("kubectl", "config", "view", "--minify", "-ojsonpath={..namespace}").Output()
if strings.TrimSpace(string(ns)) == "" {
return fmt.Errorf("context %s has no default namespace", ctxName)
} Try / catch
if _, err := cli.ReadManifests(ctx, out, files, ns); err != nil {
if strings.Contains(err.Error(), "kubectl create") {
log.Errorf("manifest read failed: %v — verify kubeconfig and kubectl version", err)
}
return err
} Prevention
- Keep kubectl at a recent version supporting client-side dry-run
- Ensure the current kube context has a default namespace
- Verify all manifest file paths exist before deploy
- Test `kubectl create --dry-run=client -o yaml -f ...` manually when debugging
When it happens
Trigger: Both `c.RunOut(create args...)` and `c.RunOutWithoutNamespace(create argsWithoutNamespace...)` fail — e.g. kubectl can't resolve the current context/namespace, the --namespace flag is rejected by an old kubectl, or a referenced file (kustomize/-f path) is missing.
Common situations: Current kubeconfig context has no default namespace and dry-run needs it; very old kubectl binaries lacking client dry-run flags; malformed manifest files passed via skaffold kubectl deployer config.
Related errors
- nothing to deploy
- CONFIG_MISSING_MANIFEST_FILE_ERR
- rendering manifests: %w
- rendering manifests: %w
- could not read the hydrated manifest from %v: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/9aedf9e31bd46126.
Report an issue: GitHub.