Cluster Autoscaler is a component that automatically adjusts the size of a Kubernetes Cluster so that all pods have a place to run and there are no unneeded nodes.
The cluster autoscaler for Flow scales worker nodes within any specified Flow Kubernetes cluster.
As there is no concept of a node group within Flow Cloud's Kubernetes offering, the configuration required is quite simple. You need to set:
Copy cluster-autoscaler.yaml
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
k8s-app: cluster-autoscaler
name: cluster-autoscaler
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cluster-autoscaler
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
k8s-app: cluster-autoscaler
rules:
- apiGroups: [""]
resources:
[
"pods",
"services",
"replicationcontrollers",
"persistentvolumeclaims",
"persistentvolumes",
"nodes",
"endpoints",
"namespaces",
"configmaps",
]
verbs: ["watch", "list", "get", "update", "create", "delete"]
- apiGroups: [""]
resources: ["events"]
verbs: ["watch", "list", "get", "create", "update", "delete", "patch"]
- apiGroups: ["extensions"]
resources: ["replicasets", "daemonsets"]
verbs: ["watch", "list", "get"]
- apiGroups: ["policy"]
resources: ["poddisruptionbudgets"]
verbs: ["watch", "list"]
- apiGroups: ["apps"]
resources: ["statefulsets", "replicasets", "daemonsets"]
verbs: ["watch", "list", "get"]
- apiGroups: ["storage.k8s.io"]
resources:
["storageclasses", "csinodes", "csistoragecapacities", "csidrivers"]
verbs: ["watch", "list", "get"]
- apiGroups: ["batch", "extensions"]
resources: ["jobs"]
verbs: ["get", "list", "watch", "patch"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "create", "update"]
- apiGroups: [""]
resources: ["pods/eviction"]
verbs: ["create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: cluster-autoscaler
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
k8s-app: cluster-autoscaler
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-autoscaler
subjects:
- kind: ServiceAccount
name: cluster-autoscaler
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: cluster-autoscaler
namespace: kube-system
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
k8s-app: cluster-autoscaler
rules:
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["create", "get", "update"]
resourceNames: ["cluster-autoscaler"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["create", "list", "watch", "update"]
---
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:
prometheus.io/scrape: "true"
prometheus.io/port: "8085"
spec:
serviceAccountName: cluster-autoscaler
containers:
- image: flowswiss/cluster-autoscaler:v0.0.4
name: cluster-autoscaler
imagePullPolicy: Always
resources:
limits:
cpu: 100m
memory: 300Mi
requests:
cpu: 100m
memory: 300Mi
command:
- ./cluster-autoscaler
- --v=4
- --stderrthreshold=info
- --cloud-provider=flow
- --nodes=1:6:workers
- --skip-nodes-with-local-storage=false
- --skip-nodes-with-system-pods=false
env:
- name: FLOW_API_TOKEN
valueFrom:
secretKeyRef:
key: **api-token** #base64_encoded_api_token
name: cluster-autoscaler-secrets
- name: FLOW_CLUSTER_ID
valueFrom:
secretKeyRef:
name: cluster-autoscaler-secrets
key: **cluster-id** #base64_encoded_cluster_id
- name: FLOW_API_URL
valueFrom:
secretKeyRef:
name: cluster-autoscaler-secrets
key: aHR0cHM6Ly9hcGkuZmxvdy5zd2lzcy8= #base64_encoded_api_url