Skip to content

Commit

Permalink
allow disabling dashboard addon in kubernetes cluster (Azure#1754)
Browse files Browse the repository at this point in the history
* initial commit

* next

* added example for deployment without dashboard

* added check for no dashboard in validation; update doc

* fix test

* added to regression set
  • Loading branch information
dmitsh authored and jackfrancis committed Nov 12, 2017
1 parent 372d59a commit bd006fc
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 107 deletions.
1 change: 1 addition & 0 deletions docs/clusterdefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Here are the valid values for the orchestrator types:
|maxPods|no|The maximum number of pods per node. The minimum valid value, necessary for running kube-system pods, is 5. Default value is 30 when networkPolicy equals azure, 110 otherwise.|
|gcHighThreshold|no|Sets the --image-gc-high-threshold value on the kublet configuration. Default is 85. [See kubelet Garbage Collection](https://kubernetes.io/docs/concepts/cluster-administration/kubelet-garbage-collection/) |
|gcLowThreshold|no|Sets the --image-gc-low-threshold value on the kublet configuration. Default is 80. [See kubelet Garbage Collection](https://kubernetes.io/docs/concepts/cluster-administration/kubelet-garbage-collection/) |
|disabledAddons.dashboard|no|Disable dashboard addon (boolean - default == false, i.e. not disabled)|

### masterProfile
`masterProfile` describes the settings for master configuration.
Expand Down
40 changes: 40 additions & 0 deletions examples/kubernetes-config/kubernetes-no-dashboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"apiVersion": "vlabs",
"properties": {
"orchestratorProfile": {
"orchestratorType": "Kubernetes",
"kubernetesConfig": {
"disabledAddons": {
"dashboard": true
}
}
},
"masterProfile": {
"count": 1,
"dnsPrefix": "",
"vmSize": "Standard_D2_v2"
},
"agentPoolProfiles": [
{
"name": "agentpool1",
"count": 1,
"vmSize": "Standard_D2_v2",
"availabilityProfile": "AvailabilitySet"
}
],
"linuxProfile": {
"adminUsername": "azureUser",
"ssh": {
"publicKeys": [
{
"keyData": ""
}
]
}
},
"servicePrincipalProfile": {
"clientId": "",
"secret": ""
}
}
}
2 changes: 2 additions & 0 deletions examples/kubernetes-config/kubernetes-no-dashboard.json.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
EXPECTED_DASHBOARD=0

4 changes: 4 additions & 0 deletions parts/kubernetesmastercustomdata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ write_files:
content: !!binary |
MASTER_ADDON_KUBE_PROXY_DAEMONSET_B64_GZIP_STR

{{if not .OrchestratorProfile.KubernetesConfig.DisabledAddons.Dashboard}}
- path: /etc/kubernetes/addons/kubernetes-dashboard-deployment.yaml
permissions: "0644"
encoding: gzip
owner: "root"
content: !!binary |
MASTER_ADDON_KUBERNETES_DASHBOARD_DEPLOYMENT_B64_GZIP_STR
{{end}}

- path: /etc/kubernetes/addons/kube-heapster-deployment.yaml
permissions: "0644"
Expand Down Expand Up @@ -273,7 +275,9 @@ write_files:
sed -i "s|<kubernetesHyperkubeSpec>|{{WrapAsVariable "kubernetesHyperkubeSpec"}}|g; s|<kubeClusterCidr>|{{WrapAsVariable "kubeClusterCidr"}}|g" "/etc/kubernetes/addons/kube-proxy-daemonset.yaml"
sed -i "s|<kubernetesKubeDNSSpec>|{{WrapAsVariable "kubernetesKubeDNSSpec"}}|g; s|<kubernetesDNSMasqSpec>|{{WrapAsVariable "kubernetesDNSMasqSpec"}}|g; s|<kubernetesExecHealthzSpec>|{{WrapAsVariable "kubernetesExecHealthzSpec"}}|g" "/etc/kubernetes/addons/kube-dns-deployment.yaml"
sed -i "s|<kubernetesHeapsterSpec>|{{WrapAsVariable "kubernetesHeapsterSpec"}}|g; s|<kubernetesAddonResizerSpec>|{{WrapAsVariable "kubernetesAddonResizerSpec"}}|g" "/etc/kubernetes/addons/kube-heapster-deployment.yaml"
{{if not .OrchestratorProfile.KubernetesConfig.DisabledAddons.Dashboard}}
sed -i "s|<kubernetesDashboardSpec>|{{WrapAsVariable "kubernetesDashboardSpec"}}|g" "/etc/kubernetes/addons/kubernetes-dashboard-deployment.yaml"
{{end}}
sed -i "s|<kubernetesTillerSpec>|{{WrapAsVariable "kubernetesTillerSpec"}}|g" "/etc/kubernetes/addons/kube-tiller-deployment.yaml"
sed -i "s|<kubernetesTillerCPURequests>|{{WrapAsVariable "kubernetesTillerCPURequests"}}|g" "/etc/kubernetes/addons/kube-tiller-deployment.yaml"
sed -i "s|<kubernetesTillerMemoryRequests>|{{WrapAsVariable "kubernetesTillerMemoryRequests"}}|g" "/etc/kubernetes/addons/kube-tiller-deployment.yaml"
Expand Down
14 changes: 8 additions & 6 deletions pkg/acsengine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

//log "github.com/sirupsen/logrus"
"github.com/Azure/acs-engine/pkg/api"
"github.com/Azure/acs-engine/pkg/api/common"
"github.com/Azure/acs-engine/pkg/i18n"
"github.com/Masterminds/semver"
"github.com/ghodss/yaml"
Expand Down Expand Up @@ -909,7 +908,7 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat

// add artifacts and addons
var artifiacts map[string]string
if profile.OrchestratorProfile.OrchestratorVersion == common.KubernetesVersion1Dot5Dot8 {
if strings.HasPrefix(profile.OrchestratorProfile.OrchestratorVersion, "1.5.") {
artifiacts = kubernetesAritfacts15
} else {
artifiacts = kubernetesAritfacts
Expand All @@ -920,20 +919,23 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
}

var addonYamls map[string]string
if profile.OrchestratorProfile.OrchestratorVersion == common.KubernetesVersion1Dot5Dot8 {
if strings.HasPrefix(profile.OrchestratorProfile.OrchestratorVersion, "1.5.") {
addonYamls = kubernetesAddonYamls15
} else {
addonYamls = kubernetesAddonYamls
}
if profile.OrchestratorProfile.KubernetesConfig.DisabledAddons.Dashboard {
delete(addonYamls, "MASTER_ADDON_KUBERNETES_DASHBOARD_DEPLOYMENT_B64_GZIP_STR")
}
for placeholder, filename := range addonYamls {
addonTextContents := getBase64CustomScript(filename)
str = strings.Replace(str, placeholder, addonTextContents, -1)
}

// add calico manifests
if profile.OrchestratorProfile.KubernetesConfig.NetworkPolicy == "calico" {
if profile.OrchestratorProfile.OrchestratorVersion == common.KubernetesVersion1Dot5Dot8 ||
profile.OrchestratorProfile.OrchestratorVersion == common.KubernetesVersion1Dot6Dot11 {
if strings.HasPrefix(profile.OrchestratorProfile.OrchestratorVersion, "1.5.") ||
strings.HasPrefix(profile.OrchestratorProfile.OrchestratorVersion, "1.6.") {
calicoAddonYamls = calicoAddonYamls15
}
for placeholder, filename := range calicoAddonYamls {
Expand All @@ -953,7 +955,7 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat

// add artifacts
var artifiacts map[string]string
if cs.Properties.OrchestratorProfile.OrchestratorVersion == common.KubernetesVersion1Dot5Dot8 {
if strings.HasPrefix(cs.Properties.OrchestratorProfile.OrchestratorVersion, "1.5.") {
artifiacts = kubernetesAritfacts15
} else {
artifiacts = kubernetesAritfacts
Expand Down
7 changes: 6 additions & 1 deletion pkg/api/converterfromapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,11 +670,16 @@ func convertKubernetesConfigToVLabs(api *KubernetesConfig, vlabs *vlabs.Kubernet
vlabs.GCHighThreshold = api.GCHighThreshold
vlabs.GCLowThreshold = api.GCLowThreshold
vlabs.EtcdVersion = api.EtcdVersion
vlabs.EtcdDiskSizeGB = api.EtcdDiskSizeGB
vlabs.TillerCPURequests = api.TillerCPURequests
vlabs.TillerCPULimit = api.TillerCPULimit
vlabs.TillerMemoryRequests = api.TillerMemoryRequests
vlabs.TillerMemoryLimit = api.TillerMemoryLimit
vlabs.EtcdDiskSizeGB = api.EtcdDiskSizeGB
convertDisabledAddonsToVLabs(&api.DisabledAddons, &vlabs.DisabledAddons)
}

func convertDisabledAddonsToVLabs(api *DisabledAddons, vlabs *vlabs.DisabledAddons) {
vlabs.Dashboard = api.Dashboard
}

func convertMasterProfileToV20160930(api *MasterProfile, v20160930 *v20160930.MasterProfile) {
Expand Down
7 changes: 6 additions & 1 deletion pkg/api/convertertoapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,16 @@ func convertVLabsKubernetesConfig(vlabs *vlabs.KubernetesConfig, api *Kubernetes
api.GCHighThreshold = vlabs.GCHighThreshold
api.GCLowThreshold = vlabs.GCLowThreshold
api.EtcdVersion = vlabs.EtcdVersion
api.EtcdDiskSizeGB = vlabs.EtcdDiskSizeGB
api.TillerCPURequests = vlabs.TillerCPURequests
api.TillerCPULimit = vlabs.TillerCPULimit
api.TillerMemoryRequests = vlabs.TillerMemoryRequests
api.TillerMemoryLimit = vlabs.TillerMemoryLimit
api.EtcdDiskSizeGB = vlabs.EtcdDiskSizeGB
convertVLabsDisabledAddons(&vlabs.DisabledAddons, &api.DisabledAddons)
}

func convertVLabsDisabledAddons(vlabs *vlabs.DisabledAddons, api *DisabledAddons) {
api.Dashboard = vlabs.Dashboard
}

func convertV20160930MasterProfile(v20160930 *v20160930.MasterProfile, api *MasterProfile) {
Expand Down
72 changes: 39 additions & 33 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,42 +156,48 @@ type OrchestratorVersionProfile struct {
Upgrades []*OrchestratorProfile `json:"upgrades,omitempty"`
}

// DisabledAddons specifies which addons are disabled
type DisabledAddons struct {
Dashboard bool `json:"dashboard,omitempty"`
}

// KubernetesConfig contains the Kubernetes config structure, containing
// Kubernetes specific configuration
type KubernetesConfig struct {
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
NonMasqueradeCidr string `json:"nonMasqueradeCidr,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
MaxPods int `json:"maxPods,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
NodeStatusUpdateFrequency string `json:"nodeStatusUpdateFrequency,omitempty"`
CtrlMgrNodeMonitorGracePeriod string `json:"ctrlMgrNodeMonitorGracePeriod,omitempty"`
CtrlMgrPodEvictionTimeout string `json:"ctrlMgrPodEvictionTimeout,omitempty"`
CtrlMgrRouteReconciliationPeriod string `json:"ctrlMgrRouteReconciliationPeriod,omitempty"`
CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty"`
CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
CloudProviderBackoffJitter float64 `json:"cloudProviderBackoffJitter,omitempty"`
CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty"`
CloudProviderBackoffExponent float64 `json:"cloudProviderBackoffExponent,omitempty"`
CloudProviderRateLimit bool `json:"cloudProviderRateLimit,omitempty"`
CloudProviderRateLimitQPS float64 `json:"cloudProviderRateLimitQPS,omitempty"`
CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty"`
UseManagedIdentity bool `json:"useManagedIdentity,omitempty"`
CustomHyperkubeImage string `json:"customHyperkubeImage,omitempty"`
UseInstanceMetadata bool `json:"useInstanceMetadata,omitempty"`
EnableRbac bool `json:"enableRbac,omitempty"`
EnableAggregatedAPIs bool `json:"enableAggregatedAPIs,omitempty"`
GCHighThreshold int `json:"gchighthreshold,omitempty"`
GCLowThreshold int `json:"gclowthreshold,omitempty"`
EtcdVersion string `json:"etcdVersion,omitempty"`
TillerCPURequests string `json:"tillerCPURequests,omitempty"`
TillerCPULimit string `json:"tillerCPULimit,omitempty"`
TillerMemoryRequests string `json:"tillerMemoryRequests,omitempty"`
TillerMemoryLimit string `json:"tillerMemoryLimit,omitempty"`
EtcdDiskSizeGB string `json:"etcdDiskSizeGB,omitempty"`
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
NonMasqueradeCidr string `json:"nonMasqueradeCidr,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
MaxPods int `json:"maxPods,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
NodeStatusUpdateFrequency string `json:"nodeStatusUpdateFrequency,omitempty"`
CtrlMgrNodeMonitorGracePeriod string `json:"ctrlMgrNodeMonitorGracePeriod,omitempty"`
CtrlMgrPodEvictionTimeout string `json:"ctrlMgrPodEvictionTimeout,omitempty"`
CtrlMgrRouteReconciliationPeriod string `json:"ctrlMgrRouteReconciliationPeriod,omitempty"`
CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty"`
CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
CloudProviderBackoffJitter float64 `json:"cloudProviderBackoffJitter,omitempty"`
CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty"`
CloudProviderBackoffExponent float64 `json:"cloudProviderBackoffExponent,omitempty"`
CloudProviderRateLimit bool `json:"cloudProviderRateLimit,omitempty"`
CloudProviderRateLimitQPS float64 `json:"cloudProviderRateLimitQPS,omitempty"`
CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty"`
UseManagedIdentity bool `json:"useManagedIdentity,omitempty"`
CustomHyperkubeImage string `json:"customHyperkubeImage,omitempty"`
UseInstanceMetadata bool `json:"useInstanceMetadata,omitempty"`
EnableRbac bool `json:"enableRbac,omitempty"`
EnableAggregatedAPIs bool `json:"enableAggregatedAPIs,omitempty"`
GCHighThreshold int `json:"gchighthreshold,omitempty"`
GCLowThreshold int `json:"gclowthreshold,omitempty"`
EtcdVersion string `json:"etcdVersion,omitempty"`
EtcdDiskSizeGB string `json:"etcdDiskSizeGB,omitempty"`
TillerCPURequests string `json:"tillerCPURequests,omitempty"`
TillerCPULimit string `json:"tillerCPULimit,omitempty"`
TillerMemoryRequests string `json:"tillerMemoryRequests,omitempty"`
TillerMemoryLimit string `json:"tillerMemoryLimit,omitempty"`
DisabledAddons DisabledAddons `json:"disabledAddons,omitempty"`
}

// DcosConfig Configuration for DC/OS
Expand Down
72 changes: 39 additions & 33 deletions pkg/api/vlabs/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,42 +174,48 @@ func (o *OrchestratorProfile) UnmarshalJSON(b []byte) error {
return nil
}

// DisabledAddons specifies which addons are disabled
type DisabledAddons struct {
Dashboard bool `json:"dashboard,omitempty"`
}

// KubernetesConfig contains the Kubernetes config structure, containing
// Kubernetes specific configuration
type KubernetesConfig struct {
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCidr string `json:"serviceCidr,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
NonMasqueradeCidr string `json:"nonMasqueradeCidr,omitempty"`
MaxPods int `json:"maxPods,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
NodeStatusUpdateFrequency string `json:"nodeStatusUpdateFrequency,omitempty"`
CtrlMgrNodeMonitorGracePeriod string `json:"ctrlMgrNodeMonitorGracePeriod,omitempty"`
CtrlMgrPodEvictionTimeout string `json:"ctrlMgrPodEvictionTimeout,omitempty"`
CtrlMgrRouteReconciliationPeriod string `json:"ctrlMgrRouteReconciliationPeriod,omitempty"`
CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty"`
CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
CloudProviderBackoffJitter float64 `json:"cloudProviderBackoffJitter,omitempty"`
CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty"`
CloudProviderBackoffExponent float64 `json:"cloudProviderBackoffExponent,omitempty"`
CloudProviderRateLimit bool `json:"cloudProviderRateLimit,omitempty"`
CloudProviderRateLimitQPS float64 `json:"cloudProviderRateLimitQPS,omitempty"`
CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty"`
UseManagedIdentity bool `json:"useManagedIdentity,omitempty"`
CustomHyperkubeImage string `json:"customHyperkubeImage,omitempty"`
UseInstanceMetadata bool `json:"useInstanceMetadata,omitempty"`
EnableRbac bool `json:"enableRbac,omitempty"`
EnableAggregatedAPIs bool `json:"enableAggregatedAPIs,omitempty"`
GCHighThreshold int `json:"gchighthreshold,omitempty"`
GCLowThreshold int `json:"gclowthreshold,omitempty"`
EtcdVersion string `json:"etcdVersion,omitempty"`
TillerCPURequests string `json:"tillerCPURequests,omitempty"`
TillerCPULimit string `json:"tillerCPULimit,omitempty"`
TillerMemoryRequests string `json:"tillerMemoryRequests,omitempty"`
TillerMemoryLimit string `json:"tillerMemoryLimit,omitempty"`
EtcdDiskSizeGB string `json:"etcdDiskSizeGB,omitempty"`
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCidr string `json:"serviceCidr,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
NonMasqueradeCidr string `json:"nonMasqueradeCidr,omitempty"`
MaxPods int `json:"maxPods,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
NodeStatusUpdateFrequency string `json:"nodeStatusUpdateFrequency,omitempty"`
CtrlMgrNodeMonitorGracePeriod string `json:"ctrlMgrNodeMonitorGracePeriod,omitempty"`
CtrlMgrPodEvictionTimeout string `json:"ctrlMgrPodEvictionTimeout,omitempty"`
CtrlMgrRouteReconciliationPeriod string `json:"ctrlMgrRouteReconciliationPeriod,omitempty"`
CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty"`
CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
CloudProviderBackoffJitter float64 `json:"cloudProviderBackoffJitter,omitempty"`
CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty"`
CloudProviderBackoffExponent float64 `json:"cloudProviderBackoffExponent,omitempty"`
CloudProviderRateLimit bool `json:"cloudProviderRateLimit,omitempty"`
CloudProviderRateLimitQPS float64 `json:"cloudProviderRateLimitQPS,omitempty"`
CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty"`
UseManagedIdentity bool `json:"useManagedIdentity,omitempty"`
CustomHyperkubeImage string `json:"customHyperkubeImage,omitempty"`
UseInstanceMetadata bool `json:"useInstanceMetadata,omitempty"`
EnableRbac bool `json:"enableRbac,omitempty"`
EnableAggregatedAPIs bool `json:"enableAggregatedAPIs,omitempty"`
GCHighThreshold int `json:"gchighthreshold,omitempty"`
GCLowThreshold int `json:"gclowthreshold,omitempty"`
EtcdVersion string `json:"etcdVersion,omitempty"`
EtcdDiskSizeGB string `json:"etcdDiskSizeGB,omitempty"`
TillerCPURequests string `json:"tillerCPURequests,omitempty"`
TillerCPULimit string `json:"tillerCPULimit,omitempty"`
TillerMemoryRequests string `json:"tillerMemoryRequests,omitempty"`
TillerMemoryLimit string `json:"tillerMemoryLimit,omitempty"`
DisabledAddons DisabledAddons `json:"disabledAddons,omitempty"`
}

// DcosConfig Configuration for DC/OS
Expand Down

0 comments on commit bd006fc

Please sign in to comment.