diff --git a/pkg/acsengine/defaults-kubelet.go b/pkg/acsengine/defaults-kubelet.go index 173dd49da..df5b6cfae 100644 --- a/pkg/acsengine/defaults-kubelet.go +++ b/pkg/acsengine/defaults-kubelet.go @@ -36,7 +36,7 @@ func setKubeletConfig(cs *api.ContainerService) { "--cluster-domain": "cluster.local", "--network-plugin": "cni", "--pod-infra-container-image": cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[o.OrchestratorVersion]["pause"], - "--max-pods": strconv.Itoa(DefaultKubernetesMaxPodsVNETIntegrated), + "--max-pods": strconv.Itoa(DefaultKubernetesMaxPods), "--eviction-hard": DefaultKubernetesHardEvictionThreshold, "--node-status-update-frequency": KubeConfigs[o.OrchestratorVersion]["nodestatusfreq"], "--image-gc-high-threshold": strconv.Itoa(DefaultKubernetesGCHighThreshold), @@ -51,6 +51,11 @@ func setKubeletConfig(cs *api.ContainerService) { "--image-pull-progress-deadline": "30m", } + // Apply Azure CNI-specific --max-pods value + if o.KubernetesConfig.NetworkPlugin == NetworkPluginAzure { + defaultKubeletConfig["--max-pods"] = strconv.Itoa(DefaultKubernetesMaxPodsVNETIntegrated) + } + // If no user-configurable kubelet config values exists, use the defaults setMissingKubeletValues(o.KubernetesConfig, defaultKubeletConfig) addDefaultFeatureGates(o.KubernetesConfig.KubeletConfig, o.OrchestratorVersion, "", "") @@ -65,7 +70,6 @@ func setKubeletConfig(cs *api.ContainerService) { if o.KubernetesConfig.NetworkPolicy != NetworkPolicyCalico { o.KubernetesConfig.KubeletConfig["--network-plugin"] = NetworkPluginKubenet } - o.KubernetesConfig.KubeletConfig["--max-pods"] = strconv.Itoa(DefaultKubernetesMaxPods) } // We don't support user-configurable values for the following, diff --git a/pkg/acsengine/defaults-kubelet_test.go b/pkg/acsengine/defaults-kubelet_test.go index b2c51d78c..72945a47b 100644 --- a/pkg/acsengine/defaults-kubelet_test.go +++ b/pkg/acsengine/defaults-kubelet_test.go @@ -175,6 +175,27 @@ func TestKubeletMaxPods(t *testing.T) { t.Fatalf("got unexpected '--max-pods' kubelet config value for NetworkPolicy=%s: %s", NetworkPluginKubenet, k["--max-pods"]) } + + // Test that user-overrides for --max-pods work as intended + cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false) + cs.Properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = NetworkPluginKubenet + cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig["--max-pods"] = "99" + setKubeletConfig(cs) + k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig + if k["--max-pods"] != "99" { + t.Fatalf("got unexpected '--max-pods' kubelet config value for NetworkPolicy=%s: %s", + NetworkPluginKubenet, k["--max-pods"]) + } + + cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false) + cs.Properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = NetworkPluginAzure + cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig["--max-pods"] = "99" + setKubeletConfig(cs) + k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig + if k["--max-pods"] != "99" { + t.Fatalf("got unexpected '--max-pods' kubelet config value for NetworkPolicy=%s: %s", + NetworkPluginKubenet, k["--max-pods"]) + } } func TestKubeletCalico(t *testing.T) { diff --git a/pkg/api/convertertoagentpoolonlyapi.go b/pkg/api/convertertoagentpoolonlyapi.go index df6e21920..2bb67319c 100644 --- a/pkg/api/convertertoagentpoolonlyapi.go +++ b/pkg/api/convertertoagentpoolonlyapi.go @@ -487,11 +487,10 @@ func convertV20180331AgentPoolOnlyAgentPoolProfile(agentPoolProfile *v20180331.A var maxPods string // agentPoolProfile.MaxPods is 0 if maxPods field is not provided in API model if agentPoolProfile.MaxPods == nil { - // default is kubenet - if networkProfile == nil || networkProfile.NetworkPlugin == v20180331.Kubenet { - maxPods = DefaultKubernetesMaxPodsKubenet - } else { + if networkProfile != nil && networkProfile.NetworkPlugin == v20180331.Azure { maxPods = DefaultKubernetesMaxPodsAzureCNI + } else { + maxPods = DefaultKubernetesMaxPodsKubenet } } else { maxPods = strconv.Itoa(*agentPoolProfile.MaxPods)