Skip to content

Commit 2f76ea1

Browse files
Merge pull request #735 from thomasferrandiz/multus-dnc
Add multus dynamic networks controller
2 parents db77b04 + e11b961 commit 2f76ea1

File tree

6 files changed

+166
-4
lines changed

6 files changed

+166
-4
lines changed

packages/rke2-multus/charts/templates/_helpers.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ tier: node
1818
app: {{ .Chart.Name }}
1919
{{- end }}
2020

21+
{{- define "dynamicNetworksController.labels" }}
22+
tier: node
23+
app: {{ .Chart.Name }}-dnc
24+
{{- end }}
25+
2126
{{- define "system_default_registry" -}}
2227
{{- if .Values.global.systemDefaultRegistry -}}
2328
{{- printf "%s/" .Values.global.systemDefaultRegistry -}}

packages/rke2-multus/charts/templates/daemonSet-thick.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ spec:
7979
image: {{ template "system_default_registry" . }}{{ .Values.thickPlugin.image.repository }}:{{ .Values.thickPlugin.image.tag }}
8080
imagePullPolicy: {{ .Values.thickPlugin.image.pullPolicy }}
8181
command: [ "/usr/src/multus-cni/bin/multus-daemon" ]
82-
{{- if .Values.pod.resources.multus }}
82+
{{- if .Values.pod.resources.enabled }}
8383
resources: {{- toYaml .Values.pod.resources.multus | nindent 10 }}
8484
{{- end }}
8585
securityContext:

