Skip to content

Commit 38138db

Browse files
pirog-spbpirog-spb
authored andcommitted
fix(helm): make default values produce a startable pod (#645) (#649)
Signed-off-by: pirog-spb <[email protected]> (cherry picked from commit 7465720) Signed-off-by: pirog-spb <[email protected]>
1 parent 6510bc8 commit 38138db

11 files changed

Lines changed: 80 additions & 181 deletions

File tree

‎.deploy/helm/eupf/README.md‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,14 @@ The default values produce a working pod: eUPF is configured via `UPF_*` environ
1919
kubelet --allowed-unsafe-sysctls 'net.ipv4.ip_forward'
2020
```
2121

22-
- **Privileges**: eUPF loads eBPF programs, mounts bpffs/debugfs (via the image entrypoint) and raises `RLIMIT_MEMLOCK`. By default the chart gives the container the capabilities this takes and nothing more:
22+
- **Privileges**: eUPF loads eBPF programs, mounts bpffs/debugfs (via the image entrypoint) and raises `RLIMIT_MEMLOCK`. By default the chart runs the container as `privileged: true`. If your environment allows a finer-grained setup, override `securityContext`, e.g.:
2323

2424
```yaml
2525
securityContext:
2626
capabilities:
2727
add: [NET_ADMIN, SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON]
2828
```
2929
30-
The container keeps the device cgroup, the masked `/proc` and `/sys` paths and the runtime's seccomp and AppArmor profiles. Some environments deny the entrypoint's mounts even with `SYS_ADMIN`: nodes whose AppArmor profile forbids `mount` (the runtime's default profile on Ubuntu and Debian does), a custom seccomp profile that blocks `mount` or `bpf`, or a runtime that rejects `BPF` and `PERFMON` on a kernel before 5.8. There, either allow the mounts (for AppArmor: `securityContext.appArmorProfile: {type: Unconfined}` on Kubernetes 1.30+, the `container.apparmor.security.beta.kubernetes.io/eupf: unconfined` pod annotation before) or fall back to a privileged container:
31-
32-
```yaml
33-
securityContext:
34-
privileged: true
35-
```
36-
3730
- The `/sys` hostPath is mounted read-only into the pod (required by the entrypoint to mount bpffs/debugfs).
3831

3932
## Configuration

‎.deploy/helm/eupf/templates/NOTES.txt‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ eUPF is configured via a ConfigMap (config.enabled=true), mounted at
2424
Notes:
2525
- Nodes must allow the unsafe sysctl net.ipv4.ip_forward
2626
(kubelet --allowed-unsafe-sysctls='net.ipv4.ip_forward').
27-
- The container runs with the capabilities the eBPF data plane needs
28-
(NET_ADMIN, SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON), not privileged; see the
29-
chart README for the environments that need the privileged fallback.
27+
- The container runs privileged by default (eBPF data plane requires it);
28+
see the chart README for a capabilities-based alternative.
3029
- The REST API is served on port {{ .Values.service.port }} (service port "http").

‎.deploy/helm/eupf/templates/configmap.yaml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
{{- if .Values.config.enabled }}
2+
{{- if .Values.config.data }}
3+
---
4+
apiVersion: v1
5+
kind: ConfigMap
6+
metadata:
7+
name: {{ include "eupf.fullname" . }}-config
8+
labels:
9+
{{- include "eupf.labels" . | nindent 4 }}
10+
data:
11+
{{- include "helpers.common.tplvalues.render" ( dict "value" .Values.config.data "context" $ ) | nindent 2 }}
12+
{{- end }}
13+
{{- end }}
114
{{- $all := . -}}
215
{{- range $k, $v := .Values.configMaps }}
316
---

‎.deploy/helm/eupf/templates/deployment.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ spec:
4040
securityContext:
4141
{{- toYaml .Values.securityContext | nindent 12 }}
4242
image: "{{ include "helpers.pod.containerImage" . }}"
43-
imagePullPolicy: {{ .Values.image.pullPolicy | default .Values.global.ImagePullPolicy }}
43+
imagePullPolicy: {{ .Values.image.pullPolicy | default .Values.global.imagePullPolicy }}
4444
{{- if .Values.command }}
4545
command: {{- include "helpers.common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }}
4646
{{- end }}
47-
{{- if .Values.args }}
48-
args: {{- include "helpers.common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }}
47+
{{- if or .Values.args .Values.config.enabled }}
48+
args: {{- include "helpers.pod.args" . | nindent 12 }}
4949
{{- end }}
50-
{{- if .Values.env }}
50+
{{- if or .Values.env (not .Values.config.enabled) }}
5151
env:
5252
- name: MY_POD_IP
5353
valueFrom:

‎.deploy/helm/eupf/templates/helpers/_pod.tpl‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,29 @@
4545

4646
{{- define "helpers.pod.envs" -}}
4747

48-
{{- range $name, $value := .Values.env }}
48+
{{- $env := deepCopy (.Values.env | default dict) }}
49+
{{- if not .Values.config.enabled }}
50+
{{- $env = merge $env (deepCopy (.Values.defaultEnv | default dict)) }}
51+
{{- end }}
52+
{{- range $name, $value := $env }}
4953
- name: {{ $name }}
5054
value: {{ $value | quote }}
5155
{{- end }}
5256

5357
{{- end -}}
5458

59+
{{/*
60+
Container args: user-provided args, prefixed with `--config <config.path>`
61+
when the ConfigMap-based configuration mode is enabled.
62+
*/}}
63+
{{- define "helpers.pod.args" -}}
64+
{{- $args := .Values.args | default list }}
65+
{{- if .Values.config.enabled }}
66+
{{- $args = prepend (prepend $args .Values.config.path) "--config" }}
67+
{{- end }}
68+
{{- include "helpers.common.tplvalues.render" (dict "value" $args "context" $) }}
69+
{{- end -}}
70+
5571
{{- define "helpers.pod.probes" -}}
5672

5773
{{- with .Values.livenessProbe }}
@@ -71,7 +87,12 @@ startupProbe:
7187

7288
{{- define "helpers.pod.volumes" -}}
7389

74-
{{- with .Values.volumes }}
90+
{{- $volumes := .Values.volumes | default list }}
91+
{{- if .Values.config.enabled }}
92+
{{- $configVolume := dict "name" "config" "configMap" (dict "name" (printf "%s-config" (include "eupf.fullname" .))) }}
93+
{{- $volumes = append $volumes $configVolume }}
94+
{{- end }}
95+
{{- with $volumes }}
7596
volumes:
7697
{{- toYaml . | nindent 2 }}
7798
{{- end }}
@@ -80,7 +101,12 @@ volumes:
80101

81102
{{- define "helpers.pod.volumeMounts" -}}
82103

83-
{{- with .Values.volumeMounts }}
104+
{{- $mounts := .Values.volumeMounts | default list }}
105+
{{- if .Values.config.enabled }}
106+
{{- $configMount := dict "name" "config" "mountPath" .Values.config.mountPath }}
107+
{{- $mounts = append $mounts $configMount }}
108+
{{- end }}
109+
{{- with $mounts }}
84110
volumeMounts:
85111
{{- toYaml . | nindent 2 }}
86112
{{- end }}

‎.deploy/helm/eupf/templates/job.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec:
2020
containers:
2121
- name: xdp-programm-install
2222
image: "{{ include "helpers.pod.containerImage" . }}"
23-
imagePullPolicy: {{ .Values.image.pullPolicy | default .Values.global.ImagePullPolicy }}
23+
imagePullPolicy: {{ .Values.image.pullPolicy | default .Values.global.imagePullPolicy }}
2424
securityContext:
2525
{{- toYaml .Values.xdpProgrammInstall.securityContext | nindent 12 }}
2626
resources:

‎.deploy/helm/eupf/templates/statefulset.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ spec:
3737
securityContext:
3838
{{- toYaml .Values.securityContext | nindent 12 }}
3939
image: "{{ include "helpers.pod.containerImage" . }}"
40-
imagePullPolicy: {{ .Values.image.pullPolicy | default .Values.global.ImagePullPolicy }}
40+
imagePullPolicy: {{ .Values.image.pullPolicy | default .Values.global.imagePullPolicy }}
4141
{{- if .Values.command }}
4242
command: {{- include "helpers.common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }}
4343
{{- end }}
44-
{{- if .Values.args }}
45-
args: {{- include "helpers.common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }}
44+
{{- if or .Values.args .Values.config.enabled }}
45+
args: {{- include "helpers.pod.args" . | nindent 12 }}
4646
{{- end }}
47-
{{- if .Values.env }}
47+
{{- if or .Values.env (not .Values.config.enabled) }}
4848
env:
4949
- name: MY_POD_IP
5050
valueFrom:

‎.deploy/helm/eupf/values.yaml‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,13 @@ podSecurityContext:
223223
- name: net.ipv4.ip_forward
224224
value: "1"
225225

226-
# eUPF loads eBPF programs (BPF, PERFMON), attaches XDP and sets routes
227-
# (NET_ADMIN), raises RLIMIT_MEMLOCK (SYS_RESOURCE) and mounts bpffs/debugfs
228-
# from the image entrypoint (SYS_ADMIN). These capabilities are all it needs;
229-
# the container keeps the device cgroup, the masked /proc and /sys paths and
230-
# the runtime's seccomp and AppArmor profiles. Where the mounts are denied
231-
# anyway (an AppArmor profile that forbids mount, a seccomp profile that
232-
# blocks mount or bpf, a runtime that does not know CAP_BPF on a kernel
233-
# before 5.8), fall back to a privileged container:
234-
# privileged: true
226+
# eUPF loads eBPF programs, mounts bpffs/debugfs and raises RLIMIT_MEMLOCK,
227+
# which requires elevated privileges. If your environment allows it, a more
228+
# fine-grained alternative is:
229+
# capabilities:
230+
# add: [NET_ADMIN, SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON]
235231
securityContext:
236-
capabilities:
237-
add: [NET_ADMIN, SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON]
232+
privileged: true
238233

239234
extraContainerPorts:
240235
- name: metrics

‎.deploy/helm/values/dev.yaml‎

Lines changed: 4 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,12 @@
11
---
2+
# Everything required to start the pod (privileged security context,
3+
# net.ipv4.ip_forward sysctl, /sys hostPath, default UPF_* env, probes,
4+
# resources, service ports) now lives in the chart defaults (ENV mode).
5+
# This profile only carries dev-environment specifics.
26

37
global:
48
imagePullPolicy: Always
59

6-
args:
7-
- --config
8-
- /app/conf/config.yml
9-
10-
securityContext:
11-
privileged: true
12-
13-
podSecurityContext:
14-
sysctls:
15-
- name: net.ipv4.ip_forward
16-
value: "1"
17-
18-
configMaps:
19-
config:
20-
data:
21-
config.yml: |
22-
interface_name: eth0
23-
api_address: :8080
24-
pfcp_address: :8805
25-
metrics_address: :9090
26-
27-
env:
28-
UPF_PFCP_NODE_ID: $(MY_POD_IP)
29-
UPF_N3_ADDRESS: $(MY_POD_IP)
30-
31-
volumes:
32-
- name: sys
33-
hostPath:
34-
path: /sys
35-
- name: config
36-
configMap:
37-
name: eupf-config
38-
39-
volumeMounts:
40-
- name: sys
41-
mountPath: /sys
42-
readOnly: true
43-
- name: config
44-
mountPath: /app/conf
45-
4610
metrics:
4711
enabled: true
4812
serviceMonitor:
@@ -52,37 +16,3 @@ metrics:
5216
endpoints:
5317
port: metrics
5418
path: "/metrics"
55-
56-
extraContainerPorts:
57-
- name: metrics
58-
containerPort: 9090
59-
protocol: TCP
60-
61-
service:
62-
type: ClusterIP
63-
port: 8080
64-
extraPorts:
65-
- port: 9090
66-
targetPort: metrics
67-
protocol: TCP
68-
name: metrics
69-
70-
resources:
71-
limits:
72-
cpu: 100m
73-
memory: 128Mi
74-
requests:
75-
cpu: 100m
76-
memory: 128Mi
77-
78-
livenessProbe:
79-
tcpSocket:
80-
port: http
81-
initialDelaySeconds: 5
82-
periodSeconds: 10
83-
84-
readinessProbe:
85-
tcpSocket:
86-
port: http
87-
initialDelaySeconds: 5
88-
periodSeconds: 10

‎.deploy/helm/values/test.yaml‎

Lines changed: 13 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,18 @@
11
---
2+
# Test environment: ConfigMap-based configuration (config.enabled=true).
3+
# In this mode the chart creates a ConfigMap from config.data, mounts it at
4+
# /app/conf and runs the container with `--config /app/conf/config.yml`.
5+
# Default UPF_* env injection is disabled (env vars would override the file).
26

3-
replicaCount: 1
4-
5-
image:
6-
registry: ghcr.io
7-
repository: edgecomllc
8-
name: eupf
9-
tag: ""
10-
11-
args:
12-
- --config
13-
- /app/conf/config.yml
14-
15-
securityContext:
16-
privileged: true
17-
18-
configMaps:
19-
config:
20-
data:
21-
config.yml: |
22-
interface_name: lo
23-
api_address: :8080
24-
pfcp_address: :8805
25-
pfcp_node_id: localhost
26-
metrics_address: :9090
27-
28-
volumes:
29-
- name: sys
30-
hostPath:
31-
path: /sys
32-
- name: config
33-
configMap:
34-
name: eupf-universal-chart-config
35-
36-
volumeMounts:
37-
- name: sys
38-
mountPath: /sys
39-
readOnly: true
40-
- name: config
41-
mountPath: /app/conf
7+
config:
8+
enabled: true
9+
data:
10+
config.yml: |
11+
interface_name: lo
12+
api_address: :8080
13+
pfcp_address: :8805
14+
pfcp_node_id: localhost
15+
metrics_address: :9090
4216
4317
metrics:
4418
enabled: true
@@ -52,37 +26,3 @@ metrics:
5226

5327
imagePullSecrets:
5428
- name: gh-container-registry
55-
56-
extraContainerPorts:
57-
- name: metrics
58-
containerPort: 9090
59-
protocol: TCP
60-
61-
service:
62-
type: ClusterIP
63-
port: 8080
64-
extraPorts:
65-
- port: 9090
66-
targetPort: metrics
67-
protocol: TCP
68-
name: metrics
69-
70-
resources:
71-
limits:
72-
cpu: 100m
73-
memory: 128Mi
74-
requests:
75-
cpu: 100m
76-
memory: 128Mi
77-
78-
livenessProbe:
79-
tcpSocket:
80-
port: http
81-
initialDelaySeconds: 5
82-
periodSeconds: 10
83-
84-
readinessProbe:
85-
tcpSocket:
86-
port: http
87-
initialDelaySeconds: 5
88-
periodSeconds: 10

0 commit comments

Comments
 (0)