apiVersion: v1
kind: Service
metadata:
  labels:
    app: aptos
  name: aptos
spec:
  ports:
    - name: node
      port: 8080
      targetPort: 8080
    - name: prometheus
      port: 6181
      targetPort: prometheus
    - name: faucet
      port: 8081
      targetPort: 8081
  selector:
    app: aptos
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: aptos
  name: aptos
spec:
  replicas: 1
  selector:
    matchLabels:
      app: aptos
  serviceName: aptos
  template:
    metadata:
      labels:
        app: aptos
    spec:
      containers:
        - name: aptos-node
          image: aptos-node
          command:
            - /bin/sh
            - -c
            - /tmp/start_node.sh
          ports:
            - containerPort: 8080
              name: node
              protocol: TCP
            - containerPort: 6181
              name: prometheus
              protocol: TCP
            - containerPort: 8081
              name: faucet
              protocol: TCP
          readinessProbe:
            tcpSocket:
              port: 8081
        - name: aptos-contracts
          image: aptos-node
          command: ["/bin/bash", "-c"]
          args:
            [
              "cd /tmp/scripts && ./wait_for_devnet && ./deploy devnet && ./register_devnet && touch success && sleep infinity",
            ]
          readinessProbe:
            periodSeconds: 1
            failureThreshold: 300
            exec:
              command:
                - cat
                - /tmp/scripts/success
