Skip to content
Open
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
18 changes: 17 additions & 1 deletion api/operator/v1/vlagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ type VLAgentSpec struct {
// UseLegacyNaming uses standalone Helm chart naming for managed resources:
// the CR name is used directly instead of the default "<type>-<name>" convention.
// +optional
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`
UseLegacyNaming bool `json:"useLegacyNaming,omitempty"`
// Configures vertical pod autoscaling.
// +optional
VPA *vmv1beta1.EmbeddedVPA `json:"vpa,omitempty"`
vmv1beta1.CommonAppsParams `json:",inline,omitempty"`
}

Expand Down Expand Up @@ -183,6 +186,11 @@ func (cr *VLAgent) Validate() error {
return fmt.Errorf("remoteWrite.tlsConfig has incorrect syntax at idx: %d: %w", idx, err)
}
}
if cr.Spec.VPA != nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We need to reject k8sCollector / daemonset mode - VPA doesn't support these

if err := cr.Spec.VPA.Validate(); err != nil {
return err
}
}
if err := cr.Spec.Validate(); err != nil {
return err
}
Expand Down Expand Up @@ -417,6 +425,14 @@ func (cr *VLAgent) PrefixedName() string {
return fmt.Sprintf("vlagent-%s", cr.Name)
}

// WorkloadKind returns the kind of workload deployed for VLAgent based on the current mode.
func (cr *VLAgent) WorkloadKind() vmv1beta1.WorkloadKind {
if cr.Spec.K8sCollector.Enabled {
return vmv1beta1.WorkloadKindDaemonSet
}
return vmv1beta1.WorkloadKindStatefulSet
}

// HealthPath returns path for health requests
func (cr *VLAgent) HealthPath() string {
return vmv1beta1.BuildPathWithPrefixFlag(cr.Spec.ExtraArgs, healthPath)
Expand Down
8 changes: 8 additions & 0 deletions api/operator/v1/vlsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ type VLSingleSpec struct {
// SyslogSpec defines syslog listener configuration
// +optional
SyslogSpec *SyslogServerSpec `json:"syslogSpec,omitempty"`
// Configures vertical pod autoscaling.
// +optional
VPA *vmv1beta1.EmbeddedVPA `json:"vpa,omitempty"`
}

// VLSingleStatus defines the observed state of VLSingle
Expand Down Expand Up @@ -297,6 +300,11 @@ func (cr *VLSingle) Validate() error {
if cr.Spec.ServiceSpec != nil && cr.Spec.ServiceSpec.Name == cr.PrefixedName() {
return fmt.Errorf("spec.serviceSpec.Name cannot be equal to prefixed name=%q", cr.PrefixedName())
}
if cr.Spec.VPA != nil {
if err := cr.Spec.VPA.Validate(); err != nil {
return err
}
}
if err := cr.Spec.Validate(); err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions api/operator/v1/vmanomaly_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type VMAnomalySpec struct {
// PodDisruptionBudget created by operator
// +optional
PodDisruptionBudget *vmv1beta1.EmbeddedPodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`
// VPA defines configuration for the VerticalPodAutoscaler.
// +optional
VPA *vmv1beta1.EmbeddedVPA `json:"vpa,omitempty"`
// ConfigRawYaml - raw configuration for anomaly,
// it helps it to start without secret.
// priority -> hardcoded ConfigRaw -> ConfigRaw, provided by user -> ConfigSecret.
Expand Down Expand Up @@ -489,6 +492,11 @@ func (cr *VMAnomaly) Validate() error {
if !cr.Spec.License.IsProvided() {
return fmt.Errorf("no license is provided!. Either spec.license.key or spec.license.keyRef is required")
}
if cr.Spec.VPA != nil {
if err := cr.Spec.VPA.Validate(); err != nil {
return err
}
}
if err := cr.Spec.Validate(); err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions api/operator/v1/vtsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ type VTSingleSpec struct {
// it can be overwritten with component specific image.tag value.
// +optional
ComponentVersion string `json:"componentVersion,omitempty"`
// Configures vertical pod autoscaling.
// +optional
VPA *vmv1beta1.EmbeddedVPA `json:"vpa,omitempty"`
}

// VTSingleStatus defines the observed state of VTSingle
Expand Down Expand Up @@ -292,6 +295,11 @@ func (cr *VTSingle) Validate() error {
if cr.Spec.ServiceSpec != nil && cr.Spec.ServiceSpec.Name == cr.PrefixedName() {
return fmt.Errorf("spec.serviceSpec.Name cannot be equal to prefixed name=%q", cr.PrefixedName())
}
if cr.Spec.VPA != nil {
if err := cr.Spec.VPA.Validate(); err != nil {
return err
}
}
if err := cr.Spec.Validate(); err != nil {
return err
}
Expand Down
20 changes: 20 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.

23 changes: 23 additions & 0 deletions api/operator/v1beta1/vmagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ type VMAgentSpec struct {
// Configures horizontal pod autoscaling.
// +optional
HPA *EmbeddedHPA `json:"hpa,omitempty"`
// Configures vertical pod autoscaling.
// +optional
VPA *EmbeddedVPA `json:"vpa,omitempty"`

CommonRelabelParams `json:",inline,omitempty"`
CommonScrapeParams `json:",inline,omitempty"`
Expand Down Expand Up @@ -189,6 +192,9 @@ func (cr *VMAgent) Validate() error {
if cr.Spec.HPA != nil {
return fmt.Errorf("hpa cannot be used with daemonSetMode")
}
if cr.Spec.VPA != nil {
return fmt.Errorf("vpa cannot be used with daemonSetMode")
}
if cr.Spec.PodDisruptionBudget != nil {
return fmt.Errorf("podDisruptionBudget cannot be used with daemonSetMode")
}
Expand All @@ -201,6 +207,11 @@ func (cr *VMAgent) Validate() error {
return err
}
}
if cr.Spec.VPA != nil {
if err := cr.Spec.VPA.Validate(); err != nil {
return err
}
}
scrapeClassNames := sets.New[string]()
defaultScrapeClass := false
for _, sc := range cr.Spec.ScrapeClasses {
Expand Down Expand Up @@ -241,6 +252,18 @@ func (cr *VMAgent) IsSharded() bool {
return cr != nil && cr.Spec.ShardCount != nil && *cr.Spec.ShardCount > 0 && !cr.Spec.DaemonSetMode
}

// WorkloadKind returns the kind of workload deployed for VMAgent based on the current mode.
func (cr *VMAgent) WorkloadKind() WorkloadKind {
switch {
case cr.Spec.DaemonSetMode:
return WorkloadKindDaemonSet
case cr.Spec.StatefulMode:
return WorkloadKindStatefulSet
default:
return WorkloadKindDeployment
}
}

// GetShardCount returns shard count for vmagent
func (cr *VMAgent) GetShardCount() int32 {
if !cr.IsSharded() {
Expand Down
8 changes: 8 additions & 0 deletions api/operator/v1beta1/vmalert_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ type VMAlertSpec struct {
// PodDisruptionBudget created by operator
// +optional
PodDisruptionBudget *EmbeddedPodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`
// Configures vertical pod autoscaling.
// +optional
VPA *EmbeddedVPA `json:"vpa,omitempty"`
// License allows to configure license key to be used for enterprise features.
// Using license key is supported starting from VictoriaMetrics v1.94.0.
// See [here](https://docs.victoriametrics.com/victoriametrics/enterprise/)
Expand Down Expand Up @@ -403,6 +406,11 @@ func (cr *VMAlert) Validate() error {
if err := validateNotifierConfigs(); err != nil {
return err
}
if cr.Spec.VPA != nil {
if err := cr.Spec.VPA.Validate(); err != nil {
return err
}
}
if err := cr.Spec.Validate(); err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions api/operator/v1beta1/vmalertmanager_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ type VMAlertmanagerSpec struct {
// it can be overwritten with component specific image.tag value.
// +optional
ComponentVersion string `json:"componentVersion,omitempty"`
// Configures vertical pod autoscaling.
// +optional
VPA *EmbeddedVPA `json:"vpa,omitempty"`

CommonConfigReloaderParams `json:",inline,omitempty"`
CommonAppsParams `json:",inline,omitempty"`
Expand Down Expand Up @@ -594,6 +597,11 @@ func (cr *VMAlertmanager) Validate() error {
if cr.Spec.DisableNamespaceMatcher && cr.Spec.EnforcedNamespaceLabel != "" {
return fmt.Errorf("cannot use both disableNamespaceMatcher and enforcedNamespaceLabel at the same time")
}
if cr.Spec.VPA != nil {
if err := cr.Spec.VPA.Validate(); err != nil {
return err
}
}
if err := cr.Spec.Validate(); err != nil {
return err
}
Expand Down
9 changes: 9 additions & 0 deletions api/operator/v1beta1/vmextra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ const (
UpdateStatusPaused UpdateStatus = "paused"
)

// WorkloadKind represents the kind of Kubernetes workload managed by an operator component.
type WorkloadKind string

const (
WorkloadKindDaemonSet WorkloadKind = "DaemonSet"
WorkloadKindStatefulSet WorkloadKind = "StatefulSet"
WorkloadKindDeployment WorkloadKind = "Deployment"
)

// ClusterComponent defines component kind for cluster
type ClusterComponent string

Expand Down
8 changes: 8 additions & 0 deletions api/operator/v1beta1/vmsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ type VMSingleSpec struct {
// it can be overwritten with component specific image.tag value.
// +optional
ComponentVersion string `json:"componentVersion,omitempty"`
// Configures vertical pod autoscaling.
// +optional
VPA *EmbeddedVPA `json:"vpa,omitempty"`

CommonRelabelParams `json:",inline,omitempty"`
CommonScrapeParams `json:",inline,omitempty"`
Expand Down Expand Up @@ -462,6 +465,11 @@ func (cr *VMSingle) Validate() error {
return fmt.Errorf("spec.volumeMounts must have at least 1 value OR spec.volumes must have volume.name `data` for spec.storageDataPath=%q", cr.Spec.StorageDataPath)
}
}
if cr.Spec.VPA != nil {
if err := cr.Spec.VPA.Validate(); err != nil {
return err
}
}
if err := cr.Spec.Validate(); err != nil {
return err
}
Expand Down
20 changes: 20 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.

Loading
Loading