GoogleContainerTools/skaffold · error

getting server resources for group version: %w

Error message

getting server resources for group version: %w

What it means

GroupVersionResource queries the Kubernetes API server's discovery endpoint (ServerResourcesForGroupVersion) to map a GroupVersionKind to its corresponding GroupVersionResource. If the discovery call fails — network problem, wrong API group/version, or server rejecting the request — the error is wrapped with this message. Callers Select and updateRuntimeObject rely on this mapping to build typed clients.

Source

Thrown at pkg/skaffold/deploy/util/util.go:162

			}
		}
	}
	log.Entry(context.TODO()).Infof("manifests hydration will take place in %v\n", hydratedDir)
	return hydratedDir, nil
}

func isDirEmpty(dir string) bool {
	f, _ := os.Open(dir)
	defer f.Close()
	_, err := f.Readdirnames(1)
	return err == io.EOF
}

// GroupVersionResource returns the first `GroupVersionResource` for the given `GroupVersionKind`.
func GroupVersionResource(disco discovery.DiscoveryInterface, gvk schema.GroupVersionKind) (bool, schema.GroupVersionResource, error) {
	resources, err := disco.ServerResourcesForGroupVersion(gvk.GroupVersion().String())
	if err != nil {
		return false, schema.GroupVersionResource{}, fmt.Errorf("getting server resources for group version: %w", err)
	}

	for _, r := range resources.APIResources {
		if r.Kind == gvk.Kind {
			return r.Namespaced, schema.GroupVersionResource{
				Group:    gvk.Group,
				Version:  gvk.Version,
				Resource: r.Name,
			}, nil
		}
	}

	return false, schema.GroupVersionResource{}, fmt.Errorf("could not find resource for %s", gvk.String())
}

func GetManifestsFromHydratedManifests(ctx context.Context, hydratedManifests []string) (manifest.ManifestList, error) {
	var manifests manifest.ManifestList
	for _, path := range hydratedManifests {

View on GitHub (pinned to a1189de023)

Solutions

  1. Verify cluster connectivity: kubectl cluster-info and check the current kubeconfig context
  2. Confirm the resource's apiVersion/group exists on the cluster (kubectl api-resources | grep <resource>)
  3. Apply the CRD or update the cluster if the API group is missing
  4. Check RBAC: ensure the service account can call the discovery endpoints (get on the API group resources)
  5. Upgrade the Kubernetes client libraries if the server/client discovery API versions mismatch

Example fix

// before
res, err := disco.ServerResourcesForGroupVersion(gvk.GroupVersion().String())
// after — pre-check the group version exists before mapping
if _, err := disco.ServerResourcesForGroupVersion(gvk.GroupVersion().String()); err != nil {
	return false, schema.GroupVersionResource{}, fmt.Errorf("getting server resources for group version: %w", err)
}
Defensive patterns

Strategy: retry

Validate before calling

func checkDiscovery(disco discovery.DiscoveryInterface) error {
	_, err := disco.ServerResourcesForGroupVersion("v1")
	return err
}

Try / catch

ok, gvr, err := GroupVersionResource(disco, gvk)
if err != nil {
	if strings.Contains(err.Error(), "getting server resources") {
		var netErr net.Error
		if errors.As(err, &netErr) {
			// retry with backoff
		}
	}
	return fmt.Errorf("cluster discovery failed, check connectivity/RBAC: %w", err)
}

Prevention

When it happens

Trigger: Calling GroupVersionResource with a GVK whose group/version does not exist on the cluster, when the API server is unreachable, when RBAC denies discovery access, or with an older client incompatible with the server's discovery API.

Common situations: Deploying to a cluster that doesn't support the resource's apiVersion (e.g. new CRDs or newer Kubernetes APIs); kubectl context pointing at the wrong cluster; cluster offline or behind a broken proxy; service account lacking discovery permissions.

Related errors


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