Restore pv and pvc in mysql chart

This change restores the pv.yaml and pvc.yaml that were previously
removed.  These are required for the case when the NFS provisioner is
disabled.  I've added a condition to these files such that they should
be disabled if the NFS provisioner is enabled.  The two ways of
managing entities need to be mutually exclusive.

Borislav: Solution for directory creation problem
  upon first deployment with persistence enabled

Borislav: Fixed licenses for mysql

Change-Id: I9879b3b6574f8026a28793b9d86d6ef3ec9ce2e9
Signed-off-by: jmac <james.macnider@amdocs.com>
Issue-ID: OOM-889
diff --git a/kubernetes/appc/values.yaml b/kubernetes/appc/values.yaml
index ea3239e..1330bd2 100644
--- a/kubernetes/appc/values.yaml
+++ b/kubernetes/appc/values.yaml
@@ -19,7 +19,7 @@
   nodePortPrefix: 302
   repositorySecret: eyJuZXh1czMub25hcC5vcmc6MTAwMDEiOnsidXNlcm5hbWUiOiJkb2NrZXIiLCJwYXNzd29yZCI6ImRvY2tlciIsImVtYWlsIjoiQCIsImF1dGgiOiJaRzlqYTJWeU9tUnZZMnRsY2c9PSJ9fQ==
   readinessRepository: oomk8s
-  readinessImage: readiness-check:1.1.0
+  readinessImage: readiness-check:1.1.1
   loggingRepository: docker.elastic.co
   loggingImage: beats/filebeat:5.5.0
   persistence:
diff --git a/kubernetes/common/mysql/Chart.yaml b/kubernetes/common/mysql/Chart.yaml
index 99e7c44..b2e7d4a 100644
--- a/kubernetes/common/mysql/Chart.yaml
+++ b/kubernetes/common/mysql/Chart.yaml
@@ -1,3 +1,17 @@
+# 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
 description: MySQL Server
 name: mysql
diff --git a/kubernetes/common/mysql/requirements.yaml b/kubernetes/common/mysql/requirements.yaml
index acca8ef..ce82a2f 100644
--- a/kubernetes/common/mysql/requirements.yaml
+++ b/kubernetes/common/mysql/requirements.yaml
@@ -1,4 +1,18 @@
+# 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
-    repository: '@local'
\ No newline at end of file
+    repository: '@local'
diff --git a/kubernetes/common/mysql/templates/configmap.yaml b/kubernetes/common/mysql/templates/configmap.yaml
index dd2b5b7..ff127e4 100644
--- a/kubernetes/common/mysql/templates/configmap.yaml
+++ b/kubernetes/common/mysql/templates/configmap.yaml
@@ -1,3 +1,19 @@
+{{/*
+# 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: ConfigMap
 metadata:
diff --git a/kubernetes/common/mysql/templates/nfs-provisoner.yaml b/kubernetes/common/mysql/templates/nfs-provisoner.yaml
index 7d12c59..3f19977 100644
--- a/kubernetes/common/mysql/templates/nfs-provisoner.yaml
+++ b/kubernetes/common/mysql/templates/nfs-provisoner.yaml
@@ -1,3 +1,19 @@
+{{/*
+# 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.
+*/}}
+
 #{{ if not .Values.disableNfsProvisioner }}
 apiVersion: extensions/v1beta1
 kind: Deployment
@@ -58,5 +74,5 @@
       volumes:
         - name: export-volume
           hostPath:
-            path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.mountSubPath }}
+            path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Namespace }}/{{ .Values.persistence.mountSubPath }}
 #{{ end }}
