# _helpers.tpl
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "cluster-autoscaler.name" -}}
{{- default (printf "%s-%s" .Values.cloudProvider .Chart.Name) .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "cluster-autoscaler.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default (printf "%s-%s" .Values.cloudProvider .Chart.Name) .Values.nameOverride -}}
{{- if ne $name .Release.Name -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s" $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "cluster-autoscaler.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return instance and name labels.
*/}}
{{- define "cluster-autoscaler.instance-name" -}}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/name: {{ include "cluster-autoscaler.name" . | quote }}
{{- end -}}


{{/*
Return labels, including instance and name.
*/}}
{{- define "cluster-autoscaler.labels" -}}
{{ include "cluster-autoscaler.instance-name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
helm.sh/chart: {{ include "cluster-autoscaler.chart" . | quote }}
{{- end -}}

{{/*
Return the appropriate apiVersion for deployment.
*/}}
{{- define "deployment.apiVersion" -}}
{{- $kubeTargetVersion := default .Capabilities.KubeVersion.GitVersion .Values.kubeTargetVersionOverride }}
{{- if semverCompare "<1.9-0" $kubeTargetVersion -}}
{{- print "apps/v1beta2" -}}
{{- else -}}
{{- print "apps/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for podsecuritypolicy.
*/}}
{{- define "podsecuritypolicy.apiVersion" -}}
{{- $kubeTargetVersion := default .Capabilities.KubeVersion.GitVersion .Values.kubeTargetVersionOverride }}
{{- if semverCompare "<1.10-0" $kubeTargetVersion -}}
{{- print "extensions/v1beta1" -}}
{{- else -}}
{{- print "policy/v1beta1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the service account name used by the pod.
*/}}
{{- define "cluster-autoscaler.serviceAccountName" -}}
{{- if .Values.rbac.serviceAccount.create -}}
    {{ default (include "cluster-autoscaler.fullname" .) .Values.rbac.serviceAccount.name }}
{{- else -}}
    {{ default "default" .Values.rbac.serviceAccount.name }}
{{- end -}}
{{- end -}}
 # clusterrole.yaml
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
  name: {{ template "cluster-autoscaler.fullname" . }}
rules:
  - apiGroups:
      - ""
    resources:
      - events
      - endpoints
    verbs:
      - create
      - patch
  - apiGroups:
    - ""
    resources:
    - pods/eviction
    verbs:
    - create
  - apiGroups:
      - ""
    resources:
      - pods/status
    verbs:
      - update
  - apiGroups:
      - ""
    resources:
      - endpoints
    resourceNames:
      - cluster-autoscaler
    verbs:
      - get
      - update
  - apiGroups:
      - ""
    resources:
      - nodes
    verbs:
    - watch
    - list
    - get
    - update
  - apiGroups:
    - ""
    resources:
      - pods
      - services
      - replicationcontrollers
      - persistentvolumeclaims
      - persistentvolumes
    verbs:
      - watch
      - list
      - get
  - apiGroups:
    - batch
    resources:
      - jobs
      - cronjobs
    verbs:
      - watch
      - list
      - get
  - apiGroups:
    - batch
    - extensions
    resources:
    - jobs
    verbs:
    - get
    - list
    - patch
    - watch
  - apiGroups:
      - extensions
    resources:
      - replicasets
      - daemonsets
    verbs:
      - watch
      - list
      - get
  - apiGroups:
      - policy
    resources:
      - poddisruptionbudgets
    verbs:
      - watch
      - list
  - apiGroups:
    - apps
    resources:
    - daemonsets
    - replicasets
    - statefulsets
    verbs:
    - watch
    - list
    - get
  - apiGroups:
    - storage.k8s.io
    resources:
    - storageclasses
    - csinodes
    verbs:
    - watch
    - list
    - get
  - apiGroups:
      - ""
    resources:
      - configmaps
    verbs:
      - list
      - watch
  - apiGroups:
    - coordination.k8s.io
    resources:
    - leases
    verbs:
    - create
  - apiGroups:
    - coordination.k8s.io
    resourceNames:
    - cluster-autoscaler
    resources:
    - leases
    verbs:
    - get
    - update
{{- if .Values.rbac.pspEnabled }}
  - apiGroups:
    - extensions
    - policy
    resources:
    - podsecuritypolicies
    resourceNames:
    - {{ template "cluster-autoscaler.fullname" . }}
    verbs:
    - use
{{- end -}}

{{- end -}}
 # clusterrolebinding.yaml
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
  name: {{ template "cluster-autoscaler.fullname" . }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "cluster-autoscaler.fullname" . }}
subjects:
  - kind: ServiceAccount
    name: {{ template "cluster-autoscaler.serviceAccountName" . }}
    namespace: {{ .Release.Namespace }}
{{- end -}}
 # deployment.yaml
{{- if or .Values.autoDiscovery.clusterName .Values.autoscalingGroups }}
{{/* one of the above is required */}}
apiVersion: {{ template "deployment.apiVersion" . }}
kind: Deployment
metadata:
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
  name: {{ template "cluster-autoscaler.fullname" . }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
{{ include "cluster-autoscaler.instance-name" . | indent 6 }}
    {{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 6 }}
    {{- end }}
{{- if .Values.updateStrategy }}
  strategy:
    {{ toYaml .Values.updateStrategy | nindent 4 | trim }}
{{- end }}
  template:
    metadata:
    {{- if .Values.podAnnotations }}
      annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
    {{- end }}
      labels:
{{ include "cluster-autoscaler.instance-name" . | indent 8 }}
      {{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
      {{- end }}
    spec:
      {{- if .Values.priorityClassName }}
      priorityClassName: "{{ .Values.priorityClassName }}"
      {{- end }}
      {{- if .Values.dnsPolicy }}
      dnsPolicy: "{{ .Values.dnsPolicy }}"
      {{- end }}
      containers:
        - name: {{ template "cluster-autoscaler.name" . }}
        {{- if eq .Values.cloudProvider "spotinst" }}
          image: "{{ .Values.spotinst.image.repository }}:{{ .Values.spotinst.image.tag }}"
          imagePullPolicy: "{{ .Values.spotinst.image.pullPolicy }}"
        {{- else }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: "{{ .Values.image.pullPolicy }}"
        {{- end }}
          command:
            - ./cluster-autoscaler
            - --cloud-provider={{ .Values.cloudProvider }}
            - --namespace={{ .Release.Namespace }}
          {{- if .Values.autoscalingGroups }}
            {{- range .Values.autoscalingGroups }}
            - --nodes={{ .minSize }}:{{ .maxSize }}:{{ .name }}
            {{- end }}
          {{- end }}
          {{- if eq .Values.cloudProvider "aws" }}
            {{- if .Values.autoDiscovery.clusterName }}
            - --node-group-auto-discovery=asg:tag={{ tpl (join "," .Values.autoDiscovery.tags) . }}
            {{- end }}
          {{- else if eq .Values.cloudProvider "gce" }}
          {{- if .Values.autoscalingGroupsnamePrefix }}
            {{- range .Values.autoscalingGroupsnamePrefix }}
            - --node-group-auto-discovery=mig:namePrefix={{ .name }},min={{ .minSize }},max={{ .maxSize }}
            {{- end }}
          {{- end }}
          {{- end }}
          {{- if eq .Values.cloudProvider "gce" }}
            - --cloud-config={{ .Values.cloudConfigPath }}
            {{- end }}
          {{- range $key, $value := .Values.extraArgs }}
            - --{{ $key }}={{ $value }}
          {{- end }}

          env:
          {{- if and (eq .Values.cloudProvider "aws") (ne .Values.awsRegion "") }}
            - name: AWS_REGION
              value: "{{ .Values.awsRegion }}"
            {{- if .Values.awsAccessKeyID }}
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  key: AwsAccessKeyId
                  name: {{ template "cluster-autoscaler.fullname" . }}
            {{- end }}
            {{- if .Values.awsSecretAccessKey }}
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  key: AwsSecretAccessKey
                  name: {{ template "cluster-autoscaler.fullname" . }}
            {{- end }}
          {{- else if eq .Values.cloudProvider "spotinst" }}
            - name: SPOTINST_TOKEN
              value: "{{ .Values.spotinst.token }}"
            - name: SPOTINST_ACCOUNT
              value: "{{ .Values.spotinst.account }}"
          {{- else if eq .Values.cloudProvider "azure" }}
            - name: ARM_SUBSCRIPTION_ID
              valueFrom:
                secretKeyRef:
                  key: SubscriptionID
                  name: {{ template "cluster-autoscaler.fullname" . }}
            - name: ARM_RESOURCE_GROUP
              valueFrom:
                secretKeyRef:
                  key: ResourceGroup
                  name: {{ template "cluster-autoscaler.fullname" . }}
            - name: ARM_VM_TYPE
              valueFrom:
                secretKeyRef:
                  key: VMType
                  name: {{ template "cluster-autoscaler.fullname" . }}
            {{- if .Values.azureUseManagedIdentityExtension }}
            - name: ARM_USE_MANAGED_IDENTITY_EXTENSION
              value: "true"
            {{- else }}
            - name: ARM_TENANT_ID
              valueFrom:
                secretKeyRef:
                  key: TenantID
                  name: {{ template "cluster-autoscaler.fullname" . }}
            - name: ARM_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  key: ClientID
                  name: {{ template "cluster-autoscaler.fullname" . }}
            - name: ARM_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  key: ClientSecret
                  name: {{ template "cluster-autoscaler.fullname" . }}
            - name: AZURE_CLUSTER_NAME
              valueFrom:
                secretKeyRef:
                  key: ClusterName
                  name: {{ template "cluster-autoscaler.fullname" . }}
            - name: AZURE_NODE_RESOURCE_GROUP
              valueFrom:
                secretKeyRef:
                  key: NodeResourceGroup
                  name: {{ template "cluster-autoscaler.fullname" . }}
            {{- end }}
          {{- end }}
          {{- range $key, $value := .Values.extraEnv }}
            - name: {{ $key }}
              value: "{{ $value }}"
          {{- end }}
          {{- range $key, $value := .Values.envFromConfigMap }}
            - name: {{ $key }}
              valueFrom:
                configMapKeyRef:
                  name: {{ default (include "cluster-autoscaler.fullname" $) $value.name }}
                  key: {{ required "Must specify key!" $value.key }}
          {{- end }}
          {{- range $key, $value := .Values.extraEnvSecrets }}
            - name: {{ $key }}
              valueFrom:
                secretKeyRef:
                  name: {{ default (include "cluster-autoscaler.fullname" $) $value.name }}
                  key: {{ required "Must specify key!" $value.key }}
          {{- end }}
          {{- if .Values.envFromSecret }}
          envFrom:
            - secretRef:
                name: {{ .Values.envFromSecret }}
          {{- end }}
          livenessProbe:
            httpGet:
              path: /health-check
              port: 8085
          ports:
            - containerPort: 8085
          resources:
{{ toYaml .Values.resources | indent 12 }}
          {{- if .Values.containerSecurityContext }}
          securityContext:
            {{ toYaml .Values.containerSecurityContext | nindent 12 | trim }}
          {{- end }}
          {{- if eq .Values.cloudProvider "gce" }}
          volumeMounts:
            - name: cloudconfig
              mountPath: {{ .Values.cloudConfigPath }}
              readOnly: true
          {{- end }}
    {{- if .Values.affinity }}
      affinity:
{{ toYaml .Values.affinity | indent 8 }}
    {{- end }}
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}
      serviceAccountName: {{ template "cluster-autoscaler.serviceAccountName" . }}
      tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
      {{- if .Values.securityContext }}
      securityContext:
        {{ toYaml .Values.securityContext | nindent 8 | trim }}
      {{- end }}
      {{- if eq .Values.cloudProvider "gce" }}
      volumes:
        - name: cloudconfig
          hostPath:
            path: {{ .Values.cloudConfigPath }}
      {{- end }}
      {{- if .Values.image.pullSecrets }}
      imagePullSecrets:
      {{- range .Values.image.pullSecrets }}
        - name: {{ . }}
      {{- end }}
    {{- end }}
{{- end }}
 # pdb.yaml
{{- if .Values.podDisruptionBudget -}}
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
  name: {{ template "cluster-autoscaler.fullname" . }}
spec:
  selector:
    matchLabels:
{{ include "cluster-autoscaler.instance-name" . | indent 6 }}
{{ .Values.podDisruptionBudget | indent 2 }}
{{- end -}}
 # podsecuritypolicy.yaml
{{- if .Values.rbac.pspEnabled }}
apiVersion: {{ template "podsecuritypolicy.apiVersion" . }}
kind: PodSecurityPolicy
metadata:
  name: {{ template "cluster-autoscaler.fullname" . }}
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
spec:
  # Prevents running in privileged mode
  privileged: false
  # Required to prevent escalations to root.
  allowPrivilegeEscalation: false
  requiredDropCapabilities:
    - ALL
  volumes:
    - 'configMap'
    - 'secret'
    - 'hostPath'
    - 'emptyDir'
    - 'projected'
    - 'downwardAPI'
{{- if eq .Values.cloudProvider "gce" }}
  allowedHostPaths:
    - pathPrefix: {{ .Values.cloudConfigPath }}
{{- end }}
  hostNetwork: false
  hostIPC: false
  hostPID: false
  runAsUser:
    rule: RunAsAny
  seLinux:
    rule: RunAsAny
  supplementalGroups:
    rule: 'MustRunAs'
    ranges:
      # Forbid adding the root group.
      - min: 1
        max: 65535
  fsGroup:
    rule: 'MustRunAs'
    ranges:
      # Forbid adding the root group.
      - min: 1
        max: 65535
  readOnlyRootFilesystem: false
{{- end }}
 # priority-expander-configmap.yaml
{{- if hasKey .Values.extraArgs "expander" }}
{{- if and (.Values.expanderPriorities) (eq .Values.extraArgs.expander "priority") -}}
apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-autoscaler-priority-expander
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
data:
  priorities: |-
{{ .Values.expanderPriorities | indent 4 }}
{{- end -}}
{{- end -}} # role.yaml
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
  name: {{ template "cluster-autoscaler.fullname" . }}
rules:
  - apiGroups:
      - ""
    resources:
      - configmaps
    verbs:
      - create
  - apiGroups:
      - ""
    resources:
      - configmaps
    resourceNames:
      - cluster-autoscaler-status
    verbs:
      - delete
      - get
      - update
{{- end -}}
 # rolebinding.yaml
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
  name: {{ template "cluster-autoscaler.fullname" . }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: {{ template "cluster-autoscaler.fullname" . }}
subjects:
  - kind: ServiceAccount
    name: {{ template "cluster-autoscaler.serviceAccountName" . }}
    namespace: {{ .Release.Namespace }}
{{- end -}}
 # secret.yaml
{{- if or (eq .Values.cloudProvider "azure") (and (eq .Values.cloudProvider "aws") (not (has "" (list .Values.awsAccessKeyID .Values.awsSecretAccessKey)))) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "cluster-autoscaler.fullname" . }}
data:
{{- if eq .Values.cloudProvider "azure" }}
  ClientID: "{{ .Values.azureClientID | b64enc }}"
  ClientSecret: "{{ .Values.azureClientSecret | b64enc }}"
  ResourceGroup: "{{ .Values.azureResourceGroup | b64enc }}"
  SubscriptionID: "{{ .Values.azureSubscriptionID | b64enc }}"
  TenantID: "{{ .Values.azureTenantID | b64enc }}"
  VMType: "{{ .Values.azureVMType | b64enc }}"
  ClusterName: "{{ .Values.azureClusterName | b64enc }}"
  NodeResourceGroup: "{{ .Values.azureNodeResourceGroup | b64enc }}"
{{- else if eq .Values.cloudProvider "aws" }}
  AwsAccessKeyId: "{{ .Values.awsAccessKeyID | b64enc }}"
  AwsSecretAccessKey: "{{ .Values.awsSecretAccessKey | b64enc }}"
{{- end }}
{{- end }}
 # service.yaml
apiVersion: v1
kind: Service
metadata:
{{- if .Values.service.annotations }}
  annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
  name: {{ template "cluster-autoscaler.fullname" . }}
spec:
{{- if .Values.service.clusterIP }}
  clusterIP: "{{ .Values.service.clusterIP }}"
{{- end }}
{{- if .Values.service.externalIPs }}
  externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
{{- if .Values.service.loadBalancerIP }}
  loadBalancerIP: "{{ .Values.service.loadBalancerIP }}"
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end }}
  ports:
    - port: {{ .Values.service.servicePort }}
      protocol: TCP
      targetPort: 8085
      name: {{ .Values.service.portName }}
  selector:
{{ include "cluster-autoscaler.instance-name" . | indent 4 }}
  type: "{{ .Values.service.type }}"
 # serviceaccount.yaml
{{- if and .Values.rbac.create .Values.rbac.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
  name: {{ template "cluster-autoscaler.serviceAccountName" . }}
{{- if .Values.rbac.serviceAccountAnnotations }}
  annotations: {{ toYaml .Values.rbac.serviceAccountAnnotations | nindent 4 }}
{{- end }}
{{- end }}
 # servicemonitor.yaml
{{ if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ include "cluster-autoscaler.fullname" . }}
  {{- if .Values.serviceMonitor.namespace }}
  namespace: {{ .Values.serviceMonitor.namespace }}
  {{- end }}
  labels:
    {{- range $key, $value := .Values.serviceMonitor.selector }}
      {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  selector:
    matchLabels:
{{ include "cluster-autoscaler.instance-name" . | indent 6 }}
  endpoints:
  - port: {{ .Values.service.portName }}
    interval: {{ .Values.serviceMonitor.interval }}
    path: {{ .Values.serviceMonitor.path }}
  namespaceSelector:
    matchNames:
      - {{.Release.Namespace}}
{{ end }} 

autoDiscovery:
# Only cloudProvider `aws` and `gce` are supported by auto-discovery at this time
# AWS: Set tags as described in https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md#auto-discovery-setup
  clusterName:  # cluster.local
  tags:
  - k8s.io/cluster-autoscaler/enabled
  - k8s.io/cluster-autoscaler/{{ .Values.autoDiscovery.clusterName }}
  # - kubernetes.io/cluster/{{ .Values.autoDiscovery.clusterName }}

autoscalingGroups: []
# At least one element is required if not using autoDiscovery
  # - name: asg1
  #   maxSize: 2
  #   minSize: 1
  # - name: asg2
  #   maxSize: 2
  #   minSize: 1

autoscalingGroupsnamePrefix: []
# At least one element is required if not using autoDiscovery
  # - name: ig01
  #   maxSize: 10
  #   minSize: 0
  # - name: ig02
  #   maxSize: 10
  #   minSize: 0

# Required if cloudProvider=aws
awsRegion: us-east-1
awsAccessKeyID: ""
awsSecretAccessKey: ""

# Required if cloudProvider=azure
# clientID/ClientSecret with contributor permission to Cluster and Node ResourceGroup
azureClientID: ""
azureClientSecret: ""
# Cluster resource Group
azureResourceGroup: ""
azureSubscriptionID: ""
azureTenantID: ""
# if using AKS azureVMType should be set to "AKS"
azureVMType: "AKS"
azureClusterName: ""
azureNodeResourceGroup: ""
# if using MSI, ensure subscription ID and resource group are set
azureUseManagedIdentityExtension: false

# Currently only `gce`, `aws`, `azure` & `spotinst` are supported
cloudProvider: aws

# Configuration file for cloud provider
cloudConfigPath: /etc/gce.conf

image:
  repository: k8s.gcr.io/cluster-autoscaler
  tag: v1.17.1
  pullPolicy: IfNotPresent

  ## Optionally specify an array of imagePullSecrets.
  ## Secrets must be manually created in the namespace.
  ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
  ##
  # pullSecrets:
  #   - myRegistrKeySecretName

tolerations: []

## Extra ENV passed to the container
extraEnv: {}

extraArgs:
  v: 4
  stderrthreshold: info
  logtostderr: true
  # write-status-configmap: true
  # leader-elect: true
  # skip-nodes-with-local-storage: false
  # expander: least-waste
  # scale-down-enabled: true
  # balance-similar-node-groups: true
  # min-replica-count: 2
  # scale-down-utilization-threshold: 0.5
  # scale-down-non-empty-candidates-count: 5
  # max-node-provision-time: 15m0s
  # scan-interval: 10s
  # scale-down-delay-after-add: 10m
  # scale-down-delay-after-delete: 0s
  # scale-down-delay-after-failure: 3m
  # scale-down-unneeded-time: 10m
  # skip-nodes-with-local-storage: false
  # skip-nodes-with-system-pods: true

## Affinity for pod assignment
## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
## affinity: {}

podDisruptionBudget: |
  maxUnavailable: 1
  # minAvailable: 2

## Node labels for pod assignment
## Ref: https://kubernetes.io/docs/user-guide/node-selection/
nodeSelector: {}

podAnnotations: {}
podLabels: {}
replicaCount: 1

rbac:
  ## If true, create & use RBAC resources
  ##
  create: true
  ## If true, create & use Pod Security Policy resources
  ## https://kubernetes.io/docs/concepts/policy/pod-security-policy/
  pspEnabled: false
  serviceAccount:
    # Specifies whether a service account should be created
    create: true
    # The name of the ServiceAccount to use.
    # If not set and create is true, a name is generated using the fullname template
    name: ""
  ## Annotations for the Service Account
  ##
  serviceAccountAnnotations: {}

resources: {}
  # limits:
  #   cpu: 100m
  #   memory: 300Mi
  # requests:
  #   cpu: 100m
  #   memory: 300Mi

priorityClassName: ""

# Defaults to "ClusterFirst". Valid values are
# 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'
# autoscaler does not depend on cluster DNS, recommended to set this to "Default"
# dnsPolicy: "Default"

## Security context for pod
## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
# securityContext:
#   runAsNonRoot: true
#   runAsUser: 1001
#   runAsGroup: 1001

## Security context for container
## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
# containerSecurityContext:
#   capabilities:
#     drop:
#       - all

## Deployment update strategy
## Ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy
# updateStrategy:
#   rollingUpdate:
#     maxSurge: 1
#     maxUnavailable: 0
#   type: RollingUpdate

service:
  annotations: {}

  ## List of IP addresses at which the service is available
  ## Ref: https://kubernetes.io/docs/user-guide/services/#external-ips
  ##
  externalIPs: []

  loadBalancerIP: ""
  loadBalancerSourceRanges: []
  servicePort: 8085
  portName: http
  type: ClusterIP

spotinst:
  account: ""
  token: ""
  image:
    repository: spotinst/kubernetes-cluster-autoscaler
    tag: 0.6.0
    pullPolicy: IfNotPresent

## Are you using Prometheus Operator?
serviceMonitor:
  enabled: false
  interval: "10s"
   # Namespace Prometheus is installed in
  namespace: monitoring
   ## Defaults to whats used if you follow CoreOS [Prometheus Install Instructions](https://github.com/helm/charts/tree/master/stable/prometheus-operator#tldr)
   ## [Prometheus Selector Label](https://github.com/helm/charts/tree/master/stable/prometheus-operator#prometheus-operator-1)
   ## [Kube Prometheus Selector Label](https://github.com/helm/charts/tree/master/stable/prometheus-operator#exporters)
  selector:
    prometheus: kube-prometheus
  # The metrics path to scrape - autoscaler exposes /metrics (standard)
  path: /metrics

## String to partially override cluster-autoscaler.fullname template (will maintain the release name)
nameOverride: ""

## String to fully override cluster-autoscaler.fullname template
fullnameOverride: ""

# Allow overridding the .Capabilities.KubeVersion.GitVersion (useful for "helm template" command)
kubeTargetVersionOverride: ""

## Priorities Expander
## If extraArgs.expander is set to priority, then expanderPriorities is used to define cluster-autoscaler-priority-expander priorities
## https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/expander/priority/readme.md
expanderPriorities: {}
