diff --git a/pkg/deployment/resources/services.go b/pkg/deployment/resources/services.go index c823e597a..d0c9f0952 100644 --- a/pkg/deployment/resources/services.go +++ b/pkg/deployment/resources/services.go @@ -78,8 +78,7 @@ func (r *Resources) EnsureServices() error { if single { role = "single" } - sessionAffinity := v1.ServiceAffinityClientIP - if err := r.ensureExternalAccessServices(eaServiceName, ns, role, "database", k8sutil.ArangoPort, false, sessionAffinity, spec.ExternalAccess, apiObject, log, kubecli); err != nil { + if err := r.ensureExternalAccessServices(eaServiceName, ns, role, "database", k8sutil.ArangoPort, false, spec.ExternalAccess, apiObject, log, kubecli); err != nil { return maskAny(err) } @@ -87,8 +86,7 @@ func (r *Resources) EnsureServices() error { // External (and internal) Sync master service eaServiceName := k8sutil.CreateSyncMasterClientServiceName(apiObject.GetName()) role := "syncmaster" - sessionAffinity := v1.ServiceAffinityNone - if err := r.ensureExternalAccessServices(eaServiceName, ns, role, "sync", k8sutil.ArangoSyncMasterPort, true, sessionAffinity, spec.Sync.ExternalAccess.ExternalAccessSpec, apiObject, log, kubecli); err != nil { + if err := r.ensureExternalAccessServices(eaServiceName, ns, role, "sync", k8sutil.ArangoSyncMasterPort, true, spec.Sync.ExternalAccess.ExternalAccessSpec, apiObject, log, kubecli); err != nil { return maskAny(err) } status := r.context.GetStatus() @@ -103,7 +101,7 @@ func (r *Resources) EnsureServices() error { } // EnsureServices creates all services needed to service the deployment -func (r *Resources) ensureExternalAccessServices(eaServiceName, ns, svcRole, title string, port int, noneIsClusterIP bool, sessionAffinity v1.ServiceAffinity, spec api.ExternalAccessSpec, apiObject k8sutil.APIObject, log zerolog.Logger, kubecli kubernetes.Interface) error { +func (r *Resources) ensureExternalAccessServices(eaServiceName, ns, svcRole, title string, port int, noneIsClusterIP bool, spec api.ExternalAccessSpec, apiObject k8sutil.APIObject, log zerolog.Logger, kubecli kubernetes.Interface) error { // Database external access service createExternalAccessService := false deleteExternalAccessService := false @@ -170,10 +168,7 @@ func (r *Resources) ensureExternalAccessServices(eaServiceName, ns, svcRole, tit // Let's create or update the database external access service nodePort := spec.GetNodePort() loadBalancerIP := spec.GetLoadBalancerIP() - if eaServiceType == v1.ServiceTypeLoadBalancer { - sessionAffinity = v1.ServiceAffinityNone - } - _, newlyCreated, err := k8sutil.CreateExternalAccessService(kubecli, eaServiceName, svcRole, apiObject, eaServiceType, port, nodePort, loadBalancerIP, sessionAffinity, apiObject.AsOwner()) + _, newlyCreated, err := k8sutil.CreateExternalAccessService(kubecli, eaServiceName, svcRole, apiObject, eaServiceType, port, nodePort, loadBalancerIP, apiObject.AsOwner()) if err != nil { log.Debug().Err(err).Msgf("Failed to create %s external access service", title) return maskAny(err) diff --git a/pkg/util/k8sutil/services.go b/pkg/util/k8sutil/services.go index 509ba11e9..dc935e37d 100644 --- a/pkg/util/k8sutil/services.go +++ b/pkg/util/k8sutil/services.go @@ -68,9 +68,8 @@ func CreateHeadlessService(kubecli kubernetes.Interface, deployment metav1.Objec }, } publishNotReadyAddresses := false - sessionAffinity := v1.ServiceAffinityNone serviceType := v1.ServiceTypeClusterIP - newlyCreated, err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), ClusterIPNone, "", serviceType, ports, "", publishNotReadyAddresses, sessionAffinity, owner) + newlyCreated, err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), ClusterIPNone, "", serviceType, ports, "", publishNotReadyAddresses, owner) if err != nil { return "", false, maskAny(err) } @@ -98,9 +97,8 @@ func CreateDatabaseClientService(kubecli kubernetes.Interface, deployment metav1 role = "coordinator" } publishNotReadyAddresses := true - sessionAffinity := v1.ServiceAffinityClientIP serviceType := v1.ServiceTypeClusterIP - newlyCreated, err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), "", role, serviceType, ports, "", publishNotReadyAddresses, sessionAffinity, owner) + newlyCreated, err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), "", role, serviceType, ports, "", publishNotReadyAddresses, owner) if err != nil { return "", false, maskAny(err) } @@ -111,7 +109,7 @@ func CreateDatabaseClientService(kubecli kubernetes.Interface, deployment metav1 // If the service already exists, nil is returned. // If another error occurs, that error is returned. // The returned bool is true if the service is created, or false when the service already existed. -func CreateExternalAccessService(kubecli kubernetes.Interface, svcName, role string, deployment metav1.Object, serviceType v1.ServiceType, port, nodePort int, loadBalancerIP string, sessionAffinity v1.ServiceAffinity, owner metav1.OwnerReference) (string, bool, error) { +func CreateExternalAccessService(kubecli kubernetes.Interface, svcName, role string, deployment metav1.Object, serviceType v1.ServiceType, port, nodePort int, loadBalancerIP string, owner metav1.OwnerReference) (string, bool, error) { deploymentName := deployment.GetName() ports := []v1.ServicePort{ v1.ServicePort{ @@ -122,7 +120,7 @@ func CreateExternalAccessService(kubecli kubernetes.Interface, svcName, role str }, } publishNotReadyAddresses := true - newlyCreated, err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), "", role, serviceType, ports, loadBalancerIP, publishNotReadyAddresses, sessionAffinity, owner) + newlyCreated, err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), "", role, serviceType, ports, loadBalancerIP, publishNotReadyAddresses, owner) if err != nil { return "", false, maskAny(err) } @@ -134,7 +132,7 @@ func CreateExternalAccessService(kubecli kubernetes.Interface, svcName, role str // If another error occurs, that error is returned. // The returned bool is true if the service is created, or false when the service already existed. func createService(kubecli kubernetes.Interface, svcName, deploymentName, ns, clusterIP, role string, serviceType v1.ServiceType, - ports []v1.ServicePort, loadBalancerIP string, publishNotReadyAddresses bool, sessionAffinity v1.ServiceAffinity, owner metav1.OwnerReference) (bool, error) { + ports []v1.ServicePort, loadBalancerIP string, publishNotReadyAddresses bool, owner metav1.OwnerReference) (bool, error) { labels := LabelsForDeployment(deploymentName, role) svc := &v1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -153,7 +151,6 @@ func createService(kubecli kubernetes.Interface, svcName, deploymentName, ns, cl Selector: labels, ClusterIP: clusterIP, PublishNotReadyAddresses: publishNotReadyAddresses, - SessionAffinity: sessionAffinity, LoadBalancerIP: loadBalancerIP, }, }