Skip to content

Commit adec99a

Browse files
schau87anthonyh209
authored andcommitted
18238 add cgroup v2 and containerd socket configuration options
This werk adds configuration guidance for mounting containerd runtime sockets in cAdvisor pods to resolve container metadata mapping issues on Kubernetes nodes running with cgroup v2. When Kubernetes nodes run with cgroup v2, cAdvisor cannot properly map container metadata (pod names, namespaces, labels) from cgroups alone, resulting in CPU and memory metrics missing required labels. Mounting the containerd socket allows cAdvisor to query containerd directly for metadata. Further information can be found in the values.yaml file. Change-Id: Ib50cdca4bacf9c99870c5b992f0e3ce1309ab54f
1 parent 862aacc commit adec99a

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

.werks/18238.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[//]: # (werk v2)
2+
# add cgroup v2 and containerd socket configuration options
3+
4+
key | value
5+
---------- | ---
6+
date | 2025-08-01T09:38:07+00:00
7+
version | 1.8.0
8+
class | feature
9+
edition | cre
10+
component | helm
11+
level | 1
12+
compatible | yes
13+
14+
This werk adds configuration guidance for mounting containerd runtime sockets in cAdvisor pods to resolve
15+
container metadata mapping issues on Kubernetes nodes running with cgroup v2.
16+
When Kubernetes nodes run with cgroup v2, cAdvisor cannot properly map container metadata
17+
(pod names, namespaces, labels) from cgroups alone, resulting in CPU and memory metrics missing
18+
required labels. Mounting the containerd socket allows cAdvisor to query containerd directly for
19+
metadata. Further information can be found in the values.yaml file.

deploy/charts/checkmk/templates/node-collector-container-metrics-ds.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ spec:
8787
- name: docker
8888
mountPath: /var/lib/docker
8989
readOnly: true
90+
{{- if .Values.nodeCollector.cadvisor.containerdSocket }}
91+
{{- if .Values.nodeCollector.cadvisor.containerdSocket.enabled }}
92+
- name: containerdsock
93+
mountPath: {{ .Values.nodeCollector.cadvisor.containerdSocket.mountPath | quote }}
94+
readOnly: true
95+
{{- end }}
96+
{{- end }}
9097
- name: container-metrics-collector
9198
securityContext:
9299
{{- toYaml .Values.nodeCollector.containerMetricsCollector.securityContext | nindent 12 }}
@@ -133,6 +140,14 @@ spec:
133140
- name: docker
134141
hostPath:
135142
path: /var/lib/docker
143+
{{- if .Values.nodeCollector.cadvisor.containerdSocket }}
144+
{{- if .Values.nodeCollector.cadvisor.containerdSocket.enabled }}
145+
- name: containerdsock
146+
hostPath:
147+
path: {{ .Values.nodeCollector.cadvisor.containerdSocket.hostPath | quote }}
148+
type: Socket
149+
{{- end }}
150+
{{- end }}
136151
{{- if .Values.tlsCommunication.enabled }}
137152
- name: checkmk-ca-cert
138153
secret:

deploy/charts/checkmk/values.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,34 @@ nodeCollector:
242242
# cpu: 150m
243243
# memory: 200Mi
244244

245+
# Configuration for containerd socket (used by cadvisor in the node collector).
246+
# This section is optional and only needed if CPU/Memory metrics are missing the required labels.
247+
# Access to the container runtime socket (e.g., for metrics collection).
248+
# Known limitation:
249+
# - When Kubernetes nodes run with cgroup v2 (common in newer distros),
250+
# cAdvisor cannot properly map container metadata (pod name, namespace, labels)
251+
# from cgroups alone.
252+
# - To work around this, the container runtime socket must be mounted inside the cAdvisor pod
253+
# so that cAdvisor can query containerd directly for metadata via its gRPC interface.
254+
#
255+
# To locate the correct socket path on your host node, run:
256+
# find / -type s -name 'containerd.sock' 2>/dev/null
257+
#
258+
# The path varies depending on your Kubernetes setup:
259+
# - MicroK8s: /var/snap/microk8s/common/run/containerd.sock
260+
# - Standard containerd: /run/containerd/containerd.sock
261+
# - k3s: /run/k3s/containerd/containerd.sock
262+
#
263+
# mountPath is where the socket is available inside the container.
264+
# hostPath is the full path to the socket file on the Kubernetes node.
265+
#
266+
# Example to enable:
267+
# containerdSocket:
268+
# enabled: true
269+
# name: containerdsock
270+
# mountPath: /var/snap/microk8s/common/run/containerd.sock
271+
# hostPath: /var/snap/microk8s/common/run/containerd.sock
272+
245273
containerMetricsCollector:
246274
image:
247275
repository: checkmk/kubernetes-collector

0 commit comments

Comments
 (0)