Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Kubernetes: --max-pods=30 should be Azure CNI-only #3543

Merged
merged 5 commits into from
Jul 25, 2018
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
8 changes: 6 additions & 2 deletions pkg/acsengine/defaults-kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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, "", "")
Expand All @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions pkg/acsengine/defaults-kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions pkg/api/convertertoagentpoolonlyapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down