+++ /dev/null
-apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: {{ .Release.Name }}-pgpool-configmap
-  namespace: {{ include "common.namespace" . }}
-  labels:
-    app: {{ include "common.name" . }}
-    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
-    release: {{ .Release.Name }}
-    heritage: {{ .Release.Service }}
-data:
-{{ tpl (.Files.Glob "configs/*").AsConfig . | indent 2 }}
 
+++ /dev/null
-kind: "Service"
-apiVersion: "v1"
-metadata:
-  name: "pgpool"
-  labels:
-    name: "pgpool"
-spec: 
-  ports:
-    - protocol: "TCP"
-      port: 5432
-      targetPort: 5432
-  selector:
-    name: "pgpool"
-  type: ClusterIP
 
 
 # - Backend Connection Settings -
 
-backend_hostname0 = '{{.Values.container.primary}}'
+backend_hostname0 = '{{.Values.container.name.primary}}'
 backend_port0 = 5432
 backend_weight0= 1
 backend_flag0= 'DISALLOW_TO_FAILOVER'
 
-backend_hostname1 = '{{.Values.container.replica}}'
+backend_hostname1 = '{{.Values.container.name.replica}}'
 backend_port1 = 5432
 backend_weight1= 1
 backend_flag1= 'DISALLOW_TO_FAILOVER'
 # LOAD BALANCING MODE
 #------------------------------------------------------------------------------
 
-load_balance_mode = off
+load_balance_mode = on
                                    # Activate load balancing mode
                                    # (change requires restart)
 ignore_leading_white_space = on
 health_check_timeout = 10
                                    # Health check timeout
                                    # 0 means no timeout
-health_check_user = '{{.Values.credentials.pguser}}'
+health_check_user = '{{.Values.credentials.pgusername}}'
                                    # Health check user
 health_check_password = '{{.Values.credentials.pgpassword}}'
                                    # Password for health check user
 # ONLINE RECOVERY
 #------------------------------------------------------------------------------
 
-recovery_user = '{{.Values.credentials.pguser}}'
+recovery_user = '{{.Values.credentials.pgusername}}'
                                    # Online recovery user
 recovery_password = '{{.Values.credentials.pgpassword}}'
                                    # Online recovery password
 
 testuser:md599e8713364988502fa6189781bcf648f
+postgres:md53175bce1d3201d16594cebf9d7eb3f9d
 
-# Copyright © 2018 Amdocs, AT&T, Bell Canada
+# 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.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-name: pgpool
-container:
-  port: 5432
-  name:
-    primary: pgset-primary
-    replica: pgset-replica
-credentials:
-  pgusername: testuser
-  pgpassword: password
-serviceType: ClusterIP
-image:
-  repository: crunchydata
-  container: crunchy-pgpool
-  tag: centos7-10.4-2.0.0
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ .Release.Name }}-pgpool-configmap
+  namespace: {{ include "common.namespace" . }}
+  labels:
+    app: {{ include "common.name" . }}
+    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+data:
+{{ tpl (.Files.Glob "configs/*").AsConfig . | indent 2 }}
 
         release: {{ .Release.Name }}
     spec:
       containers:
-      - name: pgpool
-        image: "{{.Values.image.repository}}/{{.Values.image.container}}:{{.Values.image.tag}}"
+      - image: "{{.Values.repository}}/{{.Values.image}}"
+        imagePullPolicy: {{ .Values.pullPolicy | default .Values.global.pullPolicy }}
+        name: {{ include "common.name" . }}
         env:
         - name: PG_PRIMARY_SERVICE_NAME
           value: {{.Values.container.name.primary}}
 
--- /dev/null
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ .Values.service.name }}
+  namespace: {{ include "common.namespace" . }}
+  labels:
+    app: {{ include "common.name" . }}
+    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+  annotations:
+spec:
+  type: {{ .Values.service.type }}
+  ports:
+    {{if eq .Values.service.type "NodePort" -}}
+    - port: {{ .Values.service.externalPort }}
+      nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.nodePort }}
+      name: {{ .Values.service.name }}
+    {{- else -}}
+    - port: {{ .Values.service.externalPort }}
+      targetPort: {{ .Values.service.internalPort }}
+      name: {{ .Values.service.name }}
+    {{- end}}
+  selector:
+    app: {{ include "common.name" . }}
+    release: {{ .Release.Name }}
 
--- /dev/null
+# Copyright © 2018 Amdocs, AT&T, 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
+  persistence: {}
+  readinessRepository: oomk8s
+  readinessImage: readiness-check:2.0.0
+
+#################################################################
+# Application configuration defaults.
+#################################################################
+# application image
+repository: crunchydata
+image: crunchy-pgpool:centos7-10.4-2.0.0
+pullPolicy: Always
+
+container:
+  port: 5432
+  name:
+    primary: pgset-primary
+    replica: pgset-replica
+credentials:
+  pgusername: testuser
+  pgpassword: password
+service:
+  name: pgpool 
+  type: ClusterIP
+  externalPort: 5432
+  internalPort: 5432