From a3bddf6ecd131068f9ad0adf472157a4e5f005bb Mon Sep 17 00:00:00 2001 From: Bryan Zubrod Date: Tue, 11 Jul 2017 18:12:11 -0500 Subject: [PATCH] services-controller: Add LoadBalancer Service support (#53) * Allow LoadBalancer Service type * Update docs --- README.md | 8 ++++---- app/controllers/network_routes_controller.go | 2 +- app/controllers/network_services_controller.go | 4 ++-- app/options/options.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8f4373ad..8cd598be 100644 --- a/README.md +++ b/README.md @@ -120,10 +120,10 @@ leverages standard Linux technologies **iptables, ipvs/lvs, ipset, iproute2** [Kubernetes network services proxy with IPVS/LVS](https://cloudnativelabs.github.io/post/2017-05-10-kube-network-service-proxy/) Kube-router uses IPVS/LVS technology built in Linux to provide L4 load -balancing. Each **ClusterIP** and **NodePort** Kubernetes Service type is -configured as an IPVS virtual service. Each Service Endpoint is configured as -real server to the virtual service. The standard **ipvsadm** tool can be used -to verify the configuration and monitor the active connections. +balancing. Each **ClusterIP**, **NodePort**, and **LoadBalancer** Kubernetes +Service type is configured as an IPVS virtual service. Each Service Endpoint is +configured as real server to the virtual service. The standard **ipvsadm** tool +can be used to verify the configuration and monitor the active connections. Below is example set of Services on Kubernetes: diff --git a/app/controllers/network_routes_controller.go b/app/controllers/network_routes_controller.go index 4adebb0d..a2d0ca22 100644 --- a/app/controllers/network_routes_controller.go +++ b/app/controllers/network_routes_controller.go @@ -118,7 +118,7 @@ func (nrc *NetworkRoutingController) Run(stopCh <-chan struct{}, wg *sync.WaitGr if nrc.advertiseClusterIp { glog.Infof("Advertising cluster ips") for _, svc := range watchers.ServiceWatcher.List() { - if svc.Spec.Type == "ClusterIP" || svc.Spec.Type == "NodePort" { + if svc.Spec.Type == "ClusterIP" || svc.Spec.Type == "NodePort" || svc.Spec.Type == "LoadBalancer" { // skip headless services if svc.Spec.ClusterIP == "None" || svc.Spec.ClusterIP == "" { diff --git a/app/controllers/network_services_controller.go b/app/controllers/network_services_controller.go index 69ed8239..bea53ac0 100644 --- a/app/controllers/network_services_controller.go +++ b/app/controllers/network_services_controller.go @@ -34,7 +34,7 @@ var ( ) // Network services controller enables local node as network service proxy through IPVS/LVS. -// Support only Kuberntes network services of type NodePort, ClusterIP. For each service a +// Support only Kubernetes network services of type NodePort, ClusterIP, and LoadBalancer. For each service a // IPVS service is created and for each service endpoint a server is added to the IPVS service. // As services and endpoints are updated, network service controller gets the updates from // the kubernetes api server and syncs the ipvs configuration to reflect state of services @@ -317,7 +317,7 @@ func buildServicesInfo() serviceInfoMap { continue } - if svc.Spec.Type == "LoadBalancer" || svc.Spec.Type == "ExternalName" { + if svc.Spec.Type == "ExternalName" { glog.Infof("Skipping service name:%s namespace:%s due to service Type=%s", svc.Name, svc.Namespace, svc.Spec.Type) continue } diff --git a/app/options/options.go b/app/options/options.go index 22a98b53..56209806 100755 --- a/app/options/options.go +++ b/app/options/options.go @@ -63,5 +63,5 @@ func (s *KubeRouterConfig) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&s.PeerAsn, "peer-asn", s.PeerAsn, "ASN number of the BGP peer to which cluster nodes will advertise cluster ip and node's pod cidr") fs.BoolVar(&s.FullMeshMode, "nodes-full-mesh", s.FullMeshMode, "When enabled each node in the cluster will setup BGP peer with rest of the nodes. True by default") fs.StringVar(&s.HostnameOverride, "hostname-override", s.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname.") - fs.BoolVar(&s.GlobalHairpinMode, "hairpin-mode", s.GlobalHairpinMode, "Adds iptable rules for every ClusterIP Service Endpoint to support hairpin traffic. False by default") + fs.BoolVar(&s.GlobalHairpinMode, "hairpin-mode", s.GlobalHairpinMode, "Adds iptable rules for every Service Endpoint to support hairpin traffic. False by default") }