terrascaler

by containeroo

Helm chartv0.1.0App v0.1.0Verified publisher

Helm chart for Terrascaler

About this chart

terrascaler chart

The terrascaler chart installs Terrascaler, a reduced Kubernetes autoscaler backed by GitLab and Terraform/OpenTofu.

Terrascaler watches Kubernetes nodes and pods directly. When eligible pending pods do not fit on current worker capacity, it commits a larger Terraform worker count to GitLab. When worker capacity stays removable long enough, it can also reduce the Terraform worker count. The repository's GitLab CI pipeline can then apply the change and add or remove Kubernetes worker nodes.

Installation

helm repo add containeroo https://charts.containeroo.ch
helm install terrascaler containeroo/terrascaler \
  --set gitlab.project=platform/cluster-infra \
  --set gitlab.existingSecret=terrascaler-gitlab \
  --set terraform.file=main.tf \
  --set terraform.blockLabels='{hostedcluster}' \
  --set terraform.attribute=worker_count

Create the GitLab token secret first:

kubectl create secret generic terrascaler-gitlab --from-literal=token="$GITLAB_TOKEN"

Configuration

The following table lists the configurable parameters of the terrascaler helm chart and their default values.

ParameterDefaultDescription
replicaCount1Number of replicas
image.repositoryghcr.io/containeroo/terrascalerImage repository
image.pullPolicyIfNotPresentImage pull policy
image.tagNoneOverrides the image tag of chart appVersion
imagePullSecrets[]Image pull secrets
nameOverrideNoneOverride chart name
fullnameOverrideNoneOverride full resource name
serviceAccount.createtrueIf true, create a new service account
serviceAccount.annotations{}Additional ServiceAccount annotations
serviceAccount.nameNoneServiceAccount name to use
autoscaling.checkInterval1mAutoscaling check interval
autoscaling.scaleUpCooldown5mMinimum time between scale-up commits
autoscaling.scaleDownCooldown10mMinimum time between scale-down commits
autoscaling.scaleDownUnneededTime10mHow long removable capacity must remain stable before scaling down
autoscaling.pendingPodMinAge30sMinimum age for pending pods without an Unschedulable condition
autoscaling.dryRunfalseLog scale decisions without updating GitLab
metrics.enabledtrueExpose Prometheus metrics on /metrics
metrics.port8080Metrics port
metrics.service.annotations{}Additional metrics Service annotations
metrics.podMonitor.enabledfalseCreate a Prometheus Operator PodMonitor
metrics.podMonitor.namespacesame as release namespaceNamespace for the PodMonitor
metrics.podMonitor.additionalLabels{}Additional PodMonitor labels
metrics.podMonitor.scrapeInterval60sPodMonitor scrape interval
metrics.prometheusRule.enabledfalseCreate a PrometheusRule for persistent scale-down potential
metrics.prometheusRule.namespacesame as release namespaceNamespace for the PrometheusRule
metrics.prometheusRule.additionalLabels{}Additional PrometheusRule labels
metrics.prometheusRule.for30mAlert duration before firing
metrics.prometheusRule.labels{severity: warning}Alert labels
metrics.prometheusRule.annotationsscale-down summary and descriptionAlert annotations
clusterRole.createtrueIf true, create ClusterRole and ClusterRoleBinding for node/pod reads
clusterRole.nameNoneClusterRole name to use
clusterRole.extraRules[]Additional ClusterRole rules
gitlab.baseURLNoneGitLab base URL; empty uses GitLab.com
gitlab.projectgroup/projectGitLab project ID or path
gitlab.branchmainGit branch to update
gitlab.tokenchangemeGitLab API token; creates a Secret when set
gitlab.existingSecretNoneExisting Secret containing the GitLab API token
gitlab.tokenKeytokenSecret key containing the GitLab API token
gitlab.mergeRequest.enabledfalseCreate merge requests instead of committing directly to the target branch
gitlab.mergeRequest.branchPrefixterrascaler/scaleSource branch prefix for merge request mode
gitlab.mergeRequest.titleterrascaler: scale worker countMerge request title
gitlab.mergeRequest.descriptionautomated proposal textMerge request description prefix
gitlab.mergeRequest.labels[terrascaler]Merge request labels
gitlab.mergeRequest.assignees[]GitLab usernames to assign
gitlab.mergeRequest.assigneeIDs[]GitLab numeric user IDs to assign
gitlab.mergeRequest.reviewers[]GitLab usernames to request review from
gitlab.mergeRequest.reviewerIDs[]GitLab numeric user IDs to request review from
gitlab.mergeRequest.removeSourceBranchtrueRemove source branch after merge
terraform.filemain.tfTerraform file path in the repository
terraform.blockTypemoduleTerraform block type containing the target field
terraform.blockLabels[hostedcluster]Terraform block labels
terraform.attributeworker_countTerraform integer attribute to update
scaling.minSize0Minimum target size
scaling.maxSize100Maximum target size
scaling.nodeSelector{}Node labels identifying Terraform-managed workers
templateNode.cpu2New worker CPU capacity
templateNode.memory8GiNew worker memory capacity
templateNode.pods110New worker pod capacity
templateNode.labels{}Reserved metadata for new worker labels
extraArgs[]Additional command line arguments
extraEnv[]Additional environment variables
extraVolumes[]Additional pod volumes
extraVolumeMounts[]Additional volume mounts for the terrascaler container
podAnnotations{}Additional pod annotations
podLabels{}Additional pod labels
podSecurityContext{}Pod security context
securityContextrestricted non-root defaultsContainer security context
openshift.enabledfalseUse OpenShift restricted SCC compatible container security context
openshift.securityContextrestricted SCC compatible defaultsContainer security context used when openshift.enabled=true
resources.requests.cpu50mCPU resource requests
resources.requests.memory64MiMemory resource requests
resources.limits.cpu100mCPU resource limits
resources.limits.memory128MiMemory resource limits
nodeSelector{}Node selector properties for the Terrascaler pod
tolerations[]Toleration properties
affinity{}Affinity properties

Deploy terrascaler with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has terrascaler 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 chartterrascaler is pinned at v0.1.0 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