Last active
January 10, 2023 15:31
-
-
Save sideshowcoder/55d8fe90f5e5d667f37f569fd153661a to your computer and use it in GitHub Desktop.
MariaDB Kubernets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: phoenix-main-mariadb | |
annotations: | |
volumeType: local | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
storageClassName: local-path | |
resources: | |
requests: | |
storage: 1Gi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: phoenix-main-mariadb | |
spec: | |
selector: | |
tier: backend | |
layer: database | |
ports: | |
- protocol: TCP | |
port: 3306 | |
targetPort: 3306 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: phoenix-main-mariadb | |
labels: | |
tier: backend | |
layer: database | |
spec: | |
selector: | |
matchLabels: | |
tier: backend | |
layer: database | |
serviceName: phoenix-main-mariadb | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
tier: backend | |
layer: database | |
spec: | |
containers: | |
- name: mariadb | |
image: mariadb | |
ports: | |
- name: mariadb-port | |
containerPort: 3306 | |
env: | |
- name: MARIADB_ROOT_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
name: phoenix-main-mariadb | |
key: root-password | |
- name: MARIADB_DATABASE | |
value: maindb | |
- name: MARIADB_MYSQL_LOCALHOST_USER | |
value: "1" | |
- name: MARIADB_USER | |
valueFrom: | |
secretKeyRef: | |
name: phoenix-main-mariadb | |
key: db-username | |
- name: MARIADB_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
name: phoenix-main-mariadb | |
key: db-password | |
- name: MARIADB_INITDB_SKIP_TZINFO | |
value: "1" | |
volumeMounts: | |
- name: data | |
mountPath: /var/lib/mysql | |
subPath: mysql | |
resources: | |
requests: | |
cpu: 300m | |
memory: 256Mi | |
livenessProbe: | |
exec: | |
command: | |
- bash | |
- -c | |
- mysqladmin -u ${MARIADB_USER} -p${MARIADB_PASSWORD} ping | |
periodSeconds: 10 | |
startupProbe: | |
exec: | |
command: | |
- bash | |
- -c | |
- mysql -u ${MARIADB_USER} -p${MARIADB_PASSWORD} -e "SELECT 1" | |
periodSeconds: 10 | |
failureThreshold: 60 # total 600s = 10min to startup and configure all the databases | |
volumes: | |
- name: data | |
persistentVolumeClaim: | |
claimName: phoenix-main-mariadb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: phoenix-main-mariadb | |
type: Opaque | |
data: | |
# notmyuser | |
db-username: bm90bXl1c2Vy | |
# notmypassword:-) | |
db-password: bm90bXlwYXNzd29yZDotKQ== | |
# notmyrootpassword:-) | |
root-password: bm90bXlyb290cGFzc3dvcmQ6LSk= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment