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/Chart.yaml b/voltha-adapter-openonu/Chart.yaml
index 7c85984..450d410 100644
--- a/voltha-adapter-openonu/Chart.yaml
+++ b/voltha-adapter-openonu/Chart.yaml
@@ -1,4 +1,3 @@
----
 # Copyright 2019-present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,9 +11,26 @@
 # 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"
+name: "voltha-adapter-openonu"
+version: 2.3.8
+description: "A Helm chart for Voltha OpenONU Adapter"
+keywords:
+  - "onf"
+  - "voltha"
+  - "adapter"
+  - "onu"
+  - "open"
+home: "https://www.opennetworking.org/voltha"
+icon: "https://guide.opencord.org/logos/voltha.svg"
+sources:
+  - "https://github.com/opencord/voltha-openonu-adapter"
+maintainers:
+  - name: "Open Networking Foundation"
+    email: "info@opennetworking.org"
+    url: "https://www.opennetworking.org"
 
-name: voltha-adapter-openonu
-description: A Helm chart for Voltha OpenONU Adapter
-icon: https://guide.opencord.org/logos/cord.svg
-
-version: 2.3.7
\ No newline at end of file
+# appVersion refers to multiple components with potentially different
+# container image versions.
+appVersion: 2.4
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 . ) . }}'
diff --git a/voltha-adapter-openonu/values.yaml b/voltha-adapter-openonu/values.yaml
index 0097619..c803098 100644
--- a/voltha-adapter-openonu/values.yaml
+++ b/voltha-adapter-openonu/values.yaml
@@ -1,4 +1,3 @@
----
 # Copyright 2019-present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,7 +11,7 @@
 # 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.
-
+---
 use_openonu_adapter_go: false
 
 # Default overrides
@@ -27,19 +26,26 @@
     adapter_open_onu_topic: "brcm_openomci_onu"
     adapter_open_olt_topic: "openolt"
 
+# Default security context under which the containers run
+securityContext:
+  enabled: true
+  fsGroup: 1001
+  runAsUser: 1001
+  runAsGroup: 1001
+
 # Define connectivity to required services
 services:
   kafka:
     adapter:
-      service: voltha-kafka.voltha.svc.cluster.local
+      service: kafka
       port: 9092
     cluster:
-      service: voltha-kafka.voltha.svc.cluster.local
+      service: kafka
       port: 9092
 
   # Define connectivity to etcd
   etcd:
-    service: voltha-etcd-cluster-client.voltha.svc.cluster.local
+    service: etcd
     port: 2379
 
 # Define the recplica count for everything