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

Create hpa from CR #1019

Merged
merged 8 commits into from
Jan 13, 2025
Merged

Create hpa from CR #1019

merged 8 commits into from
Jan 13, 2025

Conversation

roypaulin
Copy link
Collaborator

A new field CustomAutoscaler was added. When set, there is a reconciler that will create an hpa whose values will come from that field. If that field change, the hpa is updated to reflect the changes. If the hpa is deleted, the reconciler will make sure it is recreated.

roypaulin and others added 5 commits January 7, 2025 19:27
This PR add make target to deploy/undeploy prometheus instance, and its
related service monitor, secrets.

---------

Co-authored-by: Roy Paulin <[email protected]>
@roypaulin
Copy link
Collaborator Author

@LiboYu2 @qindotguan @HaoYang0000 thoughts, comments, questions?

@LiboYu2
Copy link
Collaborator

LiboYu2 commented Jan 8, 2025

@LiboYu2 @qindotguan @HaoYang0000 thoughts, comments, questions?

I will take a look this afternoon.

@@ -58,6 +58,8 @@ const (
// Starting in v24.1.0, the default deployment method supported changes from admintools to vclusterops
// for official releases of vertica-k8s images
VcluseropsAsDefaultDeploymentMethodMinVersion = "v24.1.0"
// The min version that exposed prometheus metrics through the http service
PrometheusMetricsMinVersion = "v12.0.4"
Copy link
Collaborator

Choose a reason for hiding this comment

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

So the new auto-scaler can work with both admintools and vcluster?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To be honest I was not sure what must be the min version. Technically you can use the new field to set non prometheus metrics like cpu/mem and it would work. But it is not going to work with prometheus metrics so I will pit 24.1.0 instead.

// +kubebuilder:Minimum:=0
// +operator-sdk:csv:customresourcedefinitions:type=spec
// The miminum number of pods when scaling.
MinReplicas int32 `json:"minReplicas,omitempty"`
MinReplicas *int32 `json:"minReplicas,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we using different types for "MinReplicas" and "MaxReplicas"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because that is how it is in the hpa. I decided to keep the same types as in the hpa.

@@ -244,7 +243,39 @@ func MakeVAS() *VerticaAutoscaler {
}
}

func MakeVASWithMetrics() *VerticaAutoscaler {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a comment for this function. Is this function only used for the test?

Copy link
Collaborator Author

@roypaulin roypaulin Jan 10, 2025

Choose a reason for hiding this comment

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

Yes, it is only used for testing.

@@ -863,6 +864,26 @@ func makeScrutinizeInitContainers(vscr *v1beta1.VerticaScrutinize, vdb *vapi.Ver
return cnts
}

func BuildHorizontalPodAutoscaler(nm types.NamespacedName, vas *v1beta1.VerticaAutoscaler) *autoscalingv2.HorizontalPodAutoscaler {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a comment for this function.

"sigs.k8s.io/controller-runtime/pkg/client"
)

// RefreshSelectorReconciler is a reconciler to update the pod selector in the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update the comment

return &HorizontalPodAutoscalerReconciler{VRec: v, Vas: vas, Log: log.WithName("HorizontalPodAutoscalerReconciler")}
}

// Reconcile will handle updating the selector in the status portion of a VerticaAutoscaler
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where does the reconcile() update the status portion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That' a copy/paste error. I will update the comment

var _ = Describe("subclusterresize_reconcile", func() {
ctx := context.Background()

It("should requeue if VerticaDB doesn't exist", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update the description of this test.

@roypaulin roypaulin merged commit 9b8b9b5 into main Jan 13, 2025
41 checks passed
@roypaulin roypaulin deleted the mytest branch January 13, 2025 11:04
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.

4 participants