From 4a0380ae845cd517f951302e2cb3c7474aefe704 Mon Sep 17 00:00:00 2001
From: Steve Wilkerson <wilkers.steve@gmail.com>
Date: Sat, 6 Jan 2018 13:48:42 -0600
Subject: [PATCH] MariaDB chart cleanup

This ps brings mariadb inline with the other charts in openstack
helm. It organizes the values trees, removes an unused duplicate
resource tree, and adds the keys for enabling specific manifests

Change-Id: I6f331d51802968620da18b687dc2f9dfa58cdd79
---
 mariadb/templates/configmap-bin.yaml          |  2 +
 mariadb/templates/configmap-etc.yaml          |  2 +
 mariadb/templates/pdb-mariadb.yaml            |  2 +
 .../templates/secret-db-root-password.yaml    |  2 +
 mariadb/templates/secrets-etc.yaml            |  2 +
 mariadb/templates/service-discovery.yaml      |  3 +-
 mariadb/templates/service.yaml                |  2 +
 mariadb/templates/statefulset.yaml            |  2 +
 mariadb/values.yaml                           | 51 ++++++++++---------
 9 files changed, 42 insertions(+), 26 deletions(-)

diff --git a/mariadb/templates/configmap-bin.yaml b/mariadb/templates/configmap-bin.yaml
index 5ccef9d41e..25168fe46e 100644
--- a/mariadb/templates/configmap-bin.yaml
+++ b/mariadb/templates/configmap-bin.yaml
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */}}
 
+{{- if .Values.manifests.configmap_bin }}
 {{- $envAll := . }}
 ---
 apiVersion: v1
