---
apiVersion: v1
kind: Service
metadata:
  name: p2w-terra-relay
  labels:
    app: p2w-terra-relay
spec:
  ports:
    - port: 8081
      name: prometheus
      protocol: TCP
    - port: 4200
      name: rest-api
      protocol: TCP
  clusterIP: None
  selector:
    app: p2w-terra-relay
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: p2w-terra-relay
spec:
  selector:
    matchLabels:
      app: p2w-terra-relay
  serviceName: p2w-terra-relay
  replicas: 1
  template:
    metadata:
      labels:
        app: p2w-terra-relay
    spec:
      terminationGracePeriodSeconds: 0
      containers:
        - name: p2w-terra-relay
          image: p2w-relay
          ports:
            - containerPort: 8081
              name: prometheus
              protocol: TCP
            - containerPort: 4200
              name: rest-api
              protocol: TCP
          readinessProbe:
            httpGet:
              path: "/health"
              port: 4200
          command:
            - node
            - lib/index.js
            - "--"
            - "--terra"
          env:
            - name: SPY_SERVICE_HOST
              value: spy:7072
            - name: SPY_SERVICE_FILTERS
              value: '[{"chain_id":1,"emitter_address":"71f8dcb863d176e2c420ad6610cf687359612b6fb392e0642b0ca6b1f186aa3b"}]'
            - name: TERRA_NODE_URL
              value: http://terra-terrad:1317
            - name: TERRA_PRIVATE_KEY
              value: notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius
            - name: TERRA_PYTH_CONTRACT_ADDRESS
              value: terra1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrquka9l6
              # ^^ It can change if order of terra contract creation changes or anything is added/removed in terra/tools/deploy.js
            - name: TERRA_CHAIN_ID
              value: localterra
            - name: TERRA_NAME
              value: localterra
            - name: TERRA_COIN
              value: uluna
            - name: REST_PORT
              value: "4200"
            - name: PROM_PORT
              value: "8081"
            - name: BAL_QUERY_INTERVAL
              value: "60000"
            - name: RETRY_MAX_ATTEMPTS
              value: "6"
            - name: RETRY_DELAY_IN_MS
              value: "1000"
            - name: MAX_MSGS_PER_BATCH
              value: "1"
            - name: MAX_HEALTHY_NO_RELAY_DURATION_IN_SECONDS
              value: "120"
            - name: LOG_LEVEL
              value: debug
