blob: 88163594182116aee7cd71ce1b42f34285ae2b38 [file] [log] [blame]
Charles Chane1e5e622022-02-16 15:17:05 -08001{{/*
2# Copyright 2020-present Open Networking Foundation
3
4# SPDX-License-Identifier: Apache-2.0
5*/}}
6
7{{- $upfConfig := index .Values.config.upf.cfgFiles "upf.json" }}
8{{- $accessConfig := index $upfConfig "access" }}
9{{- $coreConfig := index $upfConfig "core" }}
10---
11apiVersion: apps/v1
12kind: StatefulSet
13metadata:
14 name: upf
15 labels:
16{{ tuple "upf" . | include "omec-user-plane.metadata_labels" | indent 4 }}
17spec:
18 replicas: 1
19 serviceName: upf-headless
20 selector:
21 matchLabels:
22{{ tuple "upf" . | include "omec-user-plane.metadata_labels" | indent 6 }}
23 template:
24 metadata:
25 labels:
26{{ tuple "upf" . | include "omec-user-plane.metadata_labels" | indent 8 }}
27 annotations:
28 k8s.v1.cni.cncf.io/networks: '[
29 {
30 "name": "access-net",
31 "interface": {{ index $accessConfig "ifname" | quote }},
32 {{- if hasKey .Values.config.upf.access "mac" }}
33 "mac": {{ .Values.config.upf.access.mac | quote }},
34 {{- end }}
35 "ips": [{{ .Values.config.upf.access.ip | quote }}]
36 },
37 {
38 "name": "core-net",
39 "interface": {{ index $coreConfig "ifname" | quote }},
40 {{- if hasKey .Values.config.upf.core "mac" }}
41 "mac": {{ .Values.config.upf.core.mac | quote }},
42 {{- end }}
43 "ips": [{{ .Values.config.upf.core.ip | quote }}]
44 }
45 ]'
46 spec:
47 shareProcessNamespace: true
48 {{- if .Values.nodeSelectors.enabled }}
49 nodeSelector:
50 {{ .Values.nodeSelectors.upf.label }}: {{ .Values.nodeSelectors.upf.value }}
51 {{- end }}
52 {{- if hasKey .Values.images "pullSecrets" }}
53 imagePullSecrets:
54{{ toYaml .Values.images.pullSecrets | indent 8 }}
55 {{- end }}
56 initContainers:
57 - name: bess-init
58 image: {{ .Values.images.tags.bess | quote }}
59 imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
60 command: ["sh", "-xec"]
61 args:
62 - ip route replace {{ .Values.config.upf.enb.subnet }} via {{ .Values.config.upf.access.gateway }};
63 ip route replace default via {{ .Values.config.upf.core.gateway }} metric 110;
64 iptables -I OUTPUT -p icmp --icmp-type port-unreachable -j DROP;
65 securityContext:
66 capabilities:
67 add:
68 - NET_ADMIN
69 resources:
70 limits:
71 cpu: 128m
72 memory: 64Mi
73 requests:
74 cpu: 128m
75 memory: 64Mi
76 {{- if .Values.config.coreDump.enabled }}
77{{ tuple "upf" . | include "omec-user-plane.coredump_init" | indent 6 }}
78 {{- end }}
79 containers:
80 - name: bessd
81 image: {{ .Values.images.tags.bess | quote }}
82 imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
83 securityContext:
84 {{- if .Values.config.upf.privileged }}
85 privileged: true
86 {{- end }}
87 capabilities:
88 add:
89 - IPC_LOCK
90 stdin: true
91 tty: true
92 command: ["/bin/bash", "-xc"]
93 args:
94 {{- if .Values.config.upf.hugepage.enabled }}
95 - bessd -f -grpc-url=0.0.0.0:10514
96 {{- else }}
97 - bessd -m 0 -f -grpc-url=0.0.0.0:10514
98 {{- end }}
99 lifecycle:
100 postStart:
101 exec:
102 command: ["/etc/bess/conf/bessd-poststart.sh"]
103 livenessProbe:
104 tcpSocket:
105 port: 10514
106 initialDelaySeconds: 15
107 periodSeconds: 20
108 resources:
109 requests:
110 {{- if .Values.resources.enabled }}
111{{ toYaml .Values.resources.bess.requests | indent 12 }}
112 {{- end }}
113 {{- if .Values.config.upf.hugepage.enabled }}
114 hugepages-1Gi: 2Gi
115 {{- end }}
116 {{- if .Values.config.upf.sriov.enabled }}
117 {{- if eq .Values.config.upf.access.resourceName .Values.config.upf.core.resourceName }}
118 {{ .Values.config.upf.access.resourceName }}: 2
119 {{- else }}
120 {{ .Values.config.upf.access.resourceName }}: 1
121 {{ .Values.config.upf.core.resourceName }}: 1
122 {{- end }}
123 {{- end }}
124 limits:
125 {{- if .Values.resources.enabled }}
126{{ toYaml .Values.resources.bess.limits | indent 12 }}
127 {{- end }}
128 {{- if .Values.config.upf.hugepage.enabled }}
129 hugepages-1Gi: 2Gi
130 {{- end }}
131 {{- if .Values.config.upf.sriov.enabled }}
132 {{- if eq .Values.config.upf.access.resourceName .Values.config.upf.core.resourceName }}
133 {{ .Values.config.upf.access.resourceName }}: 2
134 {{- else }}
135 {{ .Values.config.upf.access.resourceName }}: 1
136 {{ .Values.config.upf.core.resourceName }}: 1
137 {{- end }}
138 {{- end }}
139 env:
140 - name: CONF_FILE
141 value: /etc/bess/conf/upf.json
142 volumeMounts:
143 - name: shared-app
144 mountPath: /pod-share
145 {{- if .Values.config.upf.hugepage.enabled }}
146 - name: hugepages
147 mountPath: /dev/hugepages
148 {{- end }}
149 - name: configs
150 mountPath: /etc/bess/conf
151 {{- if .Values.config.coreDump.enabled }}
152 - name: coredump
153 mountPath: /tmp/coredump
154 {{- end }}
155 - name: routectl
156 image: {{ .Values.images.tags.bess | quote }}
157 imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
158 env:
159 - name: PYTHONUNBUFFERED
160 value: "1"
161 command: ["/opt/bess/bessctl/conf/route_control.py"]
162 args:
163 - -i
164 - {{ index $accessConfig "ifname" }}
165 - {{ index $coreConfig "ifname" }}
166 {{- if .Values.resources.enabled }}
167 resources:
168{{ toYaml .Values.resources.routectl | indent 10 }}
169 {{- end }}
170 - name: web
171 image: {{ .Values.images.tags.bess | quote }}
172 imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
173 command: ["/bin/bash", "-xc", "bessctl http 0.0.0.0 8000"]
174 {{- if .Values.resources.enabled }}
175 resources:
176{{ toYaml .Values.resources.web | indent 10 }}
177 {{- end }}
178 - name: pfcp-agent
179 image: {{ .Values.images.tags.pfcpiface | quote }}
180 imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
181 command: ["pfcpiface"]
182 args:
183 - -config
184 - /tmp/conf/upf.json
185 {{- if .Values.resources.enabled }}
186 resources:
187{{ toYaml .Values.resources.cpiface | indent 10 }}
188 {{- end }}
189 volumeMounts:
190 - name: shared-app
191 mountPath: /pod-share
192 - name: configs
193 mountPath: /tmp/conf
194 {{- if .Values.config.gratuitousArp.enabled }}
195 - name: arping
196 image: {{ .Values.images.tags.tools | quote }}
197 imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
198 command: ["sh", "-xc"]
199 args:
200 - |
201 while true; do
202 # arping does not work - BESS graph is still disconnected
203 #arping -c 2 -I {{ index $accessConfig "ifname" }} {{ .Values.config.upf.access.gateway }}
204 #arping -c 2 -I {{ index $coreConfig "ifname" }} {{ .Values.config.upf.core.gateway }}
205 ping -c 2 {{ .Values.config.upf.access.gateway }}
206 ping -c 2 {{ .Values.config.upf.core.gateway }}
207 sleep {{ .Values.config.gratuitousArp.interval }}
208 done
209 resources:
210 limits:
211 cpu: 128m
212 memory: 64Mi
213 requests:
214 cpu: 128m
215 memory: 64Mi
216 {{- end }}
217 volumes:
218 - name: configs
219 configMap:
220 name: upf
221 defaultMode: 493
222 - name: shared-app
223 emptyDir: {}
224 {{- if .Values.config.upf.hugepage.enabled }}
225 - name: hugepages
226 emptyDir:
227 medium: HugePages
228 {{- end }}
229 {{- if .Values.config.coreDump.enabled }}
230 - name: host-rootfs
231 hostPath:
232 path: /
233 - name: coredump
234 hostPath:
235 path: {{ .Values.config.coreDump.path }}
236 {{- end }}