Wei-Yu Chen | 0f12b9c | 2019-04-18 11:12:59 -0700 | [diff] [blame] | 1 | --- |
| 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 | --- |
| 17 | apiVersion: v1 |
| 18 | kind: ConfigMap |
| 19 | metadata: |
| 20 | name: {{ .Values.spgwu.name }} |
| 21 | data: |
| 22 | launch.sh: | |
| 23 | #!/bin/bash -xe |
| 24 | |
| 25 | RUN_DIR=${RUN_DIR:-"/opt/dp"} |
| 26 | mkdir -p $RUN_DIR/config |
| 27 | cd $RUN_DIR/config |
| 28 | cp /etc/dp/config/{cdr.cfg,dp_config.cfg,interface.cfg} . |
| 29 | sed -i "s/CP_ADDR/$CP_ADDR/g" interface.cfg |
| 30 | sed -i "s/DP_ADDR/$DP_ADDR/g" interface.cfg |
| 31 | . dp_config.cfg |
| 32 | ngic_dataplane $EAL_ARGS -- $APP_ARGS |
| 33 | dp_config.cfg: | |
| 34 | if [ ! -d "/dev/hugepages" ]; then |
| 35 | MEMORY="--no-huge -m $((MEM_LIMIT-1024))" |
| 36 | fi |
| 37 | |
| 38 | CORES="-c $(taskset -p $$ | awk '{print $NF}')" |
| 39 | EAL_ARGS="${CORES} ${MEMORY} ${DEVICES}" |
| 40 | |
| 41 | SPGW_CFG="--spgw_cfg 03" |
| 42 | S1U_IP=$(ip -4 addr show dev ${S1U_DEVNAME} | grep -oP '(?<=inet\s)\d+(\.\d+){3}') |
| 43 | SGI_IP=$(ip -4 addr show dev ${SGI_DEVNAME} | grep -oP '(?<=inet\s)\d+(\.\d+){3}') |
| 44 | S1U_MAC=$(ip addr show dev ${S1U_DEVNAME} | awk '$1=="link/ether"{print $2}') |
| 45 | SGI_MAC=$(ip addr show dev ${SGI_DEVNAME} | awk '$1=="link/ether"{print $2}') |
| 46 | S1U="--s1u_ip ${S1U_IP} --s1u_mac ${S1U_MAC} --ul_iface ${S1U_DEVNAME}" |
| 47 | SGI="--sgi_ip ${SGI_IP} --sgi_mac ${SGI_MAC} --dl_iface ${SGI_DEVNAME} --sgi_gw_ip ${RTR_SGI_IP} --sgi_mask ${SGI_MASK}" |
| 48 | MISC="--log 1" |
| 49 | APP_ARGS="${S1U} ${SGI} ${MISC} ${SPGW_CFG}" |
| 50 | cdr.cfg: | |
| 51 | CDR_PATH=./cdr |
| 52 | MASTER_CDR=./cdr/master.csv |
| 53 | interface.cfg: | |
| 54 | [0] |
| 55 | dp_comm_ip = DP_ADDR |
| 56 | dp_comm_port = 20 |
| 57 | cp_comm_ip = CP_ADDR |
| 58 | cp_comm_port = 21 |
| 59 | --- |
| 60 | apiVersion: v1 |
| 61 | kind: Service |
| 62 | metadata: |
| 63 | name: {{ .Values.spgwu.name }} |
| 64 | spec: |
| 65 | selector: |
| 66 | app: {{ .Values.spgwu.name }} |
| 67 | clusterIP: None |
| 68 | ports: |
| 69 | - name: cpdp |
| 70 | port: 20 |
| 71 | protocol: UDP |
| 72 | --- |
| 73 | apiVersion: apps/v1 |
| 74 | kind: StatefulSet |
| 75 | metadata: |
| 76 | name: {{ .Values.spgwu.name }} |
| 77 | labels: |
| 78 | app: {{ .Values.spgwu.name }} |
| 79 | spec: |
| 80 | replicas: 1 |
| 81 | selector: |
| 82 | matchLabels: |
| 83 | app: {{ .Values.spgwu.name }} |
| 84 | serviceName: {{ .Values.spgwu.name | quote }} |
| 85 | template: |
| 86 | metadata: |
| 87 | labels: |
| 88 | app: {{ .Values.spgwu.name }} |
| 89 | annotations: |
| 90 | k8s.v1.cni.cncf.io/networks: '[ |
| 91 | { "name": "s1u-net", "interface": "s1u-net" }, |
| 92 | { "name": "sgi-net", "interface": "sgi-net" } |
| 93 | ]' |
| 94 | spec: |
| 95 | # Required if working with Linux bound devices so that kernel does not |
| 96 | # reply to GTP-U packets |
| 97 | #initContainers: |
| 98 | #- name: init |
| 99 | # image: "ngick8stesting/c3po-init" |
| 100 | # command: [ "sh", "-xec"] |
| 101 | # securityContext: |
| 102 | # capabilities: |
| 103 | # add: |
| 104 | # - NET_ADMIN |
| 105 | # args: |
| 106 | # - iptables -I OUTPUT -p icmp --icmp-type destination-unreachable -j DROP; |
| 107 | containers: |
| 108 | - name: {{ .Values.spgwu.name }} |
| 109 | image: {{ .Values.spgwu.image }} |
| 110 | imagePullPolicy: {{ .Values.global.imagepullpolicy }} |
| 111 | stdin: true |
| 112 | tty: true |
| 113 | env: |
| 114 | - name: MEM_LIMIT |
| 115 | valueFrom: |
| 116 | resourceFieldRef: |
| 117 | containerName: {{ .Values.spgwu.name }} |
| 118 | resource: limits.memory |
| 119 | divisor: 1Mi |
| 120 | - name: S1U_DEVNAME |
| 121 | value: s1u-net |
| 122 | - name: SGI_DEVNAME |
| 123 | value: sgi-net |
| 124 | - name: DEVICES |
| 125 | value: "" # "--no-pci --vdev eth_af_packet0,iface=s1u-net --vdev eth_af_packet1,iface=sgi-net" |
| 126 | - name: CP_ADDR |
| 127 | value: spgwc-0.{{ .Values.spgwc.name }}.{{ .Values.global.namespace }}.{{ .Values.global.fqdn }} |
| 128 | - name: DP_ADDR |
| 129 | valueFrom: |
| 130 | fieldRef: |
| 131 | fieldPath: status.podIP |
| 132 | - name: RTR_SGI_IP |
| 133 | value: "13.1.1.254" |
| 134 | - name: SGI_MASK |
| 135 | value: "255.255.255.0" |
| 136 | command: ["bash", "-xc"] |
| 137 | args: |
| 138 | - ip a; |
| 139 | /opt/dp/scripts/launch.sh; |
| 140 | volumeMounts: |
| 141 | - name: dp-script |
| 142 | mountPath: /opt/dp/scripts/launch.sh |
| 143 | subPath: launch.sh |
| 144 | - name: dp-config |
| 145 | mountPath: /etc/dp/config |
| 146 | #- name: hugepage |
| 147 | # mountPath: /dev/hugepages |
| 148 | resources: |
| 149 | limits: |
| 150 | #hugepages-1Gi: 8Gi |
| 151 | cpu: {{ .Values.spgwu.cpu | quote }} |
| 152 | memory: {{ .Values.spgwu.memory }} |
| 153 | intel.com/sriov: 2 |
| 154 | securityContext: |
| 155 | capabilities: |
| 156 | add: |
| 157 | - IPC_LOCK |
| 158 | volumes: |
| 159 | - name: dp-script |
| 160 | configMap: |
| 161 | name: {{ .Values.spgwu.name }} |
| 162 | defaultMode: 493 |
| 163 | - name: dp-config |
| 164 | configMap: |
| 165 | name: {{ .Values.spgwu.name }} |
| 166 | defaultMode: 420 |
| 167 | #- name: hugepage |
| 168 | # emptyDir: |
| 169 | # medium: HugePages |