Repository: kubernetes/kube-state-metrics

Issue #499: metrics kube_pod_container_resource_* missing for some pods
Created: 2018-07-24T12:14:00Z
/kind bug
What happened:
kube-state-metrics is not exposing kube_pod_container_resource_requests_* metrics for every pod, but just for some of them.
For example, listing pods running on kube-system namespace
$ kubectl get pods --namespace=kube-system
NAME                                                  READY     STATUS    RESTARTS   AGE
aws-node-hkmvv                                        1/1       Running   0          24d
aws-node-qt4ff                                        1/1       Running   0          24d
calico-node-dd2kz                                     1/1       Running   0          4d
calico-node-vd75j                                     1/1       Running   0          4d
calico-typha-75667d89cb-jffb6                         1/1       Running   0          4d
calico-typha-horizontal-autoscaler-78f747b679-8jw88   1/1       Running   0          10d
kube-dns-7cc87d595-tfzb9                              3/3       Running   0          25d
kube-proxy-7w9r7                                      1/1       Running   0          24d
kube-proxy-vq9wz                                      1/1       Running   0          24d
kube2iam-565vd                                        1/1       Running   0          11d
kube2iam-5wqr8                                        1/1       Running   0          11d

However when querying Prometheus, I only get the information for kube-dns:
kube_pod_container_resource_requests_memory_bytes{exported_namespace="kube-system"}

kube_pod_container_resource_requests_memory_bytes{container="dnsmasq",endpoint="http-metrics",exported_namespace="kube-system",exported_pod="kube-dns-7cc87d595-tfzb9",instance="10.0.0.180:8080",job="kube-state-metrics",namespace="monitoring",node="ip-10-0-1-100.us-west-2.compute.internal",pod="kube-state-metrics-59599f757-wpr9d",service="kube-state-metrics"} | 20971520
-- | --
kube_pod_container_resource_requests_memory_bytes{container="kubedns",endpoint="http-metrics",exported_namespace="kube-system",exported_pod="kube-dns-7cc87d595-tfzb9",instance="10.0.0.180:8080",job="kube-state-metrics",namespace="monitoring",node="ip-10-0-1-100.us-west-2.compute.internal",pod="kube-state-metrics-59599f757-wpr9d",service="kube-state-metrics"} | 73400320
kube_pod_container_resource_requests_memory_bytes{container="sidecar",endpoint="http-metrics",exported_namespace="kube-system",exported_pod="kube-dns-7cc87d595-tfzb9",instance="10.0.0.180:8080",job="kube-state-metrics",namespace="monitoring",node="ip-10-0-1-100.us-west-2.compute.internal",pod="kube-state-metrics-59599f757-wpr9d",service="kube-state-metrics"} | 20971520

What you expected to happen:
To see kube_pod_container_resource_* metric for all pods in all namespaces
How to reproduce it (as minimally and precisely as possible):
Not sure how to reproduce it from scratch, because also seems no one else is having this problem
Environment:

Kubernetes version (use kubectl version): 1.11
Kube-state-metrics image version: 1.3.1

Duplicate issue #1336: kube_pod_container_resource* only available for kube-system namespace
Created: 2020-12-22T22:30:52Z
Hello,
What happened:
kube_pod_container_resource* only available for kube-system namespace pods (namespace of kube-state-metrics pod).
But kube_pod_container_status_last_terminated_reason works by example for all pods of all namespaces.
What you expected to happen:
kube_pod_container_resource* available for all pods of all namespaces.
How to reproduce it (as minimally and precisely as possible):

git clone https://github.com/kubernetes/kube-state-metrics
cd kube-state-metrics/examples/standard
git checkout v1.9.7 (or master)
service.yaml patched:

diff --git a/examples/standard/service.yaml b/examples/standard/service.yaml
index f5b488f5..1609e488 100644
--- a/examples/standard/service.yaml
+++ b/examples/standard/service.yaml
@@ -7,7 +7,6 @@ metadata:
   name: kube-state-metrics
   namespace: kube-system
 spec:
-  clusterIP: None
   ports:
   - name: http-metrics
     port: 8080
@@ -17,3 +16,5 @@ spec:
     targetPort: telemetry
   selector:
     app.kubernetes.io/name: kube-state-metrics
+  externalIPs:
+    - IP
Anything else we need to know?:
Environment:

kube-state-metrics version: 1.9 (also tested with v2)
Kubernetes version (use kubectl version): v1.20.1
Cloud provider or hardware configuration: Ubuntu 20.04
Other info:

Please tell me if you need more infos.

Closing comment (2020-12-29T23:02:55Z): Fixed. Related to #499