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
6 changes: 3 additions & 3 deletions api/operator/v1/vmanomaly_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type VMAnomalySpec struct {
// in this case operator will use 1 sts per shard with
// replicas count according to spec.replicas.
// +optional
ShardCount *int `json:"shardCount,omitempty"`
ShardCount *int32 `json:"shardCount,omitempty"`
// PodDisruptionBudget created by operator
// +optional
PodDisruptionBudget *vmv1beta1.EmbeddedPodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`
Expand Down Expand Up @@ -306,7 +306,7 @@ func (cr *VMAnomaly) GetStatus() *VMAnomalyStatus {
func (cr *VMAnomaly) DefaultStatusFields(vs *VMAnomalyStatus) {
var shardCnt int32
if cr.IsSharded() {
shardCnt = int32(*cr.Spec.ShardCount)
shardCnt = *cr.Spec.ShardCount
}
vs.Shards = shardCnt
}
Expand Down Expand Up @@ -441,7 +441,7 @@ func (cr *VMAnomaly) IsSharded() bool {
}

// GetShardCount returns shard count for vmanomaly
func (cr *VMAnomaly) GetShardCount() int {
func (cr *VMAnomaly) GetShardCount() int32 {
if !cr.IsSharded() {
return 1
}
Expand Down
2 changes: 1 addition & 1 deletion api/operator/v1/zz_generated.deepcopy.go

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

15 changes: 15 additions & 0 deletions api/operator/v1alpha1/vmdistributed_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ type VMDistributedZoneAgentSpec struct {
// set it to RollingUpdate for disabling operator statefulSet rollingUpdate
// +optional
StatefulRollingUpdateStrategy appsv1.StatefulSetUpdateStrategyType `json:"statefulRollingUpdateStrategy,omitempty"`
// StatefulRollingUpdateStrategyBehavior defines customized behavior for rolling updates.
// It applies if the RollingUpdateStrategy is set to OnDelete, which is the default.
// +optional
StatefulRollingUpdateStrategyBehavior *vmv1beta1.StatefulSetUpdateStrategyBehavior `json:"statefulRollingUpdateStrategyBehavior,omitempty"`
// PersistentVolumeClaimRetentionPolicy allows configuration of PVC retention policy
// +optional
PersistentVolumeClaimRetentionPolicy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty"`
Expand All @@ -214,6 +218,10 @@ type VMDistributedZoneAgentSpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// Configures horizontal pod autoscaling.
// +optional
HPA *vmv1beta1.EmbeddedHPA `json:"hpa,omitempty"`

vmv1beta1.CommonAppsParams `json:",inline,omitempty"`
}

Expand Down Expand Up @@ -459,6 +467,13 @@ func (cr *VMDistributed) Validate() error {
}
agents[agentName] = struct{}{}
}
if zone.VMAgent.Spec.StatefulMode {
if zone.VMAgent.Spec.StatefulRollingUpdateStrategyBehavior != nil {
if err := zone.VMAgent.Spec.StatefulRollingUpdateStrategyBehavior.Validate(); err != nil {
return fmt.Errorf("spec.zones[%d].vmagent.spec.statefulRollingUpdateStrategyBehavior: %w", i, err)
}
}
}
if zone.VMCluster.Spec.VMInsert == nil && !hasCommonVMInsert {
return fmt.Errorf("either zoneCommon.vmcluster.spec.vminsert or spec.zones[%d].vmcluster.spec.vminsert is required", i)
}
Expand Down
10 changes: 10 additions & 0 deletions api/operator/v1alpha1/zz_generated.deepcopy.go

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

