apiVersion: apps/v1
kind: Deployment
metadata:
  name: scheduler
  labels:
    app: scheduler
    env: production
spec:
  replicas: 1  # stateful service, so only a single replica must be used
  selector:
    matchLabels:
      app: scheduler
      env: production
  template:
    metadata:
      name: scheduler
      labels:
        app: scheduler
        env: production
    spec:
      containers:
        - name: scheduler
          image: fnndsc/chris
          args: [
            "celery", "-A", "core", "beat", "-l", "info", "--pidfile", "/home/localuser/celerybeat.pid",
            "--scheduler", "django_celery_beat.schedulers:DatabaseScheduler"
          ]
          env:
            - name: DJANGO_DB_MIGRATE
              value: "off"
            - name: DJANGO_COLLECTSTATIC
              value: "off"
            - name: DATABASE_HOST
              value: $(CHRIS_DB_SERVICE_NAME)
            - name: DATABASE_PORT
              value: "5432"
            - name: CHRIS_STORE_URL
              value: http://$(CHRIS_STORE_SERVICE_NAME):8010/api/v1/
            - name: SWIFT_AUTH_URL
              value: http://$(SWIFT_SERVICE_NAME):8080/auth/v1.0
            - name: CELERY_BROKER_URL
              value: amqp://$(QUEUE_SERVICE_NAME):5672
          envFrom:
            - configMapRef:
                name: chris-config
            - configMapRef:
                name: chris-db-config
            - configMapRef:
                name: swift-config
