kubectl "the server could not find the requested resource" in CI
This NotFound is about the API endpoint, not a named object. kubectl asked for a resource path the API server does not serve - usually a removed/renamed API version or a kubectl too far out of step with the cluster version.
What this error means
A command fails with Error from server (NotFound): the server could not find the requested resource. It differs from "<name>" not found: here the whole resource endpoint is unavailable, often after a cluster upgrade.
Error from server (NotFound): the server could not find the requested resourceCommon causes
Removed or renamed API version
A cluster upgrade dropped an old API (e.g. a */v1beta1 endpoint), so a manifest or command targeting it no longer resolves to a served path.
Client/server version skew
A kubectl far newer or older than the cluster requests paths the server does not expose. Kubernetes supports only ±1 minor of skew.
Stale discovery cache
kubectl’s cached API discovery under ~/.kube/cache is out of date after a CRD/API change, so it requests a path that is no longer there.
How to fix it
Check version skew and served APIs
kubectl version --output=yaml | grep -E 'gitVersion'
kubectl api-versionsAlign kubectl and refresh discovery
- Use a kubectl within one minor version of the cluster.
- Update manifests/commands to an API version the cluster serves.
- Clear the discovery cache if it is stale:
rm -rf ~/.kube/cache.
How to prevent it
- Pin a kubectl version matched to the cluster’s minor version in CI.
- Track API deprecations (
pluto,kubectl convert) before cluster upgrades. - Refresh kubectl discovery after API/CRD changes.