add setup for dbtestapp
Change-Id: I9001eaf2274e6628ff1c6d67e1de45b108bd35d6
diff --git a/5g-test-apps/Chart.yaml b/5g-test-apps/Chart.yaml
new file mode 100644
index 0000000..0f0c4e7
--- /dev/null
+++ b/5g-test-apps/Chart.yaml
@@ -0,0 +1,11 @@
+---
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+description: This is the dbtestapp
+name: 5g-test-apps
+icon: https://guide.opencord.org/logos/cord.svg
+
+version: 0.0.1
diff --git a/5g-test-apps/templates/NOTES.txt b/5g-test-apps/templates/NOTES.txt
new file mode 100644
index 0000000..d81d019
--- /dev/null
+++ b/5g-test-apps/templates/NOTES.txt
@@ -0,0 +1,9 @@
+{{- /*
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+*/ -}}
+
+Notes - Instructions to use dbtestapp
diff --git a/5g-test-apps/templates/_helpers.tpl b/5g-test-apps/templates/_helpers.tpl
new file mode 100644
index 0000000..c03ba2a
--- /dev/null
+++ b/5g-test-apps/templates/_helpers.tpl
@@ -0,0 +1,115 @@
+{{- /*
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+*/ -}}
+
+{{/*
+Renders a set of standardised labels
+*/}}
+{{- define "5g-test-apps.metadata_labels" -}}
+{{- $application := index . 0 -}}
+{{- $context := index . 1 -}}
+release: {{ $context.Release.Name }}
+app: {{ $application }}
+{{- end -}}
+
+{{/*
+Render the given template.
+*/}}
+{{- define "5g-test-apps.template" -}}
+{{- $name := index . 0 -}}
+{{- $context := index . 1 -}}
+{{- $last := base $context.Template.Name }}
+{{- $wtf := $context.Template.Name | replace $last $name -}}
+{{ include $wtf $context }}
+{{- end -}}
+
+{{/*
+Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
+*/}}
+{{- define "5g-test-apps.service_account" -}}
+{{- $context := index . 1 -}}
+{{- $saName := index . 0 -}}
+{{- $saNamespace := $context.Release.Namespace }}
+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ $saName }}
+ namespace: {{ $saNamespace }}
+ labels:
+{{ tuple $saName $context | include "5g-test-apps.metadata_labels" | indent 4 }}
+---
+{{- if semverCompare ">=1.16-0" $context.Capabilities.KubeVersion.GitVersion }}
+apiVersion: rbac.authorization.k8s.io/v1
+{{- else }}
+apiVersion: rbac.authorization.k8s.io/v1beta1
+{{- end }}
+kind: RoleBinding
+metadata:
+ name: {{ $saName }}
+ namespace: {{ $saNamespace }}
+ labels:
+{{ tuple $saName $context | include "5g-test-apps.metadata_labels" | indent 4 }}
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: Role
+ name: {{ $saName }}
+subjects:
+ - kind: ServiceAccount
+ name: {{ $saName }}
+ namespace: {{ $saNamespace }}
+---
+{{- if semverCompare ">=1.16-0" $context.Capabilities.KubeVersion.GitVersion }}
+apiVersion: rbac.authorization.k8s.io/v1
+{{- else }}
+apiVersion: rbac.authorization.k8s.io/v1beta1
+{{- end }}
+kind: Role
+metadata:
+ name: {{ $saName }}
+ namespace: {{ $saNamespace }}
+ labels:
+{{ tuple $saName $context | include "5g-test-apps.metadata_labels" | indent 4 }}
+rules:
+ - apiGroups:
+ - ""
+ - extensions
+ - batch
+ - apps
+ verbs:
+ - get
+ - list
+ - patch
+ resources:
+ - statefulsets
+ - daemonsets
+ - jobs
+ - pods
+ - services
+ - endpoints
+ - configmaps
+{{- end -}}
+
+{{/*
+Render init container for coredump.
+*/}}
+{{- define "5g-test-apps.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/5g-test-apps/templates/bin/_dbtestapp-run.sh.tpl b/5g-test-apps/templates/bin/_dbtestapp-run.sh.tpl
new file mode 100644
index 0000000..804fd26
--- /dev/null
+++ b/5g-test-apps/templates/bin/_dbtestapp-run.sh.tpl
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+set -xe
+
+{{- if .Values.config.coreDump.enabled }}
+cp /dbtestapp/bin/dbtestapp /tmp/coredump/
+{{- end }}
+
+/dbtestapp/bin/testapp
diff --git a/5g-test-apps/templates/configmap-dbtestapp.yaml b/5g-test-apps/templates/configmap-dbtestapp.yaml
new file mode 100644
index 0000000..ec46eb0
--- /dev/null
+++ b/5g-test-apps/templates/configmap-dbtestapp.yaml
@@ -0,0 +1,24 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.config.dbtestapp.deploy }}
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: dbtestapp
+ labels:
+{{ tuple "dbtestapp" . | include "5g-test-apps.metadata_labels" | indent 4 }}
+data:
+ dbtestapp-run.sh: |
+{{ tuple "bin/_dbtestapp-run.sh.tpl" . | include "5g-test-apps.template" | indent 4 }}
+{{- if not .Values.config.useExistingConfigMap -}}
+{{- range $key, $value := .Values.config.dbtestapp.cfgFiles }}
+ {{ $key }}: |-
+{{ toYaml $value | indent 4 }}
+{{- end }}
+{{- end }}
+{{- end }}
diff --git a/5g-test-apps/templates/deployment-dbtestapp.yaml b/5g-test-apps/templates/deployment-dbtestapp.yaml
new file mode 100644
index 0000000..5bb82dd
--- /dev/null
+++ b/5g-test-apps/templates/deployment-dbtestapp.yaml
@@ -0,0 +1,85 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.config.dbtestapp.deploy }}
+{{ tuple "dbtestapp" . | include "5g-test-apps.service_account" }}
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: dbtestapp
+ labels:
+{{ tuple "dbtestapp" . | include "5g-test-apps.metadata_labels" | indent 4 }}
+spec:
+ replicas: {{ .Values.config.dbtestapp.replica }}
+ #serviceName: dbtestapp-headless
+ selector:
+ matchLabels:
+{{ tuple "dbtestapp" . | include "5g-test-apps.metadata_labels" | indent 6 }}
+ template:
+ metadata:
+ labels:
+{{ tuple "dbtestapp" . | include "5g-test-apps.metadata_labels" | indent 8 }}
+ {{- with .Values.config.dbtestapp.podAnnotations }}
+ annotations:
+ helm.sh/hook: pre-install
+ helm.sh/hook-weight: "5"
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ spec:
+ serviceAccountName: dbtestapp
+ {{- if hasKey .Values.images "pullSecrets" }}
+ imagePullSecrets:
+{{ toYaml .Values.images.pullSecrets | indent 8 }}
+ {{- end }}
+ containers:
+ - name: dbtestapp
+ image: {{ .Values.images.tags.dbtestapp }}
+ imagePullPolicy: {{ .Values.images.pullPolicy }}
+ {{- if .Values.config.coreDump.enabled }}
+ securityContext:
+ runAsUser: 0
+ {{- end }}
+ stdin: true
+ tty: true
+ command: ["/dbtestapp/script/dbtestapp-run.sh"]
+ env:
+ - name: POD_IP
+ valueFrom:
+ fieldRef:
+ fieldPath: status.podIP
+ {{- if .Values.resources.enabled }}
+ resources:
+{{ toYaml .Values.resources.dbtestapp | indent 10 }}
+ {{- end }}
+ volumeMounts:
+ - name: run-script
+ mountPath: /dbtestapp/script/dbtestapp-run.sh
+ subPath: dbtestapp-run.sh
+ - name: nf-config
+ mountPath: /dbtestapp/config
+ {{- if .Values.config.coreDump.enabled }}
+ - name: coredump
+ mountPath: /tmp/coredump
+ {{- end }}
+ volumes:
+ - name: run-script
+ configMap:
+ name: dbtestapp
+ defaultMode: 493
+ - name: nf-config
+ configMap:
+ name: dbtestapp
+ defaultMode: 493
+ {{- if .Values.config.coreDump.enabled }}
+ - name: host-rootfs
+ hostPath:
+ path: /
+ - name: coredump
+ hostPath:
+ path: {{ .Values.config.coreDump.path }}
+ {{- end }}
+{{- end }}
diff --git a/5g-test-apps/values.yaml b/5g-test-apps/values.yaml
new file mode 100644
index 0000000..b600116
--- /dev/null
+++ b/5g-test-apps/values.yaml
@@ -0,0 +1,31 @@
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+images:
+ tags:
+ init: docker.io/omecproject/pod-init:1.0.0
+ dbtestapp: "dbtestapp:osman1"
+ pullPolicy: IfNotPresent
+ # Optionally specify an array of imagePullSecrets.
+ # Secrets must be manually created in the namespace.
+ pullSecrets:
+ - name: aether.registry
+
+resources:
+ enabled: false
+ dbtestapp:
+ requests:
+ cpu: 1
+ memory: 1Gi
+ limits:
+ cpu: 1
+ memory: 1Gi
+
+config:
+ coreDump:
+ enabled: false
+ path: /tmp/coredump
+ dbtestapp:
+ deploy: true
+ replica: 1
\ No newline at end of file