apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: mysql
  labels:
    app: fleet
    component: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      component: mysql
  template:
    metadata:
      labels:
        app: fleet
        component: mysql
    spec:
      containers:
      - name: mysql
        image: mysql:5.7
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "toor"
        - name: MYSQL_DATABASE
          value: "fleet"
        - name: MYSQL_USER
          value: "fleet"
        - name: MYSQL_PASSWORD
          value: "insecure"
        args: ["mysqld", "--slow_query_log=1", "--log_output=TABLE", "--log-queries-not-using-indexes"]
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
        ports:
        - containerPort: 3306
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql
  labels:
    app: fleet
    component: mysql
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
---
apiVersion: v1
kind: Service
metadata:
  name: mysql
  labels:
    app: fleet
    component: mysql
spec:
  clusterIP: None
  ports:
  - port: 3306
  selector:
    component: mysql
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: mysql-test
  labels:
    app: fleet
    component: mysql-test
spec:
  replicas: 1
  selector:
    matchLabels:
      component: mysql-test
  template:
    metadata:
      labels:
        app: fleet
        component: mysql-test
    spec:
      containers:
      - name: mysql
        image: mysql:5.7
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "toor"
        - name: MYSQL_DATABASE
          value: "fleet"
        - name: MYSQL_USER
          value: "fleet"
        - name: MYSQL_PASSWORD
          value: "insecure"
        args: ["mysqld", "--slow_query_log=1", "--log_output=TABLE", "--log-queries-not-using-indexes"]
        ports:
        - containerPort: 3306
---
apiVersion: v1
kind: Service
metadata:
  name: mysql-test
  labels:
    app: fleet
    component: mysql-test
spec:
  clusterIP: None
  ports:
  - port: 3307
    targetPort: 3306
  selector:
    component: mysql-test
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: mailhog
  labels:
    app: fleet
    component: mailhog
spec:
  replicas: 1
  selector:
    matchLabels:
      component: mailhog
  template:
    metadata:
      labels:
        app: fleet
        component: mailhog
    spec:
      containers:
      - name: mailhog
        image: mailhog/mailhog:latest
        ports:
        - name: smtp
          containerPort: 1025
        - name: http
          containerPort: 8025
---
apiVersion: v1
kind: Service
metadata:
  name: mailhog
  labels:
    app: fleet
    component: mailhog
spec:
  type: NodePort
  ports:
  - name: smtp
    port: 1025
    nodePort: 31025
  - name: http
    port: 8025
    nodePort: 32025
  selector:
    component: mailhog
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: redis
  labels:
    app: fleet
    component: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      app: fleet
      component: redis
  template:
    metadata:
      labels:
        app: fleet
        component: redis
    spec:
      containers:
      - name: redis
        image: redis:3.2.4
        ports:
        - containerPort: 6379
---
apiVersion: v1
kind: Service
metadata:
  name: redis
  labels:
    app: fleet
    component: redis
spec:
  ports:
    - port: 6379
  selector:
    component: redis
