This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generic controller-manager config (#1960)
* wip generic controller-manager config * clean up tests * controller-manager yaml uses controllerManagerConfig * array command usage for controller-manager yaml * more rebase fun * dispatch --route-reconciliation-period to cloud controller manager * 1 fix and 2 cleanups - actually using passed-in *api.KubernetesConfig reference in GetControllerManagerConfigKeyVals() - removing unnecessary validations for both controller manager and kubelet
- Loading branch information
1 parent
2137719
commit 39081b8
Showing
25 changed files
with
672 additions
and
2,926 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package acsengine | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/Azure/acs-engine/pkg/api" | ||
) | ||
|
||
func setControllerManagerConfig(cs *api.ContainerService) { | ||
o := cs.Properties.OrchestratorProfile | ||
staticLinuxControllerManagerConfig := map[string]string{ | ||
"--kubeconfig": "/var/lib/kubelet/kubeconfig", | ||
"--allocate-node-cidrs": strconv.FormatBool(!o.IsAzureCNI()), | ||
"--cluster-cidr": o.KubernetesConfig.ClusterSubnet, | ||
"--cloud-provider": "azure", | ||
"--cloud-config": "/etc/kubernetes/azure.json", | ||
"--root-ca-file": "/etc/kubernetes/certs/ca.crt", | ||
"--cluster-signing-cert-file": "/etc/kubernetes/certs/ca.crt", | ||
"--cluster-signing-key-file": "/etc/kubernetes/certs/ca.key", | ||
"--service-account-private-key-file": "/etc/kubernetes/certs/apiserver.key", | ||
"--leader-elect": "true", | ||
"--v": "2", | ||
"--profiling": "False", | ||
} | ||
|
||
// Set --cluster-name based on appropriate DNS prefix | ||
if cs.Properties.MasterProfile != nil { | ||
staticLinuxControllerManagerConfig["--cluster-name"] = cs.Properties.MasterProfile.DNSPrefix | ||
} else if cs.Properties.HostedMasterProfile != nil { | ||
staticLinuxControllerManagerConfig["--cluster-name"] = cs.Properties.HostedMasterProfile.DNSPrefix | ||
} | ||
|
||
staticWindowsControllerManagerConfig := make(map[string]string) | ||
for key, val := range staticLinuxControllerManagerConfig { | ||
staticWindowsControllerManagerConfig[key] = val | ||
} | ||
// Windows controller-manager config overrides | ||
// TODO placeholder for specific config overrides for Windows clusters | ||
|
||
// Default controller-manager config | ||
defaultControllerManagerConfig := map[string]string{ | ||
"--node-monitor-grace-period": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod, | ||
"--pod-eviction-timeout": DefaultKubernetesCtrlMgrPodEvictionTimeout, | ||
"--route-reconciliation-period": DefaultKubernetesCtrlMgrRouteReconciliationPeriod, | ||
} | ||
|
||
// If no user-configurable controller-manager config values exists, use the defaults | ||
if o.KubernetesConfig.ControllerManagerConfig == nil { | ||
o.KubernetesConfig.ControllerManagerConfig = defaultControllerManagerConfig | ||
} else { | ||
for key, val := range defaultControllerManagerConfig { | ||
// If we don't have a user-configurable controller-manager config for each option | ||
if _, ok := o.KubernetesConfig.ControllerManagerConfig[key]; !ok { | ||
// then assign the default value | ||
o.KubernetesConfig.ControllerManagerConfig[key] = val | ||
} | ||
} | ||
} | ||
|
||
// We don't support user-configurable values for the following, | ||
// so any of the value assignments below will override user-provided values | ||
var overrideControllerManagerConfig map[string]string | ||
if cs.Properties.HasWindows() { | ||
overrideControllerManagerConfig = staticWindowsControllerManagerConfig | ||
} else { | ||
overrideControllerManagerConfig = staticLinuxControllerManagerConfig | ||
} | ||
for key, val := range overrideControllerManagerConfig { | ||
o.KubernetesConfig.ControllerManagerConfig[key] = val | ||
} | ||
|
||
if *o.KubernetesConfig.EnableRbac { | ||
o.KubernetesConfig.ControllerManagerConfig["--use-service-account-credentials"] = "true" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package acsengine | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/Azure/acs-engine/pkg/api" | ||
"github.com/Azure/acs-engine/pkg/helpers" | ||
) | ||
|
||
func setKubeletConfig(cs *api.ContainerService) { | ||
o := cs.Properties.OrchestratorProfile | ||
cloudSpecConfig := GetCloudSpecConfig(cs.Location) | ||
staticLinuxKubeletConfig := map[string]string{ | ||
"--address": "0.0.0.0", | ||
"--allow-privileged": "true", | ||
"--pod-manifest-path": "/etc/kubernetes/manifests", | ||
"--cloud-config": "/etc/kubernetes/azure.json", | ||
"--cluster-domain": "cluster.local", | ||
"--cluster-dns": DefaultKubernetesDNSServiceIP, | ||
"--cgroups-per-qos": "false", | ||
"--enforce-node-allocatable": "", | ||
"--kubeconfig": "/var/lib/kubelet/kubeconfig", | ||
"--azure-container-registry-config": "/etc/kubernetes/azure.json", | ||
} | ||
|
||
staticWindowsKubeletConfig := make(map[string]string) | ||
for key, val := range staticLinuxKubeletConfig { | ||
staticWindowsKubeletConfig[key] = val | ||
} | ||
// Windows kubelet config overrides | ||
staticWindowsKubeletConfig["--network-plugin"] = NetworkPluginKubenet | ||
|
||
// Default Kubelet config | ||
defaultKubeletConfig := map[string]string{ | ||
"--network-plugin": "cni", | ||
"--pod-infra-container-image": cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[o.OrchestratorVersion]["pause"], | ||
"--max-pods": strconv.Itoa(DefaultKubernetesKubeletMaxPods), | ||
"--eviction-hard": DefaultKubernetesHardEvictionThreshold, | ||
"--node-status-update-frequency": KubeConfigs[o.OrchestratorVersion]["nodestatusfreq"], | ||
"--image-gc-high-threshold": strconv.Itoa(DefaultKubernetesGCHighThreshold), | ||
"--image-gc-low-threshold": strconv.Itoa(DefaultKubernetesGCLowThreshold), | ||
"--non-masquerade-cidr": DefaultNonMasqueradeCidr, | ||
"--cloud-provider": "azure", | ||
} | ||
|
||
// If no user-configurable kubelet config values exists, use the defaults | ||
setMissingKubeletValues(o.KubernetesConfig, defaultKubeletConfig) | ||
|
||
// Override default cloud-provider? | ||
if helpers.IsTrueBoolPointer(o.KubernetesConfig.UseCloudControllerManager) { | ||
staticLinuxKubeletConfig["--cloud-provider"] = "external" | ||
} | ||
|
||
// Override default --network-plugin? | ||
if o.KubernetesConfig.NetworkPolicy == NetworkPolicyNone { | ||
o.KubernetesConfig.KubeletConfig["--network-plugin"] = NetworkPluginKubenet | ||
} | ||
|
||
// We don't support user-configurable values for the following, | ||
// so any of the value assignments below will override user-provided values | ||
var overrideKubeletConfig map[string]string | ||
if cs.Properties.HasWindows() { | ||
overrideKubeletConfig = staticWindowsKubeletConfig | ||
} else { | ||
overrideKubeletConfig = staticLinuxKubeletConfig | ||
} | ||
for key, val := range overrideKubeletConfig { | ||
o.KubernetesConfig.KubeletConfig[key] = val | ||
} | ||
|
||
// Get rid of values not supported in v1.5 clusters | ||
if !isKubernetesVersionGe(o.OrchestratorVersion, "1.6.0") { | ||
for _, key := range []string{"--non-masquerade-cidr", "--cgroups-per-qos", "--enforce-node-allocatable"} { | ||
delete(o.KubernetesConfig.KubeletConfig, key) | ||
} | ||
} | ||
|
||
// Master-specific kubelet config changes go here | ||
if cs.Properties.MasterProfile != nil { | ||
if cs.Properties.MasterProfile.KubernetesConfig == nil { | ||
cs.Properties.MasterProfile.KubernetesConfig = &api.KubernetesConfig{} | ||
} | ||
setMissingKubeletValues(cs.Properties.MasterProfile.KubernetesConfig, o.KubernetesConfig.KubeletConfig) | ||
} | ||
// Agent-specific kubelet config changes go here | ||
for _, profile := range cs.Properties.AgentPoolProfiles { | ||
if profile.KubernetesConfig == nil { | ||
profile.KubernetesConfig = &api.KubernetesConfig{} | ||
} | ||
setMissingKubeletValues(profile.KubernetesConfig, o.KubernetesConfig.KubeletConfig) | ||
} | ||
} | ||
|
||
func setMissingKubeletValues(p *api.KubernetesConfig, d map[string]string) { | ||
if p.KubeletConfig == nil { | ||
p.KubeletConfig = d | ||
} else { | ||
for key, val := range d { | ||
// If we don't have a user-configurable value for each option | ||
if _, ok := p.KubeletConfig[key]; !ok { | ||
// then assign the default value | ||
p.KubeletConfig[key] = val | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.