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

Commit 062740b

Browse files
authored
Merge pull request #1860 from kubernetes-incubator/feature/v0.16.x-enable-pod-autoscaler
[v0.16.0] Allow use of PodAutoscalerUseRestClient without addon metrics-server.
2 parents 6d2fee1 + 28b4eb5 commit 062740b

File tree

5 files changed

+86
-10
lines changed

5 files changed

+86
-10
lines changed

builtin/files/cluster.yaml.tmpl

+4
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,10 @@ kubernetes:
11661166
encryptionAtRest:
11671167
enabled: false
11681168

1169+
# Tells Kubernetes to enable the autoscaler rest client (not using heapster) without the requirement to use metrics-server.
1170+
podAutoscalerUseRestClient:
1171+
enabled: false
1172+
11691173
# controllerManager:
11701174
# resources:
11711175
# requests:

builtin/files/userdata/cloud-config-controller

+1-1
Original file line numberDiff line numberDiff line change
@@ -3569,7 +3569,7 @@ write_files:
35693569
- --configure-cloud-routes=false
35703570
{{ end -}}
35713571
- --service-cluster-ip-range={{.ServiceCIDR}} {{/* removes the service CIDR range from the cluster CIDR if it intersects */}}
3572-
{{ if not .Addons.MetricsServer.Enabled -}}
3572+
{{ if and (not .Addons.MetricsServer.Enabled) (not .Kubernetes.PodAutoscalerUseRestClient.Enabled) -}}
35733573
- --horizontal-pod-autoscaler-use-rest-clients=false
35743574
{{end}}
35753575
{{range $f := .ControllerFlags -}}

pkg/api/kubernetes.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package api
22

33
type Kubernetes struct {
4-
Authentication KubernetesAuthentication `yaml:"authentication"`
5-
EncryptionAtRest EncryptionAtRest `yaml:"encryptionAtRest"`
6-
Networking Networking `yaml:"networking,omitempty"`
7-
ControllerManager ControllerManager `yaml:"controllerManager,omitempty"`
8-
KubeScheduler KubeScheduler `yaml:"kubeScheduler,omitempty"`
9-
KubeProxy KubeProxy `yaml:"kubeProxy,omitempty"`
10-
KubeApiServer KubeApiServer `yaml:"apiServer,omitempty"`
11-
Kubelet Kubelet `yaml:"kubelet,omitempty"`
12-
APIServer KubernetesAPIServer `yaml:"apiserver,omitempty"`
4+
Authentication KubernetesAuthentication `yaml:"authentication"`
5+
EncryptionAtRest EncryptionAtRest `yaml:"encryptionAtRest"`
6+
PodAutoscalerUseRestClient PodAutoscalerUseRestClient `yaml:"podAutoscalerUseRestClient"`
7+
Networking Networking `yaml:"networking,omitempty"`
8+
ControllerManager ControllerManager `yaml:"controllerManager,omitempty"`
9+
KubeScheduler KubeScheduler `yaml:"kubeScheduler,omitempty"`
10+
KubeProxy KubeProxy `yaml:"kubeProxy,omitempty"`
11+
KubeApiServer KubeApiServer `yaml:"apiServer,omitempty"`
12+
Kubelet Kubelet `yaml:"kubelet,omitempty"`
13+
APIServer KubernetesAPIServer `yaml:"apiserver,omitempty"`
1314

1415
// Manifests is a list of manifests to be installed to the cluster.
1516
// Note that the list is sorted by their names by kube-aws so that it won't result in unnecessarily node replacements.

pkg/api/types.go

+4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ type EncryptionAtRest struct {
113113
Enabled bool `yaml:"enabled"`
114114
}
115115

116+
type PodAutoscalerUseRestClient struct {
117+
Enabled bool `yaml:"enabled"`
118+
}
119+
116120
type EphemeralImageStorage struct {
117121
Enabled bool `yaml:"enabled"`
118122
Disk string `yaml:"disk"`

pkg/model/cluster_test.go

+67
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,73 @@ encryptionAtRest:
10591059
}
10601060
}
10611061

1062+
func TestPodAutoscalerUseRestClientConfig(t *testing.T) {
1063+
validConfigs := []struct {
1064+
conf string
1065+
podAutoscalerUseRestClient api.PodAutoscalerUseRestClient
1066+
}{
1067+
{
1068+
conf: `
1069+
`,
1070+
podAutoscalerUseRestClient: api.PodAutoscalerUseRestClient{
1071+
Enabled: false,
1072+
},
1073+
},
1074+
{
1075+
conf: `
1076+
kubernetes:
1077+
podAutoscalerUseRestClient:
1078+
enabled: false
1079+
`,
1080+
podAutoscalerUseRestClient: api.PodAutoscalerUseRestClient{
1081+
Enabled: false,
1082+
},
1083+
},
1084+
{
1085+
conf: `
1086+
kubernetes:
1087+
podAutoscalerUseRestClient:
1088+
enabled: true
1089+
`,
1090+
podAutoscalerUseRestClient: api.PodAutoscalerUseRestClient{
1091+
Enabled: true,
1092+
},
1093+
},
1094+
{
1095+
conf: `
1096+
# Settings for an experimental feature must be under the "experimental" field. Ignored.
1097+
podAutoscalerUseRestClient:
1098+
enabled: true
1099+
`,
1100+
podAutoscalerUseRestClient: api.PodAutoscalerUseRestClient{
1101+
Enabled: false,
1102+
},
1103+
},
1104+
}
1105+
1106+
for _, conf := range validConfigs {
1107+
confBody := singleAzConfigYaml + conf.conf
1108+
c, err := ClusterFromBytes([]byte(confBody))
1109+
if err != nil {
1110+
y, err2 := json.MarshalIndent(c, "", " ")
1111+
if err2 != nil {
1112+
t.Errorf("%v", err2)
1113+
t.FailNow()
1114+
}
1115+
t.Logf("%s", string(y))
1116+
t.Errorf("failed to parse config: %v:\n%s", err, confBody)
1117+
continue
1118+
}
1119+
if !reflect.DeepEqual(c.Kubernetes.PodAutoscalerUseRestClient, conf.podAutoscalerUseRestClient) {
1120+
t.Errorf(
1121+
"parsed encryption at rest settings %+v does not match config: %s",
1122+
c.Kubernetes.PodAutoscalerUseRestClient,
1123+
confBody,
1124+
)
1125+
}
1126+
}
1127+
}
1128+
10621129
func TestKubeletReserved(t *testing.T) {
10631130

10641131
validConfigs := []struct {

0 commit comments

Comments
 (0)