Skip to content

Commit 5c380f4

Browse files
authored
feat: Add resource quota metrics collection (#1302)
- Disabled by default, enable by setting `ksm.enableResourceQuotaSamples` to true
1 parent 82efaa0 commit 5c380f4

85 files changed

Lines changed: 79479 additions & 72657 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ Session.vim
3232
.netrwhist
3333

3434
/values-local.yaml
35-
CHANGELOG.partial.md
35+
CHANGELOG.partial.md

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## Unreleased
9+
### enhancement
10+
- Add metrics for ResourceQuota @NRhzhao [#1302](https://github.com/newrelic/nri-kubernetes/pull/1302)
911

1012
## v3.46.0 - 2025-10-13
1113

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: nri-test-namespace
5+
labels:
6+
name: nri-test-namespace
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: v1
2+
kind: ResourceQuota
3+
metadata:
4+
name: nri-test-namespace-quota
5+
namespace: nri-test-namespace
6+
labels:
7+
# Labels are for identifying and selecting objects.
8+
team: "k8-team"
9+
annotations:
10+
# Annotations are for non-identifying metadata, perfect for soft limits.
11+
# These are NOT enforced by Kubernetes.
12+
"owner": "newrelic"
13+
"newrelic.com/soft-limit.pods": "8" # A warning threshold at 80% of the hard limit.
14+
"newrelic.com/soft-limit.requests.cpu": "800m" # A warning at 80% of the 1-core request limit.
15+
"description": "Hard and soft resource limits for the nri-test-namespace."
16+
spec:
17+
hard:
18+
pods: "10"
19+
secrets: "20"
20+
requests.cpu: "1"
21+
requests.memory: "1Gi"
22+
limits.cpu: "2"
23+
limits.memory: "2Gi"
24+
persistentvolumeclaims: "5" # Limit total number of PVCs
25+
services: "10" # Limit total number of services
26+
replicationcontrollers: "5" # Limit total number of replication controllers
27+
configmaps: "10" # Limit total number of config maps
28+
resourcequotas: "1" # Limit total number of resource quotas
29+
services.loadbalancers: "2" # Limit number of external load balancer services
30+
services.nodeports: "5" # Limit number of nodeport servic

charts/internal/e2e-resources/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ windows:
6868
is2019: false
6969
# -- Deploy resources on Windows Server 2022 nodes
7070
is2022: false
71+
72+
kube-state-metrics:
73+
metricLabelsAllowlist: "resourcequotas=[team,environment,app.kubernetes.io/name]"
74+
metricAnnotationsAllowList: "resourcequotas=[owner,description,newrelic.com/soft-limit.pods,newrelic.com/soft-limit.cpu]"

charts/newrelic-infrastructure/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ Infrastructure Agent integrations (Kafka, Cassandra, Redis, etc.) are not suppor
208208
| ksm.config.scheme | string | `"http"` | Scheme to use to connect to kube-state-metrics. Supported values are `http` and `https`. |
209209
| ksm.config.selector | string | `"app.kubernetes.io/name=kube-state-metrics"` | Label selector that will be used to automatically discover an instance of kube-state-metrics running in the cluster. |
210210
| ksm.config.timeout | string | `"10s"` | Timeout for the ksm API contacted by the integration |
211+
| ksm.enableResourceQuotaSamples | bool | `false` | Enable to collect metrics for resource quota. |
211212
| ksm.enabled | bool | `true` | Enable cluster state monitoring. Advanced users only. Setting this to `false` is not supported and will break the New Relic experience. |
212213
| ksm.forwarder | object | 100m/150M -/850M | Resources for the Frowarder pod. large clusters. |
213214
| ksm.hostNetwork | bool | Not set | Sets pod's hostNetwork. When set bypasses global/common variable |

charts/newrelic-infrastructure/templates/ksm/deployment.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ spec:
7272
value: {{ include "newrelic.common.cluster" . }}
7373
- name: "NRI_KUBERNETES_VERBOSE"
7474
value: {{ include "newrelic.common.verboseLog.valueAsBoolean" . | quote }}
75-
75+
{{- if .Values.ksm.enableResourceQuotaSamples }}
76+
- name: "NRI_KUBERNETES_KSM_ENABLERESOURCEQUOTASAMPLES"
77+
value: "true"
78+
{{- end }}
7679
- name: "NRI_KUBERNETES_NODENAME"
7780
valueFrom:
7881
fieldRef:

charts/newrelic-infrastructure/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ ksm:
223223
extraVolumes: []
224224
extraVolumeMounts: []
225225
initContainers: []
226+
# -- Enable to collect metrics for resource quota.
227+
enableResourceQuotaSamples: false
226228
# -- Resources for the KSM scraper pod.
227229
# Keep in mind that sharding is not supported at the moment, so memory usage for this component ramps up quickly on
228230
# large clusters.

e2e/e2e-values.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ images:
33
pullPolicy: Never
44
tag: e2e
55
repository: e2e/nri-kubernetes
6+
7+
ksm:
8+
enableResourceQuotaSamples: true

e2e/k8s.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15182,4 +15182,4 @@ entities:
1518215182
- displayName
1518315183
- event_type
1518415184
- provider
15185-
- networkTag.*
15185+
- networkTag.*

0 commit comments

Comments
 (0)