update to 2.x models

Change-Id: I341d160d53c0870c271d37c9207abd577876505c
diff --git a/sdcore-adapter-v2/templates/_helpers.tpl b/sdcore-adapter-v2/templates/_helpers.tpl
new file mode 100644
index 0000000..e7d9bab
--- /dev/null
+++ b/sdcore-adapter-v2/templates/_helpers.tpl
@@ -0,0 +1,56 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+Expand the name of the chart.
+*/}}
+{{- define "sdcore-adapter.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- 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 "sdcore-adapter.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 -}}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "sdcore-adapter.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+
+{{/*
+Common labels
+*/}}
+{{- define "sdcore-adapter.labels" -}}
+helm.sh/chart: {{ include "sdcore-adapter.chart" . }}
+{{ include "sdcore-adapter.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end -}}
+
+{{/*
+Selector labels
+*/}}
+{{- define "sdcore-adapter.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "sdcore-adapter.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end -}}
diff --git a/sdcore-adapter-v2/templates/configmap.yaml b/sdcore-adapter-v2/templates/configmap.yaml
new file mode 100644
index 0000000..057871f
--- /dev/null
+++ b/sdcore-adapter-v2/templates/configmap.yaml
@@ -0,0 +1,33 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ template "sdcore-adapter.fullname" . }}-targetconfig
+  labels:
+    app: {{ template "sdcore-adapter.fullname" . }}
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+    release: "{{ .Release.Name }}"
+    heritage: "{{ .Release.Service }}"
+data:
+  {{ $root := . }}
+  {{ range $path, $bytes := .Files.Glob "files/configs/*.json" }}
+  {{ base $path }}: '{{ $root.Files.Get $path }}'
+  {{ end }}
+
+---
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ template "sdcore-adapter.fullname" . }}-logconfig
+  labels:
+    app: {{ template "sdcore-adapter.fullname" . }}
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+    release: "{{ .Release.Name }}"
+    heritage: "{{ .Release.Service }}"
+data:
+  logging.yaml: |-
+{{ toYaml .Values.logging | indent 4 }}
diff --git a/sdcore-adapter-v2/templates/deployment.yaml b/sdcore-adapter-v2/templates/deployment.yaml
new file mode 100644
index 0000000..2f52b53
--- /dev/null
+++ b/sdcore-adapter-v2/templates/deployment.yaml
@@ -0,0 +1,100 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ template "sdcore-adapter.fullname" . }}
+  namespace: {{ .Release.Namespace }}
+  labels:
+    name: {{ template "sdcore-adapter.fullname" . }}
+spec:
+  replicas: {{ .Values.replicaCount }}
+  selector:
+    matchLabels:
+      {{- include "sdcore-adapter.selectorLabels" . | nindent 6 }}
+  template:
+    metadata:
+      labels:
+        name: {{ template "sdcore-adapter.fullname" . }}
+        {{- include "sdcore-adapter.selectorLabels" . | nindent 8 }}
+    spec:
+    {{- with .Values.imagePullSecrets }}
+      imagePullSecrets:
+        {{- toYaml . | nindent 6 }}
+    {{- end }}
+      securityContext:
+        {{- toYaml .Values.podSecurityContext | nindent 8 }}
+      containers:
+        - name: {{ .Chart.Name }}
+          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+          imagePullPolicy: {{ .Values.image.pullPolicy }}
+          env:
+            - name: POD_NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+            - name: POD_NAME
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.name
+            - name: NODE_NAME
+              valueFrom:
+                fieldRef:
+                  fieldPath: spec.nodeName
+          args:
+            - "/usr/local/bin/sdcore-adapter"
+            - "-bind_address=:{{ .Values.ports.gnmi.secure }}"
+            - "-key=/etc/sdcore-adapter/certs/tls.key"
+            - "-cert=/etc/sdcore-adapter/certs/tls.crt"
+            - "-ca=/etc/sdcore-adapter/certs/tls.cacert"
+            - "-alsologtostderr"
+            - "-hostCheckDisabled"
+            {{ if .Values.initialConfig }}
+            - "-config={{ .Values.initialConfig }}"
+            {{ end }}
+            {{ if .Values.output }}
+            - "-output={{ .Values.output }}"
+            {{ end }}
+            {{ if .Values.spgwEndpoint }}
+            - "-spgw_endpoint={{ .Values.spgwEndpoint }}"
+            {{ end }}
+            {{ if not .Values.partialUpdateEnabled }}
+            - "-partial_update_disable"
+            {{ end }}
+          ports:
+            {{- range $key, $port := .Values.ports.gnmi }}
+            - name: gnmi{{ $key }}
+              containerPort: {{ $port }}
+            {{- end}}
+          readinessProbe:
+            tcpSocket:
+              port: {{ .Values.ports.gnmi.secure }}
+            initialDelaySeconds: 5
+            periodSeconds: 10
+          livenessProbe:
+            tcpSocket:
+              port: {{ .Values.ports.gnmi.secure }}
+            initialDelaySeconds: 15
+            periodSeconds: 20
+          volumeMounts:
+            - name: targetconfig
+              mountPath: /etc/sdcore-adapter/configs
+              readOnly: true
+            - name: secret
+              mountPath: /etc/sdcore-adapter/certs
+              readOnly: true              
+            - name: logconfig
+              mountPath: /etc/onos/config
+              readOnly: true
+      volumes:
+        - name: logconfig
+          configMap:
+            name: {{ template "sdcore-adapter.fullname" . }}-logconfig
+        - name: targetconfig
+          configMap:
+            name: {{ template "sdcore-adapter.fullname" . }}-targetconfig            
+        - name: secret
+          secret:
+            secretName: {{ template "sdcore-adapter.fullname" . }}-secret
diff --git a/sdcore-adapter-v2/templates/secret.yaml b/sdcore-adapter-v2/templates/secret.yaml
new file mode 100644
index 0000000..f54e403
--- /dev/null
+++ b/sdcore-adapter-v2/templates/secret.yaml
@@ -0,0 +1,18 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+kind: Secret
+metadata:
+  name: {{ template "sdcore-adapter.fullname" . }}-secret
+  labels:
+     chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+     release: "{{ .Release.Name }}"
+     heritage: "{{ .Release.Service }}"
+data:
+  {{ $root := . }}
+  {{ range $path, $bytes := .Files.Glob "files/certs/tls.*" }}
+  {{ base $path }}: '{{ $root.Files.Get $path | b64enc }}'
+  {{ end }}
+type: Opaque
diff --git a/sdcore-adapter-v2/templates/service.yaml b/sdcore-adapter-v2/templates/service.yaml
new file mode 100644
index 0000000..42aa78a
--- /dev/null
+++ b/sdcore-adapter-v2/templates/service.yaml
@@ -0,0 +1,27 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ template "sdcore-adapter.fullname" . }}
+  labels:
+    app: {{ template "sdcore-adapter.fullname" . }}
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+    release: "{{ .Release.Name }}"
+    heritage: "{{ .Release.Service }}"
+    {{- include "sdcore-adapter.labels" . | nindent 4 }}
+spec:
+  type: {{ .Values.service.type }}
+  selector:
+    name: {{ template "sdcore-adapter.fullname" . }}
+  ports:
+    {{- range $key, $port := .Values.ports.gnmi }}
+    - name: gnmi{{ $key }}
+      port: {{ $port }}
+    {{- end}}
+    - name: prometheus
+      port: {{ .Values.ports.prometheus }}
+    - name: diag-api
+      port: {{ .Values.ports.diagApi }}
diff --git a/sdcore-adapter-v2/templates/servicemonitor.yaml b/sdcore-adapter-v2/templates/servicemonitor.yaml
new file mode 100644
index 0000000..f3d9c89
--- /dev/null
+++ b/sdcore-adapter-v2/templates/servicemonitor.yaml
@@ -0,0 +1,21 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+{{- if eq .Values.prometheusEnabled true }}
+
+apiVersion: monitoring.coreos.com/v1
+kind: ServiceMonitor
+metadata:
+  name: sdcore-adapter
+  labels:
+    {{- include "sdcore-adapter.labels" . | nindent 4 }}
+spec:
+  selector:
+    matchLabels:
+      {{- include "sdcore-adapter.selectorLabels" . | nindent 6 }}
+  endpoints:
+  - port: prometheus
+    path: /metrics
+    scheme: HTTP
+{{ end }}