Add Aether files and directories from helm-charts

Change-Id: I2edb76ebbf8f1da147f760c0fa4618219c49b6cc
diff --git a/omec/omec-user-plane/templates/_helpers.tpl b/omec/omec-user-plane/templates/_helpers.tpl
new file mode 100644
index 0000000..fd03283
--- /dev/null
+++ b/omec/omec-user-plane/templates/_helpers.tpl
@@ -0,0 +1,56 @@
+{{- /*
+# Copyright 2020-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/ -}}
+
+{{/*
+Renders a set of standardised labels.
+*/}}
+{{- define "omec-user-plane.metadata_labels" -}}
+{{- $application := index . 0 -}}
+{{- $context := index . 1 -}}
+release: {{ $context.Release.Name }}
+app: {{ $application }}
+{{- end -}}
+
+{{/*
+Render the given template.
+*/}}
+{{- define "omec-user-plane.template" -}}
+{{- $name := index . 0 -}}
+{{- $context := index . 1 -}}
+{{- $last := base $context.Template.Name }}
+{{- $wtf := $context.Template.Name | replace $last $name -}}
+{{ include $wtf $context }}
+{{- end -}}
+
+{{/*
+Render init container for coredump.
+*/}}
+{{- define "omec-user-plane.coredump_init" -}}
+{{- $pod := index . 0 -}}
+{{- $context := index . 1 -}}
+- name: {{ $pod }}-coredump-init
+  image: {{ $context.Values.images.tags.init | quote }}
+  imagePullPolicy: {{ $context.Values.images.pullPolicy }}
+  securityContext:
+    privileged: true
+    runAsUser: 0
+  command: ["bash", "-xc"]
+  args:
+    - echo '/tmp/coredump/core.%h.%e.%t' > /mnt/host-rootfs/proc/sys/kernel/core_pattern
+  volumeMounts:
+    - name: host-rootfs
+      mountPath: /mnt/host-rootfs
+{{- end -}}
diff --git a/omec/omec-user-plane/templates/bin/_bessd-poststart.sh.tpl b/omec/omec-user-plane/templates/bin/_bessd-poststart.sh.tpl
new file mode 100644
index 0000000..8c6b37a
--- /dev/null
+++ b/omec/omec-user-plane/templates/bin/_bessd-poststart.sh.tpl
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# Copyright 2020-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -ex
+
+until bessctl run /opt/bess/bessctl/conf/spgwu; do
+    sleep 2;
+done;
+
+# Add route to eNB
+ip route add {{ .Values.networks.enb.subnet }} via {{ .Values.networks.s1u.gateway }}
+# Add default gw to SGI gateway
+ip route add default via {{ .Values.networks.sgi.gateway }} metric 110
diff --git a/omec/omec-user-plane/templates/config/_spgwu.json.tpl b/omec/omec-user-plane/templates/config/_spgwu.json.tpl
new file mode 100644
index 0000000..ba36cc7
--- /dev/null
+++ b/omec/omec-user-plane/templates/config/_spgwu.json.tpl
@@ -0,0 +1,12 @@
+{
+  "ue_cidr": {{ .Values.networks.ue.subnet | quote }},
+  "enb_cidr": {{ .Values.networks.enb.subnet | quote }},
+  "s1u": {
+    "ifname": {{ .Values.config.spgwu.s1u.device | quote }}
+  },
+  "sgi": {
+    "ifname": {{ .Values.config.spgwu.sgi.device | quote }}
+  },
+  "workers": {{ .Values.config.spgwu.workers }},
+  "max_sessions": {{ .Values.config.spgwu.maxSessions }}
+}
diff --git a/omec/omec-user-plane/templates/configmap-spgwu.yaml b/omec/omec-user-plane/templates/configmap-spgwu.yaml
new file mode 100644
index 0000000..488cf64
--- /dev/null
+++ b/omec/omec-user-plane/templates/configmap-spgwu.yaml
@@ -0,0 +1,28 @@
+{{/*
+Copyright 2020-present Open Networking Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/}}
+
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: spgwu
+  labels:
+{{ tuple "spgwu" . | include "omec-user-plane.metadata_labels" | indent 4 }}
+data:
+  spgwu.json: |
+{{ tuple "config/_spgwu.json.tpl" . | include "omec-user-plane.template" | indent 4 }}
+  bessd-poststart.sh: |
+{{ tuple "bin/_bessd-poststart.sh.tpl" . | include "omec-user-plane.template" | indent 4 }}
diff --git a/omec/omec-user-plane/templates/networks.yaml b/omec/omec-user-plane/templates/networks.yaml
new file mode 100644
index 0000000..77ef973
--- /dev/null
+++ b/omec/omec-user-plane/templates/networks.yaml
@@ -0,0 +1,48 @@
+{{/*
+Copyright 2020-present Open Networking Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/}}
+
+---
+apiVersion: "k8s.cni.cncf.io/v1"
+kind: NetworkAttachmentDefinition
+metadata:
+  name: s1u-net
+{{- if $.Values.networks.sriov.enabled }}
+  annotations:
+    k8s.v1.cni.cncf.io/resourceName: intel.com/sriov_vfio_s1u_net
+{{- end }}
+spec:
+  config: '{
+    "type": {{ .Values.networks.cniPlugin | quote }},
+    "ipam": {
+        "type": {{ .Values.networks.ipam | quote }}
+    }
+  }'
+---
+apiVersion: "k8s.cni.cncf.io/v1"
+kind: NetworkAttachmentDefinition
+metadata:
+  name: sgi-net
+{{- if $.Values.networks.sriov.enabled }}
+  annotations:
+    k8s.v1.cni.cncf.io/resourceName: intel.com/sriov_vfio_sgi_net
+{{- end }}
+spec:
+  config: '{
+    "type": {{ .Values.networks.cniPlugin | quote }},
+    "ipam": {
+        "type": {{ .Values.networks.ipam | quote }}
+    }
+  }'
diff --git a/omec/omec-user-plane/templates/service-spgwu.yaml b/omec/omec-user-plane/templates/service-spgwu.yaml
new file mode 100644
index 0000000..eca2345
--- /dev/null
+++ b/omec/omec-user-plane/templates/service-spgwu.yaml
@@ -0,0 +1,47 @@
+{{/*
+Copyright 2020-present Open Networking Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/}}
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: spgwu-headless
+  labels:
+{{ tuple "spgwu" . | include "omec-user-plane.metadata_labels" | indent 4 }}
+spec:
+  clusterIP: None
+  selector:
+{{ tuple "spgwu" . | include "omec-user-plane.metadata_labels" | indent 4 }}
+  ports:
+  - name: zmq
+    protocol: TCP
+    port: {{ .Values.config.spgwu.zmq.recvPort }}
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: spgwu-external
+  labels:
+{{ tuple "spgwu" . | include "omec-user-plane.metadata_labels" | indent 4 }}
+spec:
+  selector:
+{{ tuple "spgwu" . | include "omec-user-plane.metadata_labels" | indent 4 }}
+  type: NodePort
+  ports:
+  - name: bess-web
+    protocol: TCP
+    port: 8000
+    nodePort: {{ .Values.config.bess.web.nodePort }}
\ No newline at end of file
diff --git a/omec/omec-user-plane/templates/statefulset-spgwu.yaml b/omec/omec-user-plane/templates/statefulset-spgwu.yaml
new file mode 100644
index 0000000..376b3d9
--- /dev/null
+++ b/omec/omec-user-plane/templates/statefulset-spgwu.yaml
@@ -0,0 +1,173 @@
+{{/*
+Copyright 2020-present Open Networking Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/}}
+
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: spgwu
+  serviceName: spgwu-headless
+  labels:
+{{ tuple "spgwu" . | include "omec-user-plane.metadata_labels" | indent 4 }}
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+{{ tuple "spgwu" . | include "omec-user-plane.metadata_labels" | indent 6 }}
+  template:
+    metadata:
+      labels:
+{{ tuple "spgwu" . | include "omec-user-plane.metadata_labels" | indent 8 }}
+      annotations:
+        k8s.v1.cni.cncf.io/networks: '[
+          {
+            "name": "s1u-net",
+            "interface": {{ .Values.config.spgwu.s1u.device | quote }},
+            "ips": {{ .Values.config.spgwu.s1u.ip | quote }}
+          },
+          {
+            "name": "sgi-net",
+            "interface": {{ .Values.config.spgwu.sgi.device | quote }},
+            "ips": {{ .Values.config.spgwu.sgi.ip | quote }}
+          }
+        ]'
+    spec:
+      shareProcessNamespace: true
+    {{- if .Values.nodeSelectors.enabled }}
+      nodeSelector:
+        {{ .Values.nodeSelectors.spgwu.label }}: {{ .Values.nodeSelectors.spgwu.value }}
+    {{- end }}
+    {{- if .Values.config.coreDump.enabled }}
+{{ tuple "spgwu" . | include "omec-user-plane.coredump_init" | indent 8 }}
+    {{- end }}
+      containers:
+      - name: routectl
+        image: {{ .Values.images.tags.bess | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
+        env:
+          - name: PYTHONUNBUFFERED
+            value: "1"
+        command: ["/opt/bess/bessctl/conf/route_control.py"]
+        args:
+          - -i
+          - {{ .Values.config.spgwu.s1u.device }}
+          - {{ .Values.config.spgwu.sgi.device }}
+      {{- if .Values.resources.enabled }}
+        resources:
+{{ toYaml .Values.resources.routectl | indent 10 }}
+      {{- end }}
+      - name: bessd
+        image: {{ .Values.images.tags.bess | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
+        securityContext:
+          privileged: true
+          capabilities:
+            add:
+            - IPC_LOCK
+            - NET_ADMIN
+        stdin: true
+        tty: true
+        command: ["/bin/bash", "-xc", "bessd -f -grpc-url=0.0.0.0:10514;"]
+        lifecycle:
+          postStart:
+            exec:
+              command: ["/etc/bess/conf/bessd-poststart.sh"]
+        livenessProbe:
+          tcpSocket:
+            port: 10514
+          initialDelaySeconds: 15
+          periodSeconds: 20
+        resources:
+          requests:
+          {{- if .Values.resources.enabled }}
+{{ toYaml .Values.resources.bess.requests | indent 12 }}
+          {{- end }}
+          {{- if .Values.networks.sriov.enabled }}
+            intel.com/sriov_vfio_s1u_net: 1
+            intel.com/sriov_vfio_sgi_net: 1
+          {{- end }}
+          limits:
+          {{- if .Values.resources.enabled }}
+{{ toYaml .Values.resources.bess.limits | indent 12 }}
+          {{- end }}
+          {{- if .Values.networks.sriov.enabled }}
+            intel.com/sriov_vfio_s1u_net: 1
+            intel.com/sriov_vfio_sgi_net: 1
+          {{- end }}
+        env:
+          - name: CONF_FILE
+            value: /etc/bess/conf/spgwu.json
+        volumeMounts:
+          - name: hugepages
+            mountPath: /dev/hugepages
+          - name: configs
+            mountPath: /etc/bess/conf
+        {{- if .Values.config.coreDump.enabled }}
+          - name: coredump
+            mountPath: /tmp/coredump
+        {{- end }}
+      - name: web
+        image: {{ .Values.images.tags.bess | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
+        command: ["/bin/bash", "-xc", "bessctl http 0.0.0.0 8000"]
+      {{- if .Values.resources.enabled }}
+        resources:
+{{ toYaml .Values.resources.web | indent 10 }}
+      {{- end }}
+      - name: cpiface
+        image: {{ .Values.images.tags.cpiface | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
+        env:
+          - name: ZMQD_IP
+            valueFrom:
+              fieldRef:
+                fieldPath: status.podIP
+          - name: GLOG_v
+            value: "1"
+        command: ["zmq-cpiface"]
+        args:
+          - --hostname
+          - {{ .Values.config.spgwu.name | quote }}
+          - --zmqd_nb_ip
+          - {{ .Values.config.spgwu.zmq.spgwc.addr | quote }}
+          - --zmqd_nb_port
+          - {{ .Values.config.spgwu.zmq.spgwc.port | quote }}
+          - --zmqd_recv_port
+          - {{ .Values.config.spgwu.zmq.recvPort | quote }}
+          - --zmqd_ip
+          - $(ZMQD_IP)
+          - --s1u_sgw_ip
+          - {{ (split "/" .Values.config.spgwu.s1u.ip)._0 | quote }}
+      {{- if .Values.resources.enabled }}
+        resources:
+{{ toYaml .Values.resources.cpiface | indent 10 }}
+      {{- end }}
+      volumes:
+      - name: configs
+        configMap:
+          name: spgwu
+          defaultMode: 493
+      - name: hugepages
+        emptyDir:
+          medium: HugePages
+    {{- if .Values.config.coreDump.enabled }}
+      - name: host-rootfs
+        hostPath:
+          path: /
+      - name: coredump
+        hostPath:
+          path: {{ .Values.config.coreDump.path }}
+    {{- end }}