diff --git a/50mariadb.yml b/50mariadb.yml deleted file mode 100644 index 9a1843d..0000000 --- a/50mariadb.yml +++ /dev/null @@ -1,121 +0,0 @@ -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: mariadb - namespace: mysql -spec: - selector: - matchLabels: - app: mariadb - serviceName: "mariadb" - replicas: 3 - podManagementPolicy: Parallel - template: - metadata: - labels: - app: mariadb - annotations: - prometheus.io/scrape: "true" - prometheus.io/port: "9104" - spec: - terminationGracePeriodSeconds: 30 - initContainers: - - name: init-config - command: ['/bin/bash', '/etc/mysql/conf.d-configmap/init.sh'] - env: - - name: K8S_NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: POD_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: DATADIR - value: /data/db - - name: AUTO_RECOVERY_MODE - value: confirm-force-bootstrap - - name: WSREP_CLUSTER_ADDRESS - value: "gcomm://mariadb-0.mariadb,mariadb-1.mariadb,mariadb-2.mariadb" - workingDir: /etc/mysql/conf.d-configmap - volumeMounts: - - name: mysql - mountPath: /data - - name: conf-readonly - mountPath: /etc/mysql/conf.d-configmap - - name: conf - mountPath: /etc/mysql/conf.d - - name: initdb - mountPath: /docker-entrypoint-initdb.d - image: mariadb:10.2.36-bionic@sha256:b7be3ade3d5441c79b5c8a9cf2c2269f14bf420876a06def7d50e1763f042238 - containers: - - name: mariadb - image: mariadb:10.2.36-bionic@sha256:b7be3ade3d5441c79b5c8a9cf2c2269f14bf420876a06def7d50e1763f042238 - ports: - - containerPort: 3306 - name: mysql - - containerPort: 4444 - name: sst - - containerPort: 4567 - name: replication - - containerPort: 4567 - protocol: UDP - name: replicationudp - - containerPort: 4568 - name: ist - env: - - name: MYSQL_ROOT_HOST - value: "localhost" - - name: MYSQL_ALLOW_EMPTY_PASSWORD - value: "yes" - - name: MYSQL_INITDB_SKIP_TZINFO - value: "yes" - readinessProbe: - exec: - command: - - /bin/sh - - -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 - - name: conf - mountPath: /etc/mysql/conf.d - - name: initdb - mountPath: /docker-entrypoint-initdb.d - - name: metrics - image: prom/mysqld-exporter:v0.12.1@sha256:9fe9938c4ac9216cc24005144338f14fac4f604f139b481cc541bead008db3c1 - env: - - name: DATA_SOURCE_NAME - value: root@(localhost:3306)/ - ports: - - containerPort: 9104 - volumes: - - name: conf - emptyDir: {} - - name: conf-readonly - configMap: - name: conf-d - - name: initdb - emptyDir: {} - volumeClaimTemplates: - - metadata: - name: mysql - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: 1Gi diff --git a/base/kustomization.yaml b/base/kustomization.yaml new file mode 100644 index 0000000..f8075f7 --- /dev/null +++ b/base/kustomization.yaml @@ -0,0 +1,5 @@ +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/base/mariadb-statefulset.yaml b/base/mariadb-statefulset.yaml new file mode 100644 index 0000000..3493704 --- /dev/null +++ b/base/mariadb-statefulset.yaml @@ -0,0 +1,75 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mariadb +spec: + selector: + matchLabels: + app: mariadb + serviceName: "mariadb" + replicas: 1 + podManagementPolicy: Parallel + template: + metadata: + labels: + app: mariadb + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9104" + spec: + terminationGracePeriodSeconds: 30 + containers: + - name: mariadb + image: mariadb:10.5.8-focal@sha256:cdc553f0515a8d41264f0855120874e86761f7c69407b5cfbe49283dc195bea8 + args: + - --character-set-server=utf8 + - --collation-server=utf8_unicode_ci + env: + - name: MYSQL_ROOT_HOST + value: "localhost" + - name: MYSQL_ALLOW_EMPTY_PASSWORD + value: "yes" + - name: MYSQL_INITDB_SKIP_TZINFO + value: "yes" + ports: + - containerPort: 3306 + name: mysql + readinessProbe: + exec: + command: + - mysql + - -e + - "SHOW DATABASES;" + livenessProbe: + exec: + command: + - mysql + - -e + - "SHOW DATABASES;" + resources: + requests: + cpu: 10m + memory: 100Mi + volumeMounts: + - name: mysql + mountPath: /data + - name: initdb + mountPath: /docker-entrypoint-initdb.d + - name: metrics + image: prom/mysqld-exporter:v0.12.1@sha256:9fe9938c4ac9216cc24005144338f14fac4f604f139b481cc541bead008db3c1 + env: + - name: DATA_SOURCE_NAME + value: root@(localhost:3306)/ + ports: + - containerPort: 9104 + volumes: + - name: initdb + emptyDir: {} + volumeClaimTemplates: + - metadata: + name: mysql + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 1Gi 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