---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: keep-ecdsa-2
  namespace: default
  labels:
    keel.sh/policy: all
    app: keep
    type: ecdsa
    id: '2'
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keep
      type: ecdsa
      id: '2'
  serviceName: keep-ecdsa-2
  volumeClaimTemplates:
    - metadata:
        name: keep-ecdsa-data
      spec:
        accessModes: [ReadWriteOnce]
        resources:
          requests:
            storage: 512Mi
    - metadata:
        name: keep-ecdsa-config
      spec:
        accessModes: [ReadWriteOnce]
        resources:
          requests:
            storage: 5Mi
  template:
    metadata:
      labels:
        app: keep
        type: ecdsa
        id: '2'
    spec:
      containers:
        - name: keep-ecdsa
          image: gcr.io/keep-dev-fe24/keep-ecdsa
          imagePullPolicy: Always
          ports:
            - containerPort: 3919
          env:
            - name: KEEP_ETHEREUM_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: eth-account-passphrases
                  key: account-2
            - name: LOG_LEVEL
              value: 'keep*=debug tss-lib=warning'
            - name: IPFS_LOGGING_FMT
              value: nocolor
          volumeMounts:
            - name: keep-ecdsa-config
              mountPath: /mnt/keep-ecdsa/config
            - name: keep-ecdsa-data
              mountPath: /mnt/keep-ecdsa/data
            - name: eth-account-keyfile
              mountPath: /mnt/keep-ecdsa/keyfile
          command:
            [
              'keep-ecdsa',
              '-config',
              '/mnt/keep-ecdsa/config/keep-ecdsa-config.toml',
              'start',
            ]
      initContainers:
        - name: initcontainer-provision-keep-ecdsa
          image: gcr.io/keep-dev-fe24/initcontainer-provision-keep-ecdsa
          imagePullPolicy: Always
          env:
            - name: ETH_RPC_URL
              valueFrom:
                configMapKeyRef:
                  name: eth-network-internal
                  key: rpc-url
            - name: ETH_WS_URL
              valueFrom:
                configMapKeyRef:
                  name: eth-network-internal
                  key: ws-url
            - name: ETH_NETWORK_ID
              valueFrom:
                configMapKeyRef:
                  name: eth-network-internal
                  key: network-id
            - name: CONTRACT_OWNER_ETH_ACCOUNT_ADDRESS
              valueFrom:
                configMapKeyRef:
                  name: eth-network-internal
                  key: contract-owner-eth-account-address
            - name: CONTRACT_OWNER_ETH_ACCOUNT_PRIVATE_KEY
              valueFrom:
                secretKeyRef:
                  name: eth-network-internal
                  key: contract-owner-eth-account-private-key
            - name: KEEP_TECDSA_ETH_KEYFILE_PATH
              value: /mnt/keep-ecdsa/keyfile/account-2-keyfile
            - name: KEEP_TECDSA_PEERS
              value: /ip4/10.102.100.8/tcp/3919/ipfs/16Uiu2HAm3eJtyFKAttzJ85NLMromHuRg4yyum3CREMf6CHBBV6KY
            - name: KEEP_TECDSA_ANNOUNCED_ADDRESSES
              value: ''
            - name: KEEP_TECDSA_PORT
              value: '3919'
            - name: KEEP_DATA_DIR
              value: /mnt/keep-ecdsa/data
            - name: SANCTIONED_APPLICATIONS
              value: '0x7F68B90dce19d2ac034477B7ba2229106656A084' # Shall we extract this property to a configmap?
          volumeMounts:
            - name: keep-ecdsa-config
              mountPath: /mnt/keep-ecdsa/config
            - name: eth-account-keyfile
              mountPath: /mnt/keep-ecdsa/keyfile
          command: ['node', '/tmp/provision-keep-ecdsa.js']
      volumes:
        - name: keep-ecdsa-config
          persistentVolumeClaim:
            claimName: keep-ecdsa-config
        - name: keep-ecdsa-data
          persistentVolumeClaim:
            claimName: keep-ecdsa-data
        - name: eth-account-keyfile
          configMap:
            name: eth-account-info
            items:
              - key: account-2-keyfile
                path: account-2-keyfile
