# sets up stateful set:
apiVersion: apps/v1
kind: StatefulSet
# follows the suggested params in question:
metadata:
  name: cs3219-db
  labels:
    app: cs3219-db
  namespace: cs3219 #  partitions a single Kubernetes cluster into multiple virtual clusters
spec:
  serviceName: cs3219-db
  replicas: 1
  selector:
    matchLabels:
      app: cs3219-db
  template:
    metadata:
      labels:
        app: cs3219-db
    spec:
      containers:
        - name: cs3219
          image: cs3219/mariadb:1.0.0 # matches locally generated image
          imagePullPolicy: IfNotPresent # check local if not in registry
          env:
            - name: MYSQL_DATABASE
              value: cs3219
            - name: MYSQL_ROOT_PASSWORD
              value: password
          ports:
            - containerPort: 3306 # port where db is running on within the container
              name: web
          volumeMounts: # to maintain state, local mount point
            - name: www
              mountPath: /usr/share/nginx/html
  volumeClaimTemplates:
    - metadata:
        name: www
      spec:
        accessModes: [ "ReadWriteOnce" ]
        resources:
          requests:
            storage: 1Gi