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

kube_proxy_metrics_bind_address: 0.0.0.0:10249

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: 0.0.0.0:10249

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: 127.0.0.1:10249/metricsBindAddress: 0.0.0.0:10249/g' | 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