VOL-3183 - chart best practice updates

- separated each resource into its own template
- added security context for runas
- added namespace to metadata
- added release name as part of selector

Change-Id: I2a63d099f6bbc4b0615addceccfbd04cff09ef4f
diff --git a/voltha-adapter-openonu/templates/adapters-openonu-go.yaml b/voltha-adapter-openonu/templates/openonu-go-deploy.yaml
similarity index 90%
rename from voltha-adapter-openonu/templates/adapters-openonu-go.yaml
rename to voltha-adapter-openonu/templates/openonu-go-deploy.yaml
index 1c3d5dd..35d1d29 100644
--- a/voltha-adapter-openonu/templates/adapters-openonu-go.yaml
+++ b/voltha-adapter-openonu/templates/openonu-go-deploy.yaml
@@ -1,4 +1,3 @@
-{{- if and (hasKey .Values "use_openonu_adapter_go") .Values.use_openonu_adapter_go }}
 # Copyright 2019-present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,8 +11,9 @@
 # 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.
+{{- if and (hasKey .Values "use_openonu_adapter_go") .Values.use_openonu_adapter_go }}
 {{- $log_level := tpl .Values.adapter_open_onu.log_level . | upper }}
-
+---
 apiVersion: apps/v1
 kind: Deployment
 metadata:
@@ -37,10 +37,13 @@
   selector:
     matchLabels:
       app: adapter-open-onu
+      release: {{ .Release.Name }}
   template:
     metadata:
+      namespace: {{ .Release.Namespace }}
       labels:
         app: adapter-open-onu
+        release: {{ .Release.Name }}
         app.kubernetes.io/name: "adapter-open-onu"
         app.kubernetes.io/version: {{ quote .Chart.AppVersion }}
         app.kubernetes.io/component: "adapter"
@@ -57,9 +60,13 @@
         {{ $key }}: {{ $val | quote }}
         {{- end }}
         {{- end }}
-      annotations:
-        cni: "calico"
     spec:
+      {{- if .Values.securityContext.enabled }}
+      securityContext:
+        runAsUser: {{ .Values.securityContext.runAsUser }}
+        runAsGroup: {{ .Values.securityContext.runAsGroup }}
+        fsGroup: {{ .Values.securityContext.fsGroup }}
+      {{- end }}
       containers:
         - name: adapter-open-onu
           image: '{{ tpl .Values.images.adapter_open_onu.registry . }}{{ tpl .Values.images.adapter_open_onu_go.repository . }}:{{ tpl ( tpl .Values.images.adapter_open_onu_go.tag . ) . }}'
diff --git a/voltha-adapter-openonu/templates/adapters-openonu.yaml b/voltha-adapter-openonu/templates/openonu-py-statefulset.yaml
similarity index 91%
rename from voltha-adapter-openonu/templates/adapters-openonu.yaml
rename to voltha-adapter-openonu/templates/openonu-py-statefulset.yaml
index f7ffa94..bba823b 100644
--- a/voltha-adapter-openonu/templates/adapters-openonu.yaml
+++ b/voltha-adapter-openonu/templates/openonu-py-statefulset.yaml
@@ -11,7 +11,6 @@
 # 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.
-
 {{- if not (and (hasKey .Values "use_openonu_adapter_go") .Values.use_openonu_adapter_go) }}
 ---
 apiVersion: apps/v1
@@ -39,10 +38,13 @@
   selector:
     matchLabels:
       app: adapter-open-onu
+      release: {{ .Release.Name }}
   template:
     metadata:
+      namespace: {{ .Release.Namespace }}
       labels:
         app: adapter-open-onu
+        release: {{ .Release.Name }}
         app.kubernetes.io/name: "adapter-open-onu"
         app.kubernetes.io/version: {{ quote .Chart.AppVersion }}
         app.kubernetes.io/component: "adapter"
@@ -59,9 +61,13 @@
         {{ $key }}: {{ $val | quote }}
         {{- end }}
         {{- end }}
-      annotations:
-        cni: "calico"
     spec:
+      {{- if .Values.securityContext.enabled }}
+      securityContext:
+        runAsUser: {{ .Values.securityContext.runAsUser }}
+        runAsGroup: {{ .Values.securityContext.runAsGroup }}
+        fsGroup: {{ .Values.securityContext.fsGroup }}
+      {{- end }}
       containers:
       - name: adapter-open-onu
         image: '{{ tpl .Values.images.adapter_open_onu.registry . }}{{ tpl .Values.images.adapter_open_onu.repository . }}:{{ tpl ( tpl .Values.images.adapter_open_onu.tag . ) . }}'