Skip to content

Commit 7465720

Browse files
authored
fix(helm): make default values produce a startable pod (#645) (#649)
Signed-off-by: pirog-spb <[email protected]>
1 parent bc686b3 commit 7465720

11 files changed

Lines changed: 256 additions & 217 deletions

File tree

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# eUPF Helm Chart
2+
3+
Deploys [eUPF](https://github.com/edgecomllc/eupf) — an open-source 5G User Plane Function built on eBPF.
4+
5+
## Quick start
6+
7+
```bash
8+
helm install eupf .deploy/helm/eupf
9+
```
10+
11+
The default values produce a working pod: eUPF is configured via `UPF_*` environment variables (see below), probes and resource requests/limits are set, and the API is served on port 8080.
12+
13+
## Cluster prerequisites
14+
15+
- **Linux kernel >= 5.15** on the nodes (eBPF/XDP requirement).
16+
- **Unsafe sysctl allowed**: the chart sets `net.ipv4.ip_forward=1` in the pod security context, which nodes must allow:
17+
18+
```
19+
kubelet --allowed-unsafe-sysctls 'net.ipv4.ip_forward'
20+
```
21+
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.:
23+
24+
```yaml
25+
securityContext:
26+
capabilities:
27+
add: [NET_ADMIN, SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON]
28+
```
29+
30+
- The `/sys` hostPath is mounted read-only into the pod (required by the entrypoint to mount bpffs/debugfs).
31+
32+
## Configuration
33+
34+
eUPF supports configuration via CLI flags, environment variables and a YAML config file (see [docs/Configuration.md](https://github.com/edgecomllc/eupf/blob/main/docs/Configuration.md)). Precedence: CLI > **env** > config file > defaults.
35+
36+
The chart supports two modes:
37+
38+
### ENV mode (default, `config.enabled: false`)
39+
40+
The chart injects a working default set of `UPF_*` variables (see `defaultEnv` in `values.yaml`), where `UPF_PFCP_NODE_ID` and `UPF_N3_ADDRESS` default to the pod IP. Override any of them via the `env` map:
41+
42+
```yaml
43+
env:
44+
UPF_INTERFACE_NAME: eth0,n6 # comma-separated, no brackets
45+
UPF_LOGGING_LEVEL: debug
46+
```
47+
48+
List-valued parameters (e.g. `UPF_INTERFACE_NAME`) are comma-separated strings.
49+
50+
### ConfigMap mode (`config.enabled: true`)
51+
52+
```yaml
53+
config:
54+
enabled: true
55+
data:
56+
config.yml: |
57+
interface_name: eth0
58+
api_address: :8080
59+
pfcp_address: :8805
60+
metrics_address: :9090
61+
```
62+
63+
The chart creates a ConfigMap from `config.data`, mounts it at `/app/conf` and starts the container with `--config /app/conf/config.yml`. In this mode the default `UPF_*` env injection is **disabled**, because environment variables take precedence over the config file. You can still add env vars as targeted overrides via `env`.
64+
65+
### Ports
66+
67+
| Port | Name | Purpose |
68+
|------|------|---------|
69+
| 8080 | http | REST API (`service.port`, must match `UPF_API_ADDRESS` / `api_address`) |
70+
| 9090 | metrics | Prometheus metrics |
71+
72+
Probes are TCP checks against the `http` port; keep `service.port` in sync with the API address if you change it.

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,24 @@ To learn more about the release, try:
66

77
$ helm status {{ .Release.Name }}
88
$ helm get all {{ .Release.Name }}
9+
10+
Check that the pod is running and passing its probes:
11+
12+
$ kubectl get pods -l app.kubernetes.io/instance={{ .Release.Name }}
13+
14+
{{- if not .Values.config.enabled }}
15+
16+
eUPF is configured via default UPF_* environment variables (ENV mode).
17+
To use a config file instead, set config.enabled=true and provide config.data.
18+
{{- else }}
19+
20+
eUPF is configured via a ConfigMap (config.enabled=true), mounted at
21+
{{ .Values.config.mountPath }} and passed with --config {{ .Values.config.path }}.
22+
{{- end }}
23+
24+
Notes:
25+
- Nodes must allow the unsafe sysctl net.ipv4.ip_forward
26+
(kubelet --allowed-unsafe-sysctls='net.ipv4.ip_forward').
27+
- The container runs privileged by default (eBPF data plane requires it);
28+
see the chart README for a capabilities-based alternative.
29+
- 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:

0 commit comments

Comments
 (0)