---
apiVersion: apps/v1
kind: "StatefulSet"
metadata:
  name: "orders-view-app"
  namespace: "default"
  labels:
    app: "orders-view-app"
spec:
  serviceName: "orders-view-app"
  replicas: 2
  podManagementPolicy: "Parallel"
  selector:
    matchLabels:
      app: "orders-view-app"
  template:
    metadata:
      labels:
        app: "orders-view-app"
    spec:
      securityContext:
        fsGroup: 2000
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app
                    operator: In
                    values:
                      - "orders-view-app"
              topologyKey: "kubernetes.io/hostname"
      volumes:
        - name: spring-boot-application-properties
          secret:
            secretName: spring-boot-application-properties
      containers:
        - name: orders-view-app
          image: docker.io/gamussa/livestreams-orders-view-app
          ports:
            - containerPort: 8080
          volumeMounts:
            - mountPath: /mnt/app
              name: spring-boot-application-properties
            - mountPath: /mnt/kafka-streams-store/
              name: rocksdb
          env:
            - name: SPRING_CONFIG_LOCATION
              value: /mnt/app/application.properties
            - name: JAVA_TOOL_OPTIONS
              value: -DLOGLEVEL=INFO
  volumeClaimTemplates:
    - metadata:
        name: rocksdb
      spec:
        accessModes: [ "ReadWriteOnce" ]
        resources:
          requests:
            storage: 1Gi
        storageClassName: standard
