#version: '3.7'
# k8s namespace network
---
apiVersion: v1
kind: Service
metadata:
  name: ecm-mysql
  labels:
    app: ecm-mysql
spec:
  ports:
    - port: 3306
      targetPort: 3306
  selector:
    app: ecm-mysql
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: ecm-mysql
  name: ecm-mysql
  namespace: kube-system
spec:
  replicas: 1
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      k8s-app: ecm-mysql
  template:
    metadata:
      labels:
        k8s-app: ecm-mysql
    #hostname: mysql
    #subdomain: mysql-subdomain
    spec:
      containers:
        - name: ecm-mysql
          image: registry.kube-system.com:5000/kube-systemv5/mysql:prod620-v8.0.17.18
          imagePullPolicy: IfNotPresent
          env:
          - name: DBBACKUP
            value: "true"
          - name: TASKS
            value: "10 0 * * *"
          - name: DAYS
            value: "15"
          - name: MODE
            value: "standalone"
          volumeMounts:
            - mountPath: /var/lib/mysql
              name: owner-mysql-volume
            - mountPath: /dbbackup
              name: mysql-dbbackup-volume
          ports:
          - containerPort: 3306
            name: ecm-mysql
            protocol: TCP
      #restartPolicy: OnFailure
      restartPolicy: Always
      volumes:
        - name: owner-mysql-volume
          hostPath:
            path: /home/kube-system/macrowing/kube-systemv5/data/mysql
            type: DirectoryOrCreate
        - name: mysql-dbbackup-volume
          hostPath:
            path: /home/kube-system/macrowing/kube-systemv5/data/dbbackup
            type: DirectoryOrCreate
      serviceAccountName: ecm-mysql
      nodeSelector:
        "node.labels.nodelabels": Middleware
---
