blob: 326991c67a2a628daeddbf75d2f26b6cb4320317 [file] [log] [blame]
Wei-Yu Chen0f12b9c2019-04-18 11:12:59 -07001---
2# Copyright 2018-present Open Networking Foundation
3# Copyright 2018 Intel Corporation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16---
17apiVersion: v1
18kind: ServiceAccount
19metadata:
20 name: spgwc-pod-reader
21---
22kind: Role
23apiVersion: rbac.authorization.k8s.io/v1
24metadata:
25 name: pod-reader
26rules:
27- apiGroups: [""]
28 resources: ["pods"]
29 verbs: ["get"]
30---
31kind: RoleBinding
32apiVersion: rbac.authorization.k8s.io/v1
33metadata:
34 name: spgwc-pod-reader-rb
35roleRef:
36 apiGroup: rbac.authorization.k8s.io
37 kind: Role
38 name: pod-reader
39subjects:
40- kind: ServiceAccount
41 name: spgwc-pod-reader
42---
43apiVersion: v1
44kind: ConfigMap
45metadata:
46 name: {{ .Values.spgwc.name }}
47data:
48 launch.sh: |
49 #!/bin/bash -xe
50
51 RUN_DIR=${RUN_DIR:-"/opt/cp"}
52 mkdir -p $RUN_DIR/config
53 cd $RUN_DIR/config
54 cp /etc/cp/config/{adc_rules.cfg,cp_config.cfg,interface.cfg,meter_profile.cfg,pcc_rules.cfg,sdf_rules.cfg} .
55 sed -i "s/CP_ADDR/$CP_ADDR/g" interface.cfg
56 sed -i "s/DP_ADDR/$DP_ADDR/g" interface.cfg
57 . cp_config.cfg
58 ngic_controlplane $EAL_ARGS -- $APP_ARGS
59 cp_config.cfg: |
60 if [ ! -d "/dev/hugepages" ]; then
61 MEMORY="--no-huge -m $((MEM_LIMIT-1024))"
62 fi
63 SHARED_DIR="/opt/cp/config/shared"
64 if [ -d ${SHARED_DIR} ]; then
65 while [ ! -f ${SHARED_DIR}/SGW_S1U_IP ]; do echo "Waiting for SGW_S1U_IP"; sleep 2; done
66 SGW_S1U_IP=$(cat ${SHARED_DIR}/SGW_S1U_IP)
67 fi
68
69 MGMT_INFO="-s ${CP_ADDR} -m ${MME_S11_IP} -w ${SGW_S1U_IP}"
70 APN_INFO="-i ${IP_POOL_IP} -p ${IP_POOL_MASK} -a ${APN}"
71 SPGW_CFG="-d 03 -l 2 -r 7.7.7.7 -g 6.6.6.6 -v 4.4.4.4 -u 5.5.5.5"
72 APP_ARGS="${MGMT_INFO} ${APN_INFO} ${SPGW_CFG} ${TEID_INFO}"
73
74 CORES="-c $(taskset -p $$ | awk '{print $NF}')"
75 DEVICES="--no-pci"
76 EAL_ARGS="${CORES} ${MEMORY} ${DEVICES}"
77 interface.cfg: |
78 [0]
79 dp_comm_ip = DP_ADDR
80 dp_comm_port = 20
81 cp_comm_ip = CP_ADDR
82 cp_comm_port = 21
83 adc_rules.cfg: |
84 [GLOBAL]
85 NUM_ADC_RULES = 5
86
87 ;FORMAT ::
88 ;ADC_TYPE : [ DOMAIN = 0 | IP = 1 | IP PREFIX =2 ]
89 ;
90 ;if ADC_TYPE = 0
91 ; DOMAIN
92 ;elseif ADC_TYPE = 1
93 ; IP
94 ;elseif ADC_TYPE = 2
95 ; IP
96 ; PREFIX
97 ;else
98 ; NONE
99 ;
100 ;NOTE :
101 ;Rules defined first have a higher priority, unless DROP is specified
102 ;(i.e. multiple rules for the same IP).
103 ;When specifying DROP with an IP address, use a prefix of 32 to prevent DNS
104 ;results from overwriting rule.
105
106
107 [ADC_RULE_1]
108 ADC_TYPE = 1
109 IP = 13.1.1.111
110
111 [ADC_RULE_2]
112 ADC_TYPE = 2
113 IP = 13.1.1.0
114 PREFIX = 24
115
116 [ADC_RULE_3]
117 ADC_TYPE = 1
118 IP = 13.1.1.112
119 PREFIX = 24
120
121 [ADC_RULE_4]
122 ADC_TYPE = 0
123 DOMAIN = www.example.gov
124
125 [ADC_RULE_5]
126 ADC_TYPE = 0
127 DOMAIN = www.drop_example.com
128 meter_profile.cfg: |
129 [GLOBAL]
130 NUM_OF_IDX = 7
131
132 [ENTRY_1]
133 ;Committed Information Rate (CIR). Measured in bytes per second.
134 ;MBR is mapped into CIR, convert MBR from bits to Bytes and set CIR.
135 CIR = 2342400
136 ;Committed Burst Size unit = Bytes
137 CBS = 5856
138 ;Excess Burst Size unit = Bytes
139 EBS = 11712
140 ;Meter profile index. Refer this index in static_pcc.cfg to set AMBR/MBR
141 MTR_PROFILE_IDX = 3
142
143 [ENTRY_2]
144 ;1200 = 1756800
145 ;1400 = 2049600
146 ;1600 = 2342400
147 CIR = 2342400
148 CBS = 5856
149 EBS = 11712
150 MTR_PROFILE_IDX = 4
151
152 [ENTRY_3]
153 ; QCI5,QCI7 15.571kbps = 1947 B
154 CIR = 2342400
155 CBS = 5856
156 EBS = 11712
157 MTR_PROFILE_IDX = 5
158
159 [ENTRY_4]
160 ; QCI1, 44kbps = 5500 B
161 CIR = 2342400
162 CBS = 5856
163 EBS = 11712
164 MTR_PROFILE_IDX = 6
165
166 [ENTRY_5]
167 ; QCI9, 31.143kbps = 3893 B
168 CIR = 2342400
169 CBS = 5856
170 EBS = 11712
171 MTR_PROFILE_IDX = 7
172
173 [ENTRY_6]
174 ; 128B, 7pps
175 CIR = 2342400
176 CBS = 512
177 EBS = 1024
178 MTR_PROFILE_IDX = 8
179
180 [ENTRY_7]
181 ; 128B, 2pps
182 CIR = 2342400
183 CBS = 512
184 EBS = 1024
185 MTR_PROFILE_IDX = 9
186
187 pcc_rules.cfg: |
188 [GLOBAL]
189 NUM_PCC_FILTERS = 9
190 ;To config AMBR/MBR values refer meter_profile.cfg. specify only the
191 ;meter profile index to be set here.
192 UL_AMBR_MTR_PROFILE_IDX = 3
193 DL_AMBR_MTR_PROFILE_IDX = 4
194
195 ;default filter - must be first for now (until DP doesn't install any filters)
196 ;associated with default adc rule
197 [PCC_FILTER_1]
198 RULE_NAME = DefaultRule
199 RATING_GROUP = 9
200 SERVICE_ID = 0
201 RULE_STATUS = 0
202 GATE_STATUS = 1
203 SESSION_CONT = 0
204 REPORT_LEVEL = 1
205 CHARGING_MODE = 0
206 METERING_METHOD = 0
207 MUTE_NOTIFY = 0
208 MONITORING_KEY = 0
209 SPONSOR_ID = 0
210 REDIRECT_INFO = 0
211 PRECEDENCE = 254
212 DROP_PKT_COUNT = 0
213 ;Specify the meter profile index from meter_profile.cfg
214 UL_MBR_MTR_PROFILE_IDX = 7
215 DL_MBR_MTR_PROFILE_IDX = 7
216 ;List of ADC filter indices
217 SDF_FILTER_IDX = 99998
218
219 [PCC_FILTER_2]
220 RULE_NAME = sdf_rule_1
221 RATING_GROUP = 5
222 SERVICE_ID = 0
223 RULE_STATUS = 0
224 GATE_STATUS = 1
225 SESSION_CONT = 0
226 REPORT_LEVEL = 2
227 CHARGING_MODE = 0
228 METERING_METHOD = 0
229 MUTE_NOTIFY = 0
230 MONITORING_KEY = 0
231 SPONSOR_ID = 0
232 REDIRECT_INFO = 0
233 PRECEDENCE = 1
234 DROP_PKT_COUNT = 0
235 UL_MBR_MTR_PROFILE_IDX = 5
236 DL_MBR_MTR_PROFILE_IDX = 5
237 ;List of SDF filter indices
238 SDF_FILTER_IDX = 1
239
240 [PCC_FILTER_3]
241 RULE_NAME = sdf_rule_2
242 RATING_GROUP = 1
243 SERVICE_ID = 0
244 RULE_STATUS = 0
245 GATE_STATUS = 1
246 SESSION_CONT = 0
247 REPORT_LEVEL = 3
248 CHARGING_MODE = 0
249 METERING_METHOD = 0
250 MUTE_NOTIFY = 0
251 MONITORING_KEY = 0
252 SPONSOR_ID = 0
253 REDIRECT_INFO = 0
254 PRECEDENCE = 18
255 DROP_PKT_COUNT = 0
256 UL_MBR_MTR_PROFILE_IDX = 6
257 DL_MBR_MTR_PROFILE_IDX = 6
258 ;List of SDF filter indices
259 SDF_FILTER_IDX = 2
260
261 [PCC_FILTER_4]
262 RULE_NAME = adc_rule_1
263 RATING_GROUP = Zero-Rate
264 SERVICE_ID = Internet
265 RULE_STATUS = 0
266 GATE_STATUS = 1
267 SESSION_CONT = 0
268 REPORT_LEVEL = 8
269 CHARGING_MODE = 0
270 METERING_METHOD = 0
271 MUTE_NOTIFY = 0
272 MONITORING_KEY = 0
273 REDIRECT_INFO = 0
274 SPONSOR_ID = Example
275 PRECEDENCE = 15
276 DROP_PKT_COUNT = 0
277 UL_MBR_MTR_PROFILE_IDX = 7
278 DL_MBR_MTR_PROFILE_IDX = 7
279 ;List of SDF filter indices
280 ADC_FILTER_IDX = 1
281
282 [PCC_FILTER_5]
283 RULE_NAME = adc_rule_2
284 RATING_GROUP = 0
285 SERVICE_ID = CIPA
286 RULE_STATUS = 0
287 GATE_STATUS = 1
288 SESSION_CONT = 0
289 REPORT_LEVEL = 9
290 CHARGING_MODE = 0
291 METERING_METHOD = 0
292 MUTE_NOTIFY = 0
293 MONITORING_KEY = 0
294 SPONSOR_ID = Example
295 REDIRECT_INFO = 0
296 SPONSOR_ID = Example
297 REDIRECT_INFO = 0
298 PRECEDENCE = 4
299 DROP_PKT_COUNT = 0
300 UL_MBR_MTR_PROFILE_IDX = 0
301 DL_MBR_MTR_PROFILE_IDX = 0
302 ;List of SDF filter indices
303 ADC_FILTER_IDX = 2
304
305 [PCC_FILTER_6]
306 RULE_NAME = sdf_rule_3
307 RATING_GROUP = 7
308 SERVICE_ID = 0
309 RULE_STATUS = 0
310 GATE_STATUS = 1
311 SESSION_CONT = 0
312 REPORT_LEVEL = 4
313 CHARGING_MODE = 0
314 METERING_METHOD = 0
315 MUTE_NOTIFY = 0
316 MONITORING_KEY = 0
317 SPONSOR_ID = 0
318 REDIRECT_INFO = 0
319 PRECEDENCE = 17
320 DROP_PKT_COUNT = 0
321 UL_MBR_MTR_PROFILE_IDX = 5
322 DL_MBR_MTR_PROFILE_IDX = 5
323 ;List of SDF filter indices
324 SDF_FILTER_IDX = 3
325
326 [PCC_FILTER_7]
327 RULE_NAME = adc_rule_3
328 RATING_GROUP = Zero-Rate
329 SERVICE_ID = Internet
330 RULE_STATUS = 0
331 GATE_STATUS = 1
332 SESSION_CONT = 0
333 REPORT_LEVEL = 5
334 CHARGING_MODE = 0
335 METERING_METHOD = 0
336 MUTE_NOTIFY = 0
337 MONITORING_KEY = 0
338 SPONSOR_ID = Example
339 REDIRECT_INFO = 0
340 PRECEDENCE = 210
341 DROP_PKT_COUNT = 0
342 UL_MBR_MTR_PROFILE_IDX = 7
343 DL_MBR_MTR_PROFILE_IDX = 7
344 ;List of SDF filter indices
345 ADC_FILTER_IDX = 4
346
347 [PCC_FILTER_8]
348 RULE_NAME = adc_rule_4
349 RATING_GROUP = Zero-Rate
350 SERVICE_ID = Management
351 RULE_STATUS = 0
352 GATE_STATUS = 1
353 SESSION_CONT = 0
354 REPORT_LEVEL = 6
355 CHARGING_MODE = 0
356 METERING_METHOD = 0
357 MUTE_NOTIFY = 0
358 MONITORING_KEY = 0
359 SPONSOR_ID = Example
360 REDIRECT_INFO = 0
361 PRECEDENCE = 200
362 DROP_PKT_COUNT = 0
363 UL_MBR_MTR_PROFILE_IDX = 7
364 DL_MBR_MTR_PROFILE_IDX = 7
365 ;List of SDF filter indices
366 ADC_FILTER_IDX = 12
367
368 [PCC_FILTER_9]
369 RULE_NAME = adc_rule_5
370 RATING_GROUP = Zero-Rate
371 SERVICE_ID = Provisioning
372 RULE_STATUS = 0
373 GATE_STATUS = 1
374 SESSION_CONT = 0
375 REPORT_LEVEL = 7
376 CHARGING_MODE = 0
377 METERING_METHOD = 0
378 MUTE_NOTIFY = 0
379 MONITORING_KEY = 0
380 SPONSOR_ID = Example
381 REDIRECT_INFO = 0
382 PRECEDENCE = 220
383 DROP_PKT_COUNT = 0
384 UL_MBR_MTR_PROFILE_IDX = 7
385 DL_MBR_MTR_PROFILE_IDX = 7
386 ;List of SDF filter indices
387 ADC_FILTER_IDX = 3
388 sdf_rules.cfg: |
389 [GLOBAL]
390 NUM_SDF_FILTERS = 4
391
392 [SDF_FILTER_1]
393 DIRECTION = downlink_only
394 IPV4_REMOTE = 13.2.1.113
395 IPV4_REMOTE_MASK = 255.255.255.0
396 PROTOCOL = 17
397 LOCAL_LOW_LIMIT_PORT = 0
398 LOCAL_HIGH_LIMIT_PORT = 65535
399 REMOTE_LOW_LIMIT_PORT = 0
400 REMOTE_HIGH_LIMIT_PORT = 65535
401
402 [SDF_FILTER_2]
403 DIRECTION = uplink_only
404 IPV4_LOCAL = 16.255.255.0
405 IPV4_LOCAL_MASK = 255.255.255.0
406 PROTOCOL = 17
407 LOCAL_LOW_LIMIT_PORT = 0
408 LOCAL_HIGH_LIMIT_PORT = 65535
409 REMOTE_LOW_LIMIT_PORT = 0
410 REMOTE_HIGH_LIMIT_PORT = 65535
411
412 [SDF_FILTER_3]
413 DIRECTION = downlink_only
414 IPV4_REMOTE = 130.10.0.0
415 IPV4_REMOTE_MASK = 255.255.0.0
416 PROTOCOL = 17
417 REMOTE_LOW_LIMIT_PORT = 5060
418 REMOTE_HIGH_LIMIT_PORT = 5060
419
420 [SDF_FILTER_4]
421 DIRECTION = uplink_only
422 IPV4_REMOTE = 103.1.0.0
423 IPV4_REMOTE_MASK = 255.255.0.0
424 PROTOCOL = 17
425 LOCAL_LOW_LIMIT_PORT = 17000
426 LOCAL_HIGH_LIMIT_PORT = 17010
427---
428apiVersion: v1
429kind: Service
430metadata:
431 name: {{ .Values.spgwc.name }}
432spec:
433 selector:
434 app: {{ .Values.spgwc.name }}
435 clusterIP: None
436 ports:
437 - name: s11
438 port: 2123
439 protocol: UDP
440 - name: cpdp
441 port: 21
442 protocol: UDP
443---
444apiVersion: apps/v1
445kind: StatefulSet
446metadata:
447 name: {{ .Values.spgwc.name }}
448 labels:
449 app: {{ .Values.spgwc.name }}
450spec:
451 replicas: 1
452 selector:
453 matchLabels:
454 app: {{ .Values.spgwc.name }}
455 serviceName: {{ .Values.spgwc.name | quote }}
456 template:
457 metadata:
458 labels:
459 app: {{ .Values.spgwc.name }}
460 spec:
461 serviceAccount: spgwc-pod-reader
462 initContainers:
463 - name: init-spgwc
464 image: {{ .Values.spgwc.initimage }}
465 command: ["/bin/sh", "-co", "pipefail"]
466 args:
Hyunsun Moon2bed68b2019-07-19 17:15:35 -0600467 - until $(kubectl get pod -ojson spgwu-0 2>/dev/null | jq -r '.metadata.annotations["k8s.v1.cni.cncf.io/networks-status"]' | jq -r '.[] | select(.name=="s1u-net") | .ips[0]' > /opt/cp/config/shared/SGW_S1U_IP | [ -s /opt/cp/config/shared/SGW_S1U_IP ]);
Wei-Yu Chen0f12b9c2019-04-18 11:12:59 -0700468 do echo "waiting for SPGWU"; sleep 2; done
469 volumeMounts:
470 - name: shared-data
471 mountPath: /opt/cp/config/shared
472 containers:
473 - name: spgwc
474 image: {{ .Values.spgwc.image }}
475 imagePullPolicy: {{ .Values.global.imagepullpolicy }}
476 stdin: true
477 tty: true
478 command: ["/opt/cp/scripts/launch.sh"]
479 env:
480 - name: MEM_LIMIT
481 valueFrom:
482 resourceFieldRef:
483 containerName: spgwc
484 resource: limits.memory
485 divisor: 1Mi
486 #- name: SGW_S1U_IP
487 # value: "11.1.1.1"
488 - name: CP_ADDR
489 valueFrom:
490 fieldRef:
491 fieldPath: status.podIP
492 - name: DP_ADDR
493 value: spgwu-0.{{ .Values.spgwu.name }}.{{ .Values.global.namespace }}.{{ .Values.global.fqdn }}
494 - name: MME_S11_IP
Hyunsun Moon636e17d2019-07-03 12:52:15 -0500495 value: {{ tuple "mme" "identity" . | include "mcord-services.endpoint_lookup" | quote }}
Wei-Yu Chen0f12b9c2019-04-18 11:12:59 -0700496 - name: APN
497 value: apn1
498 - name: IP_POOL_IP
499 value: "16.0.0.0"
500 - name: IP_POOL_MASK
501 value: "255.0.0.0"
502 volumeMounts:
503 - name: cp-script
504 mountPath: /opt/cp/scripts/launch.sh
505 subPath: launch.sh
506 - name: cp-config
507 mountPath: /etc/cp/config
508 - name: shared-data
509 mountPath: /opt/cp/config/shared
510 #- name: hugepage
511 # mountPath: /dev/hugepages
512 resources:
513 limits:
514 #hugepages-2Mi: 4Gi
515 cpu: {{ .Values.spgwc.cpu | quote }}
516 memory: {{ .Values.spgwc.memory }}
517 volumes:
518 - name: cp-script
519 configMap:
520 name: {{ .Values.spgwc.name }}
521 defaultMode: 493
522 - name: cp-config
523 configMap:
524 name: {{ .Values.spgwc.name }}
525 defaultMode: 420
526 - name: shared-data
527 emptyDir: {}
528 #- name: hugepage
529 # emptyDir:
530 # medium: HugePages