From 796c0066cc0d2341565552b1c0605054c9500b71 Mon Sep 17 00:00:00 2001 From: Alan Meadows Date: Thu, 29 Dec 2016 11:22:02 -0800 Subject: [PATCH 1/2] Add development mode for mariadb chart. This can be enabled with: helm install --name mariadb --set development.enabled=true local/mariadb This will ensure only a single replica is used and that PVCs (which require a persistent volume solution) like ceph are not used. Instead this flag enables a single replica with hostDir storage using the host path defined in values.yaml which defaults to the following: /var/lib/openstack-helm/mariadb --- mariadb/templates/bin/_seed.sh.tpl | 4 ++++ mariadb/templates/bin/_start.sh.tpl | 4 ++++ mariadb/templates/deployment.yaml | 16 +++++++++++++--- mariadb/templates/service.yaml | 2 +- mariadb/values.yaml | 14 ++++++++++++++ 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/mariadb/templates/bin/_seed.sh.tpl b/mariadb/templates/bin/_seed.sh.tpl index f04e986bd4..95f2b80fb7 100644 --- a/mariadb/templates/bin/_seed.sh.tpl +++ b/mariadb/templates/bin/_seed.sh.tpl @@ -57,7 +57,11 @@ function wait_for_cluster { # the implementation will be switched to Deployment # (using anti-affinity feature). +{{- if .Values.development.enabled }} +REPLICAS=1 +{{- else }} REPLICAS={{ .Values.replicas }} +{{- end }} if [ "$REPLICAS" -eq 1 ] ; then echo "Requested to build one-instance MariaDB cluster. There is no need to run seed. Exiting." diff --git a/mariadb/templates/bin/_start.sh.tpl b/mariadb/templates/bin/_start.sh.tpl index 6a379defc8..f46d6cfc9e 100644 --- a/mariadb/templates/bin/_start.sh.tpl +++ b/mariadb/templates/bin/_start.sh.tpl @@ -5,7 +5,11 @@ trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT sudo chown mysql: /var/lib/mysql rm -rf /var/lib/mysql/lost+found +{{- if .Values.development.enabled }} +REPLICAS=1 +{{- else }} REPLICAS={{ .Values.replicas }} +{{- end }} PETSET_NAME={{ printf "%s" .Values.service_name }} INIT_MARKER="/var/lib/mysql/init_done" diff --git a/mariadb/templates/deployment.yaml b/mariadb/templates/deployment.yaml index f4fd9b4a07..d56fb879a9 100644 --- a/mariadb/templates/deployment.yaml +++ b/mariadb/templates/deployment.yaml @@ -5,7 +5,11 @@ metadata: name: {{ .Values.service_name }} spec: serviceName: "{{ .Values.service_name }}" - replicas: 3 +{{- if .Values.development.enabled }} + replicas: 1 +{{- else }} + replicas: {{ .Values.replicas }} +{{- end }} template: metadata: labels: @@ -149,7 +153,12 @@ spec: name: mariadb-etc - name: wsrep configMap: - name: mariadb-etc + name: mariadb-etc +{{- if .Values.development.enabled }} + - name: mysql-data + hostPath: + path: {{ .Values.developer.storage_path }} +{{- else }} volumeClaimTemplates: - metadata: name: mysql-data @@ -159,4 +168,5 @@ spec: accessModes: [ "ReadWriteOnce" ] resources: requests: - storage: {{ .Values.volume.size }} \ No newline at end of file + storage: {{ .Values.volume.size }} +{{- end }} \ No newline at end of file diff --git a/mariadb/templates/service.yaml b/mariadb/templates/service.yaml index 01d67e8b9a..7cadcaadc7 100644 --- a/mariadb/templates/service.yaml +++ b/mariadb/templates/service.yaml @@ -9,7 +9,7 @@ metadata: # one. If it creates a new cluster when it should have joined an existing # one, we'd end up with two separate clusters listening at the same service # endpoint, which would be very bad. - service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + service.alpha.kubernetes.io/tolerate-unready-endpoints: "false" spec: ports: - name: db diff --git a/mariadb/values.yaml b/mariadb/values.yaml index 03db6b2e49..2ee02847b7 100644 --- a/mariadb/values.yaml +++ b/mariadb/values.yaml @@ -7,6 +7,20 @@ # below when changing this value replicas: 3 +# this flag allows a "leaner" version of this chart to be installed +# likely lacking any resiliency or persistence, but will help +# both laptop developers and cicd systems +# +# it will deploy a single instance of mariadb, use nodeDir +# for persistence and satisfy the mariadb-seed job with +# a busybox mock +# +# note enabling this flag takes precedence when enabled and +# will override certain things, like the replicas requested +development: + enabled: false + storage_path: /var/lib/openstack-helm/mariadb + # this drives the service name, and statefulset name service_name: mariadb From fe8ad47f9b851d14ab59fbb58d940d94b1294f06 Mon Sep 17 00:00:00 2001 From: Alan Meadows Date: Thu, 29 Dec 2016 14:58:09 -0800 Subject: [PATCH 2/2] Bugfix typo with development storage path --- mariadb/templates/deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mariadb/templates/deployment.yaml b/mariadb/templates/deployment.yaml index d56fb879a9..3867213fb8 100644 --- a/mariadb/templates/deployment.yaml +++ b/mariadb/templates/deployment.yaml @@ -157,7 +157,7 @@ spec: {{- if .Values.development.enabled }} - name: mysql-data hostPath: - path: {{ .Values.developer.storage_path }} + path: {{ .Values.development.storage_path }} {{- else }} volumeClaimTemplates: - metadata: @@ -169,4 +169,4 @@ spec: resources: requests: storage: {{ .Values.volume.size }} -{{- end }} \ No newline at end of file +{{- end }}