-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: add support for label generation for ephemeral volumes in pod #2891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
|
@@ -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, | ||
| "", | ||
|
|
@@ -1273,6 +1274,12 @@ func createPodSpecVolumesPersistentVolumeClaimsInfoFamilyGenerator() generator.F | |
| LabelValues: []string{v.Name, v.PersistentVolumeClaim.ClaimName}, | ||
| Value: 1, | ||
| }) | ||
| } else if v.Ephemeral != nil { | ||
| ms = append(ms, &metric.Metric{ | ||
| LabelKeys: []string{"volume", "persistentvolumeclaim"}, | ||
| LabelValues: []string{v.Name, ephemeral.VolumeClaimName(p, &v)}, | ||
| Value: 1, | ||
| }) | ||
|
eminaktas marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -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, | ||
| "", | ||
|
|
@@ -1300,6 +1307,12 @@ func createPodSpecVolumesPersistentVolumeClaimsReadonlyFamilyGenerator() generat | |
| LabelValues: []string{v.Name, v.PersistentVolumeClaim.ClaimName}, | ||
| Value: boolFloat64(v.PersistentVolumeClaim.ReadOnly), | ||
| }) | ||
| } else if v.Ephemeral != nil { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we expose that this is an ephemeral pvc volume in metrics as well?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it make sense to have it. Should we introduce a new metric or a new label? |
||
| ms = append(ms, &metric.Metric{ | ||
| LabelKeys: []string{"volume", "persistentvolumeclaim"}, | ||
| LabelValues: []string{v.Name, ephemeral.VolumeClaimName(p, &v)}, | ||
| Value: 0, | ||
| }) | ||
|
eminaktas marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.