apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: noobaa-core
  labels:
    app: noobaa
spec:
  replicas: 1
  selector:
    matchLabels:
      noobaa-core: noobaa
  serviceName: noobaa-mgmt
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: noobaa
        noobaa-core: noobaa
        noobaa-mgmt: noobaa
      annotations:
        noobaa.io/configmap-hash: ""
    spec:
      serviceAccountName: noobaa
      volumes:
        - name: logs
          emptyDir: {}
        - name: mgmt-secret
          secret:
            secretName: noobaa-mgmt-serving-cert
            optional: true
        - name: s3-secret
          secret:
            secretName: noobaa-s3-serving-cert
            optional: true
      containers:
        #----------------#
        # CORE CONTAINER #
        #----------------#
        - name: core
          image: NOOBAA_CORE_IMAGE
          volumeMounts:
            - name: logs
              mountPath: /log
            - name: mgmt-secret
              mountPath: /etc/mgmt-secret
              readOnly: true
            - name: s3-secret
              mountPath: /etc/s3-secret
              readOnly: true
          resources:
            requests:
              cpu: "1"
              memory: "4Gi"
            limits:
              cpu: "1"
              memory: "4Gi"
          ports:
            - containerPort: 8080
            - containerPort: 8443
            - containerPort: 8444
            - containerPort: 8445
            - containerPort: 8446
            - containerPort: 60100
          env:
            - name: NOOBAA_DISABLE_COMPRESSION
              valueFrom:
                configMapKeyRef:
                  name: noobaa-config
                  key: NOOBAA_DISABLE_COMPRESSION
            - name: DISABLE_DEV_RANDOM_SEED
              valueFrom:
                configMapKeyRef:
                  name: noobaa-config
                  key: DISABLE_DEV_RANDOM_SEED
            - name: NOOBAA_LOG_LEVEL
              valueFrom:
                configMapKeyRef:
                  name: noobaa-config
                  key: NOOBAA_LOG_LEVEL
            - name: MONGODB_URL
              value: "mongodb://noobaa-db-0.noobaa-db/nbcore"
            - name: POSTGRES_HOST
              value: "noobaa-db-pg-0.noobaa-db-pg"
            - name: POSTGRES_DBNAME
              value: nbcore
            - name: POSTGRES_USER
            - name: POSTGRES_PASSWORD
            - name: DB_TYPE
              value: mongodb
            - name: CONTAINER_PLATFORM
              value: KUBERNETES
            - name: JWT_SECRET
              valueFrom:
                secretKeyRef:
                  name: noobaa-server
                  key: jwt
            - name: SERVER_SECRET
              valueFrom:
                secretKeyRef:
                  name: noobaa-server
                  key: server_secret
            - name: NOOBAA_ROOT_SECRET
            - name: NODE_EXTRA_CA_CERTS
            - name: AGENT_PROFILE
              value: VALUE_AGENT_PROFILE
            - name: OAUTH_AUTHORIZATION_ENDPOINT
              value: ""
            - name: OAUTH_TOKEN_ENDPOINT
              value: ""
            - name: NOOBAA_SERVICE_ACCOUNT
              valueFrom:
                fieldRef:
                  fieldPath: spec.serviceAccountName
            - name: CONTAINER_CPU_REQUEST
              valueFrom:
                resourceFieldRef:
                  resource: requests.cpu
            - name: CONTAINER_MEM_REQUEST
              valueFrom:
                resourceFieldRef:
                  resource: requests.memory
            - name: CONTAINER_CPU_LIMIT
              valueFrom:
                resourceFieldRef:
                  resource: limits.cpu
            - name: CONTAINER_MEM_LIMIT
              valueFrom:
                resourceFieldRef:
                  resource: limits.memory
