-
Notifications
You must be signed in to change notification settings - Fork 92
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 TLS support to HTTP Server #185
Conversation
Signed-off-by: Annanay <annanayagarwal@gmail.com>
Signed-off-by: Annanay <annanayagarwal@gmail.com>
Signed-off-by: Annanay <annanayagarwal@gmail.com>
Signed-off-by: Annanay <annanayagarwal@gmail.com>
I don't know; what are the trade-offs? What did someone else do when faced with this question? |
Signed-off-by: Annanay <annanayagarwal@gmail.com>
Adding certs to the repo for testing purposes seems like the most common solution, the only trade-off being that the test will fail once the certs expire. |
I would like to confirm that both variants (enabled, not enabled) of this functionality will be tested in CI. Scenario Now that cortex is 1.0+ we plan to begin using it in production. We have been rolling out a service mesh across our infra, for a few reasons - one of which is consistent mTLS across all k8s services which are on the mesh. We expect this to be how we handle service <-> service encryption. While The motivation to bake this into the project is rational, I would hope that it doesn’t over time become mandatory as it adds another layer/place where certificates need to be managed. The mesh we are using is able to integrate with external CA’s, and cert rotation/renewal is handled by cert-manager (using LetsEncrypt). We are planning to run Cortex atop this existing infra, which in addition to providing mTLS, also enables observability, a layer of resiliency, and (I’m hoping) the ability to have blue-greens via traffic split for cortex service versions. If I’m misunderstanding the use case here or intent apologies! We are still learning about the project, code, and operational aspects of running cortex in our infra. |
Thanks for your feedback, I completely agree with your reasoning @halcyondude. The PR has been designed to remain backward compatible. TLS remains optional, and can be setup via a service mesh as you have mentioned. If the relevant flags are not initialised, tls will not be initiated and the server will work exactly as before. That said, some users may not want to add a service mesh dependency and IMO it makes sense to bake this feature into the server :) |
I think having certs (even dummy certs) checked in is undesirable; it makes it looks like a leak of secrets, even if it isn't. Can we easily generate them in the unit test? |
Can we reuse https://github.com/prometheus/node_exporter/blob/master/https/tls_config.go instead of building it ourself? This also has more options for client cert - which might be a good thing. I think we'll need to be able to specify different TLS settings for gRPC and HTTP - for instance, not needing client cert verification on HTTP but needing it on gRPC sounds reasonable to me. |
Signed-off-by: Annanay <annanayagarwal@gmail.com>
Signed-off-by: Annanay <annanayagarwal@gmail.com>
I tried exposing the function upstream but I am not sure it will be done anytime soon prometheus/node_exporter#1677 (comment) I don't think we should block this PR on that but we should add a TODO in the code and in an issue to move to the upstream function when its exposed. I also see that upstream is waiting for a security review, and I don't think we should block on that imo. The upstream code has already gone through robust code review here: prometheus/node_exporter#1277 and from what I can see, by reusing that code, we're getting a free security review :) |
Signed-off-by: Annanay <annanayagarwal@gmail.com>
Signed-off-by: Annanay <annanayagarwal@gmail.com>
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.
A few more thoughts below.
Signed-off-by: Annanay <annanayagarwal@gmail.com>
Updated PR description as well. Please let me know if this is sufficient to move forward. :) |
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, thanks!
@@ -0,0 +1,23 @@ | |||
# From https://github.com/joe-elliott/cert-exporter/blob/master/test/files/genCerts.sh |
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.
Note this is under Apache 2 licence.
(also it's more future-proof to use a commit hash than master
in the URL)
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.
Ah, right. I could send a follow up PR to change this.
Thanks! |
Part of cortexproject/cortex#2350
Changes
server.http-cert-path
,server.http-key-path
,server.http-ca-path
server.grpc-cert-path
,server.grpc-key-path
,server.grpc-ca-path
ConfigToTLSConfig
, which is used from the prometheusnode_exporter
library and generates a*tls.Config
struct from the config options, is awaiting security review.client_golang
library:/cc @bboreham