---
apiVersion: v1
kind: Service
metadata:
  name: pyth
  labels:
    app: pyth
spec:
  clusterIP: None
  selector:
    app: pyth
  ports:
    - port: 4242
      name: pyth-accounts
      protocol: TCP
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: pyth
spec:
  selector:
    matchLabels:
      app: pyth
  serviceName: pyth
  template:
    metadata:
      labels:
        app: pyth
    spec:
      restartPolicy: Always
      terminationGracePeriodSeconds: 0
      containers:
        - name: pyth-publisher
          image: pyth
          command:
            - python3
            - /opt/pyth/pyth_publisher.py
          readinessProbe:
            tcpSocket:
              port: 2000
            periodSeconds: 1
            failureThreshold: 300
          ports:
            - containerPort: 4242
              name: pyth-accounts
              protocol: TCP
