apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: molecule
  labels:
    app: molecule
spec:
  selector:
    matchLabels:
      app: molecule
  serviceName: "molecule-service"
  replicas: 3
  template:
    metadata:
      labels:
        app: molecule
    spec:
      terminationGracePeriodSeconds: 60
      volumes:
        - name: molecule-storage
          persistentVolumeClaim:
            claimName: efs-claim
        - name: tmpfs
          emptyDir: {}
        - name: cgroup
          hostPath:
            path: /sys/fs/cgroup
            type: Directory
      containers:
      - image: boomi/molecule:release
        imagePullPolicy: Always
        name: atom-node
        ports:
        - name: http
          containerPort: 9090
          protocol: TCP
        - name: https
          containerPort: 9093
          protocol: TCP
        lifecycle:
          preStop:
            exec:
              command:
                - sh
                - /home/boomi/scaledown.sh
        resources:
          limits:
            cpu: "1000m"
            memory: "1536Mi"
          requests:
            cpu: "500m"
            memory: "1024Mi"
        volumeMounts:
          - mountPath: "/mnt/boomi"
            name: molecule-storage
          - name: tmpfs
            mountPath: "/run"
          - name: tmpfs
            mountPath: "/tmp"
          - name: cgroup
            mountPath: /sys/fs/cgroup
        startupProbe:
          failureThreshold: 60
          exec:
            command:
              - sh
              - /home/boomi/probe.sh
              - startup
        readinessProbe:
          periodSeconds: 10
          initialDelaySeconds: 10
          exec:
            command:
              - sh
              - /home/boomi/probe.sh
              - readiness
        livenessProbe:
          periodSeconds: 60
          exec:
            command:
              - sh
              - /home/boomi/probe.sh
              - liveness
        env:
        - name: BOOMI_ATOMNAME
          value: "Boomi-EKS"
        - name: ATOM_LOCALHOSTID
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: BOOMI_ACCOUNTID
          valueFrom:
            secretKeyRef:
              name: boomi-secret
              key: account
        - name: BOOMI_USERNAME
          valueFrom:
            secretKeyRef:
              name: boomi-secret
              key: username
        - name: BOOMI_PASSWORD
          valueFrom:
            secretKeyRef:
              name: boomi-secret
              key: password
        - name: BOOMI_CONTAINERNAME
          value: "Boomi-EKS"
        - name: INSTALLATION_DIRECTORY
          value: "/mnt/boomi"
