# limitations under the License.
 
 apiVersion: v1
-description: ONAP Consul Heath Monitor
+description: ONAP Consul Agent
 name: consul
-version: 1.1.0
+version: 2.0.0
 
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-#{{ if not .Values.disableConsulConsulServer }}
 apiVersion: v1
-kind: Service
-metadata:
-  labels:
-    app: consul-server
-  name: consul-server
-  namespace: "{{ .Values.nsPrefix }}"
-spec:
-  ports:
-  - name: consul-ui
-    nodePort: {{ .Values.nodePortPrefix }}70
-    port: 8500
-    protocol: TCP
-    targetPort: 8500
-  - name: consul-join
-    nodePort: {{ .Values.nodePortPrefix }}71
-    port: 8301
-    protocol: TCP
-    targetPort: 8301
-  selector:
-    app: consul-server
-  type: {{ .Values.service.type | quote }}
-#{{ end }}
\ No newline at end of file
+description: ONAP Consul Server
+name: consul-server
+version: 2.0.0
 
--- /dev/null
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+
+dependencies:
+  - name: common
+    version: ~2.0.0
+    # local reference to common chart, as it is
+    # a part of this chart's package and will not
+    # be published independently to a repo (at this point)
+    repository: '@local'
 
--- /dev/null
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range .Values.ingress.hosts }}
+  http://{{ . }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+  export NODE_PORT=$(kubectl get --namespace {{ include "common.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.fullname" . }})
+  export NODE_IP=$(kubectl get nodes --namespace {{ include "common.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
+  echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+     NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+           You can watch the status of by running 'kubectl get svc -w {{ include "common.fullname" . }}'
+  export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.namespace" . }} {{ include "common.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
+  echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+  export POD_NAME=$(kubectl get pods --namespace {{ include "common.namespace" . }} -l "app={{ template "so.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+  echo "Visit http://127.0.0.1:8080 to use your application"
+  kubectl port-forward $POD_NAME 8080:{{ .Values.service.internalPort }}
+{{- end }}
 
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-#{{ if not .Values.disableConsulConsulServer }}
 apiVersion: extensions/v1beta1
 kind: Deployment
 metadata:
+  name: {{ include "common.fullname" . }}
+  namespace: {{ include "common.namespace" . }}
   labels:
-    app: consul-server
-  name: consul-server
-  namespace: "{{ .Values.nsPrefix }}"
+    app: {{ include "common.name" . }}
+    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
 spec:
-  replicas: {{ .Values.consulServerReplicas }}
+  replicas: {{ .Values.replicaCount }}
   selector:
     matchLabels:
-      app: consul-server
+      app: {{ include "common.name" . }}
   template:
     metadata:
       labels:
-        app: consul-server
-      name: consul-server
+        app: {{ include "common.name" . }}
+        release: {{ .Release.Name }}
+      name: {{ include "common.name" . }}
     spec:
       containers:
-      - image: "{{ .Values.consulserverRegistry }}"
+      - image: "{{ .Values.repository | default .Values.global.repository }}/{{ .Values.image }}"
         command: ["/usr/local/bin/docker-entrypoint.sh"]
-        args: ["agent","-server","-client","0.0.0.0","-enable-script-checks","-bootstrap-expect=3","-ui","-join","consul-server.{{ .Values.nsPrefix }}"]
-        name: consul-server
-#{{ end }}
+        args: ["agent","-server","-client","0.0.0.0","-enable-script-checks","-bootstrap-expect=3","-ui","-join","{{ include "common.fullname" . }}.{{ include "common.namespace" . }}"]
+        name: {{ include "common.name" . }}
 
--- /dev/null
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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
+kind: Service
+metadata:
+  name: {{ include "common.fullname" . }}
+  namespace: {{ include "common.namespace" . }}
+  labels:
+    app: {{ include "common.name" . }}
+    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+spec:
+  type: {{ .Values.service.type }}
+  ports:
+    - port: {{ .Values.service.internalPort }}
+      targetPort: {{ .Values.service.internalPort }}
+      nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.nodePort }}
+      name: {{ .Values.service.name }}
+    - port: {{ .Values.service.internalPort2 }}
+      targetPort: {{ .Values.service.internalPort2 }}
+      nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.nodePort2 }}
+      name: {{ .Values.service.name2 }}
+  selector:
+    app: {{ template "common.name" . }}
+    release: {{ .Release.Name }}
 
