---
apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
  name: mongodb
spec:
  additionalMongodConfig:
    systemLog:
      quiet: true
  members: 3
  type: ReplicaSet
  version: "5.0.9"
  security:
    authentication:
      modes: ["SCRAM"]
  users:
    - name: readwrite
      db: application
      passwordSecretRef:
        name: mongodb-application-readwrite-password
      roles:
        - name: readWrite
          db: application
      scramCredentialsSecretName: mongodb-application-readwrite
    - name: readonly
      db: application
      passwordSecretRef:
        name: mongodb-application-readonly-password
      roles:
        - name: readOnly
          db: application
      scramCredentialsSecretName: mongodb-application-readonly
  statefulSet:
    spec:
      logLevel: WARN
      template:
        spec:
          affinity:
            podAntiAffinity:
              requiredDuringSchedulingIgnoredDuringExecution:
                - labelSelector:
                    matchExpressions:
                      - key: app
                        operator: In
                        values:
                          - mongodb-svc
                  topologyKey: kubernetes.io/hostname
          nodeSelector:
            dedicated: storage
          tolerations:
            - key: dedicated
              operator: Equal
              value: storage
              effect: NoSchedule
      volumeClaimTemplates:
        - metadata:
            name: logs-volume
          spec:
            storageClassName: local-path
            accessModes:
            - ReadWriteOnce
            resources:
              requests:
                storage: 512Mi
        - metadata:
            name: data-volume
          spec:
            storageClassName: local-path
            accessModes:
            - ReadWriteOnce
            resources:
              requests:
                storage: 2Gi
---
apiVersion: minio.min.io/v2
kind: Tenant
metadata:
  name: minio
  annotations:
    prometheus.io/path: /minio/prometheus/metrics
    prometheus.io/port: "9000"
    prometheus.io/scrape: "true"
spec:
  credsSecret:
    name: minio-secret
  buckets:
    - name: application
  requestAutoCert: false
  users:
    - name: minio-user-0
  pools:
    - name: pool-0
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: v1.min.io/tenant
                    operator: In
                    values:
                      - minio
                  - key: v1.min.io/pool
                    operator: In
                    values:
                      - pool-0
              topologyKey: kubernetes.io/hostname
      resources:
        requests:
          cpu: '1'
          memory: 512Mi
      servers: 4
      volumesPerServer: 1
      volumeClaimTemplate:
        metadata:
          name: data
        spec:
          accessModes:
            - ReadWriteOnce
          resources:
            requests:
              storage: '30Gi'
          storageClassName: local-path
        status: {}
      nodeSelector:
        dedicated: storage
      tolerations:
        - key: dedicated
          operator: Equal
          value: storage
          effect: NoSchedule