Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support scale to zero #55

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Conversation

skonto
Copy link
Contributor

@skonto skonto commented Sep 18, 2024

Changes

  • Allows to scale to zero based on an external metrics. KEDA de-activates hpa by setting its targets to unknown.
$ k get hpa -n serving-tests
NAME                           REFERENCE                                            TARGETS       MINPODS   MAXPODS   REPLICAS   AGE
scale-to-zero-gotnxmxb-00001   Deployment/scale-to-zero-gotnxmxb-00001-deployment   <unknown>/5   1         10        0          6m53s

Similarly the scaledobject shows to be inactive.

$k get scaledobject -n serving-tests
NAME                           SCALETARGETKIND      SCALETARGETNAME                           MIN   MAX   TRIGGERS     AUTHENTICATION   READY   ACTIVE   FALLBACK   PAUSED    AGE
scale-to-zero-lllzzbds-00001   apps/v1.Deployment   scale-to-zero-lllzzbds-00001-deployment         10    prometheus                    True    False    False      Unknown   6m14s
  • Tested locally:
stream.go:304: I 12:57:22.399 controller-6f874b497b-jcwkt [knative.dev.serving.pkg.reconciler.gc.reconciler] [serving-tests/scale-to-zero-gotnxmxb] Reconcile succeeded
stream.go:304: I 12:57:22.399 controller-6f874b497b-jcwkt [knative.dev.serving.pkg.reconciler.configuration.Reconciler] [serving-tests/scale-to-zero-gotnxmxb] Reconcile succeeded
--- PASS: TestScaleToZero (430.80s)
PASS
ok  	knative.dev/autoscaler-keda/test/e2e	430.821s

/kind enhancement

Fixes #15

Release Note

Support scale to zero. When we scale down to zero external metrics need to be available for scaling up again. Initially when a service is created it will not become ready unless hpa reports its target correctly (external metrics are available).  

@knative-prow knative-prow bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/enhancement labels Sep 18, 2024
@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 18, 2024
@knative-prow knative-prow bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 18, 2024
@skonto skonto removed the request for review from upodroid September 18, 2024 14:19
Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.77%. Comparing base (c2fa22d) to head (13881fe).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #55      +/-   ##
==========================================
- Coverage   73.46%   72.77%   -0.69%     
==========================================
  Files           8        8              
  Lines         520      518       -2     
==========================================
- Hits          382      377       -5     
- Misses        108      110       +2     
- Partials       30       31       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@skonto skonto changed the title [wip] Support scale to zero Support scale to zero Sep 20, 2024
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 20, 2024
names.Service = svc.Name

// Wait before getting the objects
time.Sleep(30 * time.Second)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't get the resources from service status as it is not ready until we get metrics. So we just wait. Can be improved in another PR to actually fetch the objects when they are ready.

Copy link
Member

@ReToCode ReToCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Sep 23, 2024
Copy link

knative-prow bot commented Sep 23, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ReToCode, skonto

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot merged commit 4c9a0cc into knative-extensions:main Sep 23, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/enhancement lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore scale to/from zero
2 participants