kind: StatefulSet
apiVersion: apps/v1
metadata:
  labels:
    name: infinispan
    app: infinispan
  name: infinispan
spec:
  replicas: 1
  serviceName: infinispan-server-headless
  selector:
    matchLabels:
      name: infinispan
      app: infinispan
  template:
    metadata:
      labels:
        name: infinispan
        app: infinispan
      name: infinispan
    spec:
      serviceAccount: infinispan
      containers:
      - args:
        - custom/cloud-ephemeral.xml
        - -Djboss.default.jgroups.stack=kubernetes
        env:
        - name: KUBERNETES_LABELS
          value: app=infinispan,name=infinispan
        - name: KUBERNETES_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: APP_USER
          valueFrom:
            secretKeyRef:
              name: conn-auth-secret
              key: username
        - name: APP_PASS
          valueFrom:
            secretKeyRef:
              name: conn-auth-secret
              key: password
        - name: MGMT_USER
          valueFrom:
            secretKeyRef:
              name: mgmt-auth-secret
              key: username
        - name: MGMT_PASS
          valueFrom:
            secretKeyRef:
              name: mgmt-auth-secret
              key: password
        image: jboss/infinispan-server:9.4.11.Final
        name: infinispan-server
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        - containerPort: 9990
          name: management
          protocol: TCP
        - containerPort: 8888
          name: ping
          protocol: TCP
        - containerPort: 11222
          name: hotrod
          protocol: TCP
        livenessProbe:
          exec:
            command:
            - /usr/local/bin/is_running.sh
          failureThreshold: 5
          initialDelaySeconds: 10
          periodSeconds: 60
          successThreshold: 1
          timeoutSeconds: 80
        readinessProbe:
          exec:
            command:
            - /usr/local/bin/is_healthy.sh
          failureThreshold: 5
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 80
        resources:
          requests:
            memory: 512Mi
        volumeMounts:
        - mountPath: /opt/jboss/infinispan-server/standalone/configuration/custom
          name: infinispan-configuration
        - mountPath: /opt/infinispan/server/data/
          name: infinispan-data
      terminationGracePeriodSeconds: 120
      volumes:
      - name: infinispan-configuration
        configMap:
          defaultMode: 420
          name: infinispan-configuration
  volumeClaimTemplates:
  - metadata:
      name: infinispan-data
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 8Gi