Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Make cluster-autoscaler resource request/limit configurable (#1554)
Browse files Browse the repository at this point in the history
* make cluster autoscaler configurable
* Adding Compute resources struct
* Fixing broken tests
  • Loading branch information
Luke Humphreys authored and davidmccormick committed Feb 13, 2019
1 parent cf9a5a9 commit f054f87
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
22 changes: 11 additions & 11 deletions core/controlplane/config/templates/cloud-config-controller
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ write_files:
echo kube-proxy stared. apiserver should be responsive again.
fi
rbac=/srv/kubernetes/rbac

{{- if .Kubernetes.Networking.SelfHosting.Enabled }}
# When using NetworkingDeamonSets ensure that all nodes
# have a podCIDR attribute
Expand All @@ -1062,7 +1062,7 @@ write_files:
applyall "${mfdir}/calico.yaml"
{{- end }}
{{- end }}

{{ if .Addons.MetricsServer.Enabled -}}
applyall \
"${mfdir}/metrics-server-sa.yaml" \
Expand All @@ -1073,12 +1073,12 @@ write_files:
"${rbac}/role-bindings/metrics-server.yaml" \
"${mfdir}/metrics-server-apisvc.yaml"
{{- end }}

{{ if .KubernetesDashboard.Enabled }}
# Secrets
applyall "${mfdir}/kubernetes-dashboard-se.yaml"
{{ end }}

# Configmaps
applyall \
"${mfdir}"/{kube-proxy,heapster-config}"-cm.yaml" \
Expand All @@ -1090,7 +1090,7 @@ write_files:
"${mfdir}/{{ .KubeDns.Provider }}-sa.yaml" \
"${mfdir}/kube-proxy-sa.yaml" \
{{ if .KubernetesDashboard.Enabled }}"${mfdir}/kubernetes-dashboard-sa.yaml"{{ end }}

{{ if eq .KubeDns.Provider "coredns" -}}
applyall \
"${mfdir}/coredns-cr.yaml" \
Expand Down Expand Up @@ -1154,7 +1154,7 @@ write_files:
if ls ${mfdir}/custom/*.yaml &> /dev/null; then
applyall ${mfdir}/custom/*.yaml
fi

{{ if $.MigrateStacks -}}
restore_webhooks() {
local type=$1
Expand Down Expand Up @@ -3644,7 +3644,7 @@ write_files:
requests:
cpu: {{ if .Kubernetes.ControllerManager.ComputeResources.Requests.Cpu }}{{ .Kubernetes.ControllerManager.ComputeResources.Requests.Cpu }}{{ else }}100m{{ end }}
memory: {{ if .Kubernetes.ControllerManager.ComputeResources.Requests.Memory }}{{ .Kubernetes.ControllerManager.ComputeResources.Requests.Memory }}{{ else }}100M{{ end }}

limits:
cpu: {{ if .Kubernetes.ControllerManager.ComputeResources.Limits.Cpu }}{{ .Kubernetes.ControllerManager.ComputeResources.Limits.Cpu }}{{ else }}250m{{ end }}
memory: {{ if .Kubernetes.ControllerManager.ComputeResources.Limits.Memory }}{{ .Kubernetes.ControllerManager.ComputeResources.Limits.Memory }}{{ else }}512M{{ end }}
Expand Down Expand Up @@ -4574,11 +4574,11 @@ write_files:
name: cluster-autoscaler
resources:
limits:
cpu: 100m
memory: 300Mi
cpu: {{ if .Addons.ClusterAutoscaler.ComputeResources.Limits.Cpu }}{{ .Addons.ClusterAutoscaler.ComputeResources.Limits.Cpu }}{{ else }}100m{{ end }}
memory: {{ if .Addons.ClusterAutoscaler.ComputeResources.Limits.Memory }}{{ .Addons.ClusterAutoscaler.ComputeResources.Limits.Memory }}{{ else }}300Mi{{ end }}
requests:
cpu: 100m
memory: 300Mi
cpu: {{ if .Addons.ClusterAutoscaler.ComputeResources.Requests.Cpu }}{{ .Addons.ClusterAutoscaler.ComputeResources.Requests.Cpu }}{{ else }}100m{{ end }}
memory: {{ if .Addons.ClusterAutoscaler.ComputeResources.Requests.Memory }}{{ .Addons.ClusterAutoscaler.ComputeResources.Requests.Memory }}{{ else }}300Mi{{ end }}
command:
- ./cluster-autoscaler
- --v=4
Expand Down
8 changes: 8 additions & 0 deletions core/root/config/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,14 @@ addons:
# If you want to run CA on worker nodes, turn on `worker.nodePools[].clusterAutoscalerSupport.enabled` for the node pool.
clusterAutoscaler:
enabled: false
resources:
# Increase these values substantially if running a cluster of 50+ nodes
limits:
cpu: 100m
memory: 300Mi
requests:
cpu: 100m
memory: 300Mi
# Options below can be used to inject custom settings for the autoscaler.
# Sensible defaults are already configured in the controller-cloud-config but if you wish to override them simply
# add them here and they'll take precedence.
Expand Down
17 changes: 14 additions & 3 deletions model/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ type Addons struct {
}

type ClusterAutoscalerSupport struct {
Enabled bool `yaml:"enabled"`
Options map[string]string `yaml:"options"`
UnknownKeys `yaml:",inline"`
Enabled bool `yaml:"enabled"`
ComputeResources ComputeResources `yaml:"resources,omitempty"`
Options map[string]string `yaml:"options"`
UnknownKeys `yaml:",inline"`
}

type Rescheduler struct {
Expand All @@ -33,3 +34,13 @@ type Prometheus struct {
type APIServerAggregator struct {
Enabled bool `yaml:"enabled"`
}

type ComputeResources struct {
Limits ResourceQuota `yaml:"limits,omitempty"`
Requests ResourceQuota `yaml:"requests,omitempty"`
}

type ResourceQuota struct {
Cpu string `yaml:"cpu"`
Memory string `yaml:"memory"`
}
2 changes: 1 addition & 1 deletion test/integration/maincluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ experimental:
image:
repo: quay.io/uswitch/kiam
tag: v2.6
sessionDuration: 30m
sessionDuration: 30m
serverAddresses:
serverAddress: localhost
agentAddress: kiam-server
Expand Down

0 comments on commit f054f87

Please sign in to comment.