apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongo-stateful
spec:
  selector:
    matchLabels:
      app: mongo-stateful
  serviceName: "mongo-stateful"
  replicas: 3
  podManagementPolicy: Parallel
  template:
    metadata:
      labels:
        app: mongo-stateful
    spec:
      terminationGracePeriodSeconds: 10
      affinity:
         podAntiAffinity:
           requiredDuringSchedulingIgnoredDuringExecution:
           - labelSelector:
               matchExpressions:
               - key: "app"
                 operator: In
                 values:
                 - mongo-stateful
             topologyKey: "kubernetes.io/hostname"
      containers:
      - name: mongo-stateful
        image: mongo:3.4.1
        command:
        - mongod
        - "--bind_ip_all"
        - "--replSet"
        - rs0
        ports:
        - containerPort: 27017
        volumeMounts:
        - name: mongo-data
          mountPath: /data/db
  volumeClaimTemplates:
  - metadata:
      name: mongo-data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: ibmc-file-bronze
      resources:
        requests:
          storage: 20Gi