--- /dev/null
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+#################################################################
+# Global configuration defaults.
+#################################################################
+global:
+  nodePortPrefix: 302
+  repository: nexus3.onap.org:10001
+  repositorySecret: eyJuZXh1czMub25hcC5vcmc6MTAwMDEiOnsidXNlcm5hbWUiOiJkb2NrZXIiLCJwYXNzd29yZCI6ImRvY2tlciIsImVtYWlsIjoiQCIsImF1dGgiOiJaRzlqYTJWeU9tUnZZMnRsY2c9PSJ9fQ==
+  readinessRepository: oomk8s
+  readinessImage: readiness-check:1.0.0
+  loggingRepository: docker.elastic.co
+  loggingImage: beats/filebeat:5.5.0
+
+#################################################################
+# Application configuration defaults.
+#################################################################
+# application image
+repository: docker.io
+image: consul:1.0.6
+pullPolicy: Always
+
+# flag to enable debugging - application support required
+debugEnabled: false
+
+replicaCount: 3
+
+nodeSelector: {}
+
+affinity: {}
+
+# probe configuration parameters
+liveness:
+  initialDelaySeconds: 10
+  periodSeconds: 10
+  # necessary to disable liveness probe when setting breakpoints
+  # in debugger so K8s doesn't restart unresponsive container
+  enabled: true
+
+readiness:
+  initialDelaySeconds: 10
+  periodSeconds: 10
+
+service:
+  type: NodePort
+  name: consul-ui
+  nodePort: 70
+  internalPort: 8500
+  name2: consul-join
+  nodePort2: 71
+  internalPort2: 8301
+
+ingress:
+  enabled: false
+
+resources: {}
 
--- /dev/null
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+
+dependencies:
+  - name: common
+    version: ~2.0.0
+    # local reference to common chart, as it is
+    # a part of this chart's package and will not
+    # be published independently to a repo (at this point)
+    repository: '@local'
 
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-#{{ if not .Values.disableConsulConsulAgent }}
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: consul-agent-configmap
-  namespace: {{ .Values.nsPrefix }}
+  name: {{ include "common.fullname" . }}-configmap
+  namespace: {{ include "common.namespace" . }}
 data:
 {{ tpl (.Files.Glob "resources/config/consul-agent-config/*").AsConfig . | indent 2 }}
 ---
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: consul-agent-scripts-configmap
-  namespace: {{ .Values.nsPrefix }}
+  name: {{ include "common.fullname" . }}-scripts-configmap
+  namespace: {{ include "common.namespace" . }}
 data:
 {{ tpl (.Files.Glob "resources/config/consul-agent-config/scripts/*").AsConfig . | indent 2 }}
----
-apiVersion: v1
-kind: Secret
-metadata:
-  name: consul-agent-certs-secret
-  namespace: {{ .Values.nsPrefix }}
-data:
-{{ tpl (.Files.Glob "resources/config/consul-agent-config/certs/*").AsSecrets . | indent 2 }}
-#{{ end }}
 
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-#{{ if not .Values.disableConsulConsulAgent }}
 apiVersion: extensions/v1beta1
 kind: Deployment
 metadata:
+  name: {{ include "common.fullname" . }}
+  namespace: {{ include "common.namespace" . }}
   labels:
-    app: consul-agent
-  name: consul-agent
-  namespace: "{{ .Values.nsPrefix }}"
+    app: {{ include "common.name" . }}
+    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
 spec:
-  replicas: {{ .Values.consulAgentReplicas }}
+  replicas: {{ .Values.replicaCount }}
   selector:
     matchLabels:
