-
Notifications
You must be signed in to change notification settings - Fork 5
Support autoscaling the API on GKE #95
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
Open
brianvans (brianvans)
wants to merge
7
commits into
main
Choose a base branch
from
brianvans/support-autoscaling-api-on-gke
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d8ded2e
Support autoscaling the API on GKE
brianvans a31c39b
Merge remote-tracking branch 'origin/main' into brianvans/support-aut…
brianvans f592b56
Inline docs for /metrics being added in v2.9.0
brianvans 4458285
Add gke autoscaling docs to README
brianvans fa13407
Force NABLE_PROMETHEUS_METRICS=true if autoscaled
brianvans 86f0fae
bump minReplicas at 4 when autoscaling enabled
brianvans 7acb818
Ensure the autoscaling.gke.io/v1beta1 CRD exists
brianvans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| {{- if .Values.api.autoscaling.enabled }} | ||
| {{- include "braintrust.apiAutoscaling.validate" . }} | ||
| apiVersion: autoscaling.gke.io/v1beta1 | ||
| kind: AutoscalingMetric | ||
| metadata: | ||
| name: {{ .Values.api.name }} | ||
| namespace: {{ include "braintrust.namespace" . }} | ||
| {{- with (merge (deepCopy .Values.api.labels) .Values.global.labels) }} | ||
| labels: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| {{- with .Values.api.annotations.autoscalingMetric }} | ||
| annotations: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| spec: | ||
| metrics: | ||
| - pod: | ||
| selector: | ||
| matchLabels: | ||
| app: {{ .Values.api.name }} | ||
| containers: | ||
| - endpoint: | ||
| port: {{ .Values.api.healthServer.port }} | ||
| path: {{ .Values.api.autoscaling.metricsPath }} | ||
| metrics: | ||
| - gauge: | ||
| # GKE gauge names must match ^[a-z]([-a-z0-9]*[a-z0-9])? | ||
| name: braintrust-api-event-loop-utilization-ratio | ||
| prometheusMetricName: braintrust_api_event_loop_utilization_ratio | ||
| - gauge: | ||
| name: braintrust-api-event-loop-delay-mean-seconds | ||
| prometheusMetricName: braintrust_api_event_loop_delay_mean_seconds | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| {{- if .Values.api.autoscaling.enabled }} | ||
| {{- include "braintrust.apiAutoscaling.validate" . }} | ||
| apiVersion: autoscaling/v2 | ||
| kind: HorizontalPodAutoscaler | ||
| metadata: | ||
| name: {{ .Values.api.name }} | ||
| namespace: {{ include "braintrust.namespace" . }} | ||
| {{- with (merge (deepCopy .Values.api.labels) .Values.global.labels) }} | ||
| labels: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| {{- with .Values.api.annotations.hpa }} | ||
| annotations: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| spec: | ||
| scaleTargetRef: | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| name: {{ .Values.api.name }} | ||
| minReplicas: {{ .Values.api.autoscaling.minReplicas }} | ||
| maxReplicas: {{ .Values.api.autoscaling.maxReplicas }} | ||
| metrics: | ||
| - type: Resource | ||
| resource: | ||
| name: cpu | ||
| target: | ||
| type: Utilization | ||
| averageUtilization: {{ .Values.api.autoscaling.cpu.targetAverageUtilization }} | ||
| - type: Pods | ||
| pods: | ||
| metric: | ||
| name: autoscaling.gke.io|{{ .Values.api.name }}|braintrust-api-event-loop-utilization-ratio | ||
| target: | ||
| type: AverageValue | ||
| averageValue: {{ .Values.api.autoscaling.eventLoopUtilization.targetAverageValue | quote }} | ||
| - type: Pods | ||
| pods: | ||
| metric: | ||
| name: autoscaling.gke.io|{{ .Values.api.name }}|braintrust-api-event-loop-delay-mean-seconds | ||
| target: | ||
| type: AverageValue | ||
| averageValue: {{ .Values.api.autoscaling.eventLoopDelayMean.targetAverageValue | quote }} | ||
| {{- with .Values.api.autoscaling.behavior }} | ||
| behavior: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| suite: test API autoscaling CRD requirement | ||
| templates: | ||
| - api-hpa.yaml | ||
| # Do not advertise autoscaling.gke.io here — this suite asserts the fail path. | ||
| tests: | ||
| - it: should fail when AutoscalingMetric API is unavailable | ||
| template: api-hpa.yaml | ||
| values: | ||
| - __fixtures__/base-values.yaml | ||
| set: | ||
| cloud: google | ||
| api.autoscaling.enabled: true | ||
| release: | ||
| namespace: "braintrust" | ||
| asserts: | ||
| - failedTemplate: | ||
| errorPattern: "api\\.autoscaling requires the AutoscalingMetric API \\(autoscaling\\.gke\\.io/v1beta1\\)" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google documents this Preview feature for GKE
1.35.1-gke.1396000or later on the Rapid release channel.This list names the version and the Performance HPA profile. It does not name the Rapid channel.
Add Rapid to the list here and in
values.yaml. Clusters on Regular or Stable will not get this feature.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think rapid channel was a launch constraint from when this feature initially became a preview. I was on the
stableregular channel while testing this and all required functionality existed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure the cluster itself was on the stable channel? When I looked right now it showed Rapid in the GCP console.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops yeah I mis-spoke re: stable. I tested on regular (the channel we default to in the gcp terraform module), and then switched to rapid to test against the newest version. At least in us-central1, these are the channels that meet the requirements
I'm not in love with documenting a channel requirement, as a) these change over time (docs burden) and b) there's no guarantee that a cluster in a channel is at the most current version.
How about we see if helm can ensure the CRD is available and fail with a friendly error if not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an explicit check for the required CRD in 7acb818
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow this channel stuff is so complicated! I like the solution you came up with.