apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: tezos-node
  namespace: tqtezos
spec:
  serviceName: tezos-node
  podManagementPolicy: Parallel
  selector:
    matchLabels:
      app: tezos-node
  template:
    metadata:
      labels:
        app: tezos-node
    spec:
      securityContext:
        fsGroup: 100
      containers:
        - args:
            - run
            - --config-file
            - /etc/tezos/config.json
          command:
            - /usr/local/bin/tezos-node
          image: tezos/tezos:v7-release
          imagePullPolicy: Always
          name: tezos-node
          ports:
            - containerPort: 8732
              name: tezos-rpc
            - containerPort: 9732
              name: tezos-p2p
          readinessProbe:
            exec:
              command:
                - nc
                - -z
                - 127.0.0.1
                - "8732"
            initialDelaySeconds: 2
            periodSeconds: 2
            timeoutSeconds: 1
          volumeMounts:
            - mountPath: /etc/tezos
              name: config-volume
            - mountPath: /var/tezos
              name: var-volume
      initContainers:
      - imagePullPolicy: Always
        name: tezos-config-generator
        image: python:alpine
        command: ["python", "/opt/tqtezos/generateTezosConfig.py"]
        envFrom:
        - configMapRef:
            name: tezos-config
        volumeMounts:
        - name: config-volume
          mountPath: /etc/tezos
        - name: tqtezos-utils
          mountPath: /opt/tqtezos
        - name: var-volume
          mountPath: /var/tezos
      volumes:
        - name: config-volume
          emptyDir: {}
        - name: tqtezos-utils
          configMap:
            name: tqtezos-utils
  volumeClaimTemplates:
  - metadata:
      name: var-volume
      namespace: tqtezos
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 15Gi
