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

remove deprecated autoscaling/v2beta1 HPA objects #865

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ VictoriaMetrics provides [helm charts](https://github.com/VictoriaMetrics/helm-c
## Kubernetes' compatibility versions

operator tested at kubernetes versions
from 1.25 to 1.28
from 1.25 to 1.29

## Troubleshooting

Expand Down
18 changes: 0 additions & 18 deletions controllers/factory/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,24 +403,6 @@ func buildProbe(container v1.Container, cr probeCRD) v1.Container {
}

func buildHPASpec(targetRef v2beta2.CrossVersionObjectReference, spec *victoriametricsv1beta1.EmbeddedHPA, or []metav1.OwnerReference, lbls map[string]string, namespace string) client.Object {
if k8stools.IsHPAV2BetaSupported() {
return &v2beta2.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{
Name: targetRef.Name,
Namespace: namespace,
Labels: lbls,
OwnerReferences: or,
},
Spec: v2beta2.HorizontalPodAutoscalerSpec{
MaxReplicas: spec.MaxReplicas,
MinReplicas: spec.MinReplicas,
ScaleTargetRef: targetRef,
Metrics: spec.Metrics,
Behavior: spec.Behaviour,
},
}
}

return &v2.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{
Name: targetRef.Name,
Expand Down
18 changes: 2 additions & 16 deletions controllers/factory/k8stools/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"

"k8s.io/api/autoscaling/v2"
"k8s.io/api/autoscaling/v2beta2"
"k8s.io/apimachinery/pkg/version"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -59,16 +58,6 @@ func IsPDBV1APISupported() bool {
return false
}

// IsHPAV2BetaSupported checks if new
// Beta deprecated since 1.26
// https://kubernetes.io/blog/2021/12/07/kubernetes-1-23-release-announcement/#horizontalpodautoscaler-v2-graduates-to-ga
func IsHPAV2BetaSupported() bool {
if ServerMajorVersion == 1 && ServerMinorVersion < 26 {
return true
}
return false
}

// IsFSGroupChangePolicySupported checks if `fsGroupChangePolicy` is supported,
// Supported since 1.20
// https://kubernetes.io/blog/2020/12/14/kubernetes-release-1.20-fsgroupchangepolicy-fsgrouppolicy/#allow-users-to-skip-recursive-permission-changes-on-mount
Expand All @@ -79,12 +68,9 @@ func IsFSGroupChangePolicySupported() bool {
return false
}

// NewHPAEmptyObject returns HorizontalPodAutoscaler object for given kubernetes version
// NewHPAEmptyObject returns HorizontalPodAutoscaler object
func NewHPAEmptyObject(opts ...func(obj client.Object)) client.Object {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think, we should remove `client.Object from this function and return exact type. It can be done at follow-up commit.

var hpa client.Object = &v2beta2.HorizontalPodAutoscaler{}
if !IsHPAV2BetaSupported() {
hpa = &v2.HorizontalPodAutoscaler{}
}
var hpa client.Object = &v2.HorizontalPodAutoscaler{}
for _, opt := range opts {
opt(hpa)
}
Expand Down
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ aliases:

## Next release

- TODO
- Remove deprecated autoscaling/v2beta1 HPA objects, previously operator still use it for k8s 1.25. See [this issue](https://github.com/VictoriaMetrics/operator/issues/864) for details.

<a name="v0.41.1"></a>
## [v0.41.1](https://github.com/VictoriaMetrics/operator/releases/tag/v0.41.1) - 1 Feb 2024
Expand Down
Loading