kubernetes部署percona:5.7.22单实例 Deployment

  sre
apiVersion: v1
kind: Namespace
metadata:
  name: test2
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      name: mysql
  template:
    metadata:
      labels:
        name: mysql
    spec:
      containers:
      - name: mysql
        image: percona:5.7.22
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 3306
        resources:
          limits:
            memory: "500Mi"
            cpu: "500m"
          requests:
            memory: "500Mi"
            cpu: "250m"
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "mysql"
        volumeMounts:
        - name: mysql-pvc
          mountPath: /var/lib/mysql
      volumes:
       - name: mysql-pvc
         persistentVolumeClaim:
           claimName: mysql

      livenessProbe:
        exec:
          command:
          - /bin/sh
          - "-c"
          - MYSQL_PWD="{MYSQL_ROOT_PASSWORD}"
          - mysql -h 127.0.0.1 -u root -e "SELECT 1"
        initialDelaySeconds: 30
        timeoutSeconds: 5
        successThreshold: 1
        failureThreshold: 3
      readinessProbe:
        exec:
          command:
          - /bin/sh
          - "-c"
          - MYSQL_PWD="{MYSQL_ROOT_PASSWORD}"
          - mysql -h 127.0.0.1 -u root -e "SELECT 1"
        initialDelaySeconds: 10
        timeoutSeconds: 1
        successThreshold: 1
        failureThreshold: 3
---
kind: Service
apiVersion: v1
metadata:
  name: mysql
spec:
  type: NodePort
  ports:
  - name: mysql
    port: 3306
    nodePort: 30306
    targetPort: 3306
    protocol: TCP
  selector:
    name: mysql
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: "5Gi"
  volumeName: 
  storageClassName: nfs

LEAVE A COMMENT

Captcha Code