-      app: consul-agent
+      app: {{ include "common.name" . }}
   template:
     metadata:
       labels:
-        app: consul-agent
-      name: consul-agent
+        app: {{ include "common.name" . }}
+        release: {{ .Release.Name }}
+      name: {{ include "common.name" . }}
     spec:
       containers:
-      - image: "{{ .Values.consulagentRegistry }}"
+      - image: "{{ .Values.repository | default .Values.global.repository }}/{{ .Values.image }}"
         command: ["/usr/local/bin/docker-entrypoint.sh"]
-        args: ["agent","-client","0.0.0.0","-enable-script-checks","-join","consul-server.{{ .Values.nsPrefix }}"]
-        name: consul-server
+        args: ["agent","-client","0.0.0.0","-enable-script-checks","-join","{{ .Release.Name }}-{{ index .Values "consul-server" "nameOverride" }}.{{ include "common.namespace" .}}"]
+        name: {{ include "common.name" . }}
         volumeMounts:
         - mountPath: /consul/config
           name: consul-agent-config
           name: consul-agent-certs-config
       volumes:
       - configMap:
-          name: consul-agent-configmap
+          name: {{ include "common.fullname" . }}-configmap
         name: consul-agent-config
       - configMap:
-          name: consul-agent-scripts-configmap
+          name: {{ include "common.fullname" . }}-scripts-configmap
           defaultMode: 0755
         name: consul-agent-scripts-config
       - secret:
-          secretName: consul-agent-certs-secret
+          secretName: {{ include "common.fullname" . }}-certs-secret
         name: consul-agent-certs-config
-#{{ end }}
+
 
--- /dev/null
+apiVersion: v1
+kind: Secret
+metadata:
+  name: {{ include "common.fullname" . }}-certs-secret
+  namespace: {{ include "common.namespace" . }}
+data:
+{{ tpl (.Files.Glob "resources/config/consul-agent-config/certs/*").AsSecrets . | indent 2 }}
 
 # 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.
+#################################################################
+# Global configuration defaults.
+#################################################################
+global:
+  nodePortPrefix: 302
+  repository: nexus3.onap.org:10001
+  repositorySecret: eyJuZXh1czMub25hcC5vcmc6MTAwMDEiOnsidXNlcm5hbWUiOiJkb2NrZXIiLCJwYXNzd29yZCI6ImRvY2tlciIsImVtYWlsIjoiQCIsImF1dGgiOiJaRzlqYTJWeU9tUnZZMnRsY2c9PSJ9fQ==
+  readinessRepository: oomk8s
+  readinessImage: readiness-check:1.0.0
+  loggingRepository: docker.elastic.co
+  loggingImage: beats/filebeat:5.5.0
 
-nsPrefix: "onap"
-nodePortPrefix: 302
-consulserverRegistry: "docker.io/consul:1.0.6"
-consulagentRegistry: "oomk8s/consul:1.0.0"
-consulAgentReplicas: 1
-consulServerReplicas: 3
-service:
-      type: NodePort
+#################################################################
+# Application configuration defaults.
+#################################################################
+# application image
+repository: oomk8s
+image: consul:1.0.0
+pullPolicy: Always
+
+#subchart name
+consul-server:
+  nameOverride: consul-server
+
+# flag to enable debugging - application support required
+debugEnabled: false
+
+# default number of instances
+replicaCount: 1
+
+nodeSelector: {}
+
+affinity: {}
+
+# probe configuration parameters
+liveness:
+  initialDelaySeconds: 10
+  periodSeconds: 10
+  # necessary to disable liveness probe when setting breakpoints
+  # in debugger so K8s doesn't restart unresponsive container
+  enabled: true
+
+readiness:
+  initialDelaySeconds: 10
+  periodSeconds: 10
+
+service: {}
+
+ingress:
+  enabled: false
+
+resources: {}
 
     version: ~2.0.0
     repository: '@local'
   - name: consul
-    version: ~1.1.0
+    version: ~2.0.0
     repository: '@local'
     condition: consul.enabled
   - name: dcaegen2