Skip to content
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
8 changes: 8 additions & 0 deletions api/operator/v1/vlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,11 @@ type VLStorage struct {
// ClaimTemplates allows adding additional VolumeClaimTemplates for StatefulSet
ClaimTemplates []corev1.PersistentVolumeClaim `json:"claimTemplates,omitempty"`

// Configures horizontal pod autoscaling.
// Note, downscaling is not supported.
// +optional
HPA *vmv1beta1.EmbeddedHPA `json:"hpa,omitempty"`

// StorageDataPath - path to storage data
// +optional
StorageDataPath string `json:"storageDataPath,omitempty"`
Expand Down Expand Up @@ -697,6 +702,9 @@ func (cr *VLCluster) Validate() error {
if vls.ServiceSpec != nil && vls.ServiceSpec.Name == name {
return fmt.Errorf(".serviceSpec.Name cannot be equal to prefixed name=%q", name)
}
if vls.HPA != nil && vls.HPA.Behaviour != nil && vls.HPA.Behaviour.ScaleDown != nil {
return fmt.Errorf("vlstorage scaledown HPA behavior is not supported")
}
}
if cr.Spec.RequestsLoadBalancer.Enabled {
rlb := cr.Spec.RequestsLoadBalancer.Spec
Expand Down
8 changes: 8 additions & 0 deletions api/operator/v1/vtcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ type VTStorage struct {
// ClaimTemplates allows adding additional VolumeClaimTemplates for StatefulSet
ClaimTemplates []corev1.PersistentVolumeClaim `json:"claimTemplates,omitempty"`

// Configures horizontal pod autoscaling.
// Note, downscaling is not supported.
// +optional
HPA *vmv1beta1.EmbeddedHPA `json:"hpa,omitempty"`

// StorageDataPath - path to storage data
// +optional
StorageDataPath string `json:"storageDataPath,omitempty"`
Expand Down Expand Up @@ -612,6 +617,9 @@ func (cr *VTCluster) Validate() error {
if vts.ServiceSpec != nil && vts.ServiceSpec.Name == name {
return fmt.Errorf(".serviceSpec.Name cannot be equal to prefixed name=%q", name)
}
if vts.HPA != nil && vts.HPA.Behaviour != nil && vts.HPA.Behaviour.ScaleDown != nil {
return fmt.Errorf("vtstorage scaledown HPA behavior is not supported")
}
}
if cr.Spec.RequestsLoadBalancer.Enabled {
rlb := cr.Spec.RequestsLoadBalancer.Spec
Expand Down
10 changes: 10 additions & 0 deletions api/operator/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions api/operator/v1beta1/vmcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ type VMStorage struct {
// +optional
PersistentVolumeClaimRetentionPolicy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty"`

// Configures horizontal pod autoscaling.
// Note, downscaling is not supported.
// +optional
HPA *EmbeddedHPA `json:"hpa,omitempty"`

// VMInsertPort for VMInsert connections
// +optional
VMInsertPort string `json:"vmInsertPort,omitempty"`
Expand Down Expand Up @@ -670,6 +675,9 @@ func (cr *VMCluster) Validate() error {
return fmt.Errorf("vmstorage: %w", err)
}
}
if vms.HPA != nil && vms.HPA.Behaviour != nil && vms.HPA.Behaviour.ScaleDown != nil {
return fmt.Errorf("vmstorage scaledown HPA behavior is not supported")
}
}
if cr.Spec.RequestsLoadBalancer.Enabled {
rlb := cr.Spec.RequestsLoadBalancer.Spec
Expand Down
5 changes: 5 additions & 0 deletions api/operator/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,893 changes: 1,893 additions & 0 deletions config/crd/overlay/crd.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ aliases:
* FEATURE: [vmagent](https://docs.victoriametrics.com/operator/resources/vmagent/): support `namespace` parameter in `attach_metadata` section for all scrape configurations. See [#1654](https://github.com/VictoriaMetrics/operator/issues/1654).
* FEATURE: [vlagent](https://docs.victoriametrics.com/operator/resources/vlagent): support logs collection. See [#1501](https://github.com/VictoriaMetrics/operator/issues/1501).
* FEATURE: [vmoperator](https://docs.victoriametrics.com/operator/): use `operator_bad_objects_total` metric with `object_namespace` and `crd` labels to track invalid objects managed by VMAgent, VMAuth, VMAlert and VMAlertmanager. Old `operator_alertmanager_bad_objects_count` and `operator_vmalert_bad_objects_count` are deprecated and will be removed in next releases.
* FEATURE: [vmoperator](https://docs.victoriametrics.com/operator/): added HPA support for all cluster CR storage. See [#1678](https://github.com/VictoriaMetrics/operator/issues/1678).

* BUGFIX: [vmoperator](https://docs.victoriametrics.com/operator/): fixed HPA cleanup logic for all cluster resources, before it was constantly recreated. Bug introduced in [this commit](https://github.com/VictoriaMetrics/operator/commit/983d1678c37497a7d03d2f57821219fd4975deec).

Expand Down
5 changes: 4 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ Appears in: [VLClusterSpec](#vlclusterspec)
| hostAliases<a href="#vlstorage-hostaliases" id="vlstorage-hostaliases">#</a><br/>_[HostAlias](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#hostalias-v1-core) array_ | _(Optional)_<br/>HostAliases provides mapping for ip and hostname,<br />that would be propagated to pod,<br />cannot be used with HostNetwork. |
| hostNetwork<a href="#vlstorage-hostnetwork" id="vlstorage-hostnetwork">#</a><br/>_boolean_ | _(Optional)_<br/>HostNetwork controls whether the pod may use the node network namespace |
| host_aliases<a href="#vlstorage-host_aliases" id="vlstorage-host_aliases">#</a><br/>_[HostAlias](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#hostalias-v1-core) array_ | _(Optional)_<br/>HostAliasesUnderScore provides mapping for ip and hostname,<br />that would be propagated to pod,<br />cannot be used with HostNetwork.<br />Has Priority over hostAliases field |
| hpa<a href="#vlstorage-hpa" id="vlstorage-hpa">#</a><br/>_[EmbeddedHPA](#embeddedhpa)_ | _(Optional)_<br/>Configures horizontal pod autoscaling.<br />Note, downscaling is not supported. |
| image<a href="#vlstorage-image" id="vlstorage-image">#</a><br/>_[Image](#image)_ | _(Optional)_<br/>Image - docker image settings<br />if no specified operator uses default version from operator config |
| imagePullSecrets<a href="#vlstorage-imagepullsecrets" id="vlstorage-imagepullsecrets">#</a><br/>_[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core) array_ | _(Optional)_<br/>ImagePullSecrets An optional list of references to secrets in the same namespace<br />to use for pulling images from registries<br />see https://kubernetes.io/docs/concepts/containers/images/#referring-to-an-imagepullsecrets-on-a-pod |
| initContainers<a href="#vlstorage-initcontainers" id="vlstorage-initcontainers">#</a><br/>_[Container](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#container-v1-core) array_ | _(Optional)_<br/>InitContainers allows adding initContainers to the pod definition.<br />Any errors during the execution of an initContainer will lead to a restart of the Pod.<br />More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ |
Expand Down Expand Up @@ -1094,6 +1095,7 @@ Appears in: [VTClusterSpec](#vtclusterspec)
| hostAliases<a href="#vtstorage-hostaliases" id="vtstorage-hostaliases">#</a><br/>_[HostAlias](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#hostalias-v1-core) array_ | _(Optional)_<br/>HostAliases provides mapping for ip and hostname,<br />that would be propagated to pod,<br />cannot be used with HostNetwork. |
| hostNetwork<a href="#vtstorage-hostnetwork" id="vtstorage-hostnetwork">#</a><br/>_boolean_ | _(Optional)_<br/>HostNetwork controls whether the pod may use the node network namespace |
| host_aliases<a href="#vtstorage-host_aliases" id="vtstorage-host_aliases">#</a><br/>_[HostAlias](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#hostalias-v1-core) array_ | _(Optional)_<br/>HostAliasesUnderScore provides mapping for ip and hostname,<br />that would be propagated to pod,<br />cannot be used with HostNetwork.<br />Has Priority over hostAliases field |
| hpa<a href="#vtstorage-hpa" id="vtstorage-hpa">#</a><br/>_[EmbeddedHPA](#embeddedhpa)_ | _(Optional)_<br/>Configures horizontal pod autoscaling.<br />Note, downscaling is not supported. |
| image<a href="#vtstorage-image" id="vtstorage-image">#</a><br/>_[Image](#image)_ | _(Optional)_<br/>Image - docker image settings<br />if no specified operator uses default version from operator config |
| imagePullSecrets<a href="#vtstorage-imagepullsecrets" id="vtstorage-imagepullsecrets">#</a><br/>_[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core) array_ | _(Optional)_<br/>ImagePullSecrets An optional list of references to secrets in the same namespace<br />to use for pulling images from registries<br />see https://kubernetes.io/docs/concepts/containers/images/#referring-to-an-imagepullsecrets-on-a-pod |
| initContainers<a href="#vtstorage-initcontainers" id="vtstorage-initcontainers">#</a><br/>_[Container](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#container-v1-core) array_ | _(Optional)_<br/>InitContainers allows adding initContainers to the pod definition.<br />Any errors during the execution of an initContainer will lead to a restart of the Pod.<br />More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ |
Expand Down Expand Up @@ -1718,7 +1720,7 @@ Appears in: [Receiver](#receiver)
EmbeddedHPA embeds HorizontalPodAutoScaler spec v2.
https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/horizontal-pod-autoscaler-v2/

Appears in: [VLInsert](#vlinsert), [VLSelect](#vlselect), [VMAuthSpec](#vmauthspec), [VMInsert](#vminsert), [VMSelect](#vmselect), [VTInsert](#vtinsert), [VTSelect](#vtselect)
Appears in: [VLInsert](#vlinsert), [VLSelect](#vlselect), [VLStorage](#vlstorage), [VMAuthSpec](#vmauthspec), [VMInsert](#vminsert), [VMSelect](#vmselect), [VMStorage](#vmstorage), [VTInsert](#vtinsert), [VTSelect](#vtselect), [VTStorage](#vtstorage)

| Field | Description |
| --- | --- |
Expand Down Expand Up @@ -4826,6 +4828,7 @@ Appears in: [VMClusterSpec](#vmclusterspec)
| hostAliases<a href="#vmstorage-hostaliases" id="vmstorage-hostaliases">#</a><br/>_[HostAlias](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#hostalias-v1-core) array_ | _(Optional)_<br/>HostAliases provides mapping for ip and hostname,<br />that would be propagated to pod,<br />cannot be used with HostNetwork. |
| hostNetwork<a href="#vmstorage-hostnetwork" id="vmstorage-hostnetwork">#</a><br/>_boolean_ | _(Optional)_<br/>HostNetwork controls whether the pod may use the node network namespace |
| host_aliases<a href="#vmstorage-host_aliases" id="vmstorage-host_aliases">#</a><br/>_[HostAlias](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#hostalias-v1-core) array_ | _(Optional)_<br/>HostAliasesUnderScore provides mapping for ip and hostname,<br />that would be propagated to pod,<br />cannot be used with HostNetwork.<br />Has Priority over hostAliases field |
| hpa<a href="#vmstorage-hpa" id="vmstorage-hpa">#</a><br/>_[EmbeddedHPA](#embeddedhpa)_ | _(Optional)_<br/>Configures horizontal pod autoscaling.<br />Note, downscaling is not supported. |
| image<a href="#vmstorage-image" id="vmstorage-image">#</a><br/>_[Image](#image)_ | _(Optional)_<br/>Image - docker image settings<br />if no specified operator uses default version from operator config |
| imagePullSecrets<a href="#vmstorage-imagepullsecrets" id="vmstorage-imagepullsecrets">#</a><br/>_[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core) array_ | _(Optional)_<br/>ImagePullSecrets An optional list of references to secrets in the same namespace<br />to use for pulling images from registries<br />see https://kubernetes.io/docs/concepts/containers/images/#referring-to-an-imagepullsecrets-on-a-pod |
| initContainers<a href="#vmstorage-initcontainers" id="vmstorage-initcontainers">#</a><br/>_[Container](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#container-v1-core) array_ | _(Optional)_<br/>InitContainers allows adding initContainers to the pod definition.<br />Any errors during the execution of an initContainer will lead to a restart of the Pod.<br />More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ |
Expand Down
1 change: 1 addition & 0 deletions internal/controller/operator/factory/finalize/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func OnStorageDelete(ctx context.Context, rclient client.Client, cr build.Parent
objsToRemove := []client.Object{
&appsv1.StatefulSet{ObjectMeta: objMeta},
&policyv1.PodDisruptionBudget{ObjectMeta: objMeta},
&autoscalingv2.HorizontalPodAutoscaler{ObjectMeta: objMeta},
&vmv1beta1.VMServiceScrape{ObjectMeta: objMeta},
}
owner := cr.AsOwner()
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/operator/factory/vlcluster/vlcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import (

// CreateOrUpdate syncs VLCluster object to the desired state
func CreateOrUpdate(ctx context.Context, rclient client.Client, cr *vmv1.VLCluster) error {
if !build.MustSkipRuntimeValidation {
if err := cr.Validate(); err != nil {
return err
}
}
var prevCR *vmv1.VLCluster
if cr.ParsedLastAppliedSpec != nil {
prevCR = cr.DeepCopy()
Expand Down Expand Up @@ -82,6 +87,9 @@ func deleteOrphaned(ctx context.Context, rclient client.Client, cr *vmv1.VLClust
if newStorage.PodDisruptionBudget != nil {
cc.KeepPDB(commonName)
}
if newStorage.HPA != nil {
cc.KeepHPA(commonName)
}
if !ptr.Deref(newStorage.DisableSelfServiceScrape, disableSelfScrape) {
cc.KeepScrape(commonName)
}
Expand Down
Loading