I have this warning message from Google Console for my GKE cluster
API clients in your cluster have recently attempted to call APIs that were removed in v1.25 and are no longer available on the cluster.
Deprecated APIs called
API User agent Total_calls (last 30 days)Last called /apis/batch/v1beta1/cronjobs v2.2.0 31145 September 22, 2023 at 5:30:00 AM UTC+5:30
but i am not using the v1beta1 anywhere, I am using the batch/v1
checked with: k get cronjobs -A -o=jsonpath='{range .items[*]}{.metadata.namespace}/{.metadata.name} : {.apiVersion}{"\n"}{end}'
and all the cronjobs api versions are not depricated it seems but warning still continue.
I tried checking the resource version and couldn't find anything which the GKE was calling /apis/batch/v1beta1/cronjobs
-->kubectl get --raw /apis/batch/v1beta1/cronjobs | jq Error from server (NotFound): the server could not find the requested resource
I was able to fix this issue, in my case I was using kube prometheus stack chart in my cluster and all the api calls was from kube-state-metrics
sub chart.
How I find the issue?: Enabled the audit logs for GKE in GCP. and in logs I was able to find the call was from the IP of kube-state-mertrics
pod
The solution I tried removed the resources that was creating the issue in kube prometheus stack values.yaml
in the kube-state-metrics
section add the collectors: section (you can find it in kube state metrics chart) by removing the deprecated API calling resource
eg:
kube-state-metrics:
namespaceOverride: ""
rbac:
create: true
podSecurityPolicy:
enabled: true
# podDisruptionBudget:
# enable: false
collectors:
- certificatesigningrequests
- configmaps
- daemonsets
- deployments
- endpoints
- ingresses
- jobs
- leases
- limitranges
- mutatingwebhookconfigurations
- namespaces
- networkpolicies
- nodes
- persistentvolumeclaims
- persistentvolumes
- pods
- replicasets
- replicationcontrollers
- resourcequotas
- secrets
- services
- statefulsets
- storageclasses
- validatingwebhookconfigurations
- volumeattachments
(pdb,psp and cronjob was listerd here)