GoogleContainerTools/skaffold · error

missing `--kube-context` or `--global`

Error message

missing `--kube-context` or `--global`

What it means

Validation in getConfigForKubectx: after resolving the current kubectl context, both the --kube-context flag value and --global are unset (empty kubecontext), so skaffold cannot tell which config section (global vs per-kubecontext) the command applies to.

Source

Thrown at cmd/skaffold/app/cmd/config/util.go:67

	if err != nil {
		return nil, err
	}

	if cfg == nil {
		cfg = &config.ContextConfig{}
		if !global {
			cfg.Kubecontext = kubecontext
		}
	}

	return cfg, nil
}

func getConfigForKubectx() (*config.ContextConfig, error) {
	resolveKubectlContext()

	if kubecontext == "" && !global {
		return nil, fmt.Errorf("missing `--kube-context` or `--global`")
	}

	cfg, err := config.ReadConfigFile(configFile)
	if err != nil {
		return nil, err
	}
	if global {
		return cfg.Global, nil
	}
	for _, contextCfg := range cfg.ContextConfigs {
		if util.RegexEqual(contextCfg.Kubecontext, kubecontext) {
			return contextCfg, nil
		}
	}
	return nil, nil
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Pass --global to operate on the global config section
  2. Pass --kube-context <name> to target a specific cluster's config
  3. Ensure kubectl's current context is set (kubectl config current-context) if you expected it to be auto-detected
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cmd/skaffold/app/cmd/config/util.go:67 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/007f7da48e5e21f8. Report an issue: GitHub.