Fixing bind address of kube-proxy metrics for prometheus monitoring

Using kubespray to install k8s the default bind address for kube-proxy metrics endpoint is localhost:10249. This makes prometheus community not scrap the metrics because it needs access at the host network level. To solve this follow this simple steps.

If using kubespray to setup the k8s add this line in your inventory k8s-cluster.yaml


You can eighter rerun the playbook (which takes at last 30 minutes) or you can change manually:

SSH in the hosts Edit the file: /etc/kubernetes/kubeadm-config.yaml change the line metricsBindAddress:

Repeat the process for all nodes running kube-proxy

Now run the command:

 kubectl --kubeconfig /etc/kubernetes/admin.conf -n kube-system get configmap kube-proxy -o yaml | sed 's/metricsBindAddress:' | kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f -

And restart kube-proxy:

kubectl --kubeconfig /etc/kubernetes/admin.conf delete pod -n kube-system -l k8s-app=kube-proxy --force --grace-period=0

Test if works, and is done