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

[addons/CA] Add support for specifying resources and metrics #10281

Merged
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
17 changes: 17 additions & 0 deletions docs/cluster_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,23 @@ spec:

For more details on `horizontalPodAutoscaler` flags see the [official HPA docs](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) and the [kOps guides on how to set it up](horizontal_pod_autoscaling.md).

## Cluster autoscaler
{{ kops_feature_table(kops_added_default='1.19', k8s_min='1.15') }}

Cluster autoscaler can be enabled to automatically adjust the size of the kubernetes cluster.

```yaml
spec:
clusterAutoscaler:
enabled: true
skipNodesWithLocalStorage: true
skipNodesWithSystemPods: true
cpuRequest: "100m"
memoryRequest: "300Mi"
```

Read more about cluster autoscaler in the [official documentation](https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler).

### Feature Gates

Feature gates can be configured on the kubelet.
Expand Down
16 changes: 16 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,14 @@ spec:
description: 'BalanceSimilarNodeGroups makes cluster autoscaler
treat similar node groups as one. Default: false'
type: boolean
cpuRequest:
anyOf:
- type: integer
- type: string
description: 'CPURequest of cluster autoscaler container. Default:
100m'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
enabled:
description: 'Enabled enables the cluster autoscaler. Default:
false'
Expand All @@ -472,6 +480,14 @@ spec:
description: 'Image is the docker container used. Default: the
latest supported image for the specified kubernetes version.'
type: string
memoryRequest:
anyOf:
- type: integer
- type: string
description: 'MemoryRequest of cluster autoscaler container. Default:
300Mi'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
newPodScaleUpDelay:
description: 'NewPodScaleUpDelay causes cluster autoscaler to
ignore unschedulable pods until they are a certain "age", regardless
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/kops/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,12 @@ type ClusterAutoscalerConfig struct {
// Image is the docker container used.
// Default: the latest supported image for the specified kubernetes version.
Image *string `json:"image,omitempty"`
// MemoryRequest of cluster autoscaler container.
// Default: 300Mi
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest of cluster autoscaler container.
// Default: 100m
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
}

// MetricsServerConfig determines the metrics server configuration.
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/kops/v1alpha2/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,12 @@ type ClusterAutoscalerConfig struct {
// Image is the docker container used.
// Default: the latest supported image for the specified kubernetes version.
Image *string `json:"image,omitempty"`
// MemoryRequest of cluster autoscaler container.
// Default: 300Mi
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest of cluster autoscaler container.
// Default: 100m
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
}

// MetricsServerConfig determines the metrics server configuration.
Expand Down
4 changes: 4 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.

10 changes: 10 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.

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

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

8 changes: 4 additions & 4 deletions pkg/model/components/clusterautoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ func (b *ClusterAutoscalerOptionsBuilder) BuildOptions(o interface{}) error {
if err == nil {
switch v.Minor {
case 19:
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.19.0"
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.19.1"
case 18:
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.18.2"
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.18.3"
case 17:
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.17.3"
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.17.4"
case 16:
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.16.6"
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.16.7"
case 15:
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.15.7"
case 14:
Expand Down
11 changes: 8 additions & 3 deletions upup/models/bindata.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ spec:
metadata:
labels:
app: cluster-autoscaler
annotations:
prometheus.io/path: "/metrics"
prometheus.io/port: "8085"
prometheus.io/scrape: "true"
spec:
serviceAccountName: cluster-autoscaler
tolerations:
Expand All @@ -146,8 +150,8 @@ spec:
name: cluster-autoscaler
resources:
requests:
cpu: 100m
memory: 300Mi
cpu: {{ or .CPURequest "100m"}}
memory: {{ or .MemoryRequest "300Mi"}}
command:
- ./cluster-autoscaler
- --balance-similar-node-groups={{ .BalanceSimilarNodeGroups }}
Expand All @@ -174,4 +178,4 @@ spec:
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
{{ end }}
{{ end }}