-
Notifications
You must be signed in to change notification settings - Fork 985
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
r/service: Add external_traffic_policy
to spec
#59
r/service: Add external_traffic_policy
to spec
#59
Conversation
kubernetes/structure_service_spec.go
Outdated
@@ -136,6 +136,9 @@ func expandServiceSpec(l []interface{}) v1.ServiceSpec { | |||
if v, ok := in["external_name"].(string); ok { | |||
obj.ExternalName = v | |||
} | |||
if v, ok := in["external_traffic_policy"].(string); ok { | |||
obj.ExternalName = v |
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.
Is this corrrect - obj.ExternalName
?
Shouldn't that be something like obj.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.
We'll also need to modify flattenServiceSpec
similarly.
external_traffic_policy
to specexternal_traffic_policy
to spec
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.
Hi @phamann
thanks for the contribution.
Except what @sl1pm4t and I mentioned we'll need to upgrade vendored K8S to 1.7 as this field was introduced in that version. I planned to do it anyway - just FYI that this is a blocker. I'll hopefully get to it this week.
After vendor upgrade is done you'd just rebase your PR and run acceptance tests to see if everything's working correctly.
kubernetes/structure_service_spec.go
Outdated
@@ -136,6 +136,9 @@ func expandServiceSpec(l []interface{}) v1.ServiceSpec { | |||
if v, ok := in["external_name"].(string); ok { | |||
obj.ExternalName = v | |||
} | |||
if v, ok := in["external_traffic_policy"].(string); ok { | |||
obj.ExternalName = v |
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.
We'll also need to modify flattenServiceSpec
similarly.
Thanks for the review. I've now updated/added all of the correct references within The build is now failing (correctly) due to the vendored K8S not having the the field. As @radeksimko suggested, I'll wait until the upgrade has been done and then re-run. |
@radeksimko Any update on when you will upgrade the vendored K8S to 1.7? To resolve the issues with this PR? |
Since #80 has been merged, it seems this is due to be rebased. |
d6aedbf
to
f169008
Compare
@radeksimko Apologies for neglecting this this, we had the provider version pinned as a temporary resolution to this problem internally. Needing some other features in the latest release reminded me of this PR. I've now rebased with master and the tests are all passing 😄 |
Any update on this @radeksimko? It still has the |
I just smacked into this as well: |
This is good but should default to the Kubernetes default of @radeksimko, what else is needed to get this in? This is a very important feature. |
@phamann @radeksimko any update on this? |
Hi, guys. any update on this? i need this field to deploy nginx ingress controller with terraform. |
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.
LGTM
I need this field as well, going to pass on terraform and use kubectl :( |
@radeksimko this is a crucial element to deploy nginx ingress controller with terraform as previously mentioned. is there any timeline on this? |
I rebased this PR on top of the origin master and I pushed the branch here: |
@phamann if my rebase looks correct, to solve the git stuff, you could do like this:
This will refresh the current PR59 with the rebased version I proposed. |
"external_traffic_policy": { | ||
Type: schema.TypeString, | ||
Description: "Denotes if this Service desires to route external traffic to node-local or cluster-wide endpoints. `Local` preserves the client source IP and avoids a second hop for LoadBalancer and Nodeport type services, but risks potentially imbalanced traffic spreading. `Cluster` obscures the client source IP and may cause a second hop to another node, but should have good overall load-spreading. More info: https://kubernetes.io/docs/tutorials/services/source-ip/", | ||
Optional: true, |
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.
There are two possible values for this field: "Local" and "Cluster".
It'd be nice to have validation in place to express this.
Optional: true, | |
Optional: true, | |
ValidateFunc: validation.StringInSlice([]string{"Local", "Cluster"}, false), |
2ef8764
to
df911a9
Compare
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.
CI passes. LGTM.
Thanks for your work on this everyone. Really looking forward to taking advantage of it. |
This adds the
externalTrafficPolicy
property to the spec schema on the Service resource.By default k8s obscures the source IP from packets replacing it with the node IP. However certain applications require source IP preservation. This behaviour is managed via the
externalTrafficPolicy
. More info here: https://kubernetes.io/docs/tutorials/services/source-ip/Until recently we got around the lack of this property by using an internal k8s annotation to apply the behaviour using
service.metadata.annotations[0]
. However, #50 (and the 1.0.0 release) broke this by treating internal annotations as invalid. Using thespec.externalTrafficPolicy
is the preferred method anyway hence this PR.