apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    io.kompose.service: cardano-graphql
  name: cardano-graphql
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: cardano-graphql
  template:
    metadata:
      labels:
        io.kompose.service: cardano-graphql
    spec:
      initContainers:
      - name: configure
        command: ["bash", "/configmap/initContainer-entrypoint"]
        image: repsistance/cardano-node:iohk-mn-passive-1.26.2-0
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: cardano-graphql-config
          mountPath: /config
        - name: cardano-graphql-configmap
          mountPath: /configmap
      containers:
      - env:
        - name: ALLOW_INTROSPECTION
          value: "true"
        - name: CACHE_ENABLED
          value: "true"
        - name: CARDANO_NODE_CONFIG_PATH
          value: /config/cardano-node-config.json
        - name: GENESIS_FILE_BYRON
          value: /config/genesis-byron.json
        - name: GENESIS_FILE_SHELLEY
          value: /config/genesis-shelley.json
        - name: HASURA_URI
          value: http://hasura-headless:8080
        - name: POSTGRES_HOST
          valueFrom:
            configMapKeyRef:
              name: common-env
              key: POSTGRES_HOST_RW
        - name: POSTGRES_PORT
          valueFrom:
            configMapKeyRef:
              name: common-env
              key: POSTGRES_PORT
        - name: POSTGRES_DB_FILE
          value: /run/secrets/common-env/POSTGRES_DB
        - name: POSTGRES_USER_FILE
          value: /run/secrets/common-env/POSTGRES_USER
        - name: POSTGRES_PASSWORD_FILE
          value: /run/secrets/postgres-password/POSTGRES_PASSWORD
        - name: CARDANO_NODE_SOCKET_PATH
          value: /ipc/node.socket
        image: inputoutput/cardano-graphql:4.0.0
        #command: ["sh", "-c", "while true; do sleep 6969; done"]
        imagePullPolicy: IfNotPresent
        name: cardano-graphql
        ports:
        - containerPort: 3100
        readinessProbe:
          tcpSocket:
            port: 3100
          initialDelaySeconds: 15
          periodSeconds: 15
        livenessProbe:
          tcpSocket:
            port: 3100
          initialDelaySeconds: 15
          periodSeconds: 15
        resources: {}
        volumeMounts:
        - name: cardano-graphql-config
          mountPath: /config
        - name: common-env
          mountPath: /run/secrets/common-env
          readOnly: true
        - name: postgres-password
          mountPath: /run/secrets/postgres-password
          readOnly: true
        - mountPath: /ipc
          name: node-ipc
      - name: socat-socket-server
        image: alpine/socat
        env:
        - name: CARDANO_NODE_SOCKET_TCP_HOST
          value: "cardano-node-headless"
        - name: CARDANO_NODE_SOCKET_TCP_PORT
          value: "30000"
        - name: SOCAT_TIMEOUT
          value: "3600"
        command: ["sh", "-c", "socat UNIX-LISTEN:/ipc/node.socket,fork TCP:${CARDANO_NODE_SOCKET_TCP_HOST}:${CARDANO_NODE_SOCKET_TCP_PORT},ignoreeof"]
        #command: ["sh", "-c", "socat -d -d -d -d -v UNIX-LISTEN:/ipc/node.socket TCP:${CARDANO_NODE_SOCKET_TCP_HOST}:${CARDANO_NODE_SOCKET_TCP_PORT},ignoreeof,keepalive,keepidle=10,keepintvl=10,keepcnt=100"]
        volumeMounts:
        - mountPath: /ipc
          name: node-ipc
      restartPolicy: Always
      serviceAccountName: ""
      volumes:
      - name: node-ipc
        emptyDir: {}
      - name: cardano-graphql-config
        emptyDir: {}
      - name: cardano-graphql-configmap
        configMap:
          name: cardano-graphql-configmap
      - name: common-env
        configMap:
          name: common-env
      - name: postgres-password
        secret:
          secretName: init0-postgresql-ha-postgresql
          items:
          - key: postgresql-password
            path: POSTGRES_PASSWORD
