apiVersion: apps/v1
kind: Deployment
metadata:
  name: cluster-autoscaler
  namespace: kube-system
  labels:
    app: cluster-autoscaler
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cluster-autoscaler
  template:
    metadata:
      labels:
        app: cluster-autoscaler
      annotations:
        cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
    spec:
      nodeSelector:
        kubernetes.io/os: linux
        node-role.kubernetes.io/control-plane: ""
      tolerations:
        - key: CriticalAddonsOnly
          operator: Exists
        - key: node-role.kubernetes.io/control-plane
          effect: NoSchedule
      priorityClassName: system-cluster-critical
      serviceAccountName: cluster-autoscaler
      containers:
        - name: cluster-autoscaler
          image: registry.cloud.croc.ru/kaas/cluster-autoscaler-amd64:1.33.0-ROCKIT1
          imagePullPolicy: Always
          command:
            - ./cluster-autoscaler
            - --cloud-provider=aws
            - --skip-nodes-with-local-storage=false
            - --expander=least-waste
            - --node-group-auto-discovery=asg:tag=k8s.io/cluster-autoscaler/enabled=true,k8s.io/cluster-autoscaler/cluster-name=owned
            - --v=5
            - --cloud-config=config/cloud.conf
          resources:
            limits:
              cpu: 100m
              memory: 300Mi
          env:
            - name: AWS_REGION
              value: ru-msk
            - name: AWS_SDK_LOAD_CONFIG
              value: "true"
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: aws-autoscaler-secret
                  key: AWS_ACCESS_KEY_ID
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  name: aws-autoscaler-secret
                  key: AWS_SECRET_ACCESS_KEY
          volumeMounts:
            - name: cloud-config
              mountPath: config
              readOnly: true
      volumes:
        - name: cloud-config
          configMap:
            name: cloud-config
