GoogleContainerTools/skaffold · error

getting cluster: %w

Error message

getting cluster: %w

What it means

As part of RunContext construction, Skaffold determines the target cluster (including minikube detection via cluster.GetCluster with the global config, default repo, and minikube options). Failure at this step is wrapped as "getting cluster: %w" and aborts runner/context creation.

Source

Thrown at pkg/skaffold/runner/runcontext/context.go:442

	}
	regList = append(regList, cfgRegistries...)
	insecureRegistries := make(map[string]bool, len(regList))
	for _, r := range regList {
		insecureRegistries[r] = true
	}
	ps := NewPipelines(pipelines, orderedConfigs)

	// TODO(https://github.com/GoogleContainerTools/skaffold/issues/3668):
	// remove minikubeProfile from here and instead detect it by matching the
	// kubecontext API Server to minikube profiles
	cluster, err := config.GetCluster(ctx, config.GetClusterOpts{
		ConfigFile:      opts.GlobalConfig,
		DefaultRepo:     opts.DefaultRepo,
		MinikubeProfile: opts.MinikubeProfile,
		DetectMinikube:  opts.DetectMinikube,
	})
	if err != nil {
		return nil, fmt.Errorf("getting cluster: %w", err)
	}

	runID := uuid.New().String()

	return &RunContext{
		Opts:               opts,
		Pipelines:          ps,
		WorkingDir:         cwd,
		KubeContext:        kubeContext,
		InsecureRegistries: insecureRegistries,
		Cluster:            cluster,
		RunID:              runID,
	}, nil
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Read the wrapped cause after 'getting cluster:' for the real failure
  2. Verify the cluster is reachable: `kubectl cluster-info`
  3. If using --minikube-profile, confirm the profile exists (`minikube profile list`) and is running
  4. Reset a corrupt skaffold global config: `skaffold config` entries or delete ~/.skaffold/config

Example fix

// before
skaffold dev --minikube-profile=missing-profile
// after
minikube start -p myprofile
skaffold dev --minikube-profile=myprofile
Defensive patterns

Strategy: try-catch

Validate before calling

if err := exec.Command("kubectl", "cluster-info").Run(); err != nil { return fmt.Errorf("cluster unreachable before skaffold run: %w", err) }

Try / catch

runCtx, err := GetRunContext(config, opts)
if err != nil && strings.Contains(err.Error(), "getting cluster") {
    return nil, fmt.Errorf("cluster detection failed; check kubectl context and minikube profile: %v", err)
}
return runCtx, err

Prevention

When it happens

Trigger: Calling GetRunContext/NewForConfig when the cluster detection call (cluster.GetCluster with DetectMinikube, MinikubeProfile, DefaultRepo, GlobalConfig) returns an error — e.g. failure inspecting kubectl contexts or minikube profile lookup.

Common situations: minikube profile specified but not running/installed, kubectl context pointing to an unreachable cluster during detection, or malformed global config (~/.skaffold/config) affecting cluster resolution.

Related errors


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