vngcloud-cluster-autoscaler

by VNG Cloud

Helm chartv0.0.2App 1.29.0Verified publisher

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.
  • 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.clusterName and provide additional autodiscovery options if necessary or
  • Set static node group configurations for one or more node groups (using autoscalingGroups or autoscalingGroupsnamePrefix).

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

  • clusterAPIMode
  • clusterAPIKubeconfigSecret
  • clusterAPIWorkloadKubeconfigPath
  • clusterAPICloudConfigPath

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 list or start clean with helm 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

KeyTypeDefaultDescription
additionalLabelsobject{}Labels to add to each object of the chart.
affinityobject{}Affinity for pod assignment
autoDiscovery.clusterNamestringnilEnable 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.labelslist[]Cluster-API labels to match https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#configuring-node-group-auto-discovery
autoDiscovery.roleslist["worker"]Magnum node group roles to match.
autoDiscovery.tagslist["k8s.io/cluster-autoscaler/enabled","k8s.io/cluster-autoscaler/{{ .Values.autoDiscovery.clusterName }}"]ASG tags to match, run through tpl.
autoscalingGroupslist[]For AWS, Azure AKS or Magnum. At least one element is required if not using autoDiscovery. For example: - name: asg1 maxSize: 2 minSize: 1
autoscalingGroupsnamePrefixlist[]For GCE. At least one element is required if not using autoDiscovery. For example: - name: ig01 maxSize: 10 minSize: 0
awsAccessKeyIDstring""AWS access key ID (if AWS user keys used)
awsRegionstring"us-east-1"AWS region (required if cloudProvider=aws)
awsSecretAccessKeystring""AWS access secret key (if AWS user keys used)
azureClientIDstring""Service Principal ClientID with contributor permission to Cluster and Node ResourceGroup. Required if cloudProvider=azure
azureClientSecretstring""Service Principal ClientSecret with contributor permission to Cluster and Node ResourceGroup. Required if cloudProvider=azure
azureResourceGroupstring""Azure resource group that the cluster is located. Required if cloudProvider=azure
azureSubscriptionIDstring""Azure subscription where the resources are located. Required if cloudProvider=azure
azureTenantIDstring""Azure tenant where the resources are located. Required if cloudProvider=azure
azureUseManagedIdentityExtensionboolfalseWhether 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.
azureUseWorkloadIdentityExtensionboolfalseWhether 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.
azureVMTypestring"vmss"Azure VM type.
cloudConfigPathstring""Configuration file for cloud provider.
cloudProviderstring"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.
clusterAPICloudConfigPathstring"/etc/kubernetes/mgmt-kubeconfig"Path to kubeconfig for connecting to Cluster API Management Cluster, only used if clusterAPIMode=kubeconfig-kubeconfig or incluster-kubeconfig
clusterAPIConfigMapsNamespacestring""Namespace on the workload cluster to store Leader election and status configmaps
clusterAPIKubeconfigSecretstring""Secret containing kubeconfig for connecting to Cluster API managed workloadcluster Required if cloudProvider=clusterapi and clusterAPIMode=kubeconfig-kubeconfig,kubeconfig-incluster or incluster-kubeconfig
clusterAPIModestring"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
clusterAPIWorkloadKubeconfigPathstring"/etc/kubernetes/value"Path to kubeconfig for connecting to Cluster API managed workloadcluster, only used if clusterAPIMode=kubeconfig-kubeconfig or kubeconfig-incluster
containerSecurityContextobject{}Security context for container
deployment.annotationsobject{}Annotations to add to the Deployment object.
dnsPolicystring"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.
envFromConfigMapstring""ConfigMap name to use as envFrom.
envFromSecretstring""Secret name to use as envFrom.
expanderPrioritiesobject{}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
extraArgsobject{"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.
extraEnvobject{}Additional container environment variables.
extraEnvConfigMapsobject{}Additional container environment variables from ConfigMaps.
extraEnvSecretsobject{}Additional container environment variables from Secrets.
extraVolumeMountslist[]Additional volumes to mount.
extraVolumeSecretsobject{}Additional volumes to mount from Secrets.
extraVolumeslist[]Additional volumes.
fullnameOverridestring""String to fully override cluster-autoscaler.fullname template.
hostNetworkboolfalseWhether to expose network interfaces of the host machine to pods.
image.pullPolicystring"IfNotPresent"Image pull policy
image.pullSecretslist[]Image pull secrets
image.repositorystring"registry.k8s.io/autoscaling/cluster-autoscaler"Image repository
image.tagstring"v1.29.0"Image tag
kubeTargetVersionOverridestring""Allow overriding the .Capabilities.KubeVersion.GitVersion check. Useful for helm template commands.
kwokConfigMapNamestring"kwok-provider-config"configmap for configuring kwok provider
magnumCABundlePathstring"/etc/kubernetes/ca-bundle.crt"Path to the host's CA bundle, from ca-file in the cloud-config file.
magnumClusterNamestring""Cluster name or ID in Magnum. Required if cloudProvider=magnum and not setting autoDiscovery.clusterName.
nameOverridestring""String to partially override cluster-autoscaler.fullname template (will maintain the release name)
nodeSelectorobject{}Node labels for pod assignment. Ref: https://kubernetes.io/docs/user-guide/node-selection/.
podAnnotationsobject{}Annotations to add to each pod.
podDisruptionBudgetobject{"maxUnavailable":1}Pod disruption budget.
podLabelsobject{}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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartvngcloud-cluster-autoscaler is pinned at v0.0.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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