packages/rke2-multus/charts/templates/daemonSet.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ spec:
107107
{{- if .Values.config.cni_conf.cleanupConfigOnExit }}
108108
- "--cleanup-config-on-exit={{ .Values.config.cni_conf.cleanupConfigOnExit }}"
109109
{{- end }}
110-
{{- if .Values.pod.resources.multus }}
111-
resources: {{- toYaml .Values.pod.resources.multus | nindent 10 }}
110+
{{- if .Values.pod.resources.enabled }}
111+
resources: {{- toYaml .Values.pod.resources.multus.enabled | nindent 10 }}
112112
{{- end }}
113113
securityContext:
114114
privileged: true
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
{{- if .Values.dynamicNetworksController.enabled }}
2+
{{- if .Values.manifests.clusterRole }}
3+
---
4+
kind: ClusterRole
5+
apiVersion: rbac.authorization.k8s.io/v1
6+
metadata:
7+
name: {{ .Chart.Name }}-dnc
8+
rules:
9+
- apiGroups: ["k8s.cni.cncf.io"]
10+
resources:
11+
- network-attachment-definitions
12+
verbs:
13+
- get
14+
- list
15+
- watch
16+
- apiGroups:
17+
- ""
18+
resources:
19+
- pods
20+
- pods/status
21+
verbs:
22+
- get
23+
- list
24+
- update
25+
- watch
26+
- apiGroups:
27+
- ""
28+
- events.k8s.io
29+
resources:
30+
- events
31+
verbs:
32+
- create
33+
- patch
34+
- update
35+
{{- end }}
36+
{{- if .Values.manifests.clusterRoleBinding }}
37+
---
38+
kind: ClusterRoleBinding
39+
apiVersion: rbac.authorization.k8s.io/v1
40+
metadata:
41+
name: {{ .Chart.Name }}-dnc
42+
roleRef:
43+
apiGroup: rbac.authorization.k8s.io
44+
kind: ClusterRole
45+
name: {{ .Chart.Name }}-dnc
46+
subjects:
47+
- kind: ServiceAccount
48+
name: {{ .Chart.Name }}-dnc
49+
namespace: {{ .Release.Namespace }}
50+
{{- end }}
51+
---
52+
{{- if .Values.manifests.serviceAccount }}
53+
apiVersion: v1
54+
kind: ServiceAccount
55+
metadata:
56+
name: {{ .Chart.Name }}-dnc
57+
namespace: {{ .Release.Namespace }}
58+
{{- end }}
59+
---
60+
{{- if .Values.manifests.configMap }}
61+
kind: ConfigMap
62+
apiVersion: v1
63+
metadata:
64+
name: dynamic-networks-controller-config
65+
namespace: {{ .Release.Namespace }}
66+
labels:
67+
{{- include "dynamicNetworksController.labels" . | indent 8 }}
68+
data:
69+
dynamic-networks-config.json: |
70+
{
71+
"criSocketPath": "/host{{ .Values.dynamicNetworksController.sockets.containerd }}",
72+
"multusSocketPath": "/host{{ .Values.dynamicNetworksController.sockets.multus }}"
73+
}
74+
{{- end }}
75+
---
76+
apiVersion: apps/v1
77+
kind: DaemonSet
78+
metadata:
79+
name: {{ .Release.Name }}-dnc
80+
namespace: {{ .Release.Namespace }}
81+
labels:
82+
{{- include "dynamicNetworksController.labels" . | indent 8 }}
83+
spec:
84+
selector:
85+
matchLabels:
86+
app: {{ .Chart.Name }}-dnc
87+
updateStrategy:
88+
type: RollingUpdate
89+
template:
90+
metadata:
91+
labels:
92+
{{- include "dynamicNetworksController.labels" . | indent 8 }}
93+
spec:
94+
{{- with .Values.tolerations }}
95+
tolerations:
96+
{{- toYaml . | trim | nindent 8 }}
97+
{{- end }}
98+
serviceAccountName: {{ .Chart.Name }}-dnc
99+
containers:
100+
- name: dynamic-networks-controller
101+
env:
102+
- name: NODE_NAME
103+
valueFrom:
104+
fieldRef:
105+
fieldPath: spec.nodeName
106+
image: {{ template "system_default_registry" . }}{{ .Values.dynamicNetworksController.image.repository }}:{{ .Values.dynamicNetworksController.image.tag }}
107+
command: [ "/dynamic-networks-controller" ]
108+
args:
109+
- "-config=/etc/dynamic-networks-controller/dynamic-networks-config.json"
110+
- "-v=5"
111+
{{- if .Values.pod.resources.enabled }}
112+
resources: {{- toYaml .Values.pod.resources.dynamicNetworksController | nindent 10 }}
113+
{{- end }}
114+
securityContext:
115+
privileged: true
116+
volumeMounts:
117+
- name: dynamic-networks-controller-config-dir
118+
mountPath: /etc/dynamic-networks-controller/
119+
readOnly: true
120+
- name: multus-server-socket
121+
mountPath: /host{{ .Values.dynamicNetworksController.sockets.multus }}
122+
- name: cri-socket
123+
mountPath: /host{{ .Values.dynamicNetworksController.sockets.containerd }}
124+
terminationMessagePolicy: FallbackToLogsOnError
125+
terminationGracePeriodSeconds: 10
126+
volumes:
127+
- name: dynamic-networks-controller-config-dir
128+
configMap:
129+
name: dynamic-networks-controller-config
130+
items:
131+
- key: dynamic-networks-config.json
132+
path: dynamic-networks-config.json
133+
- name: multus-server-socket
134+
hostPath:
135+
path: {{ .Values.dynamicNetworksController.sockets.multus }}
136+
type: Socket
137+
- name: cri-socket
138+
hostPath:
139+
path: {{ .Values.dynamicNetworksController.sockets.containerd }}
140+
type: Socket
141+
{{- end }}

packages/rke2-multus/charts/values.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ pod:
4646
limits:
4747
memory: "1024Mi"
4848
cpu: "2000m"
49+
dynamicNetworksController:
50+
requests:
51+
cpu: "100m"
52+
memory: "50Mi"
4953

5054
#podSecurityContext: {}
5155
# fsGroup: 2000
@@ -156,3 +160,15 @@ thickPlugin:
156160
tag: v4.2.1-build20250627
157161
pullPolicy: IfNotPresent
158162

163+
# This deploys the dynamic networks controller add-on.
164+
# It can only be used with thickPlugin.enabled=true.
165+
# See https://github.com/k8snetworkplumbingwg/multus-dynamic-networks-controller/ for more details
166+
dynamicNetworksController:
167+
enabled: false
168+
image:
169+
repository: rancher/hardened-multus-dynamic-networks-controller
170+
tag: v0.3.7-build20250711
171+
pullPolicy: IfNotPresent
172+
sockets:
173+
containerd: /run/k3s/containerd/containerd.sock
174+
multus: /run/multus/multus.sock

packages/rke2-multus/package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
url: local
22
workingDir: charts
3-
packageVersion: 05
3+
packageVersion: 06

0 commit comments

Comments
 (0)