OKR/tob-upgrade/mysql/mysql.yaml

76 lines
1.9 KiB
YAML
Raw Normal View History

2023-11-06 16:36:03 +08:00
apiVersion: apps/v1
2023-11-06 16:35:18 +08:00
kind: StatefulSet
2023-06-01 19:28:28 +08:00
metadata:
2023-11-06 11:33:27 +08:00
name: mysql
2023-06-01 19:28:28 +08:00
spec:
replicas: 1
2023-11-06 16:37:18 +08:00
serviceName: mysql
2023-06-01 19:28:28 +08:00
selector:
2023-11-06 16:44:34 +08:00
matchLabels:
app: mysql
2023-06-01 19:28:28 +08:00
template:
metadata:
labels:
2023-11-06 16:44:34 +08:00
app: mysql
2023-06-01 19:28:28 +08:00
spec:
2023-11-06 11:33:27 +08:00
initContainers:
- name: init
image: busybox
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- |
sysctl -w net.ipv4.tcp_keepalive_time=300
sysctl -w net.ipv4.tcp_keepalive_intvl=10
sysctl -w net.ipv4.tcp_keepalive_probes=3
securityContext:
privileged: true
2023-06-01 19:28:28 +08:00
containers:
2023-11-06 11:33:27 +08:00
- name: mysql
2023-06-01 19:28:28 +08:00
image: mysql:8.0.33
2023-08-28 22:45:41 +08:00
args: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci", "--max_connections=2000", "--binlog_expire_logs_seconds=432000","--sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"]
2023-06-01 19:28:28 +08:00
ports:
- containerPort: 3306
volumeMounts:
2025-03-13 13:08:18 +08:00
- name: training-mysql
2023-06-01 19:28:28 +08:00
mountPath: /var/lib/mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: "Beaconfire@2099"
- name: MYSQL_DATABASE
2023-11-06 11:33:27 +08:00
value: "test"
- name: MYSQL_USER
value: "app"
- name: MYSQL_PASSWORD
value: "beaconfire@123"
2023-08-28 18:50:53 +08:00
volumes:
2025-03-13 13:08:18 +08:00
- name: training-mysql
2023-06-01 19:28:28 +08:00
hostPath:
2025-03-13 13:08:18 +08:00
path: /data/training/mysql
2023-11-06 11:40:03 +08:00
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "kubernetes.io/hostname"
operator: In
values:
2025-02-14 10:14:01 +08:00
- bfs-k8snode-10-2-3-7.hetzner.base.beaconfireinc.com
2023-06-01 19:28:28 +08:00
---
apiVersion: v1
kind: Service
metadata:
2023-11-06 11:33:27 +08:00
name: mysql
2023-06-01 19:28:28 +08:00
labels:
2023-11-06 16:44:34 +08:00
app: mysql
2023-06-01 19:28:28 +08:00
spec:
ports:
- protocol: TCP
port: 3306
targetPort: 3306
nodePort: 30016
selector:
2023-11-06 16:44:34 +08:00
app: mysql
2023-11-06 11:33:27 +08:00
type: NodePort