33 changes: 28 additions & 5 deletions api/operator/v1beta1/vmagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type VMAgentSpec struct {
// replicas count according to spec.replicas,
// see [here](https://docs.victoriametrics.com/victoriametrics/vmagent/#scraping-big-number-of-targets)
// +optional
ShardCount *int `json:"shardCount,omitempty"`
ShardCount *int32 `json:"shardCount,omitempty"`

// UpdateStrategy - overrides default update strategy.
// works only for deployments, statefulset always use OnDelete.
Expand Down Expand Up @@ -97,6 +97,10 @@ type VMAgentSpec struct {
// set it to RollingUpdate for disabling operator statefulSet rollingUpdate
// +optional
StatefulRollingUpdateStrategy appsv1.StatefulSetUpdateStrategyType `json:"statefulRollingUpdateStrategy,omitempty"`
// StatefulRollingUpdateStrategyBehavior defines customized behavior for rolling updates.
// It applies if the RollingUpdateStrategy is set to OnDelete, which is the default.
// +optional
StatefulRollingUpdateStrategyBehavior *StatefulSetUpdateStrategyBehavior `json:"statefulRollingUpdateStrategyBehavior,omitempty"`
// PersistentVolumeClaimRetentionPolicy allows configuration of PVC retention policy
// +optional
PersistentVolumeClaimRetentionPolicy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty"`
Expand All @@ -119,6 +123,10 @@ type VMAgentSpec struct {
// +optional
ComponentVersion string `json:"componentVersion,omitempty"`

// Configures horizontal pod autoscaling.
// +optional
HPA *EmbeddedHPA `json:"hpa,omitempty"`

CommonRelabelParams `json:",inline,omitempty"`
CommonScrapeParams `json:",inline,omitempty"`
CommonConfigReloaderParams `json:",inline,omitempty"`
Expand Down Expand Up @@ -156,17 +164,32 @@ func (cr *VMAgent) Validate() error {
}
}
}
if cr.Spec.DaemonSetMode && cr.Spec.StatefulMode {
return fmt.Errorf("daemonSetMode and statefulMode cannot be used in the same time")
if cr.Spec.StatefulMode {
if cr.Spec.DaemonSetMode {
return fmt.Errorf("daemonSetMode and statefulMode cannot be used in the same time")
}
if cr.Spec.StatefulRollingUpdateStrategyBehavior != nil {
if err := cr.Spec.StatefulRollingUpdateStrategyBehavior.Validate(); err != nil {
return fmt.Errorf("vmagent.spec.statefulRollingUpdateStrategyBehavior: %w", err)
}
}
}
if cr.Spec.DaemonSetMode {
if cr.Spec.HPA != nil {
return fmt.Errorf("hpa cannot be used with daemonSetMode")
}
if cr.Spec.PodDisruptionBudget != nil {
return fmt.Errorf("podDisruptionBudget cannot be used with daemonSetMode")
}
if cr.Spec.EnableKubernetesAPISelectors {
return fmt.Errorf("enableKubernetesAPISelectors cannot be used with daemonSetMode")
}
}
if cr.Spec.HPA != nil {
if err := cr.Spec.HPA.Validate(); err != nil {
return err
}
}
scrapeClassNames := make(map[string]struct{})
defaultScrapeClass := false
for _, sc := range cr.Spec.ScrapeClasses {
Expand Down Expand Up @@ -203,7 +226,7 @@ func (cr *VMAgent) IsSharded() bool {
}

// GetShardCount returns shard count for vmagent
func (cr *VMAgent) GetShardCount() int {
func (cr *VMAgent) GetShardCount() int32 {
if !cr.IsSharded() {
return 1
}
Expand Down Expand Up @@ -470,7 +493,7 @@ func (cr *VMAgent) DefaultStatusFields(vs *VMAgentStatus) {
}
var shardCnt int32
if cr.IsSharded() {
shardCnt = int32(*cr.Spec.ShardCount)
shardCnt = *cr.Spec.ShardCount
}
vs.Replicas = replicaCount
vs.Shards = shardCnt
Expand Down
7 changes: 3 additions & 4 deletions api/operator/v1beta1/vmcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,7 @@ type VMAuthLoadBalancerSpec struct {
// LogLevel for vmauth container.
// +optional
// +kubebuilder:validation:Enum=INFO;WARN;ERROR;FATAL;PANIC
LogLevel string `json:"logLevel,omitempty"`
CommonAppsParams `json:",inline"`
LogLevel string `json:"logLevel,omitempty"`
// PodDisruptionBudget created by operator
// +optional
PodDisruptionBudget *EmbeddedPodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`
Expand All @@ -1006,8 +1005,8 @@ type VMAuthLoadBalancerSpec struct {
RollingUpdate *appsv1.RollingUpdateDeployment `json:"rollingUpdate,omitempty"`
// License configures enterprise features license key
// +optional
License *License `json:"license,omitempty"`
CommonConfigReloaderParams `json:",inline,omitempty"`
License *License `json:"license,omitempty"`
CommonAppsParams `json:",inline"`
}

// ProbePort returns port for probe requests
Expand Down
15 changes: 12 additions & 3 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