-
Notifications
You must be signed in to change notification settings - Fork 969
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
Allow to overwrite default ExternalTrafficPolicy for the service #1136
Allow to overwrite default ExternalTrafficPolicy for the service #1136
Conversation
Since you want to overwrite, should this not be in config map / crd config vs in the Postgres manifest? |
It could just come with "cluster" from config map as default and allow overwrite in manifest like we do with other properties and then this sounds good. |
pkg/cluster/k8sres.go
Outdated
// if spec.externalTrafficPolicy is not defined default value is "Cluster" | ||
if spec.ExternalTrafficPolicy != nil { | ||
serviceSpec.ExternalTrafficPolicy = *spec.ExternalTrafficPolicy | ||
if c.OpConfig.ExternalTrafficPolicy == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the absence of any kind of error handling just dealing with the empty case does not make sense or? it is already set to default to "Cluster" if not set. so just line 1625 is good enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if I am doing anything wrong, but I don't get default values in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but in no case is c.opconfig.externaltrafficpolicy "", which is fine. I would just argue this whole if statement can just be
serviceSpec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyType(c.OpConfig.ExternalTrafficPolicy)
You have the default properly set, so it should be cluster for everyone.
Everyone else switches it to Local.
And everyone else using something invalid gets an error.
So why deal/cover """
case extra?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, if I run tests and I don't define c.opConfig.ExternalTrafficPolicy, then I get "" here. Not the default "Cluster" that I expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's just because the way how the config is defined in tests.
Looks good to me, thanks for the fixes. |
👍 |
1 similar comment
👍 |
@yanchenko-igor thanks for a yet another contribution ! |
We would like to use Local ExternalTrafficPolicy for the services, so we can properly see the source IP of the clients connecting to the database, for this reason we would like to overwrite detault ExternalTraffixPolicy for the services created by postgres-operator.