From 4165510395a3354c2488a2db6bbceb644b5376e8 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Mon, 5 Feb 2018 17:50:39 +0200 Subject: [PATCH] Move network plugin images to SystemImages --- cluster.yml | 13 +++++++-- cluster/defaults.go | 55 ++++++++++++++++++++++++++++++-------- cluster/network.go | 65 ++++++++------------------------------------- 3 files changed, 66 insertions(+), 67 deletions(-) diff --git a/cluster.yml b/cluster.yml index c6b8c7ab..29fdeb2d 100644 --- a/cluster.yml +++ b/cluster.yml @@ -17,11 +17,20 @@ auth: # 'calico_cloud_provider: aws' # or # 'calico_cloud_provider: gce' +# network: +# plugin: calico +# options: +# calico_cloud_provider: aws +# +# To specify flannel interface, you can use the 'flannel_iface' option: +# network: +# plugin: flannel +# options: +# flannel_iface: eth1 + network: plugin: flannel options: - flannel_image: quay.io/coreos/flannel:v0.9.1 - flannel_cni_image: quay.io/coreos/flannel-cni:v0.2.0 ssh_key_path: ~/.ssh/test enforce_docker_version: false diff --git a/cluster/defaults.go b/cluster/defaults.go index 34e5acb9..2cc29845 100644 --- a/cluster/defaults.go +++ b/cluster/defaults.go @@ -25,7 +25,7 @@ const ( DefaultNetworkPlugin = "flannel" DefaultNetworkCloudProvider = "none" - DefaultInfraContainerImage = "gcr.io/google_containers/pause-amd64:3.0" + DefaultInfraContainerImage = "rancher/pause-amd64:3.0" DefaultAplineImage = "alpine:latest" DefaultNginxProxyImage = "rancher/rke-nginx-proxy:v0.1.1" DefaultCertDownloaderImage = "rancher/rke-cert-deployer:v0.1.1" @@ -35,20 +35,20 @@ const ( DefaultEtcdImage = "rancher/etcd:v3.0.17" DefaultK8sImage = "rancher/k8s:v1.8.5-rancher4" - DefaultFlannelImage = "quay.io/coreos/flannel:v0.9.1" - DefaultFlannelCNIImage = "quay.io/coreos/flannel-cni:v0.2.0" + DefaultFlannelImage = "rancher/coreos-flannel:v0.9.1" + DefaultFlannelCNIImage = "rancher/coreos-flannel-cni:v0.2.0" - DefaultCalicoNodeImage = "quay.io/calico/node:v2.6.2" - DefaultCalicoCNIImage = "quay.io/calico/cni:v1.11.0" - DefaultCalicoControllersImage = "quay.io/calico/kube-controllers:v1.0.0" - DefaultCalicoctlImage = "quay.io/calico/ctl:v1.6.2" + DefaultCalicoNodeImage = "rancher/calico-node:v2.6.2" + DefaultCalicoCNIImage = "rancher/calico-cni:v1.11.0" + DefaultCalicoControllersImage = "rancher/calico-kube-controllers:v1.0.0" + DefaultCalicoctlImage = "rancher/calico-ctl:v1.6.2" DefaultWeaveImage = "weaveworks/weave-kube:2.1.2" DefaultWeaveCNIImage = "weaveworks/weave-npc:2.1.2" - DefaultCanalNodeImage = "quay.io/calico/node:v2.6.2" - DefaultCanalCNIImage = "quay.io/calico/cni:v1.11.0" - DefaultCanalFlannelImage = "quay.io/coreos/flannel:v0.9.1" + DefaultCanalNodeImage = "rancher/calico-node:v2.6.2" + DefaultCanalCNIImage = "rancher/calico-cni:v1.11.0" + DefaultCanalFlannelImage = "rancher/coreos-flannel:v0.9.1" DefaultKubeDNSImage = "rancher/k8s-dns-kube-dns-amd64:1.14.5" DefaultDNSmasqImage = "rancher/k8s-dns-dnsmasq-nanny-amd64:1.14.5" @@ -123,7 +123,7 @@ func (c *Cluster) setClusterServicesDefaults() { &c.Services.KubeController.ClusterCIDR: DefaultClusterCIDR, &c.Services.Kubelet.ClusterDNSServer: DefaultClusterDNSService, &c.Services.Kubelet.ClusterDomain: DefaultClusterDomain, - &c.Services.Kubelet.InfraContainerImage: DefaultInfraContainerImage, + &c.Services.Kubelet.InfraContainerImage: c.SystemImages.PodInfraContainer, &c.Authentication.Strategy: DefaultAuthStrategy, &c.Services.KubeAPI.Image: c.SystemImages.Kubernetes, &c.Services.Scheduler.Image: c.SystemImages.Kubernetes, @@ -150,8 +150,41 @@ func (c *Cluster) setClusterImageDefaults() { &c.SystemImages.KubernetesServicesSidecar: DefaultKubernetesServicesSidecarImage, &c.SystemImages.Etcd: DefaultEtcdImage, &c.SystemImages.Kubernetes: DefaultK8sImage, + &c.SystemImages.PodInfraContainer: DefaultInfraContainerImage, + &c.SystemImages.Flannel: DefaultFlannelImage, + &c.SystemImages.FlannelCNI: DefaultFlannelCNIImage, + &c.SystemImages.CalicoNode: DefaultCalicoNodeImage, + &c.SystemImages.CalicoCNI: DefaultCalicoCNIImage, + &c.SystemImages.CalicoControllers: DefaultCalicoControllersImage, + &c.SystemImages.CalicoCtl: DefaultCalicoctlImage, + &c.SystemImages.CanalNode: DefaultCanalNodeImage, + &c.SystemImages.CanalCNI: DefaultCanalCNIImage, + &c.SystemImages.CanalFlannel: DefaultCanalFlannelImage, + &c.SystemImages.WeaveNode: DefaultWeaveImage, + &c.SystemImages.WeaveCNI: DefaultWeaveCNIImage, } for k, v := range systemImagesDefaultsMap { setDefaultIfEmpty(k, v) } } + +func (c *Cluster) setClusterNetworkDefaults() { + setDefaultIfEmpty(&c.Network.Plugin, DefaultNetworkPlugin) + + if c.Network.Options == nil { + // don't break if the user didn't define options + c.Network.Options = make(map[string]string) + } + networkPluginConfigDefaultsMap := make(map[string]string) + switch c.Network.Plugin { + + case CalicoNetworkPlugin: + networkPluginConfigDefaultsMap = map[string]string{ + CalicoCloudProvider: DefaultNetworkCloudProvider, + } + } + for k, v := range networkPluginConfigDefaultsMap { + setDefaultIfEmptyMapValue(c.Network.Options, k, v) + } + +} diff --git a/cluster/network.go b/cluster/network.go index 5b6026aa..85faaba5 100644 --- a/cluster/network.go +++ b/cluster/network.go @@ -115,8 +115,8 @@ func (c *Cluster) DeployNetworkPlugin(ctx context.Context) error { func (c *Cluster) doFlannelDeploy(ctx context.Context) error { flannelConfig := map[string]string{ ClusterCIDR: c.ClusterCIDR, - Image: c.Network.Options[FlannelImage], - CNIImage: c.Network.Options[FlannelCNIImage], + Image: c.SystemImages.Flannel, + CNIImage: c.SystemImages.FlannelCNI, FlannelInterface: c.Network.Options[FlannelIface], RBACConfig: c.Authorization.Mode, } @@ -143,10 +143,10 @@ func (c *Cluster) doCalicoDeploy(ctx context.Context) error { ClientCAPath: pki.GetCertPath(pki.CACertName), KubeCfg: clientConfig, ClusterCIDR: c.ClusterCIDR, - CNIImage: c.Network.Options[CalicoCNIImage], - NodeImage: c.Network.Options[CalicoNodeImage], - ControllersImage: c.Network.Options[CalicoControllersImage], - Calicoctl: c.Network.Options[CalicoctlImage], + CNIImage: c.SystemImages.CalicoCNI, + NodeImage: c.SystemImages.CalicoNode, + ControllersImage: c.SystemImages.CalicoControllers, + Calicoctl: c.SystemImages.CalicoCtl, CloudProvider: c.Network.Options[CalicoCloudProvider], RBACConfig: c.Authorization.Mode, } @@ -166,9 +166,9 @@ func (c *Cluster) doCanalDeploy(ctx context.Context) error { ClientCAPath: pki.GetCertPath(pki.CACertName), KubeCfg: clientConfig, ClusterCIDR: c.ClusterCIDR, - NodeImage: c.Network.Options[CanalNodeImage], - CNIImage: c.Network.Options[CanalCNIImage], - CanalFlannelImg: c.Network.Options[CanalFlannelImage], + NodeImage: c.SystemImages.CanalNode, + CNIImage: c.SystemImages.CanalCNI, + CanalFlannelImg: c.SystemImages.CanalFlannel, RBACConfig: c.Authorization.Mode, } pluginYaml, err := c.getNetworkPluginManifest(canalConfig) @@ -181,8 +181,8 @@ func (c *Cluster) doCanalDeploy(ctx context.Context) error { func (c *Cluster) doWeaveDeploy(ctx context.Context) error { weaveConfig := map[string]string{ ClusterCIDR: c.ClusterCIDR, - Image: c.Network.Options[WeaveImage], - CNIImage: c.Network.Options[WeaveCNIImage], + Image: c.SystemImages.WeaveNode, + CNIImage: c.SystemImages.WeaveCNI, RBACConfig: c.Authorization.Mode, } pluginYaml, err := c.getNetworkPluginManifest(weaveConfig) @@ -192,49 +192,6 @@ func (c *Cluster) doWeaveDeploy(ctx context.Context) error { return c.doAddonDeploy(ctx, pluginYaml, NetworkPluginResourceName) } -func (c *Cluster) setClusterNetworkDefaults() { - setDefaultIfEmpty(&c.Network.Plugin, DefaultNetworkPlugin) - - if c.Network.Options == nil { - // don't break if the user didn't define options - c.Network.Options = make(map[string]string) - } - networkPluginConfigDefaultsMap := make(map[string]string) - switch c.Network.Plugin { - case FlannelNetworkPlugin: - networkPluginConfigDefaultsMap = map[string]string{ - FlannelImage: DefaultFlannelImage, - FlannelCNIImage: DefaultFlannelCNIImage, - } - - case CalicoNetworkPlugin: - networkPluginConfigDefaultsMap = map[string]string{ - CalicoCNIImage: DefaultCalicoCNIImage, - CalicoNodeImage: DefaultCalicoNodeImage, - CalicoControllersImage: DefaultCalicoControllersImage, - CalicoCloudProvider: DefaultNetworkCloudProvider, - CalicoctlImage: DefaultCalicoctlImage, - } - - case CanalNetworkPlugin: - networkPluginConfigDefaultsMap = map[string]string{ - CanalCNIImage: DefaultCanalCNIImage, - CanalNodeImage: DefaultCanalNodeImage, - CanalFlannelImage: DefaultCanalFlannelImage, - } - - case WeaveNetworkPlugin: - networkPluginConfigDefaultsMap = map[string]string{ - WeaveImage: DefaultWeaveImage, - WeaveCNIImage: DefaultWeaveCNIImage, - } - } - for k, v := range networkPluginConfigDefaultsMap { - setDefaultIfEmptyMapValue(c.Network.Options, k, v) - } - -} - func (c *Cluster) getNetworkPluginManifest(pluginConfig map[string]string) (string, error) { switch c.Network.Plugin { case FlannelNetworkPlugin: