Skip to content

feat(infra): Add rateLimitHpa support in EnvoyGateway API#4983

Merged
arkodg merged 4 commits intoenvoyproxy:mainfrom
keithfz:ratelimit-hpa
Jan 6, 2025
Merged

feat(infra): Add rateLimitHpa support in EnvoyGateway API#4983
arkodg merged 4 commits intoenvoyproxy:mainfrom
keithfz:ratelimit-hpa

Conversation

@keithfz
Copy link
Copy Markdown
Contributor

@keithfz keithfz commented Dec 30, 2024

What type of PR is this?

Adds HPA support for rate limit deployment under the EnvoyGateway API

What this PR does / why we need it:
Allows autoscaling of the rate limit deployment similar to what is done today for the envoy proxy deployment.

Which issue(s) this PR fixes:

Fixes #4930

Release Notes: Yes

@keithfz keithfz requested a review from a team as a code owner December 30, 2024 21:15
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 30, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 66.77%. Comparing base (43621b4) to head (3a74a19).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...tructure/kubernetes/ratelimit/resource_provider.go 78.57% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4983      +/-   ##
==========================================
+ Coverage   66.75%   66.77%   +0.02%     
==========================================
  Files         209      209              
  Lines       32058    32101      +43     
==========================================
+ Hits        21399    21435      +36     
- Misses       9381     9385       +4     
- Partials     1278     1281       +3     

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

imo we shouldnt do this, its bad practice to set replicas and hpa, but we shouldnt override a user setting, and instead recommend a user to leave replicas unset when using hpa

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh nvm youre following

if provider.GetEnvoyProxyKubeProvider().EnvoyHpa != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i wonder why that is needed
cc @ardikabs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, honestly I kind of agree, but I just went for consistency between this and the EnvoyProxy API. If we choose not to override a user setting here, we should probably have similar behavior in the EnvoyProxy HPA case as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah, lets wait for ardikabs' response, else keep it as is for now

Copy link
Copy Markdown
Contributor

@ardikabs ardikabs Jan 4, 2025

Choose a reason for hiding this comment

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

It primarily prevents unwanted values from being set during HPA configuration, with the Envoy Gateway proactively ensuring such scenarios are avoided. This condition is already documented in the EG API Reference, highlighting when Replicas and HPA are being set.

// EnvoyHpa defines the Horizontal Pod Autoscaler settings for Envoy Proxy Deployment.
// Once the HPA is being set, Replicas field from EnvoyDeployment will be ignored.
//
// +optional
EnvoyHpa *KubernetesHorizontalPodAutoscalerSpec `json:"envoyHpa,omitempty"`
.

Historically, this behavior was implemented because EG previously set default replicas. As a result, even if users left the field empty (as recommended when using HPA), a default value of 1 was still applied.

But after this PR #2816, I think we can remove it, wdyt @arkodg?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah thanks for adding clarity here @ardikabs, this extra step can be cleaned up in a follow up commit

@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Jan 4, 2025

thanks @keithfz, this PR looks great ! added some minor non blocking comments

Copy link
Copy Markdown
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks !

@arkodg arkodg requested review from a team January 6, 2025 18:31
Comment on lines 203 to 209
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this' fine now, if we bring more fields in the future, pefer to something like:

ratelimit:
  deployment:
     ...
  hpa:
    ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

would we want to consider the same for other APIs in the future as well? e.g. EnvoyProxy:

type EnvoyProxyKubernetesProvider struct {
// EnvoyDeployment defines the desired state of the Envoy deployment resource.
// If unspecified, default settings for the managed Envoy deployment resource
// are applied.
//
// +optional
EnvoyDeployment *KubernetesDeploymentSpec `json:"envoyDeployment,omitempty"`
// EnvoyDaemonSet defines the desired state of the Envoy daemonset resource.
// Disabled by default, a deployment resource is used instead to provision the Envoy Proxy fleet
//
// +optional
EnvoyDaemonSet *KubernetesDaemonSetSpec `json:"envoyDaemonSet,omitempty"`
// EnvoyService defines the desired state of the Envoy service resource.
// If unspecified, default settings for the managed Envoy service resource
// are applied.
//
// +optional
EnvoyService *KubernetesServiceSpec `json:"envoyService,omitempty"`
// EnvoyHpa defines the Horizontal Pod Autoscaler settings for Envoy Proxy Deployment.
// Once the HPA is being set, Replicas field from EnvoyDeployment will be ignored.
//
// +optional
EnvoyHpa *KubernetesHorizontalPodAutoscalerSpec `json:"envoyHpa,omitempty"`
// UseListenerPortAsContainerPort disables the port shifting feature in the Envoy Proxy.
// When set to false (default value), if the service port is a privileged port (1-1023), add a constant to the value converting it into an ephemeral port.
// This allows the container to bind to the port without needing a CAP_NET_BIND_SERVICE capability.
//
// +optional
UseListenerPortAsContainerPort *bool `json:"useListenerPortAsContainerPort,omitempty"`
// EnvoyPDB allows to control the pod disruption budget of an Envoy Proxy.
// +optional
EnvoyPDB *KubernetesPodDisruptionBudgetSpec `json:"envoyPDB,omitempty"`
}

Copy link
Copy Markdown
Contributor

@arkodg arkodg Jan 6, 2025

Choose a reason for hiding this comment

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

Both are making a good point, the extra hierarchy hides the component specific details, but the current style is envoyHpa which is probably why the same style was adopted for rateLimitDeployment

Signed-off-by: keithfz <[email protected]>
Signed-off-by: keithfz <[email protected]>
Signed-off-by: keithfz <[email protected]>
@arkodg arkodg merged commit d4a0756 into envoyproxy:main Jan 6, 2025
zirain pushed a commit to arkodg/gateway that referenced this pull request Jan 9, 2025
This is no longer needed after
envoyproxy#2816 was merged

Relates to envoyproxy#4983 (comment)

Signed-off-by: Arko Dasgupta <[email protected]>
arkodg added a commit that referenced this pull request Jan 9, 2025
dont reset deployment replicas when hpa is set

This is no longer needed after
#2816 was merged

Relates to #4983 (comment)

Signed-off-by: Arko Dasgupta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add HPA Support for the Rate Limit Service

4 participants