Skip to content

Commit

Permalink
Gateway hpa based on cpu (#1892)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirdavid1 authored Dec 2, 2024
1 parent 36f258c commit f0a38fb
Show file tree
Hide file tree
Showing 16 changed files with 347 additions and 131 deletions.
24 changes: 21 additions & 3 deletions api/config/crd/bases/odigos.io_collectorsgroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,32 @@ spec:
This can be used to resolve conflicting ports when a collector is using the host network.
format: int32
type: integer
memorySettings:
resourcesSettings:
description: |-
Memory settings for the collectors group.
Resources [memory/cpu] settings for the collectors group.
these settings are used to protect the collectors instances from:
- running out of memory and being killed by the k8s OOM killer
- consuming all available memory on the node which can lead to node instability
- pushing back pressure to the instrumented applications
properties:
cpuLimitMillicores:
description: |-
CPU resource limit to be used on the pod template.
it will be embedded in the as a resource limit of the form "cpu: <value>m"
type: integer
cpuRequestMillicores:
description: |-
CPU resource request to be used on the pod template.
it will be embedded in the as a resource request of the form "cpu: <value>m"
type: integer
gomemlimitMiB:
description: |-
the GOMEMLIMIT environment variable value for the collector pod.
this is when go runtime will start garbage collection.
it is recommended to be set to 80% of the hard limit of the memory limiter.
type: integer
maxReplicas:
type: integer
memoryLimitMiB:
description: |-
This option sets the limit on the memory usage of the collector.
Expand Down Expand Up @@ -92,7 +104,13 @@ spec:
MemoryRequestMiB is the memory resource request to be used on the pod template.
it will be embedded in the as a resource request of the form "memory: <value>Mi"
type: integer
minReplicas:
description: Minumum + Maximum number of replicas for the collector
- these relevant only for gateway.
type: integer
required:
- cpuLimitMillicores
- cpuRequestMillicores
- gomemlimitMiB
- memoryLimitMiB
- memoryLimiterLimitMiB
Expand All @@ -106,7 +124,7 @@ spec:
type: string
required:
- collectorOwnMetricsPort
- memorySettings
- resourcesSettings
- role
type: object
status:
Expand Down

This file was deleted.

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

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

4 changes: 2 additions & 2 deletions api/generated/odigos/applyconfiguration/utils.go

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

19 changes: 15 additions & 4 deletions api/odigos/v1alpha1/collectorsgroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ const (
CollectorsGroupRoleNodeCollector CollectorsGroupRole = CollectorsGroupRole(k8sconsts.CollectorsRoleNodeCollector)
)

// The raw values of the memory settings for the collectors group.
// The raw values to control the collectors group resources and behavior.
// any defaulting, validations and calculations should be done in the controllers
// that create this CR.
// Values will be used as is without any further processing.
type CollectorsGroupMemorySettings struct {
type CollectorsGroupResourcesSettings struct {

// Minumum + Maximum number of replicas for the collector - these relevant only for gateway.
MinReplicas *int `json:"minReplicas,omitempty"`
MaxReplicas *int `json:"maxReplicas,omitempty"`

// MemoryRequestMiB is the memory resource request to be used on the pod template.
// it will be embedded in the as a resource request of the form "memory: <value>Mi"
Expand All @@ -47,6 +51,13 @@ type CollectorsGroupMemorySettings struct {
// so one can set this to the same value as the memory request or higher to allow for some buffer for bursts.
MemoryLimitMiB int `json:"memoryLimitMiB"`

// CPU resource request to be used on the pod template.
// it will be embedded in the as a resource request of the form "cpu: <value>m"
CpuRequestMillicores int `json:"cpuRequestMillicores"`
// CPU resource limit to be used on the pod template.
// it will be embedded in the as a resource limit of the form "cpu: <value>m"
CpuLimitMillicores int `json:"cpuLimitMillicores"`

// this parameter sets the "limit_mib" parameter in the memory limiter configuration for the collector.
// it is the hard limit after which a force garbage collection will be performed.
// this value will end up comparing against the go runtime reported heap Alloc value.
Expand Down Expand Up @@ -76,12 +87,12 @@ type CollectorsGroupSpec struct {
// This can be used to resolve conflicting ports when a collector is using the host network.
CollectorOwnMetricsPort int32 `json:"collectorOwnMetricsPort"`

// Memory settings for the collectors group.
// Resources [memory/cpu] settings for the collectors group.
// these settings are used to protect the collectors instances from:
// - running out of memory and being killed by the k8s OOM killer
// - consuming all available memory on the node which can lead to node instability
// - pushing back pressure to the instrumented applications
MemorySettings CollectorsGroupMemorySettings `json:"memorySettings"`
ResourcesSettings CollectorsGroupResourcesSettings `json:"resourcesSettings"`
}

// CollectorsGroupStatus defines the observed state of Collector
Expand Down
Loading

0 comments on commit f0a38fb

Please sign in to comment.