commit b804ebb0748348077154228478a97862ea3c6e2f
parent 120bea24145e35e27784eb3bb9b7b0c98dee65c0
Author: MTRNord <mtrnord1@gmail.com>
Date: Tue, 7 Jan 2025 22:13:24 +0100
Add mariadb
Diffstat:
2 files changed, 159 insertions(+), 0 deletions(-)
diff --git a/apps/base/mariadb-operator/kustomization.yaml b/apps/base/mariadb-operator/kustomization.yaml
@@ -4,3 +4,4 @@ namespace: mariadb-operator
resources:
- repository.yaml
- release.yaml
+ - mariadb.yaml
diff --git a/apps/base/mariadb-operator/mariadb.yaml b/apps/base/mariadb-operator/mariadb.yaml
@@ -0,0 +1,158 @@
+apiVersion: k8s.mariadb.com/v1alpha1
+kind: MariaDB
+metadata:
+ name: mariadb
+spec:
+ rootPasswordSecretKeyRef:
+ name: mariadb-root
+ key: root-password
+
+ storage:
+ size: 5Gi
+ storageClassName: hcloud-volumes
+
+ # Recreate the MariaDB resource and bootstrap from a backup in S3.
+ # bootstrapFrom:
+ # s3:
+ # bucket: backups
+ # prefix: mariadb
+ # endpoint: minio.minio.svc.cluster.local:9000
+ # accessKeyIdSecretKeyRef:
+ # name: minio
+ # key: access-key-id
+ # secretAccessKeySecretKeyRef:
+ # name: minio
+ # key: secret-access-key
+ # tls:
+ # enabled: true
+ # caSecretKeyRef:
+ # name: minio-ca
+ # key: ca.crt
+ # targetRecoveryTime: 2023-12-19T09:00:00Z
+ # stagingStorage:
+ # persistentVolumeClaim:
+ # resources:
+ # requests:
+ # storage: 10Gi
+ # accessModes:
+ # - ReadWriteOnce
+ # restoreJob:
+ # resources:
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+ # limits:
+ # memory: 1Gi
+
+ replicas: 3
+
+ galera:
+ enabled: true
+ config:
+ reuseStorageVolume: true
+
+ metrics:
+ enabled: true
+
+ updateStrategy:
+ type: ReplicasFirstPrimaryLast
+ # Pause updates.
+ # type: Never
+ # Update the data-plane after an operator upgrade.
+ autoUpdateDataPlane: true
+
+ # Configure enough compute resources. This is just an example, take a look at your historic compute metrics to estimate.
+ resources:
+ requests:
+ cpu: 0.25
+ memory: 1Gi
+ limits:
+ memory: 4Gi
+
+ # Tune your liveness probe accordingly to avoid Pod restarts.
+ livenessProbe:
+ initialDelaySeconds: 20
+ periodSeconds: 5
+ timeoutSeconds: 5
+
+ # Tune your readiness probe accordingly to prevent disruptions in network traffic.
+ readinessProbe:
+ initialDelaySeconds: 20
+ periodSeconds: 5
+ timeoutSeconds: 5
+
+ # innodb_buffer_pool_size: 80% of memory limits.
+ myCnf: |
+ [mariadb]
+ bind-address=*
+ default_storage_engine=InnoDB
+ binlog_format=row
+ innodb_autoinc_lock_mode=2
+ innodb_buffer_pool_size=3200MB
+ max_allowed_packet=1GB
+
+ # Schedule Pods in different Nodes to achieve real HA.
+ affinity:
+ antiAffinityEnabled: true
+
+ # When draining Nodes, make sure that you have at least 2 Pods available.
+ podDisruptionBudget:
+ maxUnavailable: 66%
+
+ maxScale:
+ enabled: true
+ kubernetesService:
+ type: ClusterIP
+---
+apiVersion: k8s.mariadb.com/v1alpha1
+kind: Database
+metadata:
+ name: osticket
+spec:
+ mariaDbRef:
+ name: mariadb
+ characterSet: utf8
+ collate: utf8_general_ci
+ # Delete the resource in the database whenever the CR gets deleted.
+ # Alternatively, you can specify Skip in order to omit deletion.
+ cleanupPolicy: Delete
+ requeueInterval: 30s
+ retryInterval: 5s
+---
+apiVersion: k8s.mariadb.com/v1alpha1
+kind: User
+metadata:
+ name: osticket
+spec:
+ # If you want the user to be created with a different name than the resource name
+ # name: user-custom
+ mariaDbRef:
+ name: mariadb
+ passwordSecretKeyRef:
+ name: mariadb-osticket
+ key: password
+ # This field defaults to 10
+ maxUserConnections: 10
+ host: "%"
+ # Delete the resource in the database whenever the CR gets deleted.
+ # Alternatively, you can specify Skip in order to omit deletion.
+ cleanupPolicy: Delete
+ requeueInterval: 30s
+ retryInterval: 5s
+---
+apiVersion: k8s.mariadb.com/v1alpha1
+kind: Grant
+metadata:
+ name: grant-osticket
+spec:
+ mariaDbRef:
+ name: mariadb
+ privileges:
+ - "SELECT"
+ - "INSERT"
+ - "UPDATE"
+ database: "osticket"
+ table: "*"
+ username: osticket
+ grantOption: true
+ host: "%"