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

[v0.16.0] Allow use of PodAutoscalerUseRestClient without addon metrics-server. #1860

Merged
merged 1 commit into from
May 27, 2020
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
4 changes: 4 additions & 0 deletions builtin/files/cluster.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,10 @@ kubernetes:
encryptionAtRest:
enabled: false

# Tells Kubernetes to enable the autoscaler rest client (not using heapster) without the requirement to use metrics-server.
podAutoscalerUseRestClient:
enabled: false

# controllerManager:
# resources:
# requests:
Expand Down
2 changes: 1 addition & 1 deletion builtin/files/userdata/cloud-config-controller
Original file line number Diff line number Diff line change
Expand Up @@ -3569,7 +3569,7 @@ write_files:
- --configure-cloud-routes=false
{{ end -}}
- --service-cluster-ip-range={{.ServiceCIDR}} {{/* removes the service CIDR range from the cluster CIDR if it intersects */}}
{{ if not .Addons.MetricsServer.Enabled -}}
{{ if and (not .Addons.MetricsServer.Enabled) (not .Kubernetes.PodAutoscalerUseRestClient.Enabled) -}}
- --horizontal-pod-autoscaler-use-rest-clients=false
{{end}}
{{range $f := .ControllerFlags -}}
Expand Down
19 changes: 10 additions & 9 deletions pkg/api/kubernetes.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package api

type Kubernetes struct {
Authentication KubernetesAuthentication `yaml:"authentication"`
EncryptionAtRest EncryptionAtRest `yaml:"encryptionAtRest"`
Networking Networking `yaml:"networking,omitempty"`
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"`
Authentication KubernetesAuthentication `yaml:"authentication"`
EncryptionAtRest EncryptionAtRest `yaml:"encryptionAtRest"`
PodAutoscalerUseRestClient PodAutoscalerUseRestClient `yaml:"podAutoscalerUseRestClient"`
Networking Networking `yaml:"networking,omitempty"`
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"`

// Manifests is a list of manifests to be installed to the cluster.
// Note that the list is sorted by their names by kube-aws so that it won't result in unnecessarily node replacements.
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ type EncryptionAtRest struct {
Enabled bool `yaml:"enabled"`
}

type PodAutoscalerUseRestClient struct {
Enabled bool `yaml:"enabled"`
}

type EphemeralImageStorage struct {
Enabled bool `yaml:"enabled"`
Disk string `yaml:"disk"`
Expand Down
67 changes: 67 additions & 0 deletions pkg/model/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,73 @@ encryptionAtRest:
}
}

func TestPodAutoscalerUseRestClientConfig(t *testing.T) {
validConfigs := []struct {
conf string
podAutoscalerUseRestClient api.PodAutoscalerUseRestClient
}{
{
conf: `
`,
podAutoscalerUseRestClient: api.PodAutoscalerUseRestClient{
Enabled: false,
},
},
{
conf: `
kubernetes:
podAutoscalerUseRestClient:
enabled: false
`,
podAutoscalerUseRestClient: api.PodAutoscalerUseRestClient{
Enabled: false,
},
},
{
conf: `
kubernetes:
podAutoscalerUseRestClient:
enabled: true
`,
podAutoscalerUseRestClient: api.PodAutoscalerUseRestClient{
Enabled: true,
},
},
{
conf: `
# Settings for an experimental feature must be under the "experimental" field. Ignored.
podAutoscalerUseRestClient:
enabled: true
`,
podAutoscalerUseRestClient: api.PodAutoscalerUseRestClient{
Enabled: false,
},
},
}

for _, conf := range validConfigs {
confBody := singleAzConfigYaml + conf.conf
c, err := ClusterFromBytes([]byte(confBody))
if err != nil {
y, err2 := json.MarshalIndent(c, "", " ")
if err2 != nil {
t.Errorf("%v", err2)
t.FailNow()
}
t.Logf("%s", string(y))
t.Errorf("failed to parse config: %v:\n%s", err, confBody)
continue
}
if !reflect.DeepEqual(c.Kubernetes.PodAutoscalerUseRestClient, conf.podAutoscalerUseRestClient) {
t.Errorf(
"parsed encryption at rest settings %+v does not match config: %s",
c.Kubernetes.PodAutoscalerUseRestClient,
confBody,
)
}
}
}

func TestKubeletReserved(t *testing.T) {

validConfigs := []struct {
Expand Down