Proposal: generic Kubernetes scaler

Open
#124 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
helm, kubernetes, rust

Research direction

Start by reading the existing scaler trait, scaling loop, and persistence code; their file paths are not given in the issue. Then review how Kubernetes deployments and HPA status can fit the proposed configuration. The issue needs maintainer feedback on the design before implementation, and done would include an accepted scaler design, implementation, and documentation of the Helm replica limitation.

Written by the indexing model from the issue text.

Description

We run Trino on k8s with helm charts and we wanna use trino-lb in front for routing, queuing,etc...

Today there is no scaler trait implemented for generic clusters.

I would like to add an implementation for this kind of workload and I'd be happy to write the PR.
Before I start with anything, I would like to have your opinion on the design and whether you would accept it upstream.

Proposal

clusterAutoscaler:
  reconcileInterval: 30s
  kubernetes:
    clusters:
      trino-batch-1:
        namespace: trino-batch
        coordinatorDeployment: trino-batch-1-trino-coordinator
        # optional, only needed for worker-aware upscale
        workerDeployment: trino-batch-1-trino-worker

The idea is the scaler only touches coordinators and workers are left to users' own autoscaler.

This mainly means spawning new clusters will be the job or scaler while autoscaling each cluster goes by an HPA.

We can also make the scaler be aware of HPA using some opt-ins, to stop both scaler and HPA reacting to the same load.

trinoClusterGroups:
  batch:
    autoscaling:
      upscaleQueuedQueriesThreshold: 1
      waitForWorkerScaleUp: 2m

When it is set and the queue is above the threshold, trino-lb does not start the next cluster while any active
cluster in the group has a worker scale-up in progress (HPA desiredReplicas > currentReplicas), for at most
waitForWorkerScaleUp. If no scale-up is in progress (workers at max, or workers idle because the coordinator
is the limit), trino-lb starts the next cluster as it does today.

Known limit

The upstream Trino chart hardcodes replicas: 1 on the coordinator Deployment.
A helm upgrade or a GitOps sync will turn a stopped cluster back on unless the deploy tool ignores
/spec/replicas on the coordinator Deployment (e.g. Argo CD ignoreDifferences with RespectIgnoreDifferences=true).
We would document this next to the scaler.

Questions

  1. Is reading HPA status from trino-lb fine, or would you prefer another signal for 'a worker scaling is in progress'?
  2. Anything in the scaling loop or persistence we should know before starting?
Dominant language
Rust
Stars
40
Forks
9
Avg merge
22m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stackabletech/trino-lb

All issues in stackabletech/trino-lb

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.