-
Notifications
You must be signed in to change notification settings - Fork 554
Generic cloud-controller-manager config interface #2017
Changes from all commits
4a2006a
e092c04
0472fd0
0af1456
2b4aa8e
77f6a77
5ee007e
e77d62f
0832780
fdd9c8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| { | ||
| "apiVersion": "vlabs", | ||
| "properties": { | ||
| "orchestratorProfile": { | ||
| "orchestratorType": "Kubernetes", | ||
| "orchestratorRelease": "1.8", | ||
| "kubernetesConfig": { | ||
| "useCloudControllerManager": true | ||
| } | ||
| }, | ||
| "masterProfile": { | ||
| "count": 1, | ||
| "dnsPrefix": "", | ||
| "vmSize": "Standard_D2_v2" | ||
| }, | ||
| "agentPoolProfiles": [ | ||
| { | ||
| "name": "agentpool1", | ||
| "count": 3, | ||
| "vmSize": "Standard_D2_v2", | ||
| "availabilityProfile": "AvailabilitySet" | ||
| } | ||
| ], | ||
| "linuxProfile": { | ||
| "adminUsername": "azureUser", | ||
| "ssh": { | ||
| "publicKeys": [ | ||
| { | ||
| "keyData": "" | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "servicePrincipalProfile": { | ||
| "clientId": "", | ||
| "secret": "" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package acsengine | ||
|
|
||
| import ( | ||
| "strconv" | ||
|
|
||
| "github.com/Azure/acs-engine/pkg/api" | ||
| ) | ||
|
|
||
| func setCloudControllerManagerConfig(cs *api.ContainerService) { | ||
| o := cs.Properties.OrchestratorProfile | ||
| staticLinuxCloudControllerManagerConfig := map[string]string{ | ||
| "--allocate-node-cidrs": strconv.FormatBool(!o.IsAzureCNI()), | ||
| "--cloud-provider": "azure", | ||
| "--cloud-config": "/etc/kubernetes/azure.json", | ||
| "--cluster-cidr": o.KubernetesConfig.ClusterSubnet, | ||
| "--kubeconfig": "/var/lib/kubelet/kubeconfig", | ||
| "--leader-elect": "true", | ||
| "--v": "2", | ||
| } | ||
|
|
||
| // Set --cluster-name based on appropriate DNS prefix | ||
| if cs.Properties.MasterProfile != nil { | ||
| staticLinuxCloudControllerManagerConfig["--cluster-name"] = cs.Properties.MasterProfile.DNSPrefix | ||
| } else if cs.Properties.HostedMasterProfile != nil { | ||
| staticLinuxCloudControllerManagerConfig["--cluster-name"] = cs.Properties.HostedMasterProfile.DNSPrefix | ||
| } | ||
|
|
||
| staticWindowsCloudControllerManagerConfig := make(map[string]string) | ||
| for key, val := range staticLinuxCloudControllerManagerConfig { | ||
| staticWindowsCloudControllerManagerConfig[key] = val | ||
| } | ||
| // Windows cloud-controller-manager config overrides | ||
| // TODO placeholder for specific config overrides for Windows clusters | ||
|
|
||
| // Default cloud-controller-manager config | ||
| defaultCloudControllerManagerConfig := map[string]string{ | ||
| "--node-monitor-grace-period": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the md file, the default is "--route-reconciliation-period", a typo?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! Actually, the doc is correct, it's an error in the |
||
| } | ||
|
|
||
| // If no user-configurable cloud-controller-manager config values exists, use the defaults | ||
| if o.KubernetesConfig.CloudControllerManagerConfig == nil { | ||
| o.KubernetesConfig.CloudControllerManagerConfig = defaultCloudControllerManagerConfig | ||
| } else { | ||
| for key, val := range defaultCloudControllerManagerConfig { | ||
| // If we don't have a user-configurable cloud-controller-manager config for each option | ||
| if _, ok := o.KubernetesConfig.CloudControllerManagerConfig[key]; !ok { | ||
| // then assign the default value | ||
| o.KubernetesConfig.CloudControllerManagerConfig[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 overrideCloudControllerManagerConfig map[string]string | ||
| if cs.Properties.HasWindows() { | ||
| overrideCloudControllerManagerConfig = staticWindowsCloudControllerManagerConfig | ||
| } else { | ||
| overrideCloudControllerManagerConfig = staticLinuxCloudControllerManagerConfig | ||
| } | ||
| for key, val := range overrideCloudControllerManagerConfig { | ||
| o.KubernetesConfig.CloudControllerManagerConfig[key] = val | ||
| } | ||
|
|
||
| // TODO add RBAC support | ||
| /*if *o.KubernetesConfig.EnableRbac { | ||
| o.KubernetesConfig.CloudControllerManagerConfig["--use-service-account-credentials"] = "true" | ||
| }*/ | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -512,7 +512,7 @@ func getParameters(cs *api.ContainerService, isClassicMode bool, generatorCode s | |
| addValue(parametersMap, "kubernetesEndpoint", properties.HostedMasterProfile.FQDN) | ||
| } | ||
|
|
||
| if properties.OrchestratorProfile.KubernetesConfig.UseCloudControllerManager != nil && *properties.OrchestratorProfile.KubernetesConfig.UseCloudControllerManager { | ||
| if helpers.IsTrueBoolPointer(properties.OrchestratorProfile.KubernetesConfig.UseCloudControllerManager) { | ||
| kubernetesCcmSpec := properties.OrchestratorProfile.KubernetesConfig.KubernetesImageBase + KubeConfigs[k8sVersion]["ccm"] | ||
| if properties.OrchestratorProfile.KubernetesConfig.CustomCcmImage != "" { | ||
| kubernetesCcmSpec = properties.OrchestratorProfile.KubernetesConfig.CustomCcmImage | ||
|
|
@@ -872,6 +872,20 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat | |
| } | ||
| return strings.TrimSuffix(buf.String(), ", ") | ||
| }, | ||
| "GetCloudControllerManagerConfigKeyVals": func(kc *api.KubernetesConfig) string { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary to pass in the KubernetesConfig here? For distinct agent/master configs it needs to be passed in but since this looks like it's using the orchestratorProfile's kubernetesConfig here you could also use cs.Properties.OrchestratorProfile.KubernetesConfig since the getTemplateFuncMap gets passed in a ContainerService
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm actually planning to submit a follow-up PR that generalizes the getter function so that it works on |
||
| cloudControllerManagerConfig := kc.CloudControllerManagerConfig | ||
| // Order by key for consistency | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this starts getting repeated in more configs (it's already in GetControllerManagerConfigKeyVals, GetKubeletConfigKeyVals and GetApiServerConfigKeyVals) maybe it's time to extract it to a function
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yes! What I said above. |
||
| keys := []string{} | ||
| for key := range cloudControllerManagerConfig { | ||
| keys = append(keys, key) | ||
| } | ||
| sort.Strings(keys) | ||
| var buf bytes.Buffer | ||
| for _, key := range keys { | ||
| buf.WriteString(fmt.Sprintf("\\\"%s=%s\\\", ", key, cloudControllerManagerConfig[key])) | ||
| } | ||
| return strings.TrimSuffix(buf.String(), ", ") | ||
| }, | ||
| "GetAPIServerConfigKeyVals": func(kc *api.KubernetesConfig) string { | ||
| apiServerConfig := kc.APIServerConfig | ||
| // Order by key for consistency | ||
|
|
||
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.
Might be beneficial to put a CloudControllerManagerConfig field here for reference
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.
I'm not sure I want to encourage someone to use this yet until we spend some time testing various custom configurations that actually work! :)