diff --git a/kubernetes/common/mysql/templates/pv.yaml b/kubernetes/common/mysql/templates/pv.yaml
new file mode 100644
index 0000000..1cc92ac
--- /dev/null
+++ b/kubernetes/common/mysql/templates/pv.yaml
@@ -0,0 +1,38 @@
+{{/*
+# 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.
+*/}}
+
+{{- if (and (and (.Values.persistence.enabled) (not .Values.persistence.existingClaim)) ( .Values.disableNfsProvisioner)) -}}
+kind: PersistentVolume
+apiVersion: v1
+metadata:
+  name: {{ include "common.fullname" . }}-data
+  namespace: {{ include "common.namespace" . }}
+  labels:
+    app: {{ include "common.name" . }}
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
+    release: "{{ .Release.Name }}"
+    heritage: "{{ .Release.Service }}"
+    name: {{ include "common.fullname" . }}
+spec:
+  capacity:
+    storage: {{ .Values.persistence.size}}
+  accessModes:
+    - {{ .Values.persistence.accessMode }}
+  storageClassName: "{{ include "common.fullname" . }}-data"
+  persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
+  hostPath:
+    path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Namespace }}/{{ .Values.persistence.mountSubPath }}
+{{- end -}}
diff --git a/kubernetes/common/mysql/templates/pvc.yaml b/kubernetes/common/mysql/templates/pvc.yaml
new file mode 100644
index 0000000..edb370a
--- /dev/null
+++ b/kubernetes/common/mysql/templates/pvc.yaml
@@ -0,0 +1,39 @@
+{{/*
+# 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.
+*/}}
+
+{{- if (and (and (.Values.persistence.enabled) (not .Values.persistence.existingClaim)) ( .Values.disableNfsProvisioner)) -}}
+kind: PersistentVolumeClaim
+apiVersion: v1
+metadata:
+  name: {{ include "common.fullname" . }}-data
+  namespace: {{ include "common.namespace" . }}
+  labels:
+    app: {{ include "common.fullname" . }}
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+    release: "{{ .Release.Name }}"
+    heritage: "{{ .Release.Service }}"
+{{- if .Values.persistence.annotations }}
+  annotations:
+{{ toYaml .Values.persistence.annotations | indent 4 }}
+{{- end }}
+spec:
+  accessModes:
+    - {{ .Values.persistence.accessMode }}
+  resources:
+    requests:
+      storage: {{ .Values.persistence.size }}
+  storageClassName: "{{ include "common.fullname" . }}-data"
+{{- end -}}
diff --git a/kubernetes/common/mysql/templates/secrets.yaml b/kubernetes/common/mysql/templates/secrets.yaml
index 7604be8..7f9b123 100644
--- a/kubernetes/common/mysql/templates/secrets.yaml
+++ b/kubernetes/common/mysql/templates/secrets.yaml
@@ -1,3 +1,19 @@
+{{/*
+# 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: Secret
 metadata:
@@ -10,4 +26,4 @@
     heritage: {{ .Release.Service }}
 type: Opaque
 data:
-  db-root-password: {{ .Values.config.dbRootPassword | b64enc | quote }}
\ No newline at end of file
+  db-root-password: {{ .Values.config.dbRootPassword | b64enc | quote }}
diff --git a/kubernetes/common/mysql/templates/service.yaml b/kubernetes/common/mysql/templates/service.yaml
index 6b8dbfb..032920c 100644
--- a/kubernetes/common/mysql/templates/service.yaml
+++ b/kubernetes/common/mysql/templates/service.yaml
@@ -1,3 +1,19 @@
+{{/*
+# 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:
diff --git a/kubernetes/common/mysql/templates/statefulset.yaml b/kubernetes/common/mysql/templates/statefulset.yaml
index 0304639..e436988 100644
--- a/kubernetes/common/mysql/templates/statefulset.yaml
+++ b/kubernetes/common/mysql/templates/statefulset.yaml
@@ -1,4 +1,5 @@
-# Copyright © 2017-2018 Amdocs, 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.
@@ -11,6 +12,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.
+*/}}
 
 apiVersion: apps/v1beta1
 kind: StatefulSet
@@ -49,7 +51,7 @@
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
 #{{ end }}
       - name: init-mysql
-        image: "{{ .Values.repository | default .Values.repository }}/{{ .Values.image }}"
+        image: "{{ .Values.dockerHubRepository }}/{{ .Values.image }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
         command:
         - bash
@@ -105,14 +107,12 @@
         volumeMounts:
         - name: {{ include "common.fullname" . }}-data
           mountPath: /var/lib/mysql
-          subPath: mysql
         - name: conf
           mountPath: /etc/mysql/conf.d
 
       containers:
-        #sdnc-db-container
         - name: {{ include "common.name" . }}
-          image: "{{ .Values.repository | default .Values.repository }}/{{ .Values.image }}"
+          image: "{{ .Values.dockerHubRepository }}/{{ .Values.image }}"
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
           ports:
           - containerPort: {{ .Values.service.internalPort }}
@@ -144,7 +144,6 @@
           volumeMounts:
           - mountPath: /var/lib/mysql
             name: {{ include "common.fullname" . }}-data
-            subPath: mysql
           - mountPath: /etc/mysql/conf.d
             name: conf
           resources:
@@ -225,7 +224,6 @@
           volumeMounts:
           - name: {{ include "common.fullname" . }}-data
             mountPath: /var/lib/mysql
-            subPath: mysql
           - name: conf
             mountPath: /etc/mysql/conf.d
       volumes:
diff --git a/kubernetes/common/mysql/templates/storageclass.yaml b/kubernetes/common/mysql/templates/storageclass.yaml
index 1a4e6b6..398c998 100644
--- a/kubernetes/common/mysql/templates/storageclass.yaml
+++ b/kubernetes/common/mysql/templates/storageclass.yaml
@@ -1,3 +1,19 @@
+{{/*
+# 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.
+*/}}
+
 kind: StorageClass
 apiVersion: storage.k8s.io/v1
 metadata:
diff --git a/kubernetes/common/mysql/values.yaml b/kubernetes/common/mysql/values.yaml
index 43b690a..1e8c8bd 100644
--- a/kubernetes/common/mysql/values.yaml
+++ b/kubernetes/common/mysql/values.yaml
@@ -1,3 +1,17 @@
+# 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.
 #################################################################
@@ -6,15 +20,14 @@
   repositorySecret: eyJuZXh1czMub25hcC5vcmc6MTAwMDEiOnsidXNlcm5hbWUiOiJkb2NrZXIiLCJwYXNzd29yZCI6ImRvY2tlciIsImVtYWlsIjoiQCIsImF1dGgiOiJaRzlqYTJWeU9tUnZZMnRsY2c9PSJ9fQ==
   persistence: {}
   readinessRepository: oomk8s
-  readinessImage: readiness-check:1.0.0
+  readinessImage: readiness-check:1.1.1
 
 
 #################################################################
 # Application configuration defaults.
 #################################################################
 
-#repository: mysql
-repository: registry.hub.docker.com
+dockerHubRepository: registry.hub.docker.com
 image: library/mysql:5.7
 pullPolicy: Always
 
@@ -29,6 +42,8 @@
 
 affinity: {}
 
+disableNfsProvisioner: true
+
 # probe configuration parameters
 liveness:
   initialDelaySeconds: 30
@@ -61,7 +76,7 @@
   accessMode: ReadWriteMany
   size: 1Gi
   mountPath: /dockerdata-nfs
-  mountSubPath: mysql/data
+  mountSubPath: "mysql/data"
 
 service:
   name: mysql