k8s安装xtrabackup和mysql在同一个pod(目的使得xtrabackup能有权限访问/var/lib/mysql)

k8s安装xtrabackup和mysql在同一个pod(目的使得xtrabackup能有权限访问/var/lib/mysql)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-xtrabackup
  namespace: test1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql-xtrabackup
  template:
    metadata:
      labels:
        app: mysql-xtrabackup
    spec:
      containers:
      - name: mysql
        image: mysql:5.7
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: 123456
        volumeMounts:
        - name: mysql-data
          mountPath: /var/lib/mysql
        - name: backup-data
          mountPath: /backup
      - name: xtrabackup
        image: gcr.io/google-samples/xtrabackup:1.0
        command: ["sleep", "infinity"]
        volumeMounts:
        - name: mysql-data
          mountPath: /var/lib/mysql
        - name: backup-data
          mountPath: /backup
      volumes:
      - name: mysql-data
        emptyDir: {}
      - name: backup-data
        emptyDir: {}

---
apiVersion: v1
kind: Service
metadata:
  name: mysql-service
  namespace: test1
spec:
  selector:
    app: mysql-xtrabackup
  ports:
  - protocol: TCP
    port: 3306
    targetPort: 3306

kubectl apply -f mysql3+xtrabackup.yaml -n test1

k8s安装xtrabackup和mysql在同一个pod(目的使得xtrabackup能有权限访问/var/lib/mysql)

发表回复

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

Scroll to top
桂ICP备2023008908号-1