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
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.

4 changes: 4 additions & 0 deletions api/operator/v1alpha1/vmdistributed_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,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
5 changes: 5 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.

18 changes: 15 additions & 3 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 @@ -119,6 +119,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 @@ -160,13 +164,21 @@ func (cr *VMAgent) Validate() error {
return fmt.Errorf("daemonSetMode and statefulMode cannot be used in the same time")
}
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 +215,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 +482,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: 6 additions & 1 deletion 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