apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: seed
  labels:
    app: seed
    type: node
spec:
  serviceName: nodes
  replicas: 1 
  selector:
    matchLabels:
      app: seed # has to match .spec.template.metadata.labels
      type: node
  template:
    metadata:
      labels:
        app: seed # has to match .spec.selector.matchLabels
        type: node
    spec:
      terminationGracePeriodSeconds: 35
      containers:
      - name: node
        image: aleskov/mightycalc-lighthouse:stable
        lifecycle:
          preStop:
            exec:
              command: ["/bin/sh", "-c", "pbm 127.0.0.1:9110 cluster leave"]
        ports:
        - name: akka
          containerPort: 2552
          protocol: TCP
        - name: akka-cmd
          containerPort: 9110
          protocol: TCP
        livenessProbe:
          tcpSocket:
            port: 2552
        env:
        - name: MightyCalc_Journal
          value: "Host=postgres-svc;Port=5432;Database=journal;User ID=postgres;"
        - name: MightyCalc_SnapshotStore
          value: "Host=postgres-svc;Port=5432;Database=snapshotstore;User ID=postgres;"
        - name: MightyCalc_ReadModel
          value: "Host=postgres-svc;Port=5432;Database=readmodel;User ID=postgres;"
        - name: MightyCalc_NodePort
          value: "2552"
        - name: MightyCalc_CmdPort
          value: "9110"
        - name: HOST_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: MightyCalc_HostName
          value: "0.0.0.0"
        - name: MightyCalc_PublicHostName
          value: "$(HOST_NAME).nodes"
        - name: MightyCalc_SeedNodes
          value: "akka.tcp://MightyCalc@seed-0.nodes:2552"
        - name: MightyCalc_NodeRoles
          value: "seed"
        - name: MightyCalc_CmdPort
          value: "9110"
       
        resources:
          requests:
            memory: "256Mi"
            cpu: "100m"
          limits:
            memory: "512Mi"
            cpu: "500m"