kube-prometheus icon indicating copy to clipboard operation
kube-prometheus copied to clipboard

Document guidance to remove metrics-server before installing kube-prometheus

Open hamid-elaosta opened this issue 3 years ago • 6 comments

What is missing?

Some (?) deployments of Kubernetes come pre-installed with a metrics-server implementation in order to provide metrics API to kubectl (e.g. kubectl top ...). It may be wise to uninstall this existing metrics-server installation before installing kube-prometheus. Documenting this as an installation step would be useful.

Why do we need it? Documenting a recommendation to remove metrics-server both encourages a clean cluster state and an understanding that parts of kube-prometheus will interact with / replace parts of metrics-server, and that with kube-prometheus, metrics-server is no longer required.

Environment

  • kube-prometheus version:

    release-0.7

Anything else we need to know?:

Raised following discussions in #kube-prometheus Slack.

hamid-elaosta avatar Feb 09 '21 16:02 hamid-elaosta

@hamid-elaosta , How to remove metrics-server cleanly Before install kube-prometheus operator ?
I just delete the svc and deployment , when i install the operator , It shows this error :

Error from server (AlreadyExists): error when creating "manifests/prometheus-adapter-apiService.yaml": apiservices.apiregistration.k8s.io "v1beta1.metrics.k8s.io" already exists
Error from server (AlreadyExists): error when creating "manifests/prometheus-adapter-clusterRoleAggregatedMetricsReader.yaml": clusterroles.rbac.authorization.k8s.io "system:aggregated-metrics-reader" already exists


latermonk avatar May 07 '21 08:05 latermonk

Unfortunately the "how" isn't covered by this ticket. In my case it was installed by Helm Chart by my provider, so it was a simple helm -n kube-system uninstall metrics-server but for you it may differ. You may need to manually remove the CRDs and other resources, or if you have access to the manifests which installed it you could kubectl -n <namespace> delete -f <manifest files>, it may also not be called metrics-server so only with knowledge of your cluster can you determine exactly what and how to remove.

Given the errors you have there, you might be able to just remove the clusterrole (system:aggregated-metrics-reader) and the apiservice (v1beta1.metrics.k8s.io) and see if any more crop up, when you apply again.

hamid-elaosta avatar May 07 '21 09:05 hamid-elaosta

@hamid-elaosta Thanks , I do the following cmds and it seems ok

k delete service/metrics-server -n  kube-system
k delete deployment.apps/metrics-server  -n  kube-system
k delete apiservices.apiregistration.k8s.io v1beta1.metrics.k8s.io
k delete clusterroles.rbac.authorization.k8s.io system:aggregated-metrics-reader

when i install the operator , There's no error reported !

latermonk avatar May 08 '21 09:05 latermonk

You miss others resources. To uninstall correctly metric-server you should launch this delete (I made this to migrate from kubectl apply to helm) :

kubectl delete service/metrics-server -n  kube-system
kubectl delete deployment.apps/metrics-server  -n  kube-system
kubectl delete apiservices.apiregistration.k8s.io v1beta1.metrics.k8s.io
kubectl delete clusterroles.rbac.authorization.k8s.io system:aggregated-metrics-reader
kubectl delete clusterroles.rbac.authorization.k8s.io system:metrics-server 
kubectl delete clusterrolebinding metrics-server:system:auth-delegator
kubectl delete clusterrolebinding system:metrics-server          
kubectl delete rolebinding metrics-server-auth-reader -n kube-system 
kubectl delete serviceaccount metrics-server -n kube-system

throrin19 avatar Aug 26 '22 07:08 throrin19

+1

luis-guimaraes-exoawk avatar Sep 19 '22 13:09 luis-guimaraes-exoawk

+1 to this, had metrics-server and installed kube-prometheus-stack via helm which resulted in my control planes going down

aleksasiriski avatar Jun 03 '23 22:06 aleksasiriski