Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6f56267
Add kube_deployment_spec_topology_spread_constraints metric
SoumyaRaikwar Aug 10, 2025
6937b62
Update deployment.go
SoumyaRaikwar Aug 10, 2025
029314c
Update deployment_test.go
SoumyaRaikwar Aug 10, 2025
f713f6d
docs: Add kube_deployment_spec_topology_spread_constraints metric doc…
SoumyaRaikwar Aug 11, 2025
cffd506
fix: Format imports in deployment_test.go
SoumyaRaikwar Aug 11, 2025
206a445
docs: Add kube_deployment_spec_topology_spread_constraints to docume…
SoumyaRaikwar Aug 12, 2025
3634213
Fix formatting in deployment_test.go
SoumyaRaikwar Aug 13, 2025
1529bb5
Add explicit topology spread constraint metric
SoumyaRaikwar Aug 19, 2025
b591c60
corrected the formatting of the commit message and added a new metric…
SoumyaRaikwar Aug 19, 2025
2a16027
Merge branch 'main' into add-deployment-topology-spread-constraints-m…
SoumyaRaikwar Aug 19, 2025
d7b89a3
Resolve merge conflict in deployment metrics documentation
SoumyaRaikwar Aug 30, 2025
655b393
Fix deployment metrics documentation with reason label
SoumyaRaikwar Aug 30, 2025
21d1ee0
updated deployment-metrics.md
SoumyaRaikwar Aug 30, 2025
dc3fec2
Update deployment metrics documentation
SoumyaRaikwar Aug 30, 2025
e67b066
Fix missing newline in deployment metrics documentation
SoumyaRaikwar Aug 30, 2025
679d205
corrected intendation in deployment-metrics.md
SoumyaRaikwar Aug 30, 2025
705afa7
Merge branch 'main' into add-deployment-topology-spread-constraints-m…
SoumyaRaikwar Aug 30, 2025
06d1481
Update deployment-metrics.md
SoumyaRaikwar Sep 1, 2025
50220e8
done
SoumyaRaikwar Sep 1, 2025
e3fbe3f
Fix YAML formatting and indentation in manifest files
SoumyaRaikwar Sep 1, 2025
ac06d33
Merge branch 'main' into add-deployment-topology-spread-constraints-m…
SoumyaRaikwar Sep 1, 2025
7e9303c
updated deployment_test..go
SoumyaRaikwar Sep 2, 2025
eb1cb72
Regenerate manifests with canonical formatting from Jsonnet
SoumyaRaikwar Sep 2, 2025
4a76538
Regenerate manifests to canonical format for validation
SoumyaRaikwar Sep 7, 2025
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
1 change: 1 addition & 0 deletions docs/metrics/workload/deployment-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
| kube_deployment_spec_paused | Gauge | Whether the deployment is paused and will not be processed by the deployment controller. | `deployment`=&lt;deployment-name&gt; <br> `namespace`=&lt;deployment-namespace&gt; | STABLE |
| kube_deployment_spec_strategy_rollingupdate_max_unavailable | Gauge | Maximum number of unavailable replicas during a rolling update of a deployment. | `deployment`=&lt;deployment-name&gt; <br> `namespace`=&lt;deployment-namespace&gt; | STABLE |
| kube_deployment_spec_strategy_rollingupdate_max_surge | Gauge | Maximum number of replicas that can be scheduled above the desired number of replicas during a rolling update of a deployment. | `deployment`=&lt;deployment-name&gt; <br> `namespace`=&lt;deployment-namespace&gt; | STABLE |
| kube_deployment_spec_topology_spread_constraint | Gauge | Explicit details of each topology spread constraint in the deployment's pod template | `deployment`=&lt;deployment-name&gt; <br> `namespace`=&lt;deployment-namespace&gt; <br> `topology_key`=&lt;topology-key&gt; <br> `max_skew`=&lt;max-skew-value&gt; <br> `when_unsatisfiable`=&lt;DoNotSchedule\|ScheduleAnyway&gt; <br> `min_domains`=&lt;min-domains-value&gt; <br> `label_selector`=&lt;label-selector-string&gt; | ALPHA |
| kube_deployment_metadata_generation | Gauge | Sequence number representing a specific generation of the desired state. | `deployment`=&lt;deployment-name&gt; <br> `namespace`=&lt;deployment-namespace&gt; | STABLE |
| kube_deployment_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](../../developer/cli-arguments.md) | `deployment`=&lt;deployment-name&gt; <br> `namespace`=&lt;deployment-namespace&gt; <br> `label_DEPLOYMENT_LABEL`=&lt;DEPLOYMENT_LABEL&gt; | STABLE |
| kube_deployment_created | Gauge | Unix creation timestamp | `deployment`=&lt;deployment-name&gt; <br> `namespace`=&lt;deployment-namespace&gt; | STABLE |
Expand Down
2 changes: 1 addition & 1 deletion examples/autosharding/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ rules:
- roles
verbs:
- list
- watch
- watch
4 changes: 2 additions & 2 deletions examples/autosharding/role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ roleRef:
kind: Role
name: kube-state-metrics
subjects:
- kind: ServiceAccount
name: kube-state-metrics
- kind: ServiceAccount
name: kube-state-metrics
2 changes: 1 addition & 1 deletion examples/autosharding/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ rules:
resources:
- statefulsets
verbs:
- get
- get
2 changes: 1 addition & 1 deletion examples/autosharding/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ spec:
targetPort: http-metrics
- name: telemetry
port: 8081
targetPort: telemetry
targetPort: telemetry
selector:
app.kubernetes.io/name: kube-state-metrics
2 changes: 1 addition & 1 deletion examples/standard/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ rules:
- roles
verbs:
- list
- watch
- watch
2 changes: 1 addition & 1 deletion examples/standard/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ spec:
targetPort: http-metrics
- name: telemetry
port: 8081
targetPort: telemetry
targetPort: telemetry
selector:
app.kubernetes.io/name: kube-state-metrics
37 changes: 37 additions & 0 deletions internal/store/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package store

import (
"context"
"strconv"

basemetrics "k8s.io/component-base/metrics"

Expand Down Expand Up @@ -289,6 +290,42 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
}
}),
),
*generator.NewFamilyGeneratorWithStability(
"kube_deployment_spec_topology_spread_constraint",
"Explicit details of each topology spread constraint in the deployment's pod template.",
metric.Gauge,
basemetrics.ALPHA,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
ms := []*metric.Metric{}
for _, constraint := range d.Spec.Template.Spec.TopologySpreadConstraints {
labelSelectorStr, err := metav1.LabelSelectorAsSelector(constraint.LabelSelector)
if err != nil {
// Skip invalid label selectors
continue
}

minDomainsStr := "1" // default value when nil
if constraint.MinDomains != nil {
minDomainsStr = strconv.Itoa(int(*constraint.MinDomains))
}

ms = append(ms, &metric.Metric{
LabelKeys: []string{"topology_key", "max_skew", "when_unsatisfiable", "min_domains", "label_selector"},
LabelValues: []string{
constraint.TopologyKey,
strconv.Itoa(int(constraint.MaxSkew)),
string(constraint.WhenUnsatisfiable),
minDomainsStr,
labelSelectorStr.String(),
},
Value: 1,
})
}
return &metric.Family{Metrics: ms}
}),
),

*generator.NewFamilyGeneratorWithStability(
"kube_deployment_metadata_generation",
"Sequence number representing a specific generation of the desired state.",
Expand Down
Loading
Loading