diff --git a/10conf-d.yml b/10conf-d.yml deleted file mode 100644 index 39a2700..0000000 --- a/10conf-d.yml +++ /dev/null @@ -1,158 +0,0 @@ -kind: ConfigMap -metadata: - name: conf-d - namespace: mysql -apiVersion: v1 -data: - datadir.cnf: | - [mysqld] - datadir=/data/db - galera.cnf: | - # - # * Galera-related settings - # - # https://mariadb.com/kb/en/mariadb/galera-cluster-system-variables/ - # - [galera] - # Mandatory settings - wsrep_on=ON - wsrep_provider="/usr/lib/galera/libgalera_smm.so" - #init-new-cluster#wsrep_new_cluster=TRUE - #init-recover#wsrep_recover=TRUE - binlog_format=ROW - default_storage_engine=InnoDB - innodb_autoinc_lock_mode=2 - #init-wsrep#wsrep_cluster_address="gcomm://mariadb-0.mariadb,mariadb-1.mariadb,mariadb-2.mariadb" - wsrep-sst-method=rsync - - # - # Allow server to accept connections on all interfaces. - # - bind-address=0.0.0.0 - # - # Optional setting - #wsrep_slave_threads=1 - #innodb_flush_log_at_trx_commit=0 - utf8.cnf: | - [client-server] - - # This will be passed to all mysql clients - [client] - default-character-set = utf8mb4 - - # The MySQL server - [mysqld] - character-set-server = utf8mb4 - collation-server = utf8mb4_unicode_ci - init-connect='SET NAMES utf8mb4' - - [mysql] - default-character-set = utf8mb4 - - [mysqldump] - - # This group is only read by MariaDB servers, not by MySQL. - # If you use the same .cnf file for MySQL and MariaDB, - # you can put MariaDB-only options here - [mariadb] - - [mariadb-10.1] - - [mariadb-10.2] - init.sh: | - #!/bin/bash - set -x - [ "$(pwd)" != "/etc/mysql/conf.d" ] && cp * /etc/mysql/conf.d/ - - HOST_ID=${HOSTNAME##*-} - - STATEFULSET_SERVICE=$(dnsdomainname -d) - POD_FQDN=$(dnsdomainname -A) - - echo "This is pod $HOST_ID ($POD_FQDN) for statefulset $STATEFULSET_SERVICE" - - [ -z "$WSREP_CLUSTER_ADDRESS" ] && echo "Missing WSREP_CLUSTER_ADDRESS env" && exit 1 - sed -i "s|^#init-wsrep#.*|wsrep_cluster_address=$WSREP_CLUSTER_ADDRESS|" /etc/mysql/conf.d/galera.cnf - - [ -z "$DATADIR" ] && exit "Missing DATADIR variable" && exit 1 - - SUGGEST_EXEC_COMMAND="kubectl --namespace=$POD_NAMESPACE exec -c init-config $POD_NAME --" - - function wsrepNewCluster { - sed -i 's|^#init-new-cluster#||' /etc/mysql/conf.d/galera.cnf - } - - function wsrepRecover { - sed -i 's|^#init-recover#||' /etc/mysql/conf.d/galera.cnf - } - - function wsrepForceBootstrap { - sed -i 's|safe_to_bootstrap: 0|safe_to_bootstrap: 1|' /data/db/grastate.dat - } - - [[ $STATEFULSET_SERVICE = mariadb.* ]] || echo "WARNING: unexpected service name $STATEFULSET_SERVICE, Peer detection below may fail falsely." - - if [ $HOST_ID -eq 0 ]; then - echo "This is the 1st statefulset pod. Checking if the statefulset is down ..." - getent hosts mariadb-ready - [ $? -eq 2 ] && { - # https://github.com/docker-library/mariadb/commit/f76084f0f9dc13f29cce48c727440eb79b4e92fa#diff-b0fa4b30392406b32de6b8ffe36e290dR80 - if [ ! -d "$DATADIR/mysql" ]; then - echo "No database in $DATADIR; configuring $POD_NAME for initial start" - wsrepNewCluster - else - set +x - echo "----- ACTION REQUIRED -----" - echo "No peers found, but data exists. To start in wsrep_new_cluster mode, run:" - echo " $SUGGEST_EXEC_COMMAND touch /tmp/confirm-new-cluster" - echo "Or to start in recovery mode, to see replication state, run:" - echo " $SUGGEST_EXEC_COMMAND touch /tmp/confirm-recover" - echo "Or to force bootstrap on this node, potentially losing writes, run:" - echo " $SUGGEST_EXEC_COMMAND touch /tmp/confirm-force-bootstrap" - #echo " NOTE This bypasses the following warning from new cluster mode:" - #echo " It may not be safe to bootstrap the cluster from this node. It was not the last one to leave the cluster and may not contain all the updates. To force cluster bootstrap with this node, edit the grastate.dat file manually and set safe_to_bootstrap to 1 ." - echo "Or to try a regular start (for example after recovery + manual intervention), run:" - echo " $SUGGEST_EXEC_COMMAND touch /tmp/confirm-resume" - if [ ! -z "$AUTO_RECOVERY_MODE" ]; then - echo "The AUTO_RECOVERY_MODE env was set to $AUTO_RECOVERY_MODE, will trigger that choice" - touch /tmp/$AUTO_RECOVERY_MODE - else - echo "Waiting for response ..." - fi - while [ ! -f /tmp/confirm-resume ]; do - if [ "$AUTO_NEW_CLUSTER" = "true" ]; then - echo "The AUTO_NEW_CLUSTER env was set to $AUTO_NEW_CLUSTER, will proceed without confirmation" - echo "NOTE this env is deprecated, use AUTO_RECOVERY_MODE instead" - wsrepNewCluster - touch /tmp/confirm-resume - elif [ -f /tmp/confirm-new-cluster ]; then - echo "Confirmation received. Resuming new cluster start ..." - wsrepNewCluster - touch /tmp/confirm-resume - elif [ -f /tmp/confirm-force-bootstrap ]; then - echo "Forcing bootstrap on this node ..." - wsrepForceBootstrap - touch /tmp/confirm-new-cluster - elif [ -f /tmp/confirm-recover ]; then - echo "Confirmation received. Resuming in recovery mode." - echo "Note: to start the other pods you need to edit OrderedReady and add a command: --wsrep-recover" - wsrepRecover - touch /tmp/confirm-resume - fi - sleep 1 - done - rm /tmp/confirm-* - set -x - fi - } - else - getent hosts mariadb-ready - [ $? -eq 2 ] && { - echo "This is NOT the 1st statefulset pod. Must not go up as primary." - echo "Found no ready pods. Will exit to trigger a crash loop back off." - exit 1 - } - fi - - # https://github.com/docker-library/mariadb/blob/master/10.2/docker-entrypoint.sh#L62 - mysqld --verbose --help --log-bin-index="$(mktemp -u)" | tee /tmp/mariadb-start-config | grep -e ^version -e ^datadir -e ^wsrep -e ^binlog -e ^character-set -e ^collation diff --git a/base-defaultconfig/datadir.cnf b/base-defaultconfig/datadir.cnf new file mode 100644 index 0000000..19af51e --- /dev/null +++ b/base-defaultconfig/datadir.cnf @@ -0,0 +1,2 @@ +[mysqld] +datadir=/data/db diff --git a/base-defaultconfig/galera.cnf b/base-defaultconfig/galera.cnf new file mode 100644 index 0000000..abf3742 --- /dev/null +++ b/base-defaultconfig/galera.cnf @@ -0,0 +1,25 @@ +# +# * Galera-related settings +# +# https://mariadb.com/kb/en/mariadb/galera-cluster-system-variables/ +# +[galera] +# Mandatory settings +wsrep_on=ON +wsrep_provider="/usr/lib/galera/libgalera_smm.so" +#init-new-cluster#wsrep_new_cluster=TRUE +#init-recover#wsrep_recover=TRUE +binlog_format=ROW +default_storage_engine=InnoDB +innodb_autoinc_lock_mode=2 +#init-wsrep#wsrep_cluster_address="gcomm://mariadb" +wsrep-sst-method=rsync + +# +# Allow server to accept connections on all interfaces. +# +bind-address=0.0.0.0 +# +# Optional setting +#wsrep_slave_threads=1 +#innodb_flush_log_at_trx_commit=0 diff --git a/base-defaultconfig/init.sh b/base-defaultconfig/init.sh new file mode 100644 index 0000000..00b1b00 --- /dev/null +++ b/base-defaultconfig/init.sh @@ -0,0 +1,96 @@ +#!/bin/bash +set -x +[ "$(pwd)" != "/etc/mysql/conf.d" ] && cp * /etc/mysql/conf.d/ + +HOST_ID=${HOSTNAME##*-} + +STATEFULSET_SERVICE=$(dnsdomainname -d) +POD_FQDN=$(dnsdomainname -A) + +echo "This is pod $HOST_ID ($POD_FQDN) for statefulset $STATEFULSET_SERVICE" + +[ -z "$WSREP_CLUSTER_ADDRESS" ] && echo "Missing WSREP_CLUSTER_ADDRESS env" && exit 1 +sed -i "s|^#init-wsrep#.*|wsrep_cluster_address=$WSREP_CLUSTER_ADDRESS|" /etc/mysql/conf.d/galera.cnf + +[ -z "$DATADIR" ] && exit "Missing DATADIR variable" && exit 1 + +SUGGEST_EXEC_COMMAND="kubectl --namespace=$POD_NAMESPACE exec -c init-config $POD_NAME --" + +function wsrepNewCluster { + sed -i 's|^#init-new-cluster#||' /etc/mysql/conf.d/galera.cnf +} + +function wsrepRecover { + sed -i 's|^#init-recover#||' /etc/mysql/conf.d/galera.cnf +} + +function wsrepForceBootstrap { + sed -i 's|safe_to_bootstrap: 0|safe_to_bootstrap: 1|' /data/db/grastate.dat +} + +[[ $STATEFULSET_SERVICE = mariadb.* ]] || echo "WARNING: unexpected service name $STATEFULSET_SERVICE, Peer detection below may fail falsely." + +if [ $HOST_ID -eq 0 ]; then + echo "This is the 1st statefulset pod. Checking if the statefulset is down ..." + getent hosts mariadb-ready + [ $? -eq 2 ] && { + # https://github.com/docker-library/mariadb/commit/f76084f0f9dc13f29cce48c727440eb79b4e92fa#diff-b0fa4b30392406b32de6b8ffe36e290dR80 + if [ ! -d "$DATADIR/mysql" ]; then + echo "No database in $DATADIR; configuring $POD_NAME for initial start" + wsrepNewCluster + else + set +x + echo "----- ACTION REQUIRED -----" + echo "No peers found, but data exists. To start in wsrep_new_cluster mode, run:" + echo " $SUGGEST_EXEC_COMMAND touch /tmp/confirm-new-cluster" + echo "Or to start in recovery mode, to see replication state, run:" + echo " $SUGGEST_EXEC_COMMAND touch /tmp/confirm-recover" + echo "Or to force bootstrap on this node, potentially losing writes, run:" + echo " $SUGGEST_EXEC_COMMAND touch /tmp/confirm-force-bootstrap" + #echo " NOTE This bypasses the following warning from new cluster mode:" + #echo " It may not be safe to bootstrap the cluster from this node. It was not the last one to leave the cluster and may not contain all the updates. To force cluster bootstrap with this node, edit the grastate.dat file manually and set safe_to_bootstrap to 1 ." + echo "Or to try a regular start (for example after recovery + manual intervention), run:" + echo " $SUGGEST_EXEC_COMMAND touch /tmp/confirm-resume" + if [ ! -z "$AUTO_RECOVERY_MODE" ]; then + echo "The AUTO_RECOVERY_MODE env was set to $AUTO_RECOVERY_MODE, will trigger that choice" + touch /tmp/$AUTO_RECOVERY_MODE + else + echo "Waiting for response ..." + fi + while [ ! -f /tmp/confirm-resume ]; do + if [ "$AUTO_NEW_CLUSTER" = "true" ]; then + echo "The AUTO_NEW_CLUSTER env was set to $AUTO_NEW_CLUSTER, will proceed without confirmation" + echo "NOTE this env is deprecated, use AUTO_RECOVERY_MODE instead" + wsrepNewCluster + touch /tmp/confirm-resume + elif [ -f /tmp/confirm-new-cluster ]; then + echo "Confirmation received. Resuming new cluster start ..." + wsrepNewCluster + touch /tmp/confirm-resume + elif [ -f /tmp/confirm-force-bootstrap ]; then + echo "Forcing bootstrap on this node ..." + wsrepForceBootstrap + touch /tmp/confirm-new-cluster + elif [ -f /tmp/confirm-recover ]; then + echo "Confirmation received. Resuming in recovery mode." + echo "Note: to start the other pods you need to edit OrderedReady and add a command: --wsrep-recover" + wsrepRecover + touch /tmp/confirm-resume + fi + sleep 1 + done + rm /tmp/confirm-* + set -x + fi + } +else + getent hosts mariadb-ready + [ $? -eq 2 ] && { + echo "This is NOT the 1st statefulset pod. Must not go up as primary." + echo "Found no ready pods. Will exit to trigger a crash loop back off." + exit 1 + } +fi + +# https://github.com/docker-library/mariadb/blob/master/10.2/docker-entrypoint.sh#L62 +mysqld --verbose --help --log-bin-index="$(mktemp -u)" | tee /tmp/mariadb-start-config | grep -e ^version -e ^datadir -e ^wsrep -e ^binlog -e ^character-set -e ^collation diff --git a/base-defaultconfig/kustomization.yaml b/base-defaultconfig/kustomization.yaml new file mode 100644 index 0000000..b0f7206 --- /dev/null +++ b/base-defaultconfig/kustomization.yaml @@ -0,0 +1,13 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../base + +configMapGenerator: +- name: conf-d + files: + - init.sh + - datadir.cnf + - galera.cnf + - utf8.cnf diff --git a/base-defaultconfig/utf8.cnf b/base-defaultconfig/utf8.cnf new file mode 100644 index 0000000..88d7995 --- /dev/null +++ b/base-defaultconfig/utf8.cnf @@ -0,0 +1,25 @@ +[client-server] + +# This will be passed to all mysql clients +[client] +default-character-set = utf8mb4 + +# The MySQL server +[mysqld] +character-set-server = utf8mb4 +collation-server = utf8mb4_unicode_ci +init-connect='SET NAMES utf8mb4' + +[mysql] +default-character-set = utf8mb4 + +[mysqldump] + +# This group is only read by MariaDB servers, not by MySQL. +# If you use the same .cnf file for MySQL and MariaDB, +# you can put MariaDB-only options here +[mariadb] + +[mariadb-10.1] + +[mariadb-10.2] diff --git a/base/kustomization.yaml b/base/kustomization.yaml new file mode 100644 index 0000000..387cd35 --- /dev/null +++ b/base/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- mariadb-service.yaml +- mariadb-ready-service.yaml +- mysql-service.yaml +- mariadb-statefulset.yaml diff --git a/21mariadb-ready-service.yml b/base/mariadb-ready-service.yaml similarity index 94% rename from 21mariadb-ready-service.yml rename to base/mariadb-ready-service.yaml index 6895dbd..718f66a 100644 --- a/21mariadb-ready-service.yml +++ b/base/mariadb-ready-service.yaml @@ -4,7 +4,6 @@ apiVersion: v1 kind: Service metadata: name: mariadb-ready - namespace: mysql annotations: service.alpha.kubernetes.io/tolerate-unready-endpoints: "false" spec: diff --git a/20mariadb-service.yml b/base/mariadb-service.yaml similarity index 96% rename from 20mariadb-service.yml rename to base/mariadb-service.yaml index c9d5f94..a0bb7f6 100644 --- a/20mariadb-service.yml +++ b/base/mariadb-service.yaml @@ -4,7 +4,6 @@ apiVersion: v1 kind: Service metadata: name: mariadb - namespace: mysql annotations: service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" spec: diff --git a/50mariadb.yml b/base/mariadb-statefulset.yaml similarity index 77% rename from 50mariadb.yml rename to base/mariadb-statefulset.yaml index 9a1843d..58ad66b 100644 --- a/50mariadb.yml +++ b/base/mariadb-statefulset.yaml @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: mariadb - namespace: mysql spec: selector: matchLabels: @@ -14,11 +13,8 @@ spec: metadata: labels: app: mariadb - annotations: - prometheus.io/scrape: "true" - prometheus.io/port: "9104" spec: - terminationGracePeriodSeconds: 30 + terminationGracePeriodSeconds: 25 initContainers: - name: init-config command: ['/bin/bash', '/etc/mysql/conf.d-configmap/init.sh'] @@ -51,10 +47,10 @@ spec: mountPath: /etc/mysql/conf.d - name: initdb mountPath: /docker-entrypoint-initdb.d - image: mariadb:10.2.36-bionic@sha256:b7be3ade3d5441c79b5c8a9cf2c2269f14bf420876a06def7d50e1763f042238 + image: mariadb:10.5.19-focal@sha256:ce75a36261b12948b411f6debb71254d92889c8a06e2ebc34c761f90416b1024 containers: - name: mariadb - image: mariadb:10.2.36-bionic@sha256:b7be3ade3d5441c79b5c8a9cf2c2269f14bf420876a06def7d50e1763f042238 + image: mariadb:10.5.19-focal@sha256:ce75a36261b12948b411f6debb71254d92889c8a06e2ebc34c761f90416b1024 ports: - containerPort: 3306 name: mysql @@ -81,14 +77,6 @@ spec: - -ec - test ON = "$(mysql -e "SHOW STATUS LIKE 'wsrep_ready';" -N -B | sed 's/wsrep_ready\t//')" initialDelaySeconds: 30 - livenessProbe: - exec: - command: - - mysql - - -e - - "SHOW DATABASES;" - # might need to be tweaked for large initial state transfers - initialDelaySeconds: 60 volumeMounts: - name: mysql mountPath: /data @@ -97,12 +85,14 @@ spec: - name: initdb mountPath: /docker-entrypoint-initdb.d - name: metrics - image: prom/mysqld-exporter:v0.12.1@sha256:9fe9938c4ac9216cc24005144338f14fac4f604f139b481cc541bead008db3c1 + image: prom/mysqld-exporter:v0.14.0@sha256:eb6fe170738bf9181c51f5bc89f93adb26672ec49ffdcb22f55c24834003b45d env: - name: DATA_SOURCE_NAME - value: root@(localhost:3306)/ + # https://github.com/prometheus/mysqld_exporter#required-grants + value: exporter:exporter@tcp(127.0.0.1:3306)/ ports: - - containerPort: 9104 + - name: metrics + containerPort: 9104 volumes: - name: conf emptyDir: {} diff --git a/30mysql-service.yml b/base/mysql-service.yaml similarity index 87% rename from 30mysql-service.yml rename to base/mysql-service.yaml index dee62dc..dcef547 100644 --- a/30mysql-service.yml +++ b/base/mysql-service.yaml @@ -3,7 +3,6 @@ apiVersion: v1 kind: Service metadata: name: mysql - namespace: mysql spec: ports: - port: 3306 diff --git a/kustomization.yaml b/kustomization.yaml deleted file mode 100644 index 176a01a..0000000 --- a/kustomization.yaml +++ /dev/null @@ -1,6 +0,0 @@ -resources: -- 10conf-d.yml -- 20mariadb-service.yml -- 21mariadb-ready-service.yml -- 30mysql-service.yml -- 50mariadb.yml diff --git a/variants/gke/gke-storageclass-ssd-regional-europewest1cd.yaml b/variants/gke/gke-storageclass-ssd-regional-europewest1cd.yaml deleted file mode 100644 index c5bd899..0000000 --- a/variants/gke/gke-storageclass-ssd-regional-europewest1cd.yaml +++ /dev/null @@ -1,11 +0,0 @@ -kind: StorageClass -apiVersion: storage.k8s.io/v1 -metadata: - name: mysql-data -provisioner: kubernetes.io/gce-pd -reclaimPolicy: Retain -allowVolumeExpansion: true -parameters: - type: pd-ssd - replication-type: regional-pd - zones: europe-west1-c, europe-west1-d diff --git a/variants/gke/gke-storageclass-ssd.yml b/variants/gke/gke-storageclass-ssd.yml deleted file mode 100644 index cd4852f..0000000 --- a/variants/gke/gke-storageclass-ssd.yml +++ /dev/null @@ -1,9 +0,0 @@ -kind: StorageClass -apiVersion: storage.k8s.io/v1 -metadata: - name: mysql-data -provisioner: kubernetes.io/gce-pd -reclaimPolicy: Retain -allowVolumeExpansion: true -parameters: - type: pd-ssd diff --git a/variants/gke/kustomization.yaml b/variants/gke/kustomization.yaml deleted file mode 100644 index 50b758f..0000000 --- a/variants/gke/kustomization.yaml +++ /dev/null @@ -1,7 +0,0 @@ -bases: -- github.com/Yolean/kubernetes-mysql-cluster?ref=009cad0 -resources: -- gke-storageclass-ssd.yml -#- gke-storageclass-ssd-regional-europewest1cd.yaml -patchesStrategicMerge: -- volume-claims.yaml diff --git a/variants/gke/volume-claims.yaml b/variants/gke/volume-claims.yaml deleted file mode 100644 index 0de97f6..0000000 --- a/variants/gke/volume-claims.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: mariadb - namespace: mysql -spec: - volumeClaimTemplates: - - metadata: - name: mysql - spec: - accessModes: [ "ReadWriteOnce" ] - storageClassName: mysql-data - resources: - requests: - storage: 1Gi diff --git a/variants/namespace/kustomization.yaml b/variants/namespace/kustomization.yaml deleted file mode 100644 index 16d767e..0000000 --- a/variants/namespace/kustomization.yaml +++ /dev/null @@ -1,3 +0,0 @@ -bases: -- github.com/Yolean/kubernetes-mysql-cluster?ref=549e804 -namespace: analytics diff --git a/variants/scale-1-ephemeral/ephemeral.yaml b/variants/scale-1-ephemeral/ephemeral.yaml index c2f015b..57b576c 100644 --- a/variants/scale-1-ephemeral/ephemeral.yaml +++ b/variants/scale-1-ephemeral/ephemeral.yaml @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: mariadb - namespace: mysql spec: template: spec: diff --git a/variants/scale-1-ephemeral/kustomization.yaml b/variants/scale-1-ephemeral/kustomization.yaml index 5498756..fccc152 100644 --- a/variants/scale-1-ephemeral/kustomization.yaml +++ b/variants/scale-1-ephemeral/kustomization.yaml @@ -1,4 +1,7 @@ -bases: +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: - ../scale-1 patchesStrategicMerge: - ephemeral.yaml diff --git a/variants/scale-1/galera.cnf b/variants/scale-1/galera.cnf new file mode 100644 index 0000000..56b788c --- /dev/null +++ b/variants/scale-1/galera.cnf @@ -0,0 +1,2 @@ +[galera] +wsrep_on=OFF diff --git a/variants/scale-1/kustomization.yaml b/variants/scale-1/kustomization.yaml index 6e1fa9a..d206f89 100644 --- a/variants/scale-1/kustomization.yaml +++ b/variants/scale-1/kustomization.yaml @@ -1,5 +1,15 @@ -bases: -- github.com/Yolean/kubernetes-mysql-cluster?ref=a9e6956000a31c973d183d8c318d6828cd73c26c +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../../base-defaultconfig + patchesStrategicMerge: - replicas-1.yaml -- wsrep-1.yaml +- wsrep-off.yaml + +configMapGenerator: +- name: conf-d + behavior: merge + files: + - galera.cnf diff --git a/variants/scale-1/replicas-1.yaml b/variants/scale-1/replicas-1.yaml index 2d5a351..212208f 100644 --- a/variants/scale-1/replicas-1.yaml +++ b/variants/scale-1/replicas-1.yaml @@ -2,6 +2,5 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: mariadb - namespace: mysql spec: replicas: 1 diff --git a/variants/scale-1/wsrep-1.yaml b/variants/scale-1/wsrep-1.yaml deleted file mode 100644 index 95a61ef..0000000 --- a/variants/scale-1/wsrep-1.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: mariadb -spec: - template: - spec: - initContainers: - - name: init-config - env: - - name: WSREP_CLUSTER_ADDRESS - value: "gcomm://mariadb-0.mariadb" diff --git a/variants/scale-1/wsrep-off.yaml b/variants/scale-1/wsrep-off.yaml new file mode 100644 index 0000000..6870398 --- /dev/null +++ b/variants/scale-1/wsrep-off.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mariadb +spec: + template: + spec: + containers: + - name: mariadb + readinessProbe: + exec: + command: + - mysqladmin + - status + initContainers: + - name: init-config + env: + # So the init script can configure galera unconditionally; galera.cnf is overridden to disable wsrep + - name: WSREP_CLUSTER_ADDRESS + value: "gcomm://mariadb-0.mariadb" diff --git a/variants/scale-2/kustomization.yaml b/variants/scale-2/kustomization.yaml index 2f7540f..bc0afbd 100644 --- a/variants/scale-2/kustomization.yaml +++ b/variants/scale-2/kustomization.yaml @@ -1,5 +1,9 @@ -bases: -- github.com/Yolean/kubernetes-mysql-cluster?ref=8c4439f +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../../base-defaultconfig + patchesStrategicMerge: - replicas-2.yaml - wsrep-2.yaml diff --git a/variants/scale-2/replicas-2.yaml b/variants/scale-2/replicas-2.yaml index e57c624..41fee73 100644 --- a/variants/scale-2/replicas-2.yaml +++ b/variants/scale-2/replicas-2.yaml @@ -2,6 +2,5 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: mariadb - namespace: mysql spec: replicas: 2