Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/metrics/workload/pod-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
| kube_pod_init_container_status_restarts_total | Counter | The number of restarts for the init container | integer | `container`=&lt;container-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `pod`=&lt;pod-name&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
| kube_pod_init_container_resource_limits | Gauge | The number of CPU cores requested limit by an init container | `cpu`=&lt;core&gt; <br> `memory`=&lt;bytes&gt; | `resource`=&lt;resource-name&gt; <br> `unit`=&lt;resource-unit&gt; <br> `container`=&lt;container-name&gt; <br> `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `node`=&lt; node-name&gt; <br> `uid`=&lt;pod-uid&gt; | EXPERIMENTAL | - |
| kube_pod_init_container_resource_requests | Gauge | The number of CPU cores requested by an init container | `cpu`=&lt;core&gt; <br> `memory`=&lt;bytes&gt; | `resource`=&lt;resource-name&gt; <br> `unit`=&lt;resource-unit&gt; <br> `container`=&lt;container-name&gt; <br> `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `node`=&lt; node-name&gt; <br> `uid`=&lt;pod-uid&gt; | EXPERIMENTAL | - |
| kube_pod_spec_volumes_persistentvolumeclaims_info | Gauge | Information about persistentvolumeclaim volumes in a pod | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `volume`=&lt;volume-name&gt; <br> `persistentvolumeclaim`=&lt;persistentvolumeclaim-claimname&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
| kube_pod_spec_volumes_persistentvolumeclaims_readonly | Gauge | Describes whether a persistentvolumeclaim is mounted read only | bool | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `volume`=&lt;volume-name&gt; <br> `persistentvolumeclaim`=&lt;persistentvolumeclaim-claimname&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
| kube_pod_spec_volumes_persistentvolumeclaims_info | Gauge | Information about persistentvolumeclaim and ephemeral volumes in a pod | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `volume`=&lt;volume-name&gt; <br> `persistentvolumeclaim`=&lt;persistentvolumeclaim-claimname&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
| kube_pod_spec_volumes_persistentvolumeclaims_readonly | Gauge | Describes whether a persistentvolumeclaim is mounted read only. Ephemeral volumes always report 0 since the ephemeral volume source does not support a read-only flag | bool | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `volume`=&lt;volume-name&gt; <br> `persistentvolumeclaim`=&lt;persistentvolumeclaim-claimname&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
| kube_pod_status_reason | Gauge | The pod status reasons | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `reason`=&lt;Evicted\|NodeAffinity\|NodeLost\|PreemptionByScheduler\|SchedulingGated\|Shutdown\|TerminationByKubelet\|UnexpectedAdmissionError&gt; <br> `uid`=&lt;pod-uid&gt; | EXPERIMENTAL | - |
| kube_pod_status_scheduled_time | Gauge | Unix timestamp when pod moved into scheduled status | seconds | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
| kube_pod_status_unschedulable | Gauge | Describes the unschedulable status for the pod | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
k8s.io/apimachinery v0.35.4
k8s.io/client-go v0.35.4
k8s.io/component-base v0.35.4
k8s.io/component-helpers v0.35.4
k8s.io/klog/v2 v2.140.0
k8s.io/sample-controller v0.35.4
k8s.io/utils v0.0.0-20260108192941-914a6e750570
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@ k8s.io/client-go v0.35.4 h1:DN6fyaGuzK64UvnKO5fOA6ymSjvfGAnCAHAR0C66kD8=
k8s.io/client-go v0.35.4/go.mod h1:2Pg9WpsS4NeOpoYTfHHfMxBG8zFMSAUi4O/qoiJC3nY=
k8s.io/component-base v0.35.4 h1:6n1tNJ87johN0Hif0Fs8K2GMthsaUwMqCebUDLYyv7U=
k8s.io/component-base v0.35.4/go.mod h1:qaDJgz5c1KYKla9occFmlJEfPpkuA55s90G509R+PeY=
k8s.io/component-helpers v0.35.4 h1:WJM/+fAeeJTAqxPDxgH0aB0q7t8DP+AbV5WkRkOoxYA=
k8s.io/component-helpers v0.35.4/go.mod h1:mE7X9mnMQEX6IbZejdMlWvCx3EPVt1/9PhH/FW0XHDI=
k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc=
k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0=
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE=
Expand Down
17 changes: 15 additions & 2 deletions internal/store/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"strconv"

basemetrics "k8s.io/component-base/metrics"
"k8s.io/component-helpers/storage/ephemeral"
"k8s.io/utils/net"

"k8s.io/kube-state-metrics/v2/pkg/constant"
Expand Down Expand Up @@ -1259,7 +1260,7 @@ func createPodRuntimeClassNameInfoFamilyGenerator() generator.FamilyGenerator {
func createPodSpecVolumesPersistentVolumeClaimsInfoFamilyGenerator() generator.FamilyGenerator {
return *generator.NewFamilyGeneratorWithStability(
"kube_pod_spec_volumes_persistentvolumeclaims_info",
"Information about persistentvolumeclaim volumes in a pod.",
"Information about persistentvolumeclaim and ephemeral volumes in a pod.",
metric.Gauge,
basemetrics.STABLE,
"",
Expand All @@ -1273,6 +1274,12 @@ func createPodSpecVolumesPersistentVolumeClaimsInfoFamilyGenerator() generator.F
LabelValues: []string{v.Name, v.PersistentVolumeClaim.ClaimName},
Value: 1,
})
} else if v.Ephemeral != nil {
Comment thread
eminaktas marked this conversation as resolved.
ms = append(ms, &metric.Metric{
LabelKeys: []string{"volume", "persistentvolumeclaim"},
LabelValues: []string{v.Name, ephemeral.VolumeClaimName(p, &v)},
Value: 1,
})
Comment thread
eminaktas marked this conversation as resolved.
}
}

