Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components): permit to define kube-controller-manager and kube-scheduler resources #16605

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
64 changes: 64 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2254,6 +2254,22 @@ spec:
items:
type: string
type: array
cpuLimit:
anyOf:
- type: integer
- type: string
description: CPULimit, cpu limit compute resource for kube-controler-manager
e.g. "500m"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
cpuRequest:
anyOf:
- type: integer
- type: string
description: CPURequest, cpu request compute resource for kube-controler-manager.
Defaults to "100m"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
disableAttachDetachReconcileSync:
description: |-
DisableAttachDetachReconcileSync disables the reconcile sync loop in the attach-detach controller.
Expand Down Expand Up @@ -2421,6 +2437,22 @@ spec:
master:
description: Master is the url for the kube api master
type: string
memoryLimit:
anyOf:
- type: integer
- type: string
description: MemoryLimit, memory limit compute resource for kube-controler-manager
e.g. "30Mi"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memoryRequest:
anyOf:
- type: integer
- type: string
description: MemoryRequest, memory request compute resource for
kube-controler-manager e.g. "30Mi"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
minResyncPeriod:
description: |-
MinResyncPeriod indicates the resync period in reflectors.
Expand Down Expand Up @@ -3708,6 +3740,22 @@ spec:
the burst quota is exhausted
format: int32
type: integer
cpuLimit:
anyOf:
- type: integer
- type: string
description: CPULimit, cpu limit compute resource for scheduler
e.g. "500m"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
cpuRequest:
anyOf:
- type: integer
- type: string
description: CPURequest, cpu request compute resource for scheduler.
Defaults to "100m"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
enableContentionProfiling:
description: EnableContentionProfiling enables block profiling,
if profiling is enabled
Expand Down Expand Up @@ -3801,6 +3849,22 @@ spec:
as outlined: https://kubernetes.io/docs/concepts/storage/storage-limits/
format: int32
type: integer
memoryLimit:
anyOf:
- type: integer
- type: string
description: MemoryLimit, memory limit compute resource for scheduler
e.g. "30Mi"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memoryRequest:
anyOf:
- type: integer
- type: string
description: MemoryRequest, memory request compute resource for
scheduler e.g. "30Mi"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
qps:
anyOf:
- type: integer
Expand Down
26 changes: 23 additions & 3 deletions nodeup/pkg/model/kube_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,27 @@ func (b *KubeControllerManagerBuilder) buildPod(kcm *kops.KubeControllerManagerC
// Add the volumePluginDir flag if provided in the kubelet spec, or set above based on the OS
flags = append(flags, "--flex-volume-plugin-dir="+volumePluginDir)

resourceRequests := v1.ResourceList{}
resourceLimits := v1.ResourceList{}

cpuRequest := resource.MustParse("100m")
if kcm.CPURequest != nil {
cpuRequest = *kcm.CPURequest
}
resourceRequests["cpu"] = cpuRequest

if kcm.CPULimit != nil {
resourceLimits["cpu"] = *kcm.CPULimit
}

if kcm.MemoryRequest != nil {
resourceRequests["memory"] = *kcm.MemoryRequest
}

if kcm.MemoryLimit != nil {
resourceLimits["memory"] = *kcm.MemoryLimit
}

image := b.RemapImage(kcm.Image)

container := &v1.Container{
Expand All @@ -221,9 +242,8 @@ func (b *KubeControllerManagerBuilder) buildPod(kcm *kops.KubeControllerManagerC
TimeoutSeconds: 15,
},
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("100m"),
},
Requests: resourceRequests,
Limits: resourceLimits,
},
}

Expand Down
26 changes: 23 additions & 3 deletions nodeup/pkg/model/kube_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,27 @@ func (b *KubeSchedulerBuilder) buildPod(kubeScheduler *kops.KubeSchedulerConfig)
},
}

resourceRequests := v1.ResourceList{}
resourceLimits := v1.ResourceList{}

cpuRequest := resource.MustParse("100m")
if kubeScheduler.CPURequest != nil {
cpuRequest = *kubeScheduler.CPURequest
}
resourceRequests["cpu"] = cpuRequest

if kubeScheduler.CPULimit != nil {
resourceLimits["cpu"] = *kubeScheduler.CPULimit
}

if kubeScheduler.MemoryRequest != nil {
resourceRequests["memory"] = *kubeScheduler.MemoryRequest
}

if kubeScheduler.MemoryLimit != nil {
resourceLimits["memory"] = *kubeScheduler.MemoryLimit
}

image := b.RemapImage(kubeScheduler.Image)

