k8s创建StatefulSet状态的mysql

k8s使用StatefulSet部署有状态的mysql

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
namespace: test1
spec:
selector:
matchLabels:
app: mysql
serviceName: mysql-service
replicas: 2
template:
metadata:
labels:
app: mysql
spec:
volumes:

  • name: mysql-data
    persistentVolumeClaim:
    claimName: mysql-pvc
    containers:
  • name: mysql
    image: mysql:5.7
    env:

    • name: MYSQL_ROOT_PASSWORD
      value: 123456
      ports:
    • containerPort: 3306
      volumeMounts:
    • name: mysql-data
      mountPath: /var/lib/mysql
      volumeClaimTemplates:

      • metadata:
        name: mysql-data
        spec:
        accessModes: [ "ReadWriteOnce" ]
        storageClassName: rook-cephfs-sc
        resources:
        requests:
        storage: 2Gi

apiVersion: v1
kind: Service
metadata:
name: mysql-service
namespace: test1
spec:
selector:
app: mysql
ports:

  • name: mysql
    protocol: TCP
    port: 3306
    targetPort: 3306
    type: ClusterIP
k8s创建StatefulSet状态的mysql

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Scroll to top
桂ICP备2023008908号-1