vngcloud-cluster-autoscaler
by VNG Cloud
Scales Kubernetes worker nodes within autoscaling groups.
About this chart
vngcloud-cluster-autoscaler
Scales Kubernetes worker nodes within autoscaling groups.
TL;DR
$ helm repo add vks-helm-charts https://vngcloud.github.io/vks-helm-charts
# Method 1 - Using Autodiscovery
$ helm install vngcloud-cluster-autoscaler vks-helm-charts/vngcloud-cluster-autoscaler \
--set 'autoDiscovery.clusterName'=<CLUSTER NAME>
# Method 2 - Specifying groups manually
$ helm install vngcloud-cluster-autoscaler vks-helm-charts/vngcloud-cluster-autoscaler \
--set "autoscalingGroups[0].name=your-asg-name" \
--set "autoscalingGroups[0].maxSize=10" \
--set "autoscalingGroups[0].minSize=1"
Introduction
This chart bootstraps a cluster-autoscaler deployment on a Kubernetes cluster using the Helm package manager.
Prerequisites
- Helm 3+
- Kubernetes 1.8+
- Older versions may work by overriding the
image. Cluster autoscaler internally simulates the scheduler and bugs between mismatched versions may be subtle.
- Older versions may work by overriding the
- Azure AKS specific Prerequisites:
- Kubernetes 1.10+ with RBAC-enabled.
Installing the Chart
By default, no deployment is created and nothing will autoscale.
You must provide some minimal configuration, either to specify instance groups or enable auto-discovery. It is not recommended to do both.
Either:
- Set
autoDiscovery.clusterNameand provide additional autodiscovery options if necessary or - Set static node group configurations for one or more node groups (using
autoscalingGroupsorautoscalingGroupsnamePrefix).
To create a valid configuration, follow instructions for your cloud provider:
- Cluster API
Templating the autoDiscovery.clusterName
The cluster name can be templated in the autoDiscovery.clusterName variable. This is useful when the cluster name is dynamically generated based on other values coming from external systems like Argo CD or Flux. This also allows you to use global Helm values to set the cluster name, e.g., autoDiscovery.clusterName=\{\{ .Values.global.clusterName }}, so that you don't need to set it in more than 1 location in the values file.
Cluster-API
cloudProvider: clusterapi must be set, and then one or more of
autoDiscovery.clusterName- or
autoDiscovery.labels
See here for more details.
Additional config parameters available, see the values.yaml for more details
clusterAPIModeclusterAPIKubeconfigSecretclusterAPIWorkloadKubeconfigPathclusterAPICloudConfigPath
Uninstalling the Chart
To uninstall my-release:
$ helm uninstall my-release
The command removes all the Kubernetes components associated with the chart and deletes the release.
Tip: List all releases using
helm listor start clean withhelm uninstall my-release
Troubleshooting
The chart will succeed even if the container arguments are incorrect. A few minutes after starting kubectl logs -l "app=aws-cluster-autoscaler" --tail=50 should loop through something like
polling_autoscaler.go:111] Poll finished
static_autoscaler.go:97] Starting main loop
utils.go:435] No pod using affinity / antiaffinity found in cluster, disabling affinity predicate for this loop
static_autoscaler.go:230] Filtering out schedulables
If not, find a pod that the deployment created and describe it, paying close attention to the arguments under Command. e.g.:
Containers:
cluster-autoscaler:
Command:
./cluster-autoscaler
--cloud-provider=aws
# if specifying ASGs manually
--nodes=1:10:your-scaling-group-name
# if using autodiscovery
--node-group-auto-discovery=asg:tag=k8s.io/cluster-autoscaler/enabled,k8s.io/cluster-autoscaler/<ClusterName>
--v=4
PodSecurityPolicy
Though enough for the majority of installations, the default PodSecurityPolicy could be too restrictive depending on the specifics of your release. Please make sure to check that the template fits with any customizations made or disable it by setting rbac.pspEnabled to false.
VerticalPodAutoscaler
The CA Helm Chart can install a VerticalPodAutoscaler object from Chart version 9.27.0
onwards for the Cluster Autoscaler Deployment to scale the CA as appropriate, but for that, we
need to install the VPA to the cluster separately. A VPA can help minimize wasted resources
when usage spikes periodically or remediate containers that are being OOMKilled.
The following example snippet can be used to install VPA that allows scaling down from the default recommendations of the deployment template:
vpa:
enabled: true
containerPolicy:
minAllowed:
cpu: 20m
memory: 50Mi
Values
| Key | Type | Default | Description |
|---|---|---|---|
| additionalLabels | object | {} | Labels to add to each object of the chart. |
| affinity | object | {} | Affinity for pod assignment |
| autoDiscovery.clusterName | string | nil | Enable autodiscovery for cloudProvider=aws, for groups matching autoDiscovery.tags. autoDiscovery.clusterName -- Enable autodiscovery for cloudProvider=azure, using tags defined in https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/azure/README.md#auto-discovery-setup. Enable autodiscovery for cloudProvider=clusterapi, for groups matching autoDiscovery.labels. Enable autodiscovery for cloudProvider=gce, but no MIG tagging required. Enable autodiscovery for cloudProvider=magnum, for groups matching autoDiscovery.roles. |
| autoDiscovery.labels | list | [] | Cluster-API labels to match https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#configuring-node-group-auto-discovery |
| autoDiscovery.roles | list | ["worker"] | Magnum node group roles to match. |
| autoDiscovery.tags | list | ["k8s.io/cluster-autoscaler/enabled","k8s.io/cluster-autoscaler/{{ .Values.autoDiscovery.clusterName }}"] | ASG tags to match, run through tpl. |
| autoscalingGroups | list | [] | For AWS, Azure AKS or Magnum. At least one element is required if not using autoDiscovery. For example: - name: asg1 maxSize: 2 minSize: 1 |
| autoscalingGroupsnamePrefix | list | [] | For GCE. At least one element is required if not using autoDiscovery. For example: - name: ig01 maxSize: 10 minSize: 0 |
| awsAccessKeyID | string | "" | AWS access key ID (if AWS user keys used) |
| awsRegion | string | "us-east-1" | AWS region (required if cloudProvider=aws) |
| awsSecretAccessKey | string | "" | AWS access secret key (if AWS user keys used) |
| azureClientID | string | "" | Service Principal ClientID with contributor permission to Cluster and Node ResourceGroup. Required if cloudProvider=azure |
| azureClientSecret | string | "" | Service Principal ClientSecret with contributor permission to Cluster and Node ResourceGroup. Required if cloudProvider=azure |
| azureResourceGroup | string | "" | Azure resource group that the cluster is located. Required if cloudProvider=azure |
| azureSubscriptionID | string | "" | Azure subscription where the resources are located. Required if cloudProvider=azure |
| azureTenantID | string | "" | Azure tenant where the resources are located. Required if cloudProvider=azure |
| azureUseManagedIdentityExtension | bool | false | Whether to use Azure's managed identity extension for credentials. If using MSI, ensure subscription ID, resource group, and azure AKS cluster name are set. You can only use one authentication method at a time, either azureUseWorkloadIdentityExtension or azureUseManagedIdentityExtension should be set. |
| azureUseWorkloadIdentityExtension | bool | false | Whether to use Azure's workload identity extension for credentials. See the project here: https://github.com/Azure/azure-workload-identity for more details. You can only use one authentication method at a time, either azureUseWorkloadIdentityExtension or azureUseManagedIdentityExtension should be set. |
| azureVMType | string | "vmss" | Azure VM type. |
| cloudConfigPath | string | "" | Configuration file for cloud provider. |
| cloudProvider | string | "aws" | The cloud provider where the autoscaler runs. Currently only gce, aws, azure, magnum and clusterapi are supported. aws supported for AWS. gce for GCE. azure for Azure AKS. magnum for OpenStack Magnum, clusterapi for Cluster API. |
| clusterAPICloudConfigPath | string | "/etc/kubernetes/mgmt-kubeconfig" | Path to kubeconfig for connecting to Cluster API Management Cluster, only used if clusterAPIMode=kubeconfig-kubeconfig or incluster-kubeconfig |
| clusterAPIConfigMapsNamespace | string | "" | Namespace on the workload cluster to store Leader election and status configmaps |
| clusterAPIKubeconfigSecret | string | "" | Secret containing kubeconfig for connecting to Cluster API managed workloadcluster Required if cloudProvider=clusterapi and clusterAPIMode=kubeconfig-kubeconfig,kubeconfig-incluster or incluster-kubeconfig |
| clusterAPIMode | string | "incluster-incluster" | Cluster API mode, see https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#connecting-cluster-autoscaler-to-cluster-api-management-and-workload-clusters Syntax: workloadClusterMode-ManagementClusterMode for kubeconfig-kubeconfig, incluster-kubeconfig and single-kubeconfig you always must mount the external kubeconfig using either extraVolumeSecrets or extraMounts and extraVolumes if you dont set clusterAPIKubeconfigSecretand thus use an in-cluster config or want to use a non capi generated kubeconfig you must do so for the workload kubeconfig as well |
| clusterAPIWorkloadKubeconfigPath | string | "/etc/kubernetes/value" | Path to kubeconfig for connecting to Cluster API managed workloadcluster, only used if clusterAPIMode=kubeconfig-kubeconfig or kubeconfig-incluster |
| containerSecurityContext | object | {} | Security context for container |
| deployment.annotations | object | {} | Annotations to add to the Deployment object. |
| dnsPolicy | string | "ClusterFirst" | Defaults to ClusterFirst. Valid values are: ClusterFirstWithHostNet, ClusterFirst, Default or None. If autoscaler does not depend on cluster DNS, recommended to set this to Default. |
| envFromConfigMap | string | "" | ConfigMap name to use as envFrom. |
| envFromSecret | string | "" | Secret name to use as envFrom. |
| expanderPriorities | object | {} | The expanderPriorities is used if extraArgs.expander contains priority and expanderPriorities is also set with the priorities. If extraArgs.expander contains priority, then expanderPriorities is used to define cluster-autoscaler-priority-expander priorities. See: https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/expander/priority/readme.md |
| extraArgs | object | {"logtostderr":true,"stderrthreshold":"info","v":4} | Additional container arguments. Refer to https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-are-the-parameters-to-ca for the full list of cluster autoscaler parameters and their default values. Everything after the first _ will be ignored allowing the use of multi-string arguments. |
| extraEnv | object | {} | Additional container environment variables. |
| extraEnvConfigMaps | object | {} | Additional container environment variables from ConfigMaps. |
| extraEnvSecrets | object | {} | Additional container environment variables from Secrets. |
| extraVolumeMounts | list | [] | Additional volumes to mount. |
| extraVolumeSecrets | object | {} | Additional volumes to mount from Secrets. |
| extraVolumes | list | [] | Additional volumes. |
| fullnameOverride | string | "" | String to fully override cluster-autoscaler.fullname template. |
| hostNetwork | bool | false | Whether to expose network interfaces of the host machine to pods. |
| image.pullPolicy | string | "IfNotPresent" | Image pull policy |
| image.pullSecrets | list | [] | Image pull secrets |
| image.repository | string | "registry.k8s.io/autoscaling/cluster-autoscaler" | Image repository |
| image.tag | string | "v1.29.0" | Image tag |
| kubeTargetVersionOverride | string | "" | Allow overriding the .Capabilities.KubeVersion.GitVersion check. Useful for helm template commands. |
| kwokConfigMapName | string | "kwok-provider-config" | configmap for configuring kwok provider |
| magnumCABundlePath | string | "/etc/kubernetes/ca-bundle.crt" | Path to the host's CA bundle, from ca-file in the cloud-config file. |
| magnumClusterName | string | "" | Cluster name or ID in Magnum. Required if cloudProvider=magnum and not setting autoDiscovery.clusterName. |
| nameOverride | string | "" | String to partially override cluster-autoscaler.fullname template (will maintain the release name) |
| nodeSelector | object | {} | Node labels for pod assignment. Ref: https://kubernetes.io/docs/user-guide/node-selection/. |
| podAnnotations | object | {} | Annotations to add to each pod. |
| podDisruptionBudget | object | {"maxUnavailable":1} | Pod disruption budget. |
| podLabels | object | {} | Lab |
Deploy vngcloud-cluster-autoscaler with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has vngcloud-cluster-autoscaler on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartvngcloud-cluster-autoscaler is pinned at v0.0.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply