Add dbuf and pfcp agent

Change-Id: Iefcdbf1e2f32e0e97ec17abab85941615ba5bac6
diff --git a/pfcp-agent/templates/_helpers.tpl b/pfcp-agent/templates/_helpers.tpl
new file mode 100644
index 0000000..2746e4c
--- /dev/null
+++ b/pfcp-agent/templates/_helpers.tpl
@@ -0,0 +1,66 @@
+{{- /*
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+*/ -}}
+
+{{/*
+Renders a set of standardised labels.
+*/}}
+{{- define "pfcp-agent.metadata_labels" -}}
+{{- $application := index . 0 -}}
+{{- $context := index . 1 -}}
+release: {{ $context.Release.Name }}
+app: {{ $application }}
+{{- end -}}
+
+{{/*
+Render the given template.
+*/}}
+{{- define "pfcp-agent.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 "pfcp-agent.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: ["sh", "-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 -}}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "pfcp-agent.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
\ No newline at end of file
diff --git a/pfcp-agent/templates/configmap-pfcp-agent.yaml b/pfcp-agent/templates/configmap-pfcp-agent.yaml
new file mode 100644
index 0000000..f8f2bb0
--- /dev/null
+++ b/pfcp-agent/templates/configmap-pfcp-agent.yaml
@@ -0,0 +1,17 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ include "pfcp-agent.fullname" . }}
+  labels:
+{{ tuple "pfcp" . | include "pfcp-agent.metadata_labels" | indent 4 }}
+data:
+{{- range $key, $value := .Values.config.pfcp.cfgFiles }}
+  {{ $key }}: {{ toJson $value | quote }}
+{{- end }}
diff --git a/pfcp-agent/templates/service-pfcp-agent.yaml b/pfcp-agent/templates/service-pfcp-agent.yaml
new file mode 100644
index 0000000..a525c2d
--- /dev/null
+++ b/pfcp-agent/templates/service-pfcp-agent.yaml
@@ -0,0 +1,29 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ include "pfcp-agent.fullname" . }}
+  labels:
+{{ tuple "pfcp" . | include "pfcp-agent.metadata_labels" | indent 4 }}
+{{- with .Values.service.annotations }}
+  annotations:
+    {{- toYaml . | nindent 4 }}
+{{- end }}
+spec:
+  type: {{ .Values.service.type }}
+{{- if .Values.service.externalIp }}
+  externalIPs:
+    - {{ .Values.service.externalIp }}
+{{- end }}
+  selector:
+{{ tuple "pfcp" . | include "pfcp-agent.metadata_labels" | indent 4 }}
+  ports:
+  - name: pfcp
+    port: 8805
+    protocol: UDP
diff --git a/pfcp-agent/templates/statefulset-pfcp-agent.yaml b/pfcp-agent/templates/statefulset-pfcp-agent.yaml
new file mode 100644
index 0000000..d4aaa6a
--- /dev/null
+++ b/pfcp-agent/templates/statefulset-pfcp-agent.yaml
@@ -0,0 +1,73 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- $upfConfig := index .Values.config.pfcp.cfgFiles "upf.json" }}
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: {{ include "pfcp-agent.fullname" . }}
+  labels:
+{{ tuple "pfcp" . | include "pfcp-agent.metadata_labels" | indent 4 }}
+spec:
+  replicas: 1
+  serviceName: pfcp-headless
+  selector:
+    matchLabels:
+{{ tuple "pfcp" . | include "pfcp-agent.metadata_labels" | indent 6 }}
+  template:
+    metadata:
+      labels:
+{{ tuple "pfcp" . | include "pfcp-agent.metadata_labels" | indent 8 }}
+    spec:
+      shareProcessNamespace: true
+    {{- if .Values.nodeSelectors.enabled }}
+      nodeSelector:
+        {{ .Values.nodeSelectors.pfcp.label }}: {{ .Values.nodeSelectors.pfcp.value }}
+    {{- end }}
+    {{- if .Values.images.pullSecrets }}
+      imagePullSecrets:
+        {{- range .Values.images.pullSecrets }}
+        - name: {{ . | quote }}
+        {{- end }}
+    {{- end }}
+    {{- if .Values.config.coreDump.enabled }}
+      initContainers:
+{{ tuple "pfcp" . | include "pfcp-agent.coredump_init" | indent 8 }}
+    {{- end }}
+      containers:
+      - name: {{ include "pfcp-agent.fullname" . }}
+        image: {{ .Values.images.tags.pfcpiface | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
+        env:
+        - name: POD_IP
+          valueFrom:
+            fieldRef:
+              fieldPath: status.podIP
+        command: ["pfcpiface"]
+        args:
+          - -config
+          - /tmp/conf/upf.json
+      {{- if .Values.resources.enabled }}
+        resources:
+{{ toYaml .Values.resources.pfcpiface | indent 10 }}
+      {{- end }}
+        volumeMounts:
+          - name: configs
+            mountPath: /tmp/conf
+      volumes:
+      - name: configs
+        configMap:
+          name: {{ include "pfcp-agent.fullname" . }}
+          defaultMode: 493
+    {{- if .Values.config.coreDump.enabled }}
+      - name: host-rootfs
+        hostPath:
+          path: /
+      - name: coredump
+        hostPath:
+          path: {{ .Values.config.coreDump.path }}
+    {{- end }}