apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
  labels:
    app: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      imagePullSecrets:
        - name: ghcr
      containers:
        - name: backend
          image: busybox
          command:
            - /app/servicebin
          livenessProbe:
            httpGet:
              path: /healthz
              port: 81
          readinessProbe:
            httpGet:
              path: /healthz
              port: 81
          ports:
            - containerPort: 80
              name: parent-bot
              protocol: TCP
            - containerPort: 81
              name: child-bot
              protocol: TCP
          resources:
            requests:
              cpu: 50m
              memory: 30Mi
            limits:
              cpu: "1"
              memory: 1Gi
          env:
            - name: SERVICE
              value: backend
            - name: MONGODB_URL
              valueFrom:
                configMapKeyRef:
                  key: url
                  name: mongodb
            - name: PARENTBOT_TOKEN
              valueFrom:
                secretKeyRef:
                  key: token
                  name: parent-bot
            - name: PARENTBOT_HOST
              value: https://vahter-robot-parent-bot.shopgrip.ru
            - name: PARENTBOT_PORT
              value: "80"
            - name: PARENTBOT_TOKENPATHPREFIX
              valueFrom:
                configMapKeyRef:
                  key: token-path-prefix
                  name: parent-bot
            - name: CHILDBOT_HOST
              value: https://vahter-robot-child-bot.shopgrip.ru
            - name: CHILDBOT_PORT
              value: "81"
            - name: CHILDBOT_TOKENPATHPREFIX
              valueFrom:
                configMapKeyRef:
                  key: token-path-prefix
                  name: child-bot
            - name: CHILDBOT_BOTSLIMITPERUSER
              valueFrom:
                configMapKeyRef:
                  key: bots-limit-per-user
                  name: child-bot
            - name: CHILDBOT_KEYWORDSLIMITPERBOT
              valueFrom:
                configMapKeyRef:
                  key: keywords-limit-per-bot
                  name: child-bot
            - name: CHILDBOT_INLIMITPERKEYWORD
              valueFrom:
                configMapKeyRef:
                  key: in-limit-per-keyword
                  name: child-bot
            - name: CHILDBOT_INLIMITCHARS
              valueFrom:
                configMapKeyRef:
                  key: in-limit-chars
                  name: child-bot
            - name: CHILDBOT_OUTLIMITCHARS
              valueFrom:
                configMapKeyRef:
                  key: out-limit-chars
                  name: child-bot
            - name: CHILDBOT_TIMEOUTONHANDLE
              valueFrom:
                configMapKeyRef:
                  key: timeout-on-handle
                  name: child-bot
            - name: SETWEBHOOKSONSTART
              valueFrom:
                configMapKeyRef:
                  key: set-webhooks-on-start
                  name: backend
            - name: LOGLEVEL
              valueFrom:
                configMapKeyRef:
                  key: log-level
                  name: backend
