---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: keep-client-2
  namespace: default
  labels:
    app: keep
    type: beacon
    id: '2'
    network: ropsten
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keep
      type: beacon
      id: '2'
  serviceName: keep-client-2
  volumeClaimTemplates:
  - metadata:
      name: keep-client-data
    spec:
      accessModes: [ReadWriteOnce]
      resources:
        requests:
          storage: 512Mi
  - metadata:
      name: keep-client-config
    spec:
      accessModes: [ReadWriteOnce]
      resources:
        requests:
          storage: 5Mi
  template:
    metadata:
      labels:
        app: keep
        type: beacon
        id: '2'
        network: ropsten
    spec:
      containers:
      - name: keep-client-2
        image: gcr.io/keep-test-f3e0/keep-client
        imagePullPolicy: Always
        ports:
          - containerPort: 3919
        env:
          - name: KEEP_ETHEREUM_PASSWORD
            valueFrom:
              secretKeyRef:
                name: eth-account-passphrases
                key: account-2
          - name: LOG_LEVEL
            value: debug
          - name: IPFS_LOGGING_FMT
            value: nocolor
        volumeMounts:
          - name: keep-client-config
            mountPath: /mnt/keep-client/config
          - name: keep-client-data
            mountPath: /mnt/keep-client/data
          - name: eth-account-keyfile
            mountPath: /mnt/keep-client/keyfile
        command: ["keep-client", "-config", "/mnt/keep-client/config/keep-client-config.toml", "start"]
      volumes:
      - name: keep-client-config
        persistentVolumeClaim:
          claimName: keep-client-config
      - name: keep-client-data
        persistentVolumeClaim:
          claimName: keep-client-data
      - name: eth-account-keyfile
        configMap:
          name: eth-account-info
          items:
            - key: account-2-keyfile
              path: account-2-keyfile
      initContainers:
      - name: initcontainer-provision-keep-client
        image: gcr.io/keep-test-f3e0/initcontainer-provision-keep-client
        imagePullPolicy: Always
        env:
          - name: ETH_RPC_URL
            valueFrom:
              configMapKeyRef:
                name: eth-network-ropsten
                key: rpc-url
          - name: ETH_WS_URL
            valueFrom:
              configMapKeyRef:
                name: eth-network-ropsten
                key: ws-url
          - name: ETH_NETWORK_ID
            valueFrom:
              configMapKeyRef:
                name: eth-network-ropsten
                key: network-id
          - name: CONTRACT_OWNER_ETH_ACCOUNT_ADDRESS
            valueFrom:
              configMapKeyRef:
                name: eth-network-ropsten
                key: contract-owner-eth-account-address
          - name: CONTRACT_OWNER_ETH_ACCOUNT_PRIVATE_KEY
            valueFrom:
              secretKeyRef:
                name: eth-network-ropsten
                key: contract-owner-eth-account-private-key
          - name: KEEP_CLIENT_ETH_ACCOUNT_ADDRESS
            valueFrom:
              configMapKeyRef:
                name: eth-account-info
                key: account-2-address
          - name: KEEP_CLIENT_ETH_KEYFILE_PATH
            value: /mnt/keep-client/keyfile/account-2-keyfile
          - name: KEEP_CLIENT_PEERS
            value: /dns4/bootstrap-0.test.keep.network/tcp/3919/ipfs/16Uiu2HAmCcfVpHwfBKNFbQuhvGuFXHVLQ65gB4sJm7HyrcZuLttH
          - name: KEEP_CLIENT_ANNOUNCED_ADDRESSES
            value: /dns4/bootstrap-2.test.keep.network/tcp/3919
          - name: KEEP_CLIENT_PORT
            value: '3919'
          - name: KEEP_CLIENT_DATA_DIR
            value: /mnt/keep-client/data
        volumeMounts:
          - name: keep-client-config
            mountPath: /mnt/keep-client/config
        command: ["node", "/tmp/provision-keep-client.js"]