-
Notifications
You must be signed in to change notification settings - Fork 270
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
enabled DNS Service discovery in HAProxy #154
Conversation
Hi, thanks for this PR! A couple of tips (and question) regarding the changes:
And a couple of doubts about HAProxy:
|
Hi, thanks
HAProxy:
|
Hi, sorry about taking so long. About the usage of endpoints instead of services, take a look here. This should be enough to explain why using Service IP is a bad idea, as you will not be able to balance between each POD/endpoint. If the idea is, anyway using DNS as backend (as this could allow HAProxy ingress to be used as proxy between non kubernetes workloads), you should always create your Services as Headless instead of using ClusterIPs (when dealing with incluster workloads). This will make kube-dns/coredns/whatever dns return the IP of each POD, and doesn't rely on kube-proxy (as shown in the link above). |
before writing docs (and cleaning to be able to merge), To clarify, in order to use DNS service discovery in HAProxy ingress controler, two things must be configured:
@rikatz |
v0.6 is close which means you will need to rebase the code just one more time. I'll wait your changes before merge v0.7 PRs. Sorry about the mess of the recent merges. |
I'll rebase and add doc and example, so you can more easily inspect changes. |
@jcmoraisjr rebased, cleaned and added docs :) the only thing that is left for discussion is usage of |
Thanks @oktalz ! Some major suggestions:
|
@jcmoraisjr I tried using ConfigurationSnippet annotation as service annotation, but it does not work for me You can look the example in 3.web-svc.yml maybe the problem is on my side somewhere, so I'm asking to confirm |
Hi, yes, all annotations was designed to be used as ingress annotations. Note that the same service can be used by several different ingress, using annotations on ingress give you more flexibility - you can have different backend configurations to the same service. |
@jcmoraisjr
and all minor changes you requested. |
Hi, thanks again to submit this niece feature. Below some minor suggestions I've found:
And also some major issues:
|
hi @jcmoraisjr thnx for the input regarding major issues
|
…minor fixes to doc
hi @jcmoraisjr dns-cluster-domain was renamed form cluster-dns-domain so we have better consistency. regarding issues you detected:
|
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, a few more comments below.
const ( | ||
DNSResolversAnn = "ingress.kubernetes.io/dns-resolvers" | ||
UseResolverAnn = "ingress.kubernetes.io/use-resolver" | ||
) |
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.
const is a local declaration, start the identifiers with lowercase instead
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.
sure, np
pkg/controller/config.go
Outdated
} | ||
} | ||
cfg.DNSResolvers = resolvers | ||
} |
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.
- Resolvers are global lists, annotations have precedence over configmap, so why not simply iterate backends and override the default resolvers without a single
if
? - Warn about "resolver name %v not found"
- What if two annotations declare the same resolver? This need to be at least warned - or resolvers from annotations could have a prefix so colisions would never happen
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 prefixes we would get multiple (same) data in haproxy config file.
- I will override configmap setup with one from annotation without checking if it exist or not
- warning 'not found' can and will be added, will still must check
if
resolver actually exist or not - I'm not sure what do you mean if two annotations declare same resolver. You can only define it in configmap or with annotations.
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 can use annotations to declare new resolvers on more than one ingress resource.
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 I distinct different ingress annotations in code?
I'm not really sure I can do that in pkg/controller/config.go (but will search a bit more)
Then maybe the best option would be to only allow configmap setting for dnsresolvers (since even in haproxy configuration this is global). That way we do not have any problem with possible miss-configuration
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.
Don't know if I understood. Ingress have name and namespace, and both configurations are unique. If name and namespace match, you have the same ingress and you have the same resolver annotation.
What I usually do is: immutable configurations or behavior are command-line options, global or infra/ops configurations are configmap options, useful configurations to devs are annotations. dns resolvers are global and sounds to me like a infra/ops responsibility so perhaps it fits better on configmap only.
reloadRequired = true | ||
} | ||
continue | ||
} |
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.
- Say a few words why to test
UseResolver != ""
- This
continue
above should only happen if the only difference between old and cur is the endpoints, so move the whole if statement after theif !reloadRequired {}
(below)
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.
in previous commits where use_resolver was used differently that was required,
now all when it only used for logging some info i can clean it.
dns-timeout-retry: 1s dns-hold-obsolete: 0s dns-hold-valid: 1s dns-accepted-payload-size: "8192" dns-cluster-domain: cluster.local
the main difference between this and last code is in removal of useResolver check in dynamicUpdateBackends and minor changes for comments you made |
After testing some options:
|
Now dns-resolvers is a global configmap option, so what about:
|
|
d3159b6
to
265e5d2
Compare
hi @jcmoraisjr with HAProxy 1.8.12 I can confirm that high CPU usage is not a problem anymore. |
Some doc updates and a minor change to the template:
|
Since DNS resolver are global in HAProxy we only need to define it in configmap. There is no need to allow extra setups that could lead to confusing configuration. Backends still have all the data related to them
hi @jcmoraisjr, I've added hints to readme files. Also I'v updated template to better follow convention. |
Hi @oktalz, perhaps missing push the changes? |
Hi @jcmoraisjr Changes was minor so I incorporated (amend) them in last commit a9aec84 and did a rebase/force push. |
I'd wait GitHub or my client git notification for a very long time ... Thanks for the PR and the patience! Merging in a few minutes. |
This is just a preview, comments are welcome :)
Add option to use DNS Service discovery
docs are missing, but they will be added soon