apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: database-cluster
  namespace: database
  labels:
    app: database-cluster
spec:
  serviceName: database-service
  replicas: 2
  selector:
    matchLabels:
      app: database-cluster
  template:
    metadata:
      labels:
        app: database-cluster
    spec:
      securityContext:
        fsGroup: 2000
      terminationGracePeriodSeconds: 10
      containers:
      - name: database-container
        image: nheidloff/database-service:v1.0.22
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8089
          name: api
        volumeMounts:
        - name: data-volume
          mountPath: /data
        env:
          - name: DATA_DIRECTORY
            value: /data/
          - name: POD_NAME
            valueFrom:
              fieldRef:
                apiVersion: v1
                fieldPath: metadata.name
          - name: NAMESPACE
            valueFrom:
              fieldRef:
                apiVersion: v1
                fieldPath: metadata.namespace
  volumeClaimTemplates:
  - metadata:
      name: data-volume
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: ibmc-vpc-block-5iops-tier
      resources:
        requests:
          storage: 1Mi