-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add option to use pod name rather than IP address for Kubernetes #1190
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 option to use pod name rather than IP address for Kubernetes #1190
Conversation
|
Reading through that whole thread, this seems a reasonable request. |
|
This seems like a reasonable option. This follows the endpoint naming spec, since the pod name is unique in the namespace. To clarify, this is "Adding option to use pod name rather than IP address for k8s endpoint fqdns" ... For example: This does not change the way pod lookups function. As far as option name goes: I think "endpointNameMode" might be a slightly better/clearer option name than "podNameMode". |
miekg
left a comment
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.
Few nit comments and the Travis failures need a fx.
And this needs to be documented in the README/
plugin/kubernetes/kubernetes.go
Outdated
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.
Can you make "name" a constant, similar to add podMode ones
plugin/kubernetes/setup.go
Outdated
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.
default is just not setting this? I.e. no need for "default"?
|
This changes the endpoint records; ie, with svc not pod type in the name. The pods config option is for the pod records. Maybe we need an endpoints config option instead. |
|
Changes made. I added an I can squash the commits if/when ready to merge. |
Codecov Report
@@ Coverage Diff @@
## master #1190 +/- ##
=========================================
+ Coverage 49.05% 49.1% +0.05%
=========================================
Files 165 165
Lines 9669 9679 +10
=========================================
+ Hits 4743 4753 +10
Misses 4627 4627
Partials 299 299
Continue to review full report at Codecov.
|
plugin/kubernetes/README.md
Outdated
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.
This should work regardless of the pods setting, I believe. We always watch endpoints, and we respond to their hostname records regardless of whether pod types are enabled.
We could add an option to pods verified that enables pod-name.namespace.pod.cluster.local.
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.
But that would be a separate PR...
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.
@johnbelamaric you are correct, it works if pods is disabled. Updating doc.
plugin/kubernetes/README.md
Outdated
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.
Normally if the endpoint has a hostname then these will resolve. This change just makes them use the pod name if it exists and the hostname doesn't. I think that needs to be made clearer here.
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.
"If hostname is set on a pod, then it always has precedence." - is that enough?
plugin/kubernetes/kubernetes.go
Outdated
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.
Actually now that I think some more; endpointNameMode is just a boolean, no need to carry a string with us all time and to a string compare - this is either on or off.
plugin/kubernetes/setup_test.go
Outdated
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.
Please create a new parse test for just this option; this adds a whole bunch of empty strings for no purpose at all in this test.
plugin/kubernetes/setup.go
Outdated
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 would reverse this and not use a switch:
if len(args) != 1 {
return nil, opts. c.ArgErr()
}
if args[0] != endpointNameModeName {
return nil, opts. fmt.Errorf("wrong value for endpoints: %s")
}
|
Changes made. Writing docs is the hardest part of any project for me, so let me know what you think. |
chrisohaver
left a comment
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.
Looks good. I've proposed an alternate documentation entry.
plugin/kubernetes/README.md
Outdated
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.
How about this instead...
-
endpointsENDPOINT-MODE sets the mode for naming endpoint A
records, e.g.endpoint-name.my-service.namespace.svc.cluster.local. in A 1.2.3.4
By default, theendpoint-nameis set to thehostnameof the endpoint, or ifhostnameis not set, the dashed form of the endpoint ip address (e.g.1-2-3-4.my-service.namespace.svc.cluster.local.)Valid values for ENDPOINT-MODE:
name: If the endpoint hostname is not set, use the pod name of the pod targeted by the endpoint. If there is no pod targeted by the endpoint, use the dashed ip address form.
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.
ok, but as @miekg said, since there is only one value for endpoints-mode, maybe we should just say that the whole directive is endpoints pod names or similar. That will simplify the config and docs a bit. I don't want to just say endpoints because it's not clear enough how it changes the behavior.
Questions:
- Will it still respond to the dashed-ip name even if this is set? That is, is this an additional name or a replacement name? Should we pick one as the A record and have a CNAME for the other?
- Which name shows up in the SRV record for the service?
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.
Per my understanding of the code...
Is this an additional name or a replacement name?
This is a replacement name, not an additional name.
Which name shows up in the SRV record for the service?
SRV targets will point to the A records of the endpoints.
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.
Agreed ... here is a "boolean" directive version...
endpoint_pod_namesUse the pod name of the pod targeted by the endpoint as the endpoint name inArecords, e.g.endpoint-name.my-service.namespace.svc.cluster.local. in A 1.2.3.4
By default, theendpoint-namename selection is as follows: Use thehostnameof the endpoint, or ifhostnameis not set, use the dashed form of the endpoint ip address (e.g.1-2-3-4.my-service.namespace.svc.cluster.local.)
If this directive is included, then name selection for endpoints changes as follows: Use thehostnameof the endpoint, or ifhostnameis not set, use the pod name of the pod targeted by the endpoint. If there is no pod targeted by the endpoint, use the dashed ip address form.
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.
👍 now @bakins please update the code to match :)
miekg
left a comment
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.
Looks good from code standpoint.
|
/integration (kicking off k8s integration tests) |
|
Integration test PASS. Run time 129 seconds. View Log
|
|
think we fleshed out what needs to be done here. Shall we wait with 0.9.10 so this can go in? |
|
No, let's just get 0.9.10 out ASAP. |
|
No problem. I'll take care of that later tonight.
…On Nov 3, 2017 18:45, "John Belamaric" ***@***.***> wrote:
No, let's just get 0.9.10 out ASAP.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1190 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AfkeGpWsZeSzP-C0XTEpbkcoAxH5R5vAks5sy19YgaJpZM4QPn1r>
.
|
|
Changes made. Let me know if this all looks good and I'll squash. |
|
/integration |
|
Integration test PASS. Run time 137 seconds. View Log
|
plugin/kubernetes/kubernetes.go
Outdated
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 can remove endpointNameModeName now...
|
Okay, pushed hopefully the last change - removed endpointNameModeName. Let me know and I will squash, if that's what you want. |
|
We squash on merge, but feel free to do it yourself and force push the
branch.
…On Nov 3, 2017 21:26, "Brian Akins" ***@***.***> wrote:
Okay, pushed hopefully the last change - removed endpointNameModeName. Let
me know and I will squash, if that's what you want.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1190 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAVkW4fB6OgaGHuX0JC9wQYiIWG-X6yhks5sy4UCgaJpZM4QPn1r>
.
|
Change to use a new 'endpoints' directive and use a constant Add initial docs for 'endpoints' directive Add tests to Kubernetes setup for endpoints Changes based on PR feedback endpoint_pod_names is a boolean config option. Chahanged docs to reflect this. Add a test when endpoints_pod_names is not set Update README.md Remove endpointNameModeName as it is no longer used
7d577eb to
906c6a6
Compare
|
squashed and pushed. |
|
@johnbelamaric are you happy w/ this? |
|
When are you going to release next version with this feature ? I'm looking forward to use it. Thanks. |
|
Yes, 1.0.0 will be released this week or early next week. |
|
Thank you, it works like a charm ! |
This PR is an idea in code form.
1. What does this pull request do?
This adds an option to use the name of a pod as the hostname rather the hostname for lookups when pods mode is set to insecure or verified for the Kubernetes plugin.
2. Which issues (if any) are related?
kubernetes/kubernetes#47992 - I did not find a related coredns issue doing a quick issue search.
We are also using airflow and this change enables DNS for pod FQDNs without setting
hostnamein the pod specs. As we use deployments, we do not want each pod to have the same hostname.3. Which documentation changes (if any) need to be made?
We would need to document the additional, optional, argument to
podsin the Kubernetes plugin.I was unsure if this should be a separate option or part of the
podsmode.As I said, this is to capture an idea in code form. It is fairly simple and has tests that pass.