Skip to content
Latchkey

kubectl "the server could not find the requested resource" in CI - Fix it

Unlike a NotFound on a specific object, this means the API server has no endpoint for the resource type at all. The CRD is not installed, the API was removed, or a much older/newer kubectl is talking to an incompatible API surface.

What this error means

A kubectl command fails with error: the server could not find the requested resource even though the syntax looks right and credentials are valid.

kubectl
error: the server could not find the requested resource

Common causes

A CRD or aggregated API is not installed

The resource type comes from a CRD or aggregated API server that is not present, so no endpoint serves it.

Version skew between kubectl and the cluster

A kubectl far ahead of or behind the cluster requests a resource path the API server does not expose.

How to fix it

Confirm the resource type is actually served

  1. List the API resources the cluster serves.
  2. Install the CRD/operator if the type is custom, or correct the resource name.
  3. Align kubectl to the cluster minor version if skew is the cause.
Terminal
kubectl api-resources | grep -i <resource>
kubectl version --output=yaml

Pin a compatible kubectl in CI

Keep kubectl within one minor version of the cluster so the served API surface matches.

.github/workflows/ci.yml
- uses: azure/setup-kubectl@v4
  with:
    version: 'v1.30.0'

How to prevent it

  • Keep kubectl within one minor version of the cluster.
  • Install CRDs/operators before using their resource types.
  • List kubectl api-resources when a resource type is unexpectedly missing.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →