From f2405cf2942739996af2bb76347c2cb0641153aa Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Fri, 1 Dec 2017 11:09:57 +0000 Subject: [PATCH] Disable session affinity for internal kuberntes service Under following conditions session affinity leads to a deadlock: - Self hosted controller-manager, where it talks to API servers via kubernetes service ClusterIP - default master-count reconcilier is used - --apiserver-count is set to >1 according to the help message - number of responsive APIServers goes below `apiserver-count` - all controller-managers happen to be hashed to APIServers which are down. What then happens is that controller managers never be able to contact APIServer, despite correctly working APIServer available. Less serious outages also possible for other consumers of kubernetes service, such as operators, kube-dns, flannel & calico, etc. There is always non zero chance, that given consumer is hashed to an apiserver which is down. Revert "give the kubernetes service client ip session affinity" This reverts commit e21ebbcac404bb6ed2b6caaf7d067a966bed2683. --- pkg/master/controller.go | 2 +- pkg/master/controller_test.go | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/master/controller.go b/pkg/master/controller.go index ef919b2963d43..fc7f52acda044 100644 --- a/pkg/master/controller.go +++ b/pkg/master/controller.go @@ -274,7 +274,7 @@ func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, ser // maintained by this code, not by the pod selector Selector: nil, ClusterIP: serviceIP.String(), - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: serviceType, }, } diff --git a/pkg/master/controller_test.go b/pkg/master/controller_test.go index ec7d63158e86e..a20d82cd698d6 100644 --- a/pkg/master/controller_test.go +++ b/pkg/master/controller_test.go @@ -570,7 +570,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -625,7 +625,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -637,7 +637,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -658,7 +658,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -671,7 +671,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -691,7 +691,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -703,7 +703,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -723,7 +723,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -735,7 +735,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -755,7 +755,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -767,7 +767,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -787,7 +787,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -799,7 +799,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -819,7 +819,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeNodePort, }, }, @@ -831,7 +831,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -851,7 +851,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, }, @@ -910,7 +910,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) { }, Selector: nil, ClusterIP: "1.2.3.4", - SessionAffinity: api.ServiceAffinityClientIP, + SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, }, },