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

add externalTrafficPolicy toggle #145

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

furstblumier
Copy link

See #144

## - Local
## - Cluster
## Set it to "Local" when used with type "LoadBalancer", unless you have a good reason not to.
# externalTrafficPolicy: Local
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe uncomment this line out? And then in service.yaml have:

externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}

Copy link
Author

Choose a reason for hiding this comment

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

Alrighty!

@furstblumier
Copy link
Author

good to go now I think

@kaktus42
Copy link

kaktus42 commented Feb 4, 2025

Great effort!

The way you do it now, it changes the original behaviour non-transparently.

When it's used with .Values.service.type: NodePort, it will not set externalTrafficPolicy to Cluster anymore.

Would be better to use an override and check if the override is given, else use original logic.

@furstblumier
Copy link
Author

Great effort!

The way you do it now, it changes the original behaviour non-transparently.

When it's used with .Values.service.type: NodePort, it will not set externalTrafficPolicy to Cluster anymore.

Would be better to use an override and check if the override is given, else use original logic.

I updated the comment in the values to reflect it a bit better, but essentially I removed the logic on purpose to also get edge cases, where the logic fails, to work. Maybe someone has a very good reason to do NodePort + Local or some other combination.

@furstblumier furstblumier requested a review from cfis February 4, 2025 20:17
@cfis
Copy link
Collaborator

cfis commented Feb 5, 2025

@kaktus42 - Not seeing a change? Service type has a default of "LoadBalancer" which would set "externalTrafficPolicy " to local, which is now its default.

Having said that, should the service default should be "ClusterIP"?

@furstblumier can you update the Chart version - that will make the lint command work.

@furstblumier
Copy link
Author

@cfis The issue isn't the chart version, but I think I can fix it. I'll also set the default to "ClusterIP" I guess.

@furstblumier
Copy link
Author

Sorry, I read it wrong. Should be good now

@cfis
Copy link
Collaborator

cfis commented Feb 6, 2025

Lint test failed....

@furstblumier
Copy link
Author

Bumped the chart version and hopefully fixed ci this time

@cfis
Copy link
Collaborator

cfis commented Feb 7, 2025

Same error as before:

namespace/docker-mailserver-oi25urtesg created
Error: INSTALLATION FAILED: 1 error occurred:

  • Service "docker-mailserver-oi25urtesg" is invalid: spec.externalTrafficPolicy: Invalid value: "Local": may only be set when type is 'NodePort' or 'LoadBalancer'

@furstblumier
Copy link
Author

Alright, now it should be fine. I wasn't aware that with service type "ClusterIP" you aren't "allowed" to set externalTrafficPolicy at all. I adjusted the values accordingly.

I also implemented the old default logic again. If you don't set "externalTrafficPolicy" it will use the previous defaults.

@@ -26,11 +26,17 @@ metadata:
spec:
## If a load balancer is being used, ensure that the newer type of LB that passes along IP information is used
## rather than the legacy one.
{{- if eq .Values.service.type "LoadBalancer" }}
{{- if or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer") }}
Copy link
Author

Choose a reason for hiding this comment

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

Only do this if we are using LB or NodePort

@@ -26,11 +26,17 @@ metadata:
spec:
## If a load balancer is being used, ensure that the newer type of LB that passes along IP information is used
## rather than the legacy one.
{{- if eq .Values.service.type "LoadBalancer" }}
{{- if or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer") }}
{{- if .Values.service.externalTrafficPolicy }}
Copy link
Author

Choose a reason for hiding this comment

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

if we have an explicit value set, use that

{{- if .Values.service.externalTrafficPolicy }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- end }}
{{- if and (not .Values.service.externalTrafficPolicy) (eq .Values.service.type "LoadBalancer") }}
Copy link
Author

Choose a reason for hiding this comment

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

if we don't have an explicit value set AND the type is Loadbalancer, use Local

externalTrafficPolicy: Local
{{- else if eq .Values.service.type "NodePort" }}
{{- end }}
{{- if and (not .Values.service.externalTrafficPolicy) (eq .Values.service.type "NodePort") }}
Copy link
Author

Choose a reason for hiding this comment

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

if we don't have an explicit value set AND the type is NodePort, use Cluster

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.

4 participants