Skip to content

Commit

Permalink
fix: remove invalid k8s v1.24 flags (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
christinalau0 authored Mar 16, 2023
1 parent f35444d commit 72f8473
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 12 deletions.
8 changes: 8 additions & 0 deletions pkg/api/defaults-apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ func (cs *ContainerService) setAPIServerConfig() {
delete(o.KubernetesConfig.APIServerConfig, key)
}

if common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.24.0") {
// https://github.com/kubernetes/kubernetes/pull/106859
removedFlags124 := []string{"--address", "--insecure-bind-address", "--port", "--insecure-port"}
for _, key := range removedFlags124 {
delete(o.KubernetesConfig.APIServerConfig, key)
}
}

if common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.25.0") {
// https://github.com/kubernetes/kubernetes/pull/108624
removedFlags125 := []string{"--service-account-api-audiences"}
Expand Down
52 changes: 40 additions & 12 deletions pkg/api/defaults-apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,18 +658,6 @@ func TestAPIServerInsecureFlag(t *testing.T) {
version: "1.23.0",
found: false,
},
{
version: "1.24.0",
found: false,
},
{
version: "1.24.0-alpha.0",
found: false,
},
{
version: "1.24.0-alpha.1-24",
found: false,
},
}

for _, tt := range apiTests {
Expand All @@ -688,6 +676,46 @@ func TestAPIServerInsecureFlag(t *testing.T) {
}
}

apiTestsForceDelete := []apiServerTest{
{
version: "1.23.0",
found: true,
},
{
version: "1.24.0",
found: false,
},
}

for _, tt := range apiTestsForceDelete {
cs := CreateMockContainerService("testcluster", tt.version, 3, 2, false)
cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig = map[string]string{
"--address": "0.0.0.0",
"--insecure-bind-address": "0.0.0.0",
"--port": "443",
"--insecure-port": "0",
}
cs.setAPIServerConfig()
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig

_, found := a["--address"]
if found != tt.found {
t.Fatalf("got --address found %t want %t", found, tt.found)
}
_, found = a["--insecure-bind-address"]
if found != tt.found {
t.Fatalf("got --insecure-bind-address found %t want %t", found, tt.found)
}
_, found = a["--port"]
if found != tt.found {
t.Fatalf("got --port found %t want %t", found, tt.found)
}
_, found = a["--insecure-port"]
if found != tt.found {
t.Fatalf("got --insecure-port found %t want %t", found, tt.found)
}
}

}

func TestAPIServerIPv6Only(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions pkg/api/defaults-controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ func (cs *ContainerService) setControllerManagerConfig() {
}
}

if common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.24.0") {
// https://github.com/kubernetes/kubernetes/pull/106860
removedFlags124 := []string{"--address", "--port"}
for _, key := range removedFlags124 {
delete(o.KubernetesConfig.ControllerManagerConfig, key)
}
}

if common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.25.0") {
// https://github.com/kubernetes/kubernetes/pull/109612
removedFlags125 := []string{"--deleting-pods-qps", "--deleting-pods-burst", "--register-retry-count"}
Expand Down
38 changes: 38 additions & 0 deletions pkg/api/defaults-controller-manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,41 @@ func TestControllerManagerDefaultConfig(t *testing.T) {
t.Fatalf("expected controller-manager to have route-reconciliation-period set to its default value")
}
}

func TestControllerManagerInsecureFlag(t *testing.T) {
type controllerManagerTest struct {
version string
found bool
}

controllerManagerTestsForceDelete := []controllerManagerTest{
{
version: "1.23.0",
found: true,
},
{
version: "1.24.0",
found: false,
},
}

for _, tt := range controllerManagerTestsForceDelete {
cs := CreateMockContainerService("testcluster", tt.version, 3, 2, false)
cs.Properties.OrchestratorProfile.KubernetesConfig.ControllerManagerConfig = map[string]string{
"--address": "0.0.0.0",
"--port": "443",
}
cs.setControllerManagerConfig()
a := cs.Properties.OrchestratorProfile.KubernetesConfig.ControllerManagerConfig

_, found := a["--address"]
if found != tt.found {
t.Fatalf("got --address found %t want %t", found, tt.found)
}
_, found = a["--port"]
if found != tt.found {
t.Fatalf("got --port found %t want %t", found, tt.found)
}
}

}

0 comments on commit 72f8473

Please sign in to comment.