From 8ff8e7aeb2fe21eab00e7a42a5b0babc4fe062ea Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Sat, 1 Jul 2017 12:59:46 -0500 Subject: [PATCH] Mariadb: Update to use endpoint values layout and lookups This PS adjusts the MariaDB chart to use the same endpoint values layout as used in other openstack-helm components. It also removes credentials and params from the configmaps and moves them to secrets and env vars as appropriate. Change-Id: I9116be7c46cdd16c743ca2784878f3de65665f8c --- .../endpoints/_endpoint_port_lookup.tpl | 2 +- mariadb/Chart.yaml | 9 +++++- mariadb/templates/bin/_readiness.sh.tpl | 4 +-- mariadb/templates/bin/_start.sh.tpl | 14 ++++---- mariadb/templates/etc/_00-base.cnf.tpl | 10 +++--- mariadb/templates/pdb-mariadb.yaml | 4 +-- .../templates/secret-db-root-password.yaml | 7 ++++ mariadb/templates/service-discovery.yaml | 6 ++-- mariadb/templates/service.yaml | 6 ++-- mariadb/templates/statefulset.yaml | 22 +++++++++---- mariadb/values.yaml | 32 ++++++++++++------- 11 files changed, 73 insertions(+), 43 deletions(-) create mode 100644 mariadb/templates/secret-db-root-password.yaml diff --git a/helm-toolkit/templates/endpoints/_endpoint_port_lookup.tpl b/helm-toolkit/templates/endpoints/_endpoint_port_lookup.tpl index 37b6a91659..8b8f7d80c9 100644 --- a/helm-toolkit/templates/endpoints/_endpoint_port_lookup.tpl +++ b/helm-toolkit/templates/endpoints/_endpoint_port_lookup.tpl @@ -15,7 +15,7 @@ # This function returns hostnames from endpoint definitions for use cases # where the uri style return is not appropriate, and only the hostname # portion is used or relevant in the template: -# { tuple "memcache" "internal" "portName" . | include "helm-toolkit.endpoints.host_and_port_endpoint_uri_lookup" } +# { tuple "memcache" "internal" "portName" . | include "helm-toolkit.endpoints.endpoint_port_lookup" } # returns: internal_host:port # # Output that requires the port aspect striped could simply split the output based on ':' diff --git a/mariadb/Chart.yaml b/mariadb/Chart.yaml index 33d211dcd7..5586c809bf 100644 --- a/mariadb/Chart.yaml +++ b/mariadb/Chart.yaml @@ -15,4 +15,11 @@ apiVersion: v1 description: OpenStack-Helm MariaDB name: mariadb -version: 0.5.0 +version: 0.1.0 +home: https://docs.openstack.org/developer/nova +icon: http://badges.mariadb.org/mariadb-badge-180x60.png +sources: + - https://github.com/MariaDB/server + - https://git.openstack.org/cgit/openstack/openstack-helm +maintainers: + - name: OpenStack-Helm Authors diff --git a/mariadb/templates/bin/_readiness.sh.tpl b/mariadb/templates/bin/_readiness.sh.tpl index 88c3044e57..e13c3b86ac 100644 --- a/mariadb/templates/bin/_readiness.sh.tpl +++ b/mariadb/templates/bin/_readiness.sh.tpl @@ -16,9 +16,7 @@ set -o pipefail -PASSWORD={{ .Values.database.root_password | quote }} - -MYSQL="mysql -u root --password=${PASSWORD}" +MYSQL="mysql -u root --password=${MYSQL_ROOT_PASSWORD}" if [ ! $($MYSQL -e 'select 1') ]; then echo "Could not SELECT 1" 1>&2 diff --git a/mariadb/templates/bin/_start.sh.tpl b/mariadb/templates/bin/_start.sh.tpl index c9f76120d3..83536ae79f 100644 --- a/mariadb/templates/bin/_start.sh.tpl +++ b/mariadb/templates/bin/_start.sh.tpl @@ -13,20 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -export MYSQL_ROOT_PASSWORD={{ .Values.database.root_password | quote }} - # # Bootstrap database # CLUSTER_INIT_ARGS= if [ ! -d /var/lib/mysql/mysql ]; then - if [ "x${POD_NAME}" = "x{{ .Values.service_name }}-0" ]; then + if [ "x${POD_NAME}" = "x${SERVICE_NAME}-0" ]; then echo No data found for pod 0 if [ "xtrue" = "x{{ .Values.force_bootstrap }}" ]; then echo force_bootstrap set, so will force-initialize node 0. CLUSTER_INIT_ARGS=--wsrep-new-cluster - elif ! mysql -h {{ .Values.service_name }} -u root --password=${MYSQL_ROOT_PASSWORD} -e 'select 1'; then + elif ! mysql -h ${SERVICE_NAME} -u root --password=${MYSQL_ROOT_PASSWORD} -e 'select 1'; then echo No other nodes found, so will initialize cluster. CLUSTER_INIT_ARGS=--wsrep-new-cluster else @@ -47,12 +45,12 @@ CLUSTER_CONFIG_PATH=/etc/mysql/conf.d/10-cluster-config.cnf MEMBERS= for i in $(seq 1 {{ .Values.replicas }}); do NUM=$(expr $i - 1) - CANDIDATE_POD="{{ .Values.service_name }}-$NUM.{{ .Values.service_name }}-discovery" - if [ "x${CANDIDATE_POD}" != "x${POD_NAME}.{{ .Values.service_name }}-discovery" ]; then + CANDIDATE_POD="${SERVICE_NAME}-$NUM.${DISCOVERY_SERVICE_NAME}" + if [ "x${CANDIDATE_POD}" != "x${POD_NAME}.${DISCOVERY_SERVICE_NAME}" ]; then if [ -n "${MEMBERS}" ]; then MEMBERS+=, fi - MEMBERS+="${CANDIDATE_POD}:{{ .Values.network.port.wsrep }}" + MEMBERS+="${CANDIDATE_POD}:${WSREP_PORT}" fi done @@ -64,7 +62,7 @@ cat <