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

feat: add HorizontalPodAutoscaler support for EnvoyProxy API #2257

Merged
merged 5 commits into from
Dec 6, 2023

Conversation

ardikabs
Copy link
Contributor

@ardikabs ardikabs commented Nov 30, 2023

What type of PR is this?
Add Horizontal Pod Autoscaler support for the Envoy Proxy deployment.

What this PR does / why we need it:

Here are the summaries of these changes:

  • Introduce the envoyHpa field under EnvoyProxy API to enable Horizontal Pod Autoscaler.
  • Move from reflect.DeepEqual to cmp.Equal with the IgnoreField helper for replicas field once HorizontalPodAutoscaler was used while comparing the live object of the EnvoyProxy Deployment spec and the generated Envoy Proxy Deployment spec.
  • Add a new method on the ResourceRender interface, named HorizontalPodAutoscaler() to fetch the HPA object from renderer if any.

Which issue(s) this PR fixes:

Address #703

@ardikabs ardikabs requested a review from a team as a code owner November 30, 2023 09:44
Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Attention: 34 lines in your changes are missing coverage. Please review.

Comparison is base (a89d95e) 64.37% compared to head (3ad932e) 64.33%.

Files Patch % Lines
...ternal/infrastructure/kubernetes/infra_resource.go 51.42% 14 Missing and 3 partials ⚠️
...frastructure/kubernetes/proxy/resource_provider.go 77.50% 6 Missing and 3 partials ⚠️
internal/infrastructure/kubernetes/infra.go 0.00% 4 Missing and 2 partials ⚠️
...tructure/kubernetes/ratelimit/resource_provider.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2257      +/-   ##
==========================================
- Coverage   64.37%   64.33%   -0.04%     
==========================================
  Files         112      112              
  Lines       15796    15874      +78     
==========================================
+ Hits        10168    10213      +45     
- Misses       4986     5011      +25     
- Partials      642      650       +8     

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

@ardikabs ardikabs marked this pull request as draft November 30, 2023 10:35
@ardikabs ardikabs force-pushed the feat/hpaSpec branch 2 times, most recently from 6f89560 to 324c9e4 Compare November 30, 2023 10:39
@ardikabs
Copy link
Contributor Author

/retest

@ardikabs ardikabs marked this pull request as ready for review December 1, 2023 06:23
api/v1alpha1/envoyproxy_types.go Show resolved Hide resolved
api/v1alpha1/shared_types.go Outdated Show resolved Hide resolved
},
ObjectMeta: metav1.ObjectMeta{
Namespace: r.Namespace,
Name: r.Name(),
Copy link
Contributor

Choose a reason for hiding this comment

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

i think it's necessary to make labels configurable, not so rush in this PR, we can do it in the future

Copy link
Member

Choose a reason for hiding this comment

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

Can you tell the scenarios ?

Copy link
Contributor

Choose a reason for hiding this comment

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

no specific scenarios on my mind right now. it's not a strong option, can be considered if someone runs into it in the future.

internal/infrastructure/kubernetes/infra_resource.go Outdated Show resolved Hide resolved
internal/infrastructure/kubernetes/infra_resource.go Outdated Show resolved Hide resolved
@@ -275,3 +276,38 @@ const (
// https://github.com/google/re2/wiki/Syntax.
StringMatchRegularExpression StringMatchType = "RegularExpression"
)

// KubernetesHorizontalPodAutoscalerSpec defines Kubernetes Horizontal Pod Autoscaler settings of Envoy Proxy Deployment
type KubernetesHorizontalPodAutoscalerSpec struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this's the right direction, at last, you need borrow everything from k8s.io.autoscaling.v2.HorizontalPodAutoScalerSpec.

Copy link
Contributor Author

@ardikabs ardikabs Dec 2, 2023

Choose a reason for hiding this comment

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

i borrow everything from HPASpec https://github.com/kubernetes/api/blob/6946e304d7b686796dc3f3bfaad56928484abf40/autoscaling/v2/types.go#L51, only exclude scaleTargetRef, because it will be automatically refers to the EnvoyProxy Deployment resource, it means i am trying to not let user specify it, because the deployment name is generated by EG. thought @zirain ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we still provide scaleTargetRef, then technically user could specify unrelated resource than Envoy Proxy Deployment

Copy link
Contributor

Choose a reason for hiding this comment

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

that's something I didn't wanted/expected, so I'm -1 on this.
I'd like to let other maintainers make the dicession.

Copy link
Member

Choose a reason for hiding this comment

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

Current approach looks well, any better ideas, IMO HPA fields are hard to abstract.

@ardikabs
Copy link
Contributor Author

ardikabs commented Dec 2, 2023

/retest

1 similar comment
@ardikabs
Copy link
Contributor Author

ardikabs commented Dec 2, 2023

/retest

Copy link
Member

@zhaohuabing zhaohuabing 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.

@Xunzhuo Xunzhuo added this to the v1.0.0-rc1 milestone Dec 6, 2023
@Xunzhuo
Copy link
Member

Xunzhuo commented Dec 6, 2023

/retest

Copy link
Member

@Xunzhuo Xunzhuo left a comment

Choose a reason for hiding this comment

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

LGTM, I have tested locally and worked as expect.

Copy link
Contributor

@shawnh2 shawnh2 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

@Xunzhuo Xunzhuo merged commit e0301d1 into envoyproxy:main Dec 6, 2023
6 checks passed
@ardikabs ardikabs deleted the feat/hpaSpec branch December 6, 2023 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

5 participants