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
Generic controller-manager config #1960
Merged
jackfrancis
merged 7 commits into
Azure:master
from
jackfrancis:generic-controller-manager
Dec 22, 2017
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4a7e957
wip generic controller-manager config
jackfrancis 0e88054
clean up tests
jackfrancis e6b1b83
controller-manager yaml uses controllerManagerConfig
jackfrancis 8a3fef4
array command usage for controller-manager yaml
jackfrancis 9a00460
more rebase fun
jackfrancis a0a3d06
dispatch --route-reconciliation-period to cloud controller manager
jackfrancis 6f52628
1 fix and 2 cleanups
jackfrancis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since o.KubernetesConfig.ControllerManagerConfig is now exposed to user, it looks we allow user to define other configs beyond the list below (default + static + rbac) but in https://kubernetes.io/docs/reference/generated/kube-controller-manager/ . Do we want to support this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what this statement in the doc update supports: