apiVersion: apps/v1
kind: Deployment
metadata:
  name: ratelimit
  namespace: {{ .Release.Namespace }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ratelimit
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: ratelimit
    spec:
      containers:
      - image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
        imagePullPolicy: IfNotPresent
        name: ratelimit
        command: ["/bin/ratelimit"]
        env:
        - name: LOG_LEVEL
          value: {{ default "WARN" .Values.log.level }}
        - name: LOG_FORMAT
          value: {{ default "text" .Values.log.format }}
        - name: REDIS_SOCKET_TYPE
          value: tcp
        - name: REDIS_URL
          value: ratelimit-valkey:6379
        - name: USE_PROMETHEUS
          value: "true"
        - name: USE_STATSD
          value: "false"
        - name: RUNTIME_ROOT
          value: /data
        - name: RUNTIME_SUBDIRECTORY
          value: ratelimit
        - name: RUNTIME_WATCH_ROOT
          value: "false"
        - name: RUNTIME_IGNOREDOTFILES
          value: "true"
        - name: LOCAL_CACHE_SIZE_IN_BYTES
          value: "{{ default 0 .Values.localCacheSize | int }}"
        ports:
        - containerPort: 8081
        #- containerPort: 8080
        #- containerPort: 6070
        volumeMounts:
        - name: ratelimit-config
          mountPath: /data/ratelimit/config
        resources:
          requests:
            cpu: 50m
            memory: 32Mi
          limits:
            cpu: 1
            memory: 256Mi
      volumes:
      - name: ratelimit-config
        configMap:
          name: ratelimit-config
