Repository navigation
feat: implement Kubernetes deployment scaler for workspace replica management - #7123
Conversation
… replica management 🔒 Scanned for secrets using gitleaks 8.28.0
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #7123 +/- ##
==========================================
- Coverage 79.88% 79.48% -0.40%
==========================================
Files 584 587 +3
Lines 65493 65618 +125
==========================================
- Hits 52319 52159 -160
- Misses 10053 10353 +300
+ Partials 3121 3106 -15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fracasula
left a comment
There was a problem hiding this comment.
Should we have something to prevent the keda autoscaler not to be below a certain threshold to avoid issues with this testing functionality? e.g. we scale up and then after 15-30s it is scaled down by keda potentially terminating the pod mid-request.
| return int(scale.Spec.Replicas), nil | ||
| } | ||
|
|
||
| func (s *k8sScaler) SetReplicaCount(ctx context.Context, workspaceID string, count int) error { |
There was a problem hiding this comment.
Would it make sense to return here not just after the kube-apiserver accepted the write but when the pods are ready?
There was a problem hiding this comment.
it should be fine I am planning to use an existing transformer client that retries on cold start, which means it will retry until the pod is ready. And also, we will be emitting a cold start metric in case of any cold start failure, which will help in keeping KEDA also happy with the replica count we are manually setting.
@fracasula, once we scale up and a request is sent to pytransformer, the metrics used in KEDA will not let the pod to go away, and we have a 10-min stabilization window, which will not take the pod away even after 10 min when the traffic is 0. |
🤖 I have created a release *beep* *boop* --- ## [1.80.0-rc.1](v1.79.0...v1.80.0-rc.1) (2026-07-06) ### Features * add control-plane connection management for processor ([#7126](#7126)) ([ea6ca00](ea6ca00)) * carry integration version on DestinationT to the transformer ([#7125](#7125)) ([421c613](421c613)) * implement Forward RPC for control-plane requests to workspace pyt transformers ([#7143](#7143)) ([8a704cf](8a704cf)) * implement Kubernetes deployment scaler for workspace replica management ([#7123](#7123)) ([84fc747](84fc747)) * monthly active records (MAR) metering pipeline ([#7119](#7119)) ([d1df486](d1df486)) ### Bug Fixes * **router:** transformer returning response with empty metadata array causes server to panic ([#7144](#7144)) ([d6a4dbc](d6a4dbc)) ### Miscellaneous * enable compression for google pubsub ([#7137](#7137)) ([11c9ab8](11c9ab8)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [1.80.0](v1.79.0...v1.80.0) (2026-07-06) ### Features * add control-plane connection management for processor ([#7126](#7126)) ([ea6ca00](ea6ca00)) * carry integration version on DestinationT to the transformer ([#7125](#7125)) ([421c613](421c613)) * implement Forward RPC for control-plane requests to workspace pyt transformers ([#7143](#7143)) ([8a704cf](8a704cf)) * implement Kubernetes deployment scaler for workspace replica management ([#7123](#7123)) ([84fc747](84fc747)) * monthly active records (MAR) metering pipeline ([#7119](#7119)) ([d1df486](d1df486)) ### Bug Fixes * **router:** transformer returning response with empty metadata array causes server to panic ([#7144](#7144)) ([d6a4dbc](d6a4dbc)) ### Miscellaneous * enable compression for google pubsub ([#7137](#7137)) ([11c9ab8](11c9ab8)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
Description
Adds
processor/internal/pytscaler— a small package that reads and sets the replica count of a workspace's per-workspacerudder-pytransformer(pyt-{workspaceID}) Deployment via the Kubernetes scale subresource.The pyt Deployments default to 0 replicas (Keda scales them back to 0 when idle), so before the processor forwards a test request
to a workspace's pyt pod, it must scale that Deployment up from zero. This package is the scaling primitive the
Forwardhandler (pipe-3144) will call. No call site is wired up yet — this PR only introduces the package and its tests.What's in here
Scalerinterface — two thin primitives over the scale subresource:GetReplicaCount(ctx, workspaceID) (int, error)SetReplicaCount(ctx, workspaceID, count int) errork8sScaler(unexported) — the real implementation:metadata.name=pyt-{lower(workspaceID)}(auniversally-supported field selector) and reads the namespace off the match — no namespace config or ExternalName parsing.
GetScale/UpdateScale), never a full Deployment update, so the pod spec — including the KataRuntimeClass— is never touched.noopScaler(NewNoop) — a do-nothing implementation so the processor starts and serves even when Kubernetes is unavailable (local dev, client-build failure, or the feature disabled). ItsGetReplicaCountreports1soa get-before-set caller naturally skips scaling.
Design notes
SetReplicaCountwrites the count unconditionally; the "scale to N only when the current count is 0" decision lives in the caller (theForwardhandler). This keeps thek8s layer a pure pass-through to the scale subresource and mirrors the orchestrator's
ReplicaManager(GetReplicaCount/SetReplicaCount) terminology.Processor.UserTransformer.pytTestScaleReplicas) is not read here — the caller decides the count and passes it in.Scaleris the abstraction boundary — theForwardhandler depends on the interface, not on Kubernetes. Two implementations (k8sScaler,noopScaler) plus a fake-client testing need justify the interface.Linear Ticket
pipe-3145
Security