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

Kubernetes: Remove Windows-specific foo for control plane config #3240

Merged
merged 2 commits into from
Jun 20, 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
34 changes: 8 additions & 26 deletions pkg/acsengine/defaults-apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func setAPIServerConfig(cs *api.ContainerService) {
o := cs.Properties.OrchestratorProfile
staticLinuxAPIServerConfig := map[string]string{
staticAPIServerConfig := map[string]string{
"--bind-address": "0.0.0.0",
"--advertise-address": "<kubernetesAPIServerIP>",
"--allow-privileged": "true",
Expand All @@ -36,28 +36,16 @@ func setAPIServerConfig(cs *api.ContainerService) {
"--v": "4",
}

// Windows apiserver config overrides
// TODO placeholder for specific config overrides for Windows clusters
staticWindowsAPIServerConfig := make(map[string]string)
for key, val := range staticLinuxAPIServerConfig {
staticWindowsAPIServerConfig[key] = val
}

// Default apiserver config
defaultAPIServerConfig := map[string]string{
"--audit-log-maxage": "30",
"--audit-log-maxbackup": "10",
"--audit-log-maxsize": "100",
}

// Data Encryption at REST configuration
if helpers.IsTrueBoolPointer(o.KubernetesConfig.EnableDataEncryptionAtRest) {
staticLinuxAPIServerConfig["--experimental-encryption-provider-config"] = "/etc/kubernetes/encryption-config.yaml"
}

// Data Encryption at REST with external KMS configuration
if helpers.IsTrueBoolPointer(o.KubernetesConfig.EnableEncryptionWithExternalKms) {
staticLinuxAPIServerConfig["--experimental-encryption-provider-config"] = "/etc/kubernetes/encryption-config.yaml"
// Data Encryption at REST configuration conditions
if helpers.IsTrueBoolPointer(o.KubernetesConfig.EnableDataEncryptionAtRest) || helpers.IsTrueBoolPointer(o.KubernetesConfig.EnableEncryptionWithExternalKms) {
staticAPIServerConfig["--experimental-encryption-provider-config"] = "/etc/kubernetes/encryption-config.yaml"
}

// Aggregated API configuration
Expand All @@ -73,8 +61,8 @@ func setAPIServerConfig(cs *api.ContainerService) {

// Enable cloudprovider if we're not using cloud controller manager
if !helpers.IsTrueBoolPointer(o.KubernetesConfig.UseCloudControllerManager) {
staticLinuxAPIServerConfig["--cloud-provider"] = "azure"
staticLinuxAPIServerConfig["--cloud-config"] = "/etc/kubernetes/azure.json"
staticAPIServerConfig["--cloud-provider"] = "azure"
staticAPIServerConfig["--cloud-config"] = "/etc/kubernetes/azure.json"
}

// AAD configuration
Expand All @@ -91,7 +79,7 @@ func setAPIServerConfig(cs *api.ContainerService) {

// Audit Policy configuration
if common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.8.0") {
staticLinuxAPIServerConfig["--audit-policy-file"] = "/etc/kubernetes/manifests/audit-policy.yaml"
staticAPIServerConfig["--audit-policy-file"] = "/etc/kubernetes/manifests/audit-policy.yaml"
}

// RBAC configuration
Expand Down Expand Up @@ -122,13 +110,7 @@ func setAPIServerConfig(cs *api.ContainerService) {

// We don't support user-configurable values for the following,
// so any of the value assignments below will override user-provided values
var overrideAPIServerConfig map[string]string
if cs.Properties.HasWindows() {
overrideAPIServerConfig = staticWindowsAPIServerConfig
} else {
overrideAPIServerConfig = staticLinuxAPIServerConfig
}
for key, val := range overrideAPIServerConfig {
for key, val := range staticAPIServerConfig {
o.KubernetesConfig.APIServerConfig[key] = val
}

Expand Down
21 changes: 4 additions & 17 deletions pkg/acsengine/defaults-cloud-controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func setCloudControllerManagerConfig(cs *api.ContainerService) {
o := cs.Properties.OrchestratorProfile
staticLinuxCloudControllerManagerConfig := map[string]string{
staticCloudControllerManagerConfig := map[string]string{
"--allocate-node-cidrs": strconv.FormatBool(!o.IsAzureCNI()),
"--configure-cloud-routes": strconv.FormatBool(o.RequireRouteTable()),
"--cloud-provider": "azure",
Expand All @@ -21,18 +21,11 @@ func setCloudControllerManagerConfig(cs *api.ContainerService) {

// Set --cluster-name based on appropriate DNS prefix
if cs.Properties.MasterProfile != nil {
staticLinuxCloudControllerManagerConfig["--cluster-name"] = cs.Properties.MasterProfile.DNSPrefix
staticCloudControllerManagerConfig["--cluster-name"] = cs.Properties.MasterProfile.DNSPrefix
} else if cs.Properties.HostedMasterProfile != nil {
staticLinuxCloudControllerManagerConfig["--cluster-name"] = cs.Properties.HostedMasterProfile.DNSPrefix
staticCloudControllerManagerConfig["--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{
"--route-reconciliation-period": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
Expand All @@ -53,13 +46,7 @@ func setCloudControllerManagerConfig(cs *api.ContainerService) {

// 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 {
for key, val := range staticCloudControllerManagerConfig {
o.KubernetesConfig.CloudControllerManagerConfig[key] = val
}

Expand Down
25 changes: 6 additions & 19 deletions pkg/acsengine/defaults-controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func setControllerManagerConfig(cs *api.ContainerService) {
o := cs.Properties.OrchestratorProfile
staticLinuxControllerManagerConfig := map[string]string{
staticControllerManagerConfig := map[string]string{
"--kubeconfig": "/var/lib/kubelet/kubeconfig",
"--allocate-node-cidrs": strconv.FormatBool(!o.IsAzureCNI()),
"--configure-cloud-routes": strconv.FormatBool(o.RequireRouteTable()),
Expand All @@ -25,24 +25,17 @@ func setControllerManagerConfig(cs *api.ContainerService) {

// Set --cluster-name based on appropriate DNS prefix
if cs.Properties.MasterProfile != nil {
staticLinuxControllerManagerConfig["--cluster-name"] = cs.Properties.MasterProfile.DNSPrefix
staticControllerManagerConfig["--cluster-name"] = cs.Properties.MasterProfile.DNSPrefix
} else if cs.Properties.HostedMasterProfile != nil {
staticLinuxControllerManagerConfig["--cluster-name"] = cs.Properties.HostedMasterProfile.DNSPrefix
staticControllerManagerConfig["--cluster-name"] = cs.Properties.HostedMasterProfile.DNSPrefix
}

// Enable cloudprovider if we're not using cloud controller manager
if !helpers.IsTrueBoolPointer(o.KubernetesConfig.UseCloudControllerManager) {
staticLinuxControllerManagerConfig["--cloud-provider"] = "azure"
staticLinuxControllerManagerConfig["--cloud-config"] = "/etc/kubernetes/azure.json"
staticControllerManagerConfig["--cloud-provider"] = "azure"
staticControllerManagerConfig["--cloud-config"] = "/etc/kubernetes/azure.json"
}

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,
Expand Down Expand Up @@ -70,13 +63,7 @@ func setControllerManagerConfig(cs *api.ContainerService) {

// 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 {
for key, val := range staticControllerManagerConfig {
o.KubernetesConfig.ControllerManagerConfig[key] = val
}

Expand Down
18 changes: 3 additions & 15 deletions pkg/acsengine/defaults-scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"github.com/Azure/acs-engine/pkg/api"
)

// staticLinuxSchedulerConfig is not user-overridable
var staticLinuxSchedulerConfig = map[string]string{
// staticSchedulerConfig is not user-overridable
var staticSchedulerConfig = map[string]string{
"--kubeconfig": "/var/lib/kubelet/kubeconfig",
"--leader-elect": "true",
"--profiling": "false",
Expand All @@ -18,12 +18,6 @@ var defaultSchedulerConfig = map[string]string{

func setSchedulerConfig(cs *api.ContainerService) {
o := cs.Properties.OrchestratorProfile
staticWindowsSchedulerConfig := make(map[string]string)
for key, val := range staticLinuxSchedulerConfig {
staticWindowsSchedulerConfig[key] = val
}
// Windows scheduler config overrides
// TODO placeholder for specific config overrides for Windows clusters

// If no user-configurable scheduler config values exists, use the defaults
if o.KubernetesConfig.SchedulerConfig == nil {
Expand All @@ -40,13 +34,7 @@ func setSchedulerConfig(cs *api.ContainerService) {

// We don't support user-configurable values for the following,
// so any of the value assignments below will override user-provided values
var overrideSchedulerConfig map[string]string
if cs.Properties.HasWindows() {
overrideSchedulerConfig = staticWindowsSchedulerConfig
} else {
overrideSchedulerConfig = staticLinuxSchedulerConfig
}
for key, val := range overrideSchedulerConfig {
for key, val := range staticSchedulerConfig {
o.KubernetesConfig.SchedulerConfig[key] = val
}
}
4 changes: 2 additions & 2 deletions pkg/acsengine/defaults-scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func TestSchedulerDefaultConfig(t *testing.T) {
cs := createContainerService("testcluster", "1.9.6", 3, 2)
setSchedulerConfig(cs)
s := cs.Properties.OrchestratorProfile.KubernetesConfig.SchedulerConfig
for key, val := range staticLinuxSchedulerConfig {
for key, val := range staticSchedulerConfig {
if val != s[key] {
t.Fatalf("got unexpected kube-scheduler static config value for %s. Expected %s, got %s",
key, val, s[key])
Expand Down Expand Up @@ -46,7 +46,7 @@ func TestSchedulerStaticConfig(t *testing.T) {
"--profiling": "user-override",
}
setSchedulerConfig(cs)
for key, val := range staticLinuxSchedulerConfig {
for key, val := range staticSchedulerConfig {
if val != cs.Properties.OrchestratorProfile.KubernetesConfig.SchedulerConfig[key] {
t.Fatalf("kube-scheduler static config did not override user values for %s. Expected %s, got %s",
key, val, cs.Properties.OrchestratorProfile.KubernetesConfig.SchedulerConfig)
Expand Down