infra/old/cluster/mariadb/mariadb-deployment.yaml

130 lines
No EOL
2.8 KiB
YAML

apiVersion: v1
kind: Secret
metadata:
name: mariadb-secret
namespace: data
type: Opaque
stringData:
root-password: "TxN9RnbTQw9GarJg5mDvsuW2bFSYot7L"
replication-password: "nXhalxeheXryAy8R6qTJWhCw4P1CtUXu"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: mariadb-config
namespace: data
data:
my.cnf: |
[mysqld]
bind-address = 0.0.0.0
default_storage_engine = InnoDB
binlog_format = ROW
innodb_autoinc_lock_mode = 2
innodb_flush_log_at_trx_commit = 0
query_cache_size = 0
query_cache_type = 0
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mariadb-data
namespace: data
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mariadb
namespace: data
labels:
app: mariadb
spec:
replicas: 1
selector:
matchLabels:
app: mariadb
template:
metadata:
labels:
app: mariadb
spec:
containers:
- name: mariadb
image: mariadb:11
ports:
- containerPort: 3306
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mariadb-secret
key: root-password
- name: MYSQL_DATABASE
value: "forgejo"
- name: MYSQL_USER
value: "forgejo"
- name: MYSQL_PASSWORD
value: "nJWD2Iv44Y2j4eQSFupjq9fBKX3rI6pg"
volumeMounts:
- name: data
mountPath: /var/lib/mysql
- name: config
mountPath: /etc/mysql/conf.d
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "2Gi"
cpu: "1000m"
livenessProbe:
exec:
command:
- /bin/bash
- -c
- "mariadb-admin ping -h localhost -u root -p$MYSQL_ROOT_PASSWORD"
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
readinessProbe:
exec:
command:
- /bin/bash
- -c
- "mariadb-admin ping -h localhost -u root -p$MYSQL_ROOT_PASSWORD"
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 1
volumes:
- name: data
persistentVolumeClaim:
claimName: mariadb-data
- name: config
configMap:
name: mariadb-config
---
apiVersion: v1
kind: Service
metadata:
name: mariadb
namespace: data
labels:
app: mariadb
spec:
type: ClusterIP
ports:
- port: 3306
targetPort: 3306
protocol: TCP
name: mysql
selector:
app: mariadb