@@ -25,3 +26,4 @@ data:
 {{ tuple "bin/_readiness.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
   start.sh: |
 {{ tuple "bin/_start.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
+{{- end }}
diff --git a/mariadb/templates/configmap-etc.yaml b/mariadb/templates/configmap-etc.yaml
index ad83624f6d..61ae503165 100644
--- a/mariadb/templates/configmap-etc.yaml
+++ b/mariadb/templates/configmap-etc.yaml
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */}}
 
+{{- if .Values.manifests.configmap_etc }}
 {{- $envAll := . }}
 ---
 apiVersion: v1
@@ -29,3 +30,4 @@ data:
 {{ tuple "etc/_20-override.cnf.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
   99-force.cnf: |
 {{ tuple "etc/_99-force.cnf.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
+{{- end }}
diff --git a/mariadb/templates/pdb-mariadb.yaml b/mariadb/templates/pdb-mariadb.yaml
index 1aefb1a2c6..4dd01ebd95 100644
--- a/mariadb/templates/pdb-mariadb.yaml
+++ b/mariadb/templates/pdb-mariadb.yaml
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */}}
 
+{{- if .Values.manifests.pdb_server }}
 {{- $envAll := . }}
 ---
 apiVersion: policy/v1beta1
@@ -25,3 +26,4 @@ spec:
   selector:
     matchLabels:
 {{ tuple $envAll "mariadb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }}
+{{- end }}
diff --git a/mariadb/templates/secret-db-root-password.yaml b/mariadb/templates/secret-db-root-password.yaml
index 198296c62a..e99f30b4ee 100644
--- a/mariadb/templates/secret-db-root-password.yaml
+++ b/mariadb/templates/secret-db-root-password.yaml
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */}}
 
+{{- if .Values.manifests.secret_db }}
 {{- $envAll := . }}
 ---
 apiVersion: v1
@@ -23,3 +24,4 @@ metadata:
 type: Opaque
 data:
   MYSQL_ROOT_PASSWORD: {{ .Values.endpoints.oslo_db.auth.admin.password | b64enc }}
+{{- end }}
diff --git a/mariadb/templates/secrets-etc.yaml b/mariadb/templates/secrets-etc.yaml
index b9f83b58d7..1e6865986a 100644
--- a/mariadb/templates/secrets-etc.yaml
+++ b/mariadb/templates/secrets-etc.yaml
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */}}
 
+{{- if .Values.manifests.secret_etc }}
 {{- $envAll := . }}
 ---
 apiVersion: v1
@@ -23,3 +24,4 @@ metadata:
 type: Opaque
 data:
   admin_user.cnf: {{ tuple "secrets/_admin_user.cnf.tpl" . | include "helm-toolkit.utils.template"  | b64enc }}
+{{- end }}
diff --git a/mariadb/templates/service-discovery.yaml b/mariadb/templates/service-discovery.yaml
index dd372a6b6f..758fe9d7a4 100644
--- a/mariadb/templates/service-discovery.yaml
+++ b/mariadb/templates/service-discovery.yaml
@@ -16,7 +16,7 @@ limitations under the License.
 
 # This service could be used for cluster pod discovery, though instead it's
 # primarily here to allow DNS lookups of cluster pods.
-
+{{- if .Values.manifests.service_discovery }}
 {{- $envAll := . }}
 ---
 apiVersion: v1
@@ -32,3 +32,4 @@ spec:
   clusterIP: None
   selector:
 {{ tuple $envAll "mariadb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
+{{- end }}
diff --git a/mariadb/templates/service.yaml b/mariadb/templates/service.yaml
index 08881f3ad3..81ce709765 100644
--- a/mariadb/templates/service.yaml
+++ b/mariadb/templates/service.yaml
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */}}
 
+{{- if .Values.manifests.service }}
 {{- $envAll := . }}
 ---
 apiVersion: v1
@@ -34,3 +35,4 @@ spec:
       port: {{ tuple "oslo_db" "internal" "mysql" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
   selector:
 {{ tuple $envAll "mariadb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
+{{- end }}
diff --git a/mariadb/templates/statefulset.yaml b/mariadb/templates/statefulset.yaml
index 19a1959c56..a5b81c9741 100644
--- a/mariadb/templates/statefulset.yaml
+++ b/mariadb/templates/statefulset.yaml
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */}}
 
+{{- if .Values.manifests.statefulset }}
 {{- $envAll := . }}
 {{- $dependencies := .Values.dependencies.mariadb }}
 
@@ -140,3 +141,4 @@ spec:
           storage: {{ .Values.volume.size }}
       storageClassName: {{ .Values.volume.class_name }}
 {{- end }}
+{{- end }}
diff --git a/mariadb/values.yaml b/mariadb/values.yaml
index fdedd1306e..dec7119412 100644
--- a/mariadb/values.yaml
+++ b/mariadb/values.yaml
@@ -12,7 +12,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-force_bootstrap: false
+images:
+  tags:
+    mariadb: docker.io/mariadb:10.1.23
+    dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.2.1
+  pull_policy: IfNotPresent
+
+labels:
+  node_selector_key: openstack-control-plane
+  node_selector_value: enabled
 
 pod:
   affinity:
@@ -30,32 +38,25 @@ pod:
   resources:
     enabled: false
     server:
-      limits:
-        memory: "128Mi"
-        cpu: "500m"
       requests:
         memory: "128Mi"
-        cpu: "500m"
-
-images:
-  tags:
-    mariadb: docker.io/mariadb:10.1.23
-    dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.2.1
-  pull_policy: IfNotPresent
+        cpu: "100m"
+      limits:
+        memory: "1024Mi"
+        cpu: "2000m"
 
 dependencies:
   mariadb:
     jobs: null
+    services: null
+
+force_bootstrap: false
 
 volume:
   enabled: true
   class_name: general
   size: 5Gi
 
-labels:
-  node_selector_key: openstack-control-plane
-  node_selector_value: enabled
-
 database:
   config_override: null
   # Any configuration here will override the base config.
@@ -63,16 +64,6 @@ database:
   #   [mysqld]
   #   wsrep_slave_threads=1
 
-resources:
-  enabled: false
-  server:
-    requests:
-      memory: "128Mi"
-      cpu: "100m"
-    limits:
-      memory: "1024Mi"
-      cpu: "2000m"
-
 # typically overriden by environmental
 # values, but should include all endpoints
 # required by this chart
@@ -95,3 +86,13 @@ endpoints:
         default: 3306
       wsrep:
         default: 4567
+
+manifests:
+  configmap_bin: true
+  configmap_etc: true
+  pdb_server: true
+  secret_db: true
+  secret_etc: true
+  service_discovery: true
+  service: true
+  statefulset: true