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

Allow resource configuration for APIServer #1746

Merged
merged 9 commits into from
Oct 3, 2019
Merged
28 changes: 20 additions & 8 deletions builtin/files/cluster.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1168,13 +1168,25 @@ kubernetes:
enabled: false

# controllerManager:
# resources:
# requests:
# cpu: 100m
# memory: 100Mi
# limits:
# cpu: 250m
# memory: 512Mi

# apiServer:
# # Memory limit for apiserver in MB (used to configure sizes of etcd caches, etc.)
# targetRamMb: 4096
# # Resource limits for the apiserver.
# resources:
# requests:
# cpu: 100m
# memory: 100M
# cpu: 256m
# memory: 256Mi
# limits:
# cpu: 250m
# memory: 512M
# cpu: 1024m
# memory: 2048Mi

# Kubernetes Self-hosted networking daemonsets
# Choose either 'canal' (calico+flannel) or 'flannel'
Expand All @@ -1194,19 +1206,19 @@ kubernetes:
# memory: "200Mi"
# calicoNodeImage:
# repo: quay.io/calico/node
# tag: v3.1.3
# tag: v3.9.1
# calicoCniImage:
# repo: quay.io/calico/cni
# tag: v3.1.3
# tag: v3.9.1
# flannelImage:
# repo: quay.io/coreos/flannel
# tag: v0.9.1
# tag: v0.11.9
# flannelCniImage:
# repo: quay.io/coreos/flannel-cni
# tag: v0.3.0
# typhaImage:
# repo: quay.io/calico/typha
# tag: v0.7.4
# tag: v3.9.1

# Create MountTargets to subnets managed by kube-aws for a pre-existing Elastic File System (Amazon EFS),
# and then mount to every node.
Expand Down
24 changes: 24 additions & 0 deletions builtin/files/userdata/cloud-config-controller
Original file line number Diff line number Diff line change
Expand Up @@ -3377,6 +3377,9 @@ write_files:
- --enable-bootstrap-token-auth=true
- --token-auth-file=/etc/kubernetes/auth/tokens.csv
- --storage-backend=etcd3
{{ if .Kubernetes.KubeApiServer.TargetRamMb -}}
- --target-ram-mb={{.Kubernetes.KubeApiServer.TargetRamMb}}
{{ end -}}
- --kubelet-preferred-address-types=InternalIP,Hostname,ExternalIP
{{if .Experimental.AuditLog.Enabled}}
- --audit-log-maxage={{.Experimental.AuditLog.MaxAge}}
Expand Down Expand Up @@ -3427,6 +3430,27 @@ write_files:
{{range $f := .APIServerFlags}}
- --{{$f.Name}}={{$f.Value}}
{{ end -}}
{{ if .Kubernetes.KubeApiServer.ComputeResources -}}
resources:
{{ if .Kubernetes.KubeApiServer.ComputeResources.Requests -}}
requests:
{{ if .Kubernetes.KubeApiServer.ComputeResources.Requests.Cpu -}}
cpu: {{.Kubernetes.KubeApiServer.ComputeResources.Requests.Cpu }}
{{ end -}}
{{ if .Kubernetes.KubeApiServer.ComputeResources.Requests.Memory -}}
memory: {{.Kubernetes.KubeApiServer.ComputeResources.Requests.Memory }}
{{ end -}}
{{ end }}
{{ if .Kubernetes.KubeApiServer.ComputeResources.Limits -}}
limits:
{{ if .Kubernetes.KubeApiServer.ComputeResources.Limits.Cpu -}}
cpu: {{.Kubernetes.KubeApiServer.ComputeResources.Limits.Cpu }}
{{ end -}}
{{- if .Kubernetes.KubeApiServer.ComputeResources.Limits.Memory -}}
memory: {{.Kubernetes.KubeApiServer.ComputeResources.Limits.Memory }}
{{ end -}}
{{ end }}
{{ end }}
livenessProbe:
tcpSocket:
port: 443
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ var KUBERNETES_VERSION = "v99.99"

const (
// Experimental SelfHosting feature default images.
kubeNetworkingSelfHostingDefaultCalicoNodeImageTag = "v3.6.1"
kubeNetworkingSelfHostingDefaultCalicoCniImageTag = "v3.6.1"
kubeNetworkingSelfHostingDefaultCalicoNodeImageTag = "v3.9.1"
kubeNetworkingSelfHostingDefaultCalicoCniImageTag = "v3.9.1"
kubeNetworkingSelfHostingDefaultFlannelImageTag = "v0.11.0"
kubeNetworkingSelfHostingDefaultFlannelCniImageTag = "v0.3.0"
kubeNetworkingSelfHostingDefaultTyphaImageTag = "v3.6.1"
kubeNetworkingSelfHostingDefaultTyphaImageTag = "v3.9.1"
)

func NewDefaultCluster() *Cluster {
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type Kubernetes struct {
ControllerManager ControllerManager `yaml:"controllerManager,omitempty"`
KubeScheduler KubeScheduler `yaml:"kubeScheduler,omitempty"`
KubeProxy KubeProxy `yaml:"kubeProxy,omitempty"`
KubeApiServer KubeApiServer `yaml:"apiServer,omitempty"`
Kubelet Kubelet `yaml:"kubelet,omitempty"`
APIServer KubernetesAPIServer `yaml:"apiserver,omitempty"`

Expand All @@ -15,6 +16,11 @@ type Kubernetes struct {
Manifests KubernetesManifests `yaml:"manifests,omitempty"`
}

type KubeApiServer struct {
ComputeResources ComputeResources `yaml:"resources,omitempty"`
TargetRamMb int `yaml:"targetRamMb,omitempty"`
}

type ControllerManager struct {
ComputeResources ComputeResources `yaml:"resources,omitempty"`
Flags CommandLineFlags `yaml:"flags,omitempty"`
Expand Down