Kube-state-metrics: kube_service_info{load_balancer_ip} is empty for LoadBalancerServices

Created on 23 Feb 2021  路  7Comments  路  Source: kubernetes/kube-state-metrics

What happened: The load_balancer_ip label for the kube_service_info metric is always returned empty, regardless of the actual IP assigned to Services of type LoadBalancer (which actually have an IP)

> $ curl -sS localhost:8080/metrics | grep load_balancer_ip | grep management-ingress-nginx-controller
kube_service_info{namespace="ingress-management",service="management-ingress-nginx-controller",cluster_ip="172.x.x.x",external_name="",load_balancer_ip=""} 1

What you expected to happen: load_balancer_ip to either have the proper value or to be removed (see below)

How to reproduce it (as minimally and precisely as possible): Reproduced for kube-state-metrics 1.9.7 and 1.9.8 on Kubernetes 1.19.3, with LoadBalancer Services and Metallb.

Anything else we need to know?:

This value is correctly returned in the ip label of the kube_service_status_load_balancer_ingress metric.

> $ curl -sS localhost:8080/metrics | grep -ie balancer | grep -e 62.x | grep nginx
kube_service_status_load_balancer_ingress{namespace="ingress-management",service="management-ingress-nginx-controller",ip="62.x.x.x",hostname=""} 1
kc -n ingress-management get service management-ingress-nginx-controller
NAME                                  TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)                      AGE
management-ingress-nginx-controller   LoadBalancer   172.x.x.x   62.x.x.x   80:32518/TCP,443:32075/TCP   78d

kc -n ingress-management get service management-ingress-nginx-controller -o yaml

Environment:

  • kube-state-metrics version: 1.9.7, 1.9.8
  • Kubernetes version (use kubectl version):
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.3", GitCommit:"1e11e4a2108024935ecfcb2912226cedeafd99df", GitTreeState:"clean", BuildDate:"2020-10-14T12:41:49Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration: Baremetal kubeadm installation (Metallb as load balancer)
kinbug

All 7 comments

It is unclear to me whether this is an implementation bug, that is, kube_service_info{load_balancer_ip} should work; or whether I should be using kube_service_status_load_balancer_ingress{ip} instead. Any advice regarding this is greatly appreciated!

As per https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer, you can specify the loadBalancerIP for a service.
kube_service_info uses this value of loadBalancerIP specified in the spec of the service in the load_balancer_ip label. If it is not specified, the value of the label is empty. However kube_service_status_load_balancer_ingress, uses the .status.loadBalancer field for the value of the ip label.
So if you are not specifying the spec.loadBalancerIP field, you can use kube_service_status_load_balancer_ingress{ip}

Many thanks for the explanation @harjas27, this actually makes sense!

Hey sorry, this seems to have gone by our radar, is everything clear or do you need any more info from our side? Thanks @harjas27 for answering!

I think my main question was solved already, but just to clarify, would kube_service_status_load_balancer_ingress{ip} be populated if loadBalancerIP is defined in the service spec? I'm trying to figure out if I need to query both, or just the kube_service_status_load_balancer_ingress{ip} will do the trick :)
Thanks!

Awesome, thanks for the clarification!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

terinjokes picture terinjokes  路  4Comments

dghubble picture dghubble  路  3Comments

towolf picture towolf  路  8Comments

mrueg picture mrueg  路  3Comments

lilic picture lilic  路  3Comments