apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: ceres
  name: ceres
spec:
  replicas: 4
  serviceName: ceres
  selector:
    matchLabels:
      app: ceres
  template:
    metadata:
      labels:
        app: ceres
        prometheus/scrape-type: actuator
    spec:
      containers:
        - image: ceres
          name: ceres
          env:
            - name: JAVA_TOOL_OPTIONS
              value: >
                -XX:MaxDirectMemorySize=1G
                -XX:NativeMemoryTracking=summary
                -XX:FlightRecorderOptions=stackdepth=128
                -Xmx3G
                -Dcom.sun.management.jmxremote.local.only=false
                -Dcom.sun.management.jmxremote.port=7091
                -Dcom.sun.management.jmxremote.rmi.port=7091
                -Dcom.sun.management.jmxremote.authenticate=false
                -Dcom.sun.management.jmxremote.ssl=false
                -Dcom.sun.management.jmxremote.host=0.0.0.0
                -Djava.rmi.server.hostname=0.0.0.0
            - name: SPRING_PROFILES_ACTIVE
              value: "debug"
            - name: SPRING_CONFIG_ADDITIONALLOCATION
              value: /config/
            - name: SPRING_REDIS_HOST
              value: loadtest-redis-master
            - name: SPRING_REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: loadtest-redis
                  key: redis-password
            - name: SPRING_DATA_CASSANDRA_USERNAME
              valueFrom:
                secretKeyRef:
                  name: loadtest-superuser
                  key: username
            - name: SPRING_DATA_CASSANDRA_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: loadtest-superuser
                  key: password
            - name: SPRING_DATA_CASSANDRA_LOCALDATACENTER
              value: dc1
            - name: SPRING_DATA_CASSANDRA_CONTACTPOINTS
              value: loadtest-dc1-service
            - name: SPRING_DATA_CASSANDRA_REQUEST_TIMEOUT
              value: 10s
          ports:
            - containerPort: 8080
              name: http
            - containerPort: 8081
              name: actuator
            - containerPort: 7091
              name: jmx
          resources:
            requests:
              cpu: 4000m
              memory: 4Gi
            limits:
              cpu: 5000m
              memory: 4Gi
          readinessProbe:
            httpGet:
              port: 8081
              path: /actuator/health/readiness
            initialDelaySeconds: 10
          livenessProbe:
            httpGet:
              port: 8081
              path: /actuator/health/liveness
            initialDelaySeconds: 10
          volumeMounts:
            - mountPath: /config
              name: ceres-config
      volumes:
        - name: ceres-config
          configMap:
            name: ceres
