# Ingestor deployment
# CCXT market data ingestor worker — connects to Flink via ZMQ, writes to Kafka
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ingestor
  labels:
    app: ingestor
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ingestor
  template:
    metadata:
      labels:
        app: ingestor
    spec:
      initContainers:
        - name: wait-for-kafka
          image: busybox:1.36
          command: ['sh', '-c', 'until nc -z kafka 9092; do echo waiting for kafka; sleep 2; done;']
        - name: wait-for-flink
          image: busybox:1.36
          command: ['sh', '-c', 'until nc -z flink-jobmanager 5567; do echo waiting for flink-jobmanager; sleep 2; done;']

      volumes:
        - name: config
          configMap:
            name: ingestor-config
        - name: secrets
          secret:
            secretName: ingestor-secrets

      containers:
        - name: ingestor
          image: dexorder/ai-ingestor
          imagePullPolicy: Always

          volumeMounts:
            - name: config
              mountPath: /config/config.yaml
              subPath: config.yaml
              readOnly: true
            - name: secrets
              mountPath: /config/secrets.yaml
              subPath: secrets.yaml
              readOnly: true

          env:
            - name: CONFIG_PATH
              value: "/config/config.yaml"
            - name: SECRETS_PATH
              value: "/config/secrets.yaml"

          resources:
            requests:
              memory: "256Mi"
              cpu: "100m"
            limits:
              memory: "1Gi"
              cpu: "500m"
