apiVersion: v1
kind: Service
metadata:
  name: app-mysql-service
  labels:
    app: staffjoy
spec:
  ports:
    - port: 3306
  selector:
    app: staffjoy
    tier: mysql
  clusterIP: 10.0.0.100 # Lets us do migrations locally 
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: app-mysql-pv-claim
  labels:
    app: staffjoy
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: app-mysql-deployment
  labels:
    app: staffjoy
spec:
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: staffjoy
        tier: mysql
    spec:
      containers:
      - image: mysql:5.7
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: SHIBBOLETH
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: app-mysql-pv-claim