healthAction := &v1.HTTPGetAction{
Expand All @@ -232,9 +253,8 @@ func (b *KubeSchedulerBuilder) buildPod(kubeScheduler *kops.KubeSchedulerConfig)
TimeoutSeconds: 15,
},
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("100m"),
},
Requests: resourceRequests,
Limits: resourceLimits,
},
}
kubemanifest.AddHostPathMapping(pod, container, "varlibkubescheduler", "/var/lib/kube-scheduler")
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/kops/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,15 @@ type KubeControllerManagerConfig struct {
EnableContentionProfiling *bool `json:"enableContentionProfiling,omitempty" flag:"contention-profiling"`
// EnableLeaderMigration enables controller leader migration.
EnableLeaderMigration *bool `json:"enableLeaderMigration,omitempty" flag:"enable-leader-migration"`

// CPURequest, cpu request compute resource for kube-controler-manager. Defaults to "100m"
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// CPULimit, cpu limit compute resource for kube-controler-manager e.g. "500m"
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`
// MemoryRequest, memory request compute resource for kube-controler-manager e.g. "30Mi"
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// MemoryLimit, memory limit compute resource for kube-controler-manager e.g. "30Mi"
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
}

// CloudControllerManagerConfig is the configuration of the cloud controller
Expand Down Expand Up @@ -783,6 +792,15 @@ type KubeSchedulerConfig struct {
TLSCertFile *string `json:"tlsCertFile,omitempty" flag:"tls-cert-file"`
// TLSPrivateKeyFile is the file containing the private key for the TLS server certificate.
TLSPrivateKeyFile string `json:"tlsPrivateKeyFile,omitempty" flag:"tls-private-key-file"`

// CPURequest, cpu request compute resource for scheduler. Defaults to "100m"
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// CPULimit, cpu limit compute resource for scheduler e.g. "500m"
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`
// MemoryRequest, memory request compute resource for scheduler e.g. "30Mi"
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// MemoryLimit, memory limit compute resource for scheduler e.g. "30Mi"
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
}

// LeaderElectionConfiguration defines the configuration of leader election
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/kops/v1alpha2/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,15 @@ type KubeControllerManagerConfig struct {
EnableContentionProfiling *bool `json:"enableContentionProfiling,omitempty" flag:"contention-profiling"`
// EnableLeaderMigration enables controller leader migration.
EnableLeaderMigration *bool `json:"enableLeaderMigration,omitempty" flag:"enable-leader-migration"`

// CPURequest, cpu request compute resource for kube-controler-manager. Defaults to "100m"
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// CPULimit, cpu limit compute resource for kube-controler-manager e.g. "500m"
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`
// MemoryRequest, memory request compute resource for kube-controler-manager e.g. "30Mi"
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// MemoryLimit, memory limit compute resource for kube-controler-manager e.g. "30Mi"
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
}

// CloudControllerManagerConfig is the configuration of the cloud controller
Expand Down Expand Up @@ -789,6 +798,15 @@ type KubeSchedulerConfig struct {
TLSCertFile *string `json:"tlsCertFile,omitempty" flag:"tls-cert-file"`
// TLSPrivateKeyFile is the file containing the private key for the TLS server certificate.
TLSPrivateKeyFile string `json:"tlsPrivateKeyFile,omitempty" flag:"tls-private-key-file"`

// CPURequest, cpu request compute resource for scheduler. Defaults to "100m"
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// CPULimit, cpu limit compute resource for scheduler e.g. "500m"
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`
// MemoryRequest, memory request compute resource for scheduler e.g. "30Mi"
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// MemoryLimit, memory limit compute resource for scheduler e.g. "30Mi"
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
}

// LeaderElectionConfiguration defines the configuration of leader election
Expand Down
16 changes: 16 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

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

40 changes: 40 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

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

18 changes: 18 additions & 0 deletions pkg/apis/kops/v1alpha3/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,15 @@ type KubeControllerManagerConfig struct {
EnableContentionProfiling *bool `json:"enableContentionProfiling,omitempty" flag:"contention-profiling"`
// EnableLeaderMigration enables controller leader migration.
EnableLeaderMigration *bool `json:"enableLeaderMigration,omitempty" flag:"enable-leader-migration"`

// CPURequest, cpu request compute resource for kube-controler-manager. Defaults to "100m"
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// CPULimit, cpu limit compute resource for kube-controler-manager e.g. "500m"
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`
// MemoryRequest, memory request compute resource for kube-controler-manager e.g. "30Mi"
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// MemoryLimit, memory limit compute resource for kube-controler-manager e.g. "30Mi"
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
}

// CloudControllerManagerConfig is the configuration of the cloud controller
Expand Down Expand Up @@ -780,6 +789,15 @@ type KubeSchedulerConfig struct {
TLSCertFile *string `json:"tlsCertFile,omitempty" flag:"tls-cert-file"`
// TLSPrivateKeyFile is the file containing the private key for the TLS server certificate.
TLSPrivateKeyFile string `json:"tlsPrivateKeyFile,omitempty" flag:"tls-private-key-file"`

// CPURequest, cpu request compute resource for scheduler. Defaults to "100m"
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// CPULimit, cpu limit compute resource for scheduler e.g. "500m"
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`
// MemoryRequest, memory request compute resource for scheduler e.g. "30Mi"
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// MemoryLimit, memory limit compute resource for scheduler e.g. "30Mi"
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
}

// LeaderElectionConfiguration defines the configuration of leader election
Expand Down
Loading
Loading