Stale APIService Causing API Discovery Failures while running kubectl
Problem
Clients such as kubectl (v1.22+), client-go, and Dynatrace components experience API discovery failures, with repeated error messages like:
couldn't get resource list for packages.operators.coreos.com/v1: the server is currently unable to handle the requestEnvironment
- Platform9 Managed Kubernetes
- kubernetes v1.23 and Higher
Cause
A stale/deprecated APIService object (v1.packages.operators.coreos.com) still exists in the cluster and references a Kubernetes Service (v1-packages-operators-coreos-com) in the pf9-olm namespace, which no longer exists. This results in a ServiceNotFound condition, which newer clients treat as a hard error during API discovery.
Resolution
Backup the APIService definition (for audit purposes):
kubectl get apiservice v1.packages.operators.coreos.com -o yaml > broken-apiservice-backup.yamlDelete the stale/deprecated APIService:
kubectl delete apiservice v1.packages.operators.coreos.comAdditional Information
The issue is not observed in kubectl versions older than v1.20.1 because older versions of kubectl and client-go handle unavailable or misconfigured APIService resources more gracefully—typically by logging warnings instead of failing or blocking discovery entirely.