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

Do not define loadBalancerIP on service unless set in values #430

Merged
merged 10 commits into from
Aug 23, 2023

Conversation

benyanke
Copy link
Contributor

@benyanke benyanke commented Aug 18, 2023

Pull Request

Description of the change

This PR sets the .Values.service.loadBalancerIP field as optional, and does not define it in the service if it's not set in the values.

This is because some LoadBalancer implementations allow or even require this value to remain unset, and while it may sometimes be fine to leave it set but blank, this could have unexpected impacts depending on your cluster configuration.

In particular, MetalLB will leave the service <pending> if the loadBalancerIP is set to nil, and hardcoding it to a value in the values breaks the ability for MetalLB's IPAM tooling to be used for dynamic address allocation. I suspect other LoadBalancer implementations may have similar behaviors.

Benefits

The primary benefit is more flexible usage with more LoadBalancer implementations.

Possible drawbacks

None I can think of, however I am open to discussion.

Applicable issues

Additional information

For easy review on the output, here is the before and after:

After - No LB set

Note how the loadBalancerIP is now gone when it's not defined, for more flexible usage.

$ helm template nextcloud . --set service.type=LoadBalancer | grep Service -A 15
kind: Service
metadata:
  name: nextcloud
  labels:
    app.kubernetes.io/name: nextcloud
    helm.sh/chart: nextcloud-3.6.0
    app.kubernetes.io/instance: nextcloud
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: app
spec:
  type: LoadBalancer
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
    name: http

After - LB Set

Note how the loadBalancerIP still works as before when it's defined, for full backward compatibility.

$ helm template nextcloud . --set service.type=LoadBalancer --set service.loadBalancerIP=1.2.3.4 | grep Service -A 15
kind: Service
metadata:
  name: nextcloud
  labels:
    app.kubernetes.io/name: nextcloud
    helm.sh/chart: nextcloud-3.6.0
    app.kubernetes.io/instance: nextcloud
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: app
spec:
  type: LoadBalancer
  loadBalancerIP: 1.2.3.4
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP

After - Forcing Previous Behavior

And if you still wish to template out the field with nil in the value as before, that is still supported by explicitly setting to nil.

$ helm template nextcloud . --set service.type=LoadBalancer --set service.loadBalancerIP=nil | grep Service -A 15
kind: Service
metadata:
  name: nextcloud
  labels:
    app.kubernetes.io/name: nextcloud
    helm.sh/chart: nextcloud-3.5.22
    app.kubernetes.io/instance: nextcloud
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: app
spec:
  type: LoadBalancer
  loadBalancerIP: nil
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP

Before

Note the nil in the loadBalancerIP field.

$ helm template nextcloud . --set service.type=LoadBalancer | grep Service -A 15
kind: Service
metadata:
  name: nextcloud
  labels:
    app.kubernetes.io/name: nextcloud
    helm.sh/chart: nextcloud-3.6.0
    app.kubernetes.io/instance: nextcloud
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: app
spec:
  type: LoadBalancer
  loadBalancerIP: nil
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
    name: http

Checklist

Signed-off-by: Ben Yanke <ben@benyanke.com>
Signed-off-by: Ben Yanke <ben@benyanke.com>
Signed-off-by: Ben Yanke <ben@benyanke.com>
Signed-off-by: Ben Yanke <ben@benyanke.com>
@benyanke
Copy link
Contributor Author

Thanks for the approval @provokateurin - is there anything else you need from me to get this merged?

@provokateurin
Copy link
Member

No, I'm just not experienced with the loadbalancer configuration so I want another review from @jessebot

@jessebot
Copy link
Collaborator

takin a peek :D

Signed-off-by: JesseBot <jessebot@linux.com>
@jessebot
Copy link
Collaborator

jessebot commented Aug 19, 2023

so this looks ok to me. I cloned benyanke:issue-428-b and did a helm template as is, and then again with service.type=LoadBalancer in the values.yaml and they both look correct. I've been using metallb and haven't seen issues with this in the past, but the pool I use is so small, and even with metallb, I still use clusterIP for my service type. Still, I think this is fair to merge :)

@jessebot jessebot self-requested a review August 19, 2023 14:30
@jessebot jessebot self-requested a review August 19, 2023 16:21
Copy link
Collaborator

@jessebot jessebot left a comment

Choose a reason for hiding this comment

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

Requesting just a bit of an update to use "" instead of omitting the value entirely. The change in templates/service.yaml is still good though :)

charts/nextcloud/values.yaml Outdated Show resolved Hide resolved
charts/nextcloud/README.md Outdated Show resolved Hide resolved
benyanke and others added 3 commits August 23, 2023 00:33
Signed-off-by: Ben Yanke <ben@benyanke.com>
Co-authored-by: JesseBot <jessebot@linux.com>
Signed-off-by: Ben Yanke <ben@benyanke.com>
Co-authored-by: JesseBot <jessebot@linux.com>
Signed-off-by: Ben Yanke <ben@benyanke.com>
@benyanke
Copy link
Contributor Author

Hi @jessebot - I've made the requested changes above.

@jessebot jessebot self-requested a review August 23, 2023 06:56
@jessebot
Copy link
Collaborator

@benyanke awesome, thanks for your hard work and patience on this! :) After the linter runs, I'll get this merged!

charts/nextcloud/README.md Outdated Show resolved Hide resolved
Signed-off-by: JesseBot <jessebot@linux.com>
Signed-off-by: JesseBot <jessebot@linux.com>
@provokateurin
Copy link
Member

Can we please squash this mess? 🙈

@jessebot
Copy link
Collaborator

Can we please squash this mess? 🙈

Absolutely! :) I always squash and merge so that the history looks a bit cleaner and then users can always inspect the PR for more granular commit data if they choose.

A maintainer can change the repo to only allow squash and merge through the general settings on this repo, but I don't have permissions for that, so right now I manually select it.

@jessebot jessebot merged commit 3d31fa1 into nextcloud:main Aug 23, 2023
2 checks passed
@benyanke
Copy link
Contributor Author

Absolutely agree, squash merging is the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not define loadBalancerIP on service unless set in values
3 participants