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.
error: the server could not find the requested resourceCommon 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
- List the API resources the cluster serves.
- Install the CRD/operator if the type is custom, or correct the resource name.
- Align kubectl to the cluster minor version if skew is the cause.
kubectl api-resources | grep -i <resource>
kubectl version --output=yamlPin a compatible kubectl in CI
Keep kubectl within one minor version of the cluster so the served API surface matches.
- 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-resourceswhen a resource type is unexpectedly missing.