Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app/name: mysql
  name: mysql
  namespace: sre
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app/name: mysql
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app/name: mysql
    spec:
      containers:
        - env:
            - name: MYSQL_ROOT_PASSWORD
              value: 123456
          image: 'mysql:5.7.37-oracle'
          imagePullPolicy: IfNotPresent
          livenessProbe:
            exec:
              command:
                - /bin/sh
                - '-c'
                - 'MYSQL_PWD="${MYSQL_ROOT_PASSWORD}"'
                - mysql -h 127.0.0.1 -u root -e "SELECT 1"
            failureThreshold: 3
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
          name: mysql
          ports:
            - containerPort: 3306
              name: mysql
              protocol: TCP
          readinessProbe:
            exec:
              command:
                - /bin/sh
                - '-c'
                - 'MYSQL_PWD="${MYSQL_ROOT_PASSWORD}"'
                - mysql -h 127.0.0.1 -u root -e "SELECT 1"
            failureThreshold: 3
            initialDelaySeconds: 5
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
          volumeMounts:
            - mountPath: /var/lib/mysql
              name: mysql-data
            - mountPath: /etc/localtime
              name: localtime
              readOnly: true
      initContainers:
        - command:
            - rm
            - '-fr'
            - /var/lib/mysql/lost+found
          image: 'busybox:1.29.3'
          imagePullPolicy: IfNotPresent
          name: remove-lost-found
          volumeMounts:
            - mountPath: /var/lib/mysql
              name: mysql-data
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
        - name: mysql-data
          persistentVolumeClaim:
            claimName: mysql-data
        - hostPath:
            path: /etc/localtime
            type: File
          name: localtime

svc

apiVersion: v1
kind: Service
metadata:
  labels:
    app/name: mysql
  name: mysql
  namespace: sre
spec:
  ports:
    - name: mysql
      port: 3306
      protocol: TCP
      targetPort: 3306
      nodePort: 30009
  selector:
    app/name: mysql
  sessionAffinity: None
  type: NodePort


发表回复

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

Captcha Code