From 9a243ac0918d65bd0fae72552852cf6816de5b91 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 18 Apr 2018 01:08:21 +0200 Subject: [PATCH 1/2] Use kubernetes major version for service options --- cluster/plan.go | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/cluster/plan.go b/cluster/plan.go index 6a05881f..3f6308fa 100644 --- a/cluster/plan.go +++ b/cluster/plan.go @@ -122,8 +122,8 @@ func (c *Cluster) BuildKubeAPIProcess(prefixPath string) v3.Process { CommandArgs["cloud-config"] = CloudConfigPath } // check if our version has specific options for this component - serviceOptions, ok := v3.K8sVersionServiceOptions[c.Version] - if ok && serviceOptions.KubeAPI != nil { + serviceOptions := GetKubernetesServicesOptions(c.Version) + if serviceOptions.KubeAPI != nil { for k, v := range serviceOptions.KubeAPI { CommandArgs[k] = v } @@ -213,8 +213,8 @@ func (c *Cluster) BuildKubeControllerProcess(prefixPath string) v3.Process { } // check if our version has specific options for this component - serviceOptions, ok := v3.K8sVersionServiceOptions[c.Version] - if ok && serviceOptions.KubeController != nil { + serviceOptions := GetKubernetesServicesOptions(c.Version) + if serviceOptions.KubeController != nil { for k, v := range serviceOptions.KubeController { CommandArgs[k] = v } @@ -302,8 +302,8 @@ func (c *Cluster) BuildKubeletProcess(host *hosts.Host, prefixPath string) v3.Pr } // check if our version has specific options for this component - serviceOptions, ok := v3.K8sVersionServiceOptions[c.Version] - if ok && serviceOptions.Kubelet != nil { + serviceOptions := GetKubernetesServicesOptions(c.Version) + if serviceOptions.Kubelet != nil { for k, v := range serviceOptions.Kubelet { CommandArgs[k] = v } @@ -375,8 +375,8 @@ func (c *Cluster) BuildKubeProxyProcess(prefixPath string) v3.Process { } // check if our version has specific options for this component - serviceOptions, ok := v3.K8sVersionServiceOptions[c.Version] - if ok && serviceOptions.Kubeproxy != nil { + serviceOptions := GetKubernetesServicesOptions(c.Version) + if serviceOptions.Kubeproxy != nil { for k, v := range serviceOptions.Kubeproxy { CommandArgs[k] = v } @@ -458,8 +458,8 @@ func (c *Cluster) BuildSchedulerProcess(prefixPath string) v3.Process { } // check if our version has specific options for this component - serviceOptions, ok := v3.K8sVersionServiceOptions[c.Version] - if ok && serviceOptions.Scheduler != nil { + serviceOptions := GetKubernetesServicesOptions(c.Version) + if serviceOptions.Scheduler != nil { for k, v := range serviceOptions.Scheduler { CommandArgs[k] = v } @@ -609,3 +609,13 @@ func (c *Cluster) getPrefixPath(osType string) string { } return prefixPath } + +func GetKubernetesServicesOptions(version string) v3.KubernetesServicesOptions { + splitVersion := strings.Split(version, ".") + majorVersion := strings.Join(splitVersion[:2], ".") + serviceOptions, ok := v3.K8sVersionServiceOptions[majorVersion] + if ok { + return serviceOptions + } + return v3.KubernetesServicesOptions{} +} From 8d928f37b079b5a0fc0f3475e848399b893923dd Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 18 Apr 2018 01:46:43 +0200 Subject: [PATCH 2/2] vendor update --- vendor.conf | 2 +- .../types/apis/management.cattle.io/v3/cluster_types.go | 3 +++ .../types/apis/management.cattle.io/v3/k8s_defaults.go | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/vendor.conf b/vendor.conf index a1c57683..a9057963 100644 --- a/vendor.conf +++ b/vendor.conf @@ -24,4 +24,4 @@ github.com/coreos/go-semver e214231b295a8ea9479f11b70b35d5acf3556d9 github.com/ugorji/go/codec ccfe18359b55b97855cee1d3f74e5efbda4869dc github.com/rancher/norman ff60298f31f081b06d198815b4c178a578664f7d -github.com/rancher/types 32ed9ccfe5b3ffd6acff15e354c0dd713f5b88d7 +github.com/rancher/types 681245a6f5e7b007ae58f0eb3e9f956d93930368 diff --git a/vendor/github.com/rancher/types/apis/management.cattle.io/v3/cluster_types.go b/vendor/github.com/rancher/types/apis/management.cattle.io/v3/cluster_types.go index 89ece733..2832fd28 100644 --- a/vendor/github.com/rancher/types/apis/management.cattle.io/v3/cluster_types.go +++ b/vendor/github.com/rancher/types/apis/management.cattle.io/v3/cluster_types.go @@ -28,6 +28,9 @@ const ( ClusterConditionconditionDefautlProjectCreated condition.Cond = "DefaultProjectCreated" // ClusterConditionDefaultNamespaceAssigned true when cluster's default namespace has been initially assigned ClusterConditionDefaultNamespaceAssigned condition.Cond = "DefaultNamespaceAssigned" + // ClusterConditionSystemNamespacesAssigned true when cluster's system namespaces has been initially assigned to + // a system project + ClusterConditionSystemNamespacesAssigned condition.Cond = "SystemNamespacesAssigned" ClusterConditionAddonDeploy condition.Cond = "AddonDeploy" ClusterConditionSystemAccountCreated condition.Cond = "SystemAccountCreated" ClusterConditionAgentDeployed condition.Cond = "AgentDeployed" diff --git a/vendor/github.com/rancher/types/apis/management.cattle.io/v3/k8s_defaults.go b/vendor/github.com/rancher/types/apis/management.cattle.io/v3/k8s_defaults.go index fc07dee8..e533c989 100644 --- a/vendor/github.com/rancher/types/apis/management.cattle.io/v3/k8s_defaults.go +++ b/vendor/github.com/rancher/types/apis/management.cattle.io/v3/k8s_defaults.go @@ -4,6 +4,8 @@ const ( K8sV18 = "v1.8.10-rancher1-1" K8sV19 = "v1.9.5-rancher1-1" K8sV110 = "v1.10.0-rancher1-1" + + MajorK8sV110 = "v1.10" ) var ( @@ -16,7 +18,7 @@ var ( // K8sVersionServiceOptions - service options per k8s version K8sVersionServiceOptions = map[string]KubernetesServicesOptions{ - K8sV110: v110ServiceOptions, + MajorK8sV110: v110ServiceOptions, } // K8SVersionToSystemImages16 - images map for 1.6. Keeping it sepate in case we have to diverge