Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the disable-load-balancer flag that replace the type of service from LoadBalancer to ClusterIP #757

Merged
merged 2 commits into from Oct 19, 2021

Conversation

liranmauda
Copy link
Contributor

@liranmauda liranmauda commented Oct 17, 2021

Adding the disable-load-balancer flag that replaces the type of service from LoadBalancer to ClusterIP

Functionality

  • Adding the disable-load-balancer flag to the options
  • Add the disable-load-balancer flag functionality in the install command

It will be respected only in pod start/restart, and will not be reconciled after

Testing

  • Run noobaa install --disable-load-balancer and see that the service type is ClusterIP

// ServiceTypeLoadBalancer (optional) sets the service type to LoadBalancer instead of ClusterIP
// +nullable
// +optional
ServiceTypeLoadBalancer bool `json:"serviceTypeLoadBalancer,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a disabling flag, e.g. DisableLoadBalancerService, instead of using an enabling flag.

the problem with using an enabling flag is that after upgrading, existing CRs will not have this flag set and it will change the service to ClusterIP.
of course, if we want ClusterIP to be the default for new systems we will need to pass DisableLoadBalancerService: true in noobaa CR from CLI or ocs-operator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was thinking the same after doing this PR.
And I think we should not default it.

I will change it.

another point is what should we do with the ExternalDNS?
@dannyzaken WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, in second thought regarding Phase4, I think we should handle it also, hance, we let it be changed after installation.
WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @liranmauda, looks good! 🙄

There is also code logic that might require tweaking in phase3 - CheckServiceStatus() assumes NodePort in service ports, however this field is missing in ClusterIP:

   clusterIP: 10.101.217.181
   ports:
   - name: mgmt
     port: 1780
     protocol: TCP
     targetPort: 8080
   ...

For dynamic LoadBalancer <-> ClusterIP transition (are we going to support that ?), those NodePorts should be removed from the ports array during LoadBalancer -> ClusterIP transition, in addition to Service type change. This logic probably belongs to phase2 SetDesiredServiceMgmt() and SetDesiredServiceS3()

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baum
Regarding the ports, yes we should probably also remove them, but as far as I know, the ports are getting ignored on ClusterIP, Am I correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure.

In OCP cluster, using kubectl patch, no NodePort removal is required:

NAME   TYPE           CLUSTER-IP      EXTERNAL-IP                                                              PORT(S)                                                    AGE
➜  noobaa-operator git:(master) k patch svc -n baum-5-9-0 s3  -p '{"spec": {"type": "ClusterIP" }}'
service/s3 patched
➜  noobaa-operator git:(master) k get svc -n baum-5-9-0 s3
NAME   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                            AGE
s3     ClusterIP   172.30.99.106   <none>        80/TCP,443/TCP,8444/TCP,7004/TCP   3d22h

However in my dev cluster, I get an error:

➜  noobaa-operator git:(master) k patch svc  s3  -p '{"spec": {"type": "ClusterIP" }}'
The Service "s3" is invalid:
* spec.ports[0].nodePort: Forbidden: may not be used when `type` is 'ClusterIP'
* spec.ports[1].nodePort: Forbidden: may not be used when `type` is 'ClusterIP'
* spec.ports[2].nodePort: Forbidden: may not be used when `type` is 'ClusterIP'
* spec.ports[3].nodePort: Forbidden: may not be used when `type` is 'ClusterIP'```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baum
So I guess we should move that into the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://pkg.go.dev/k8s.io/api/core/v1#ServicePort.NodePort

This field will be wiped when updating a Service to no longer need it (e.g. changing type
from NodePort to ClusterIP).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@liranmauda liranmauda changed the title Replace the type of service from LoadBalancer to ClusterIP Adding the disable-load-balancer flag that replace the type of service from LoadBalancer to ClusterIP Oct 18, 2021
@liranmauda liranmauda force-pushed the liran-ClusterIP branch 3 times, most recently from f7e1166 to 96619e1 Compare October 18, 2021 12:40
Adding the disable-load-balancer flag to the options

Signed-off-by: liranmauda <liran.mauda@gmail.com>
pkg/system/phase2_creating.go Outdated Show resolved Hide resolved
pkg/system/phase2_creating.go Outdated Show resolved Hide resolved
pkg/system/phase2_creating.go Outdated Show resolved Hide resolved
pkg/system/phase2_creating.go Outdated Show resolved Hide resolved
Add the disable-load-balancer flag functionality in install

Signed-off-by: liranmauda <liran.mauda@gmail.com>
@liranmauda liranmauda merged commit 90b21f4 into noobaa:master Oct 19, 2021
@liranmauda liranmauda deleted the liran-ClusterIP branch November 7, 2021 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants