moved backoff-related config to api model (#964)

* converted —node-status-update-frequency

nodeStatusUpdateFrequency is now delivered via KubernetesConfig

* all recent k8s config params are api-model-enabled

* rationalizing config outputs as string params

* added k8s version-specific validation
This commit is contained in:
Jack Francis 2017-07-13 15:09:05 -07:00 коммит произвёл GitHub
Родитель 33e9e04c91
Коммит 75d52db447
10 изменённых файлов: 410 добавлений и 122 удалений

Просмотреть файл

@ -3,7 +3,21 @@
"properties": {
"orchestratorProfile": {
"orchestratorType": "Kubernetes",
"orchestratorVersion": "1.6.6"
"orchestratorVersion": "1.6.6",
"kubernetesConfig": {
"nodeStatusUpdateFrequency": "1m",
"ctrlMgrNodeMonitorGracePeriod": "5m",
"ctrlMgrPodEvictionTimeout": "1m",
"ctrlMgrRouteReconciliationPeriod": "1m",
"cloudProviderBackoff": true,
"cloudProviderBackoffRetries": 6,
"cloudProviderBackoffJitter": 1,
"cloudProviderBackoffDuration": 6,
"cloudProviderBackoffExponent": 1.5,
"cloudProviderRateLimit": true,
"cloudProviderRateLimitQPS": 3,
"cloudProviderRateLimitBucket": 10
}
},
"masterProfile": {
"count": 1,

Просмотреть файл

@ -1,6 +1,8 @@
package acsengine
import (
"strconv"
"github.com/Azure/acs-engine/pkg/api"
)
@ -41,6 +43,30 @@ const (
DefaultInternalLbStaticIPOffset = 10
// DefaultNetworkPolicy is disabling network policy enforcement
DefaultNetworkPolicy = "none"
// DefaultKubernetesNodeStatusUpdateFrequency is 10s, see --node-status-update-frequency at https://kubernetes.io/docs/admin/kubelet/
DefaultKubernetesNodeStatusUpdateFrequency = "10s"
// DefaultKubernetesCtrlMgrNodeMonitorGracePeriod is 40s, see --node-monitor-grace-period at https://kubernetes.io/docs/admin/kube-controller-manager/
DefaultKubernetesCtrlMgrNodeMonitorGracePeriod = "40s"
// DefaultKubernetesCtrlMgrPodEvictionTimeout is 5m0s, see --pod-eviction-timeout at https://kubernetes.io/docs/admin/kube-controller-manager/
DefaultKubernetesCtrlMgrPodEvictionTimeout = "5m0s"
// DefaultKubernetesCtrlMgrRouteReconciliationPeriod is 10s, see --route-reconciliation-period at https://kubernetes.io/docs/admin/kube-controller-manager/
DefaultKubernetesCtrlMgrRouteReconciliationPeriod = "10s"
// DefaultKubernetesCloudProviderBackoff is false to disable cloudprovider backoff implementation for API calls
DefaultKubernetesCloudProviderBackoff = false
// DefaultKubernetesCloudProviderBackoffRetries is 6, takes effect if DefaultKubernetesCloudProviderBackoff is true
DefaultKubernetesCloudProviderBackoffRetries = 6
// DefaultKubernetesCloudProviderBackoffJitter is 1, takes effect if DefaultKubernetesCloudProviderBackoff is true
DefaultKubernetesCloudProviderBackoffJitter = 1.0
// DefaultKubernetesCloudProviderBackoffDuration is 5, takes effect if DefaultKubernetesCloudProviderBackoff is true
DefaultKubernetesCloudProviderBackoffDuration = 5
// DefaultKubernetesCloudProviderBackoffExponent is 1.5, takes effect if DefaultKubernetesCloudProviderBackoff is true
DefaultKubernetesCloudProviderBackoffExponent = 1.5
// DefaultKubernetesCloudProviderRateLimit is false to disable cloudprovider rate limiting implementation for API calls
DefaultKubernetesCloudProviderRateLimit = false
// DefaultKubernetesCloudProviderRateLimitQPS is 3, takes effect if DefaultKubernetesCloudProviderRateLimit is true
DefaultKubernetesCloudProviderRateLimitQPS = 3.0
// DefaultKubernetesCloudProviderRateLimitBucket is 10, takes effect if DefaultKubernetesCloudProviderRateLimit is true
DefaultKubernetesCloudProviderRateLimitBucket = 10
)
const (
@ -55,95 +81,93 @@ const (
// KubeImages represents Docker images used for Kubernetes components based on Kubernetes version
var KubeImages = map[api.OrchestratorVersion]map[string]string{
api.Kubernetes166: {
"hyperkube": "hyperkube-amd64:v1.6.6",
"dashboard": "kubernetes-dashboard-amd64:v1.6.1",
"exechealthz": "exechealthz-amd64:1.2",
"addonresizer": "addon-resizer:1.7",
"heapster": "heapster:v1.3.0",
"dns": "k8s-dns-kube-dns-amd64:1.14.4",
"addonmanager": "kube-addon-manager-amd64:v6.4-beta.2",
"dnsmasq": "k8s-dns-dnsmasq-amd64:1.13.0",
"pause": "pause-amd64:3.0",
"windowszip": "v1.6.6intwinnat.zip",
"nodestatusfreq": "10s",
"nodegraceperiod": "40s",
"podeviction": "5m0s",
"routeperiod": "10s",
"backoff": "false",
"backoffduration": "5",
"backoffexponent": "1.5",
"backoffretries": "6",
"backoffjitter": "1",
"ratelimit": "false",
"ratelimitqps": "1",
"ratelimitbucket": "5",
"hyperkube": "hyperkube-amd64:v1.6.6",
"dashboard": "kubernetes-dashboard-amd64:v1.6.1",
"exechealthz": "exechealthz-amd64:1.2",
"addonresizer": "addon-resizer:1.7",
"heapster": "heapster:v1.3.0",
"dns": "k8s-dns-kube-dns-amd64:1.14.4",
"addonmanager": "kube-addon-manager-amd64:v6.4-beta.2",
"dnsmasq": "k8s-dns-dnsmasq-amd64:1.13.0",
"pause": "pause-amd64:3.0",
"windowszip": "v1.6.6intwinnat.zip",
"nodestatusfreq": DefaultKubernetesNodeStatusUpdateFrequency,
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
"backoffretries": strconv.Itoa(DefaultKubernetesCloudProviderBackoffRetries),
"backoffjitter": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
"backoffduration": strconv.Itoa(DefaultKubernetesCloudProviderBackoffDuration),
"backoffexponent": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
},
api.Kubernetes162: {
"hyperkube": "hyperkube-amd64:v1.6.2",
"dashboard": "kubernetes-dashboard-amd64:v1.6.0",
"exechealthz": "exechealthz-amd64:1.2",
"addonresizer": "addon-resizer:1.6",
"heapster": "heapster:v1.2.0",
"dns": "k8s-dns-kube-dns-amd64:1.13.0",
"addonmanager": "kube-addon-manager-amd64:v6.4",
"dnsmasq": "k8s-dns-dnsmasq-amd64:1.13.0",
"pause": "pause-amd64:3.0",
"windowszip": "v1.6.2intwinnat.zip",
"nodestatusfreq": "10s",
"nodegraceperiod": "40s",
"podeviction": "5m0s",
"routeperiod": "10s",
"hyperkube": "hyperkube-amd64:v1.6.2",
"dashboard": "kubernetes-dashboard-amd64:v1.6.0",
"exechealthz": "exechealthz-amd64:1.2",
"addonresizer": "addon-resizer:1.6",
"heapster": "heapster:v1.2.0",
"dns": "k8s-dns-kube-dns-amd64:1.13.0",
"addonmanager": "kube-addon-manager-amd64:v6.4",
"dnsmasq": "k8s-dns-dnsmasq-amd64:1.13.0",
"pause": "pause-amd64:3.0",
"windowszip": "v1.6.2intwinnat.zip",
"nodestatusfreq": DefaultKubernetesNodeStatusUpdateFrequency,
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
},
api.Kubernetes160: {
"hyperkube": "hyperkube-amd64:v1.6.0",
"dashboard": "kubernetes-dashboard-amd64:v1.6.0",
"exechealthz": "exechealthz-amd64:1.2",
"addonresizer": "addon-resizer:1.6",
"heapster": "heapster:v1.2.0",
"dns": "k8s-dns-kube-dns-amd64:1.13.0",
"addonmanager": "kube-addon-manager-amd64:v6.4",
"dnsmasq": "k8s-dns-dnsmasq-amd64:1.13.0",
"pause": "pause-amd64:3.0",
"windowszip": "v1.6.0intwinnat.zip",
"nodestatusfreq": "10s",
"nodegraceperiod": "40s",
"podeviction": "5m0s",
"routeperiod": "10s",
"hyperkube": "hyperkube-amd64:v1.6.0",
"dashboard": "kubernetes-dashboard-amd64:v1.6.0",
"exechealthz": "exechealthz-amd64:1.2",
"addonresizer": "addon-resizer:1.6",
"heapster": "heapster:v1.2.0",
"dns": "k8s-dns-kube-dns-amd64:1.13.0",
"addonmanager": "kube-addon-manager-amd64:v6.4",
"dnsmasq": "k8s-dns-dnsmasq-amd64:1.13.0",
"pause": "pause-amd64:3.0",
"windowszip": "v1.6.0intwinnat.zip",
"nodestatusfreq": DefaultKubernetesNodeStatusUpdateFrequency,
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
},
api.Kubernetes157: {
"hyperkube": "hyperkube-amd64:v1.5.7",
"dashboard": "kubernetes-dashboard-amd64:v1.5.1",
"exechealthz": "exechealthz-amd64:1.2",
"addonresizer": "addon-resizer:1.6",
"heapster": "heapster:v1.2.0",
"dns": "kubedns-amd64:1.7",
"addonmanager": "kube-addon-manager-amd64:v6.2",
"dnsmasq": "kube-dnsmasq-amd64:1.3",
"pause": "pause-amd64:3.0",
"windowszip": "v1.5.7intwinnat.zip",
"nodestatusfreq": "10s",
"nodegraceperiod": "40s",
"podeviction": "5m0s",
"routeperiod": "10s",
"hyperkube": "hyperkube-amd64:v1.5.7",
"dashboard": "kubernetes-dashboard-amd64:v1.5.1",
"exechealthz": "exechealthz-amd64:1.2",
"addonresizer": "addon-resizer:1.6",
"heapster": "heapster:v1.2.0",
"dns": "kubedns-amd64:1.7",
"addonmanager": "kube-addon-manager-amd64:v6.2",
"dnsmasq": "kube-dnsmasq-amd64:1.3",
"pause": "pause-amd64:3.0",
"windowszip": "v1.5.7intwinnat.zip",
"nodestatusfreq": DefaultKubernetesNodeStatusUpdateFrequency,
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
},
api.Kubernetes153: {
"hyperkube": "hyperkube-amd64:v1.5.3",
"dashboard": "kubernetes-dashboard-amd64:v1.5.1",
"exechealthz": "exechealthz-amd64:1.2",
"addonresizer": "addon-resizer:1.6",
"heapster": "heapster:v1.2.0",
"dns": "kubedns-amd64:1.7",
"addonmanager": "kube-addon-manager-amd64:v6.2",
"dnsmasq": "kube-dnsmasq-amd64:1.3",
"pause": "pause-amd64:3.0",
"windowszip": "v1.5.3intwinnat.zip",
"nodestatusfreq": "10s",
"nodegraceperiod": "40s",
"podeviction": "5m0s",
"routeperiod": "10s",
"hyperkube": "hyperkube-amd64:v1.5.3",
"dashboard": "kubernetes-dashboard-amd64:v1.5.1",
"exechealthz": "exechealthz-amd64:1.2",
"addonresizer": "addon-resizer:1.6",
"heapster": "heapster:v1.2.0",
"dns": "kubedns-amd64:1.7",
"addonmanager": "kube-addon-manager-amd64:v6.2",
"dnsmasq": "kube-dnsmasq-amd64:1.3",
"pause": "pause-amd64:3.0",
"windowszip": "v1.5.3intwinnat.zip",
"nodestatusfreq": DefaultKubernetesNodeStatusUpdateFrequency,
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
},
}

Просмотреть файл

@ -75,6 +75,7 @@ func setOrchestratorDefaults(cs *api.ContainerService) {
cloudSpecConfig := GetCloudSpecConfig(location)
if a.OrchestratorProfile.OrchestratorType == api.Kubernetes {
k8sVersion := a.OrchestratorProfile.OrchestratorVersion
if a.OrchestratorProfile.KubernetesConfig == nil {
a.OrchestratorProfile.KubernetesConfig = &api.KubernetesConfig{}
}
@ -93,6 +94,42 @@ func setOrchestratorDefaults(cs *api.ContainerService) {
if a.OrchestratorProfile.KubernetesConfig.DockerBridgeSubnet == "" {
a.OrchestratorProfile.KubernetesConfig.DockerBridgeSubnet = DefaultDockerBridgeSubnet
}
if a.OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency == "" {
a.OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency = KubeImages[k8sVersion]["nodestatusfreq"]
}
if a.OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod == "" {
a.OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod = KubeImages[k8sVersion]["nodegraceperiod"]
}
if a.OrchestratorProfile.KubernetesConfig.CtrlMgrPodEvictionTimeout == "" {
a.OrchestratorProfile.KubernetesConfig.CtrlMgrPodEvictionTimeout = KubeImages[k8sVersion]["podeviction"]
}
if a.OrchestratorProfile.KubernetesConfig.CtrlMgrRouteReconciliationPeriod == "" {
a.OrchestratorProfile.KubernetesConfig.CtrlMgrRouteReconciliationPeriod = KubeImages[k8sVersion]["routeperiod"]
}
// Enforce sane cloudprovider backoff defaults, if CloudProviderBackoff is true in KubernetesConfig
if a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoff == true {
if a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffDuration == 0 {
a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffDuration = DefaultKubernetesCloudProviderBackoffDuration
}
if a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffExponent == 0 {
a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffExponent = DefaultKubernetesCloudProviderBackoffExponent
}
if a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffJitter == 0 {
a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffJitter = DefaultKubernetesCloudProviderBackoffJitter
}
if a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffRetries == 0 {
a.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffRetries = DefaultKubernetesCloudProviderBackoffRetries
}
}
// Enforce sane cloudprovider rate limit defaults, if CloudProviderRateLimit is true in KubernetesConfig
if a.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimit == true && k8sVersion == api.Kubernetes166 {
if a.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitQPS == 0 {
a.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitQPS = DefaultKubernetesCloudProviderRateLimitQPS
}
if a.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitBucket == 0 {
a.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitBucket = DefaultKubernetesCloudProviderRateLimitBucket
}
}
}
}

Просмотреть файл

@ -10,6 +10,7 @@ import (
"hash/fnv"
"math/rand"
"regexp"
"strconv"
"strings"
"text/template"
@ -395,18 +396,18 @@ func getParameters(cs *api.ContainerService, isClassicMode bool) (map[string]int
addValue(parametersMap, "kubernetesHeapsterSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["heapster"])
addValue(parametersMap, "kubernetesKubeDNSSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["dns"])
addValue(parametersMap, "kubernetesPodInfraContainerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeImages[KubernetesVersion]["pause"])
addValue(parametersMap, "kubernetesNodeStatusUpdateFrequency", KubeImages[KubernetesVersion]["nodestatusfreq"])
addValue(parametersMap, "kubernetesCtrlMgrNodeMonitorGracePeriod", KubeImages[KubernetesVersion]["nodegraceperiod"])
addValue(parametersMap, "kubernetesCtrlMgrPodEvictionTimeout", KubeImages[KubernetesVersion]["podeviction"])
addValue(parametersMap, "kubernetesCtrlMgrRouteReconciliationPeriod", KubeImages[KubernetesVersion]["routeperiod"])
addValue(parametersMap, "cloudProviderBackoff", KubeImages[KubernetesVersion]["backoff"])
addValue(parametersMap, "cloudProviderBackoffRetries", KubeImages[KubernetesVersion]["backoffretries"])
addValue(parametersMap, "cloudProviderBackoffExponent", KubeImages[KubernetesVersion]["backoffexponent"])
addValue(parametersMap, "cloudProviderBackoffDuration", KubeImages[KubernetesVersion]["backoffduration"])
addValue(parametersMap, "cloudProviderBackoffJitter", KubeImages[KubernetesVersion]["backoffjitter"])
addValue(parametersMap, "cloudProviderRatelimit", KubeImages[KubernetesVersion]["ratelimit"])
addValue(parametersMap, "cloudProviderRatelimitQPS", KubeImages[KubernetesVersion]["ratelimitqps"])
addValue(parametersMap, "cloudProviderRatelimitBucket", KubeImages[KubernetesVersion]["ratelimitbucket"])
addValue(parametersMap, "kubernetesNodeStatusUpdateFrequency", properties.OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency)
addValue(parametersMap, "kubernetesCtrlMgrNodeMonitorGracePeriod", properties.OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod)
addValue(parametersMap, "kubernetesCtrlMgrPodEvictionTimeout", properties.OrchestratorProfile.KubernetesConfig.CtrlMgrPodEvictionTimeout)
addValue(parametersMap, "kubernetesCtrlMgrRouteReconciliationPeriod", properties.OrchestratorProfile.KubernetesConfig.CtrlMgrRouteReconciliationPeriod)
addValue(parametersMap, "cloudProviderBackoff", strconv.FormatBool(properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoff))
addValue(parametersMap, "cloudProviderBackoffRetries", strconv.Itoa(properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffRetries))
addValue(parametersMap, "cloudProviderBackoffExponent", strconv.FormatFloat(properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffExponent, 'f', -1, 64))
addValue(parametersMap, "cloudProviderBackoffDuration", strconv.Itoa(properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffDuration))
addValue(parametersMap, "cloudProviderBackoffJitter", strconv.FormatFloat(properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffJitter, 'f', -1, 64))
addValue(parametersMap, "cloudProviderRatelimit", strconv.FormatBool(properties.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimit))
addValue(parametersMap, "cloudProviderRatelimitQPS", strconv.FormatFloat(properties.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitQPS, 'f', -1, 64))
addValue(parametersMap, "cloudProviderRatelimitBucket", strconv.Itoa(properties.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitBucket))
addValue(parametersMap, "kubeClusterCidr", properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet)
addValue(parametersMap, "dockerBridgeCidr", properties.OrchestratorProfile.KubernetesConfig.DockerBridgeSubnet)
addValue(parametersMap, "networkPolicy", properties.OrchestratorProfile.KubernetesConfig.NetworkPolicy)
@ -818,29 +819,29 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) map[str
case "kubernetesPodInfraContainerSpec":
val = cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeImages[kubernetesVersion]["pause"]
case "kubernetesNodeStatusUpdateFrequency":
val = KubeImages[kubernetesVersion]["nodestatusfreq"]
val = cs.Properties.OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency
case "kubernetesCtrlMgrNodeMonitorGracePeriod":
val = KubeImages[kubernetesVersion]["nodegraceperiod"]
val = cs.Properties.OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod
case "kubernetesCtrlMgrPodEvictionTimeout":
val = KubeImages[kubernetesVersion]["podeviction"]
val = cs.Properties.OrchestratorProfile.KubernetesConfig.CtrlMgrPodEvictionTimeout
case "kubernetesCtrlMgrRouteReconciliationPeriod":
val = KubeImages[kubernetesVersion]["routeperiod"]
val = cs.Properties.OrchestratorProfile.KubernetesConfig.CtrlMgrRouteReconciliationPeriod
case "cloudProviderBackoff":
val = KubeImages[kubernetesVersion]["backoff"]
val = strconv.FormatBool(cs.Properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoff)
case "cloudProviderBackoffRetries":
val = KubeImages[kubernetesVersion]["backoffretries"]
val = strconv.Itoa(cs.Properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffRetries)
case "cloudProviderBackoffExponent":
val = KubeImages[kubernetesVersion]["backoffexponent"]
val = strconv.FormatFloat(cs.Properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffExponent, 'f', -1, 64)
case "cloudProviderBackoffDuration":
val = KubeImages[kubernetesVersion]["backoffduration"]
val = strconv.Itoa(cs.Properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffDuration)
case "cloudProviderBackoffJitter":
val = KubeImages[kubernetesVersion]["backoffjitter"]
val = strconv.FormatFloat(cs.Properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoffJitter, 'f', -1, 64)
case "cloudProviderRatelimit":
val = KubeImages[kubernetesVersion]["ratelimit"]
val = strconv.FormatBool(cs.Properties.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimit)
case "cloudProviderRatelimitQPS":
val = KubeImages[kubernetesVersion]["ratelimitqps"]
val = strconv.FormatFloat(cs.Properties.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitQPS, 'f', -1, 64)
case "cloudProviderRatelimitBucket":
val = KubeImages[kubernetesVersion]["ratelimitbucket"]
val = strconv.Itoa(cs.Properties.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimitBucket)
case "kubeBinariesSASURL":
val = cloudSpecConfig.KubernetesSpecConfig.KubeBinariesSASURLBase + KubeImages[kubernetesVersion]["windowszip"]
case "kubeClusterCidr":

Просмотреть файл

@ -549,6 +549,18 @@ func convertKubernetesConfigToVLabs(api *KubernetesConfig, vlabs *vlabs.Kubernet
vlabs.ClusterSubnet = api.ClusterSubnet
vlabs.NetworkPolicy = api.NetworkPolicy
vlabs.DockerBridgeSubnet = api.DockerBridgeSubnet
vlabs.NodeStatusUpdateFrequency = api.NodeStatusUpdateFrequency
vlabs.CtrlMgrNodeMonitorGracePeriod = api.CtrlMgrNodeMonitorGracePeriod
vlabs.CtrlMgrPodEvictionTimeout = api.CtrlMgrPodEvictionTimeout
vlabs.CtrlMgrRouteReconciliationPeriod = api.CtrlMgrRouteReconciliationPeriod
vlabs.CloudProviderBackoff = api.CloudProviderBackoff
vlabs.CloudProviderBackoffDuration = api.CloudProviderBackoffDuration
vlabs.CloudProviderBackoffExponent = api.CloudProviderBackoffExponent
vlabs.CloudProviderBackoffJitter = api.CloudProviderBackoffJitter
vlabs.CloudProviderBackoffRetries = api.CloudProviderBackoffRetries
vlabs.CloudProviderRateLimit = api.CloudProviderRateLimit
vlabs.CloudProviderRateLimitBucket = api.CloudProviderRateLimitBucket
vlabs.CloudProviderRateLimitQPS = api.CloudProviderRateLimitQPS
}
func convertMasterProfileToV20160930(api *MasterProfile, v20160930 *v20160930.MasterProfile) {

Просмотреть файл

@ -572,6 +572,18 @@ func convertVLabsKubernetesConfig(vlabs *vlabs.KubernetesConfig, api *Kubernetes
api.ClusterSubnet = vlabs.ClusterSubnet
api.NetworkPolicy = vlabs.NetworkPolicy
api.DockerBridgeSubnet = vlabs.DockerBridgeSubnet
api.NodeStatusUpdateFrequency = vlabs.NodeStatusUpdateFrequency
api.CtrlMgrNodeMonitorGracePeriod = vlabs.CtrlMgrNodeMonitorGracePeriod
api.CtrlMgrPodEvictionTimeout = vlabs.CtrlMgrPodEvictionTimeout
api.CtrlMgrRouteReconciliationPeriod = vlabs.CtrlMgrRouteReconciliationPeriod
api.CloudProviderBackoff = vlabs.CloudProviderBackoff
api.CloudProviderBackoffDuration = vlabs.CloudProviderBackoffDuration
api.CloudProviderBackoffExponent = vlabs.CloudProviderBackoffExponent
api.CloudProviderBackoffJitter = vlabs.CloudProviderBackoffJitter
api.CloudProviderBackoffRetries = vlabs.CloudProviderBackoffRetries
api.CloudProviderRateLimit = vlabs.CloudProviderRateLimit
api.CloudProviderRateLimitBucket = vlabs.CloudProviderRateLimitBucket
api.CloudProviderRateLimitQPS = vlabs.CloudProviderRateLimitQPS
}
func convertV20160930MasterProfile(v20160930 *v20160930.MasterProfile, api *MasterProfile) {

Просмотреть файл

@ -126,10 +126,22 @@ type OrchestratorProfile struct {
// KubernetesConfig contains the Kubernetes config structure, containing
// Kubernetes specific configuration
type KubernetesConfig struct {
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
NetworkPolicy string `json:"networkPolicy,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"`
}
// MasterProfile represents the definition of the master cluster

Просмотреть файл

@ -130,10 +130,22 @@ type OrchestratorProfile struct {
// KubernetesConfig contains the Kubernetes config structure, containing
// Kubernetes specific configuration
type KubernetesConfig struct {
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
DockerBridgeSubnet string `json:"DockerBridgeSubnet,omitempty"`
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
NetworkPolicy string `json:"networkPolicy,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"`
}
// MasterProfile represents the definition of the master cluster

Просмотреть файл

@ -6,6 +6,7 @@ import (
"net"
"net/url"
"regexp"
"time"
)
// Validate implements APIObject
@ -39,7 +40,7 @@ func (o *OrchestratorProfile) Validate() error {
}
if o.KubernetesConfig != nil {
err := o.KubernetesConfig.Validate()
err := o.KubernetesConfig.Validate(o.OrchestratorVersion)
if err != nil {
return err
}
@ -316,7 +317,16 @@ func (a *Properties) Validate() error {
}
// Validate validates the KubernetesConfig.
func (a *KubernetesConfig) Validate() error {
func (a *KubernetesConfig) Validate(k8sVersion OrchestratorVersion) error {
// number of minimum retries allowed for kubelet to post node status
const minKubeletRetries = 4
// k8s versions that have cloudprovider backoff enabled
var backoffEnabledVersions = map[OrchestratorVersion]bool{
Kubernetes166: true,
}
// k8s versions that have cloudprovider rate limiting enabled (currently identical with backoff enabled versions)
ratelimitEnabledVersions := backoffEnabledVersions
if a.ClusterSubnet != "" {
_, _, err := net.ParseCIDR(a.ClusterSubnet)
if err != nil {
@ -331,6 +341,61 @@ func (a *KubernetesConfig) Validate() error {
}
}
if a.NodeStatusUpdateFrequency != "" {
_, err := time.ParseDuration(a.NodeStatusUpdateFrequency)
if err != nil {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency '%s' is not a valid duration", a.NodeStatusUpdateFrequency)
}
if a.CtrlMgrNodeMonitorGracePeriod == "" {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency was set to '%s' but OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod was not set", a.NodeStatusUpdateFrequency)
}
}
if a.CtrlMgrNodeMonitorGracePeriod != "" {
_, err := time.ParseDuration(a.CtrlMgrNodeMonitorGracePeriod)
if err != nil {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod '%s' is not a valid duration", a.CtrlMgrNodeMonitorGracePeriod)
}
if a.NodeStatusUpdateFrequency == "" {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.CtrlMgrNodeMonitorGracePeriod was set to '%s' but OrchestratorProfile.KubernetesConfig.NodeStatusUpdateFrequency was not set", a.NodeStatusUpdateFrequency)
}
}
if a.NodeStatusUpdateFrequency != "" && a.CtrlMgrNodeMonitorGracePeriod != "" {
nodeStatusUpdateFrequency, _ := time.ParseDuration(a.NodeStatusUpdateFrequency)
ctrlMgrNodeMonitorGracePeriod, _ := time.ParseDuration(a.CtrlMgrNodeMonitorGracePeriod)
kubeletRetries := ctrlMgrNodeMonitorGracePeriod.Seconds() / nodeStatusUpdateFrequency.Seconds()
if kubeletRetries < minKubeletRetries {
return fmt.Errorf("acs-engine requires that ctrlMgrNodeMonitorGracePeriod(%f)s be larger than nodeStatusUpdateFrequency(%f)s by at least a factor of %d; ", ctrlMgrNodeMonitorGracePeriod.Seconds(), nodeStatusUpdateFrequency.Seconds(), minKubeletRetries)
}
}
if a.CtrlMgrPodEvictionTimeout != "" {
_, err := time.ParseDuration(a.CtrlMgrPodEvictionTimeout)
if err != nil {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.CtrlMgrPodEvictionTimeout '%s' is not a valid duration", a.CtrlMgrPodEvictionTimeout)
}
}
if a.CtrlMgrRouteReconciliationPeriod != "" {
_, err := time.ParseDuration(a.CtrlMgrRouteReconciliationPeriod)
if err != nil {
return fmt.Errorf("OrchestratorProfile.KubernetesConfig.CtrlMgrRouteReconciliationPeriod '%s' is not a valid duration", a.CtrlMgrRouteReconciliationPeriod)
}
}
if a.CloudProviderBackoff {
if !backoffEnabledVersions[k8sVersion] {
return fmt.Errorf("cloudprovider backoff functionality not available in kubernetes version %s", k8sVersion)
}
}
if a.CloudProviderRateLimit {
if !ratelimitEnabledVersions[k8sVersion] {
return fmt.Errorf("cloudprovider rate limiting functionality not available in kubernetes version %s", k8sVersion)
}
}
return nil
}

Просмотреть файл

@ -4,6 +4,21 @@ import (
"testing"
)
const (
ValidKubernetesNodeStatusUpdateFrequency = "10s"
ValidKubernetesCtrlMgrNodeMonitorGracePeriod = "40s"
ValidKubernetesCtrlMgrPodEvictionTimeout = "5m0s"
ValidKubernetesCtrlMgrRouteReconciliationPeriod = "10s"
ValidKubernetesCloudProviderBackoff = false
ValidKubernetesCloudProviderBackoffRetries = 6
ValidKubernetesCloudProviderBackoffJitter = 1
ValidKubernetesCloudProviderBackoffDuration = 5
ValidKubernetesCloudProviderBackoffExponent = 1.5
ValidKubernetesCloudProviderRateLimit = false
ValidKubernetesCloudProviderRateLimitQPS = 3
ValidKubernetesCloudProviderRateLimitBucket = 10
)
func Test_OrchestratorProfile_Validate(t *testing.T) {
o := &OrchestratorProfile{
OrchestratorType: "DCOS",
@ -21,20 +36,104 @@ func Test_OrchestratorProfile_Validate(t *testing.T) {
}
func Test_KubernetesConfig_Validate(t *testing.T) {
c := KubernetesConfig{}
// Tests that should pass across all versions
for _, k8sVersion := range []OrchestratorVersion{Kubernetes153, Kubernetes157, Kubernetes160, Kubernetes162, Kubernetes166} {
c := KubernetesConfig{}
if err := c.Validate(k8sVersion); err != nil {
t.Errorf("should not error on empty KubernetesConfig: %v, version %s", err, k8sVersion)
}
if err := c.Validate(); err != nil {
t.Errorf("should not error on empty KubernetesConfig: %v", err)
c = KubernetesConfig{
ClusterSubnet: "10.120.0.0/16",
DockerBridgeSubnet: "10.120.1.0/16",
NodeStatusUpdateFrequency: ValidKubernetesNodeStatusUpdateFrequency,
CtrlMgrNodeMonitorGracePeriod: ValidKubernetesCtrlMgrNodeMonitorGracePeriod,
CtrlMgrPodEvictionTimeout: ValidKubernetesCtrlMgrPodEvictionTimeout,
CtrlMgrRouteReconciliationPeriod: ValidKubernetesCtrlMgrRouteReconciliationPeriod,
CloudProviderBackoff: ValidKubernetesCloudProviderBackoff,
CloudProviderBackoffRetries: ValidKubernetesCloudProviderBackoffRetries,
CloudProviderBackoffJitter: ValidKubernetesCloudProviderBackoffJitter,
CloudProviderBackoffDuration: ValidKubernetesCloudProviderBackoffDuration,
CloudProviderBackoffExponent: ValidKubernetesCloudProviderBackoffExponent,
CloudProviderRateLimit: ValidKubernetesCloudProviderRateLimit,
CloudProviderRateLimitQPS: ValidKubernetesCloudProviderRateLimitQPS,
CloudProviderRateLimitBucket: ValidKubernetesCloudProviderRateLimitBucket,
}
if err := c.Validate(k8sVersion); err != nil {
t.Errorf("should not error on a KubernetesConfig with valid param values: %v", err)
}
c = KubernetesConfig{
ClusterSubnet: "10.16.x.0/invalid",
}
if err := c.Validate(k8sVersion); err == nil {
t.Error("should error on invalid ClusterSubnet")
}
c = KubernetesConfig{
DockerBridgeSubnet: "10.120.1.0/invalid",
}
if err := c.Validate(k8sVersion); err == nil {
t.Error("should error on invalid DockerBridgeSubnet")
}
c = KubernetesConfig{
NodeStatusUpdateFrequency: "invalid",
}
if err := c.Validate(k8sVersion); err == nil {
t.Error("should error on invalid NodeStatusUpdateFrequency")
}
c = KubernetesConfig{
CtrlMgrNodeMonitorGracePeriod: "invalid",
}
if err := c.Validate(k8sVersion); err == nil {
t.Error("should error on invalid CtrlMgrNodeMonitorGracePeriod")
}
c = KubernetesConfig{
NodeStatusUpdateFrequency: "10s",
CtrlMgrNodeMonitorGracePeriod: "30s",
}
if err := c.Validate(k8sVersion); err == nil {
t.Error("should error when CtrlMgrRouteReconciliationPeriod is not sufficiently larger than NodeStatusUpdateFrequency")
}
c = KubernetesConfig{
CtrlMgrPodEvictionTimeout: "invalid",
}
if err := c.Validate(k8sVersion); err == nil {
t.Error("should error on invalid CtrlMgrPodEvictionTimeout")
}
c = KubernetesConfig{
CtrlMgrRouteReconciliationPeriod: "invalid",
}
if err := c.Validate(k8sVersion); err == nil {
t.Error("should error on invalid CtrlMgrRouteReconciliationPeriod")
}
}
c.ClusterSubnet = "10.120.0.0/16"
if err := c.Validate(); err != nil {
t.Errorf("should not error on valid ClusterSubnet: %v", err)
// Tests that apply to pre-1.6.6 versions
for _, k8sVersion := range []OrchestratorVersion{Kubernetes153, Kubernetes157, Kubernetes160, Kubernetes162} {
c := KubernetesConfig{
CloudProviderBackoff: true,
CloudProviderRateLimit: true,
}
if err := c.Validate(k8sVersion); err == nil {
t.Error("should error because backoff and rate limiting are not available before v1.6.6")
}
}
c.ClusterSubnet = "10.16.x.0/invalid"
if err := c.Validate(); err == nil {
t.Error("should error on invalid ClusterSubnet")
// Tests that apply to 1.6.6 and later versions
for _, k8sVersion := range []OrchestratorVersion{Kubernetes166} {
c := KubernetesConfig{
CloudProviderBackoff: true,
CloudProviderRateLimit: true,
}
if err := c.Validate(k8sVersion); err != nil {
t.Error("should not error when basic backoff and rate limiting are set to true with no options")
}
}
}