Expand All @@ -1286,7 +1293,7 @@ func createPodSpecVolumesPersistentVolumeClaimsInfoFamilyGenerator() generator.F
func createPodSpecVolumesPersistentVolumeClaimsReadonlyFamilyGenerator() generator.FamilyGenerator {
return *generator.NewFamilyGeneratorWithStability(
"kube_pod_spec_volumes_persistentvolumeclaims_readonly",
"Describes whether a persistentvolumeclaim is mounted read only.",
"Describes whether a persistentvolumeclaim is mounted read only. Ephemeral volumes always report 0 since the ephemeral volume source does not support a read-only flag.",
metric.Gauge,
basemetrics.STABLE,
"",
Expand All @@ -1300,6 +1307,12 @@ func createPodSpecVolumesPersistentVolumeClaimsReadonlyFamilyGenerator() generat
LabelValues: []string{v.Name, v.PersistentVolumeClaim.ClaimName},
Value: boolFloat64(v.PersistentVolumeClaim.ReadOnly),
})
} else if v.Ephemeral != nil {
ms = append(ms, &metric.Metric{
LabelKeys: []string{"volume", "persistentvolumeclaim"},
LabelValues: []string{v.Name, ephemeral.VolumeClaimName(p, &v)},
Value: 0,
})
Comment thread
eminaktas marked this conversation as resolved.
}
}

Expand Down
10 changes: 8 additions & 2 deletions internal/store/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,10 @@ func TestPodStore(t *testing.T) {
},
},
},
{
Name: "my-ephemeral-vol",
VolumeSource: v1.VolumeSource{Ephemeral: &v1.EphemeralVolumeSource{}},
},
{
Name: "not-pvc-vol",
VolumeSource: v1.VolumeSource{
Expand All @@ -2043,14 +2047,16 @@ func TestPodStore(t *testing.T) {
},
},
Want: `
# HELP kube_pod_spec_volumes_persistentvolumeclaims_info [STABLE] Information about persistentvolumeclaim volumes in a pod.
# HELP kube_pod_spec_volumes_persistentvolumeclaims_readonly [STABLE] Describes whether a persistentvolumeclaim is mounted read only.
# HELP kube_pod_spec_volumes_persistentvolumeclaims_info [STABLE] Information about persistentvolumeclaim and ephemeral volumes in a pod.
# HELP kube_pod_spec_volumes_persistentvolumeclaims_readonly [STABLE] Describes whether a persistentvolumeclaim is mounted read only. Ephemeral volumes always report 0 since the ephemeral volume source does not support a read-only flag.
# TYPE kube_pod_spec_volumes_persistentvolumeclaims_info gauge
# TYPE kube_pod_spec_volumes_persistentvolumeclaims_readonly gauge
kube_pod_spec_volumes_persistentvolumeclaims_info{namespace="ns1",persistentvolumeclaim="claim1",pod="pod1",volume="myvol",uid="uid1"} 1
kube_pod_spec_volumes_persistentvolumeclaims_info{namespace="ns1",persistentvolumeclaim="claim2",pod="pod1",volume="my-readonly-vol",uid="uid1"} 1
kube_pod_spec_volumes_persistentvolumeclaims_info{namespace="ns1",persistentvolumeclaim="pod1-my-ephemeral-vol",pod="pod1",volume="my-ephemeral-vol",uid="uid1"} 1
kube_pod_spec_volumes_persistentvolumeclaims_readonly{namespace="ns1",persistentvolumeclaim="claim1",pod="pod1",volume="myvol",uid="uid1"} 0
kube_pod_spec_volumes_persistentvolumeclaims_readonly{namespace="ns1",persistentvolumeclaim="claim2",pod="pod1",volume="my-readonly-vol",uid="uid1"} 1
kube_pod_spec_volumes_persistentvolumeclaims_readonly{namespace="ns1",persistentvolumeclaim="pod1-my-ephemeral-vol",pod="pod1",volume="my-ephemeral-vol",uid="uid1"} 0

`,
MetricNames: []string{
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ func TestFullScrapeCycle(t *testing.T) {
# HELP kube_pod_service_account The service account for a pod.
# HELP kube_pod_owner [STABLE] Information about the Pod's owner.
# HELP kube_pod_restart_policy [STABLE] Describes the restart policy in use by this pod.
# HELP kube_pod_spec_volumes_persistentvolumeclaims_info [STABLE] Information about persistentvolumeclaim volumes in a pod.
# HELP kube_pod_spec_volumes_persistentvolumeclaims_readonly [STABLE] Describes whether a persistentvolumeclaim is mounted read only.
# HELP kube_pod_spec_volumes_persistentvolumeclaims_info [STABLE] Information about persistentvolumeclaim and ephemeral volumes in a pod.
# HELP kube_pod_spec_volumes_persistentvolumeclaims_readonly [STABLE] Describes whether a persistentvolumeclaim is mounted read only. Ephemeral volumes always report 0 since the ephemeral volume source does not support a read-only flag.
# HELP kube_pod_start_time [STABLE] Start time in unix timestamp for a pod.
# HELP kube_pod_status_container_ready_time Readiness achieved time in unix timestamp for a pod containers.
# HELP kube_pod_status_initialized_time Initialized time in unix timestamp for a pod.
Expand Down