---
apiVersion: v1
kind: Service
metadata:
  name: fly
  labels:
    app: fly
spec:
  clusterIP: None
  selector:
    app: fly
  ports:
    - port: 8001
      name: fly
      protocol: TCP
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: fly
spec:
  selector:
    matchLabels:
      app: fly
  serviceName: fly
  template:
    metadata:
      labels:
        app: fly
    spec:
      restartPolicy: Always
      terminationGracePeriodSeconds: 0
      containers:
        - name: fly
          image: fly:latest
          args: ["-local"]
          env:
            - name: MONGODB_URI
              value: mongodb://mongo-0.mongo/?replicaSet=rs0
            - name: API_PORT
              value: "8001"
          readinessProbe:
            httpGet:
              path: /api/ready
              port: 8001
            initialDelaySeconds: 30
            periodSeconds: 20
            timeoutSeconds: 3
            failureThreshold: 3
          ports:
            - containerPort: 8001
              name: server
              protocol: TCP
