Skip to content
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

Adds Operator support for TLS enabled observatorium-api #273

Closed
wants to merge 1 commit into from

Conversation

nmagnezi
Copy link
Contributor

@nmagnezi nmagnezi commented May 14, 2020

@nmagnezi nmagnezi force-pushed the api-tls branch 4 times, most recently from 4ccd142 to be679f2 Compare May 14, 2020 16:20
Copy link
Contributor

@brancz brancz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I see this correctly this is still missing the part of actually wiring up the files mounted from the secret, right (presumably that's why it's WIP :) )?

components/observatorium-api-tls-secret.libsonnet Outdated Show resolved Hide resolved
@nmagnezi nmagnezi force-pushed the api-tls branch 23 times, most recently from b005ba9 to 493af8a Compare May 21, 2020 14:25
@nmagnezi nmagnezi force-pushed the api-tls branch 2 times, most recently from 1f294e9 to 72792ef Compare May 24, 2020 20:53
Copy link
Member

@squat squat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nir, the mTLS failures look like a configuration issue in this PR rather than a problem with the API code. Please take a look at the comments. Otherwise, this generally looks very good :)

environments/base/default-config.libsonnet Outdated Show resolved Hide resolved
namespace: obs.config.namespace,
},
data: {
'ca.pem': importstr '../../tmp/certs/up_client/ca.pem',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason that mTLS is failing is that you have generated two different sets of client certs each with a different CA. The client certs for the up binary were generated using this certificate, so using this CA as the client-ca means up will work. But the client certs for the healthchecks were generated using the observatorium/ca.pem cert, so when the API checks the client certificates against the up_client/ca.pem cert, the validation will fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested this as well, and Done per your request. Yet I still get theTLS handshake error

environments/dev/main.jsonnet Outdated Show resolved Hide resolved
example/main.jsonnet Outdated Show resolved Hide resolved
@brancz
Copy link
Contributor

brancz commented Jun 24, 2020

Looks like this needs a rebase and CI is failing. Once green we can have another look.

@nmagnezi
Copy link
Contributor Author

nmagnezi commented Jun 24, 2020

Looks like this needs a rebase and CI is failing. Once green we can have another look.

@brancz rebase done. it will fail CI for the same reason I mentioned here

@squat
Copy link
Member

squat commented Jun 24, 2020

This should not fail for the same reason since the healthchecks no longer use mTLS. e.g. these flags no longer exist: https://github.com/observatorium/deployments/pull/273/files#diff-600fb07f5f3b3600a9a1111605f807ceR48
I think we need to fix the rebase actually

@squat
Copy link
Member

squat commented Jun 24, 2020

let me know if you need help :)

TLSSecret TLSSecret `json:"secret"`
}

type MTLSConfigMap struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any Observatorium-wide mTLS settings (anymore), so we should remove this struct

CertFile string `json:"certFile"`
Name string `json:"name"`
PrivateKeyFile string `json:"privateKeyFile"`
ReloadInterval string `json:"reloadInterval"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need an optional field to load the CA that signed the certificate. This is optional because the healthchecker needs to know that the certificate is valid and if the CA is not in the system certs then it needs to be specified. Note, this is different from an mTLS CA used to check clients of the API; this is for clients to validate the server's cert

@@ -38,6 +38,9 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
'--latency=10s',
'--initial-query-delay=5s',
'--threshold=0.90',
'--tls-ca-file=' + up.config.withTLS.clientCAFile,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really be called serverCAFile because it's the CA that signed the server's certificate that matters here, not the client's

@@ -34,14 +34,41 @@ local dex = (import '../../components/dex.libsonnet') + {
};

local obs = (import '../base/observatorium.jsonnet') + {
tls_secret: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep everything here camelCase for consistency

},

withMTLS: {
local apiWithMTLS = self,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this because the API doesn't support any process-wide mTLS

config+:: obs.config.withTLS,
},

withMTLS+:: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: there is no longer any API-wide mTLS settings

- --web.healthchecks.url=https://127.0.0.1:8080
- --tls.server.cert-file=/mnt/certs/server.pem
- --tls.server.key-file=/mnt/certs/server.key
- --tls.healthchecks.cert-file=/mnt/certs/client.pem
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several of these flags no longer exist.

- --tls.server.cert-file=/mnt/certs/server.pem
- --tls.server.key-file=/mnt/certs/server.key
- --tls.healthchecks.cert-file=/mnt/certs/client.pem
- --tls.healthchecks.key-file=/mnt/certs/client.key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too

- --tls.healthchecks.key-file=/mnt/certs/client.key
- --tls.healthchecks.server-ca-file=/mnt/certs/ca.pem
- --tls.reload-interval=1m
- --tls.server.client-ca-file=/mnt/clientca/ca.pem
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this one

@squat
Copy link
Member

squat commented Aug 5, 2020

ping @nmagnezi will you be able to take a look at the issues/comments I added a few weeks ago?


CONTROLLER_GEN ?= $(BIN_DIR)/controller-gen
JB ?= $(BIN_DIR)/jb
GENERATE_TLS_CERT ?= $(BIN_DIR)/generate-tls-cert
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra space here

mkdir -p $(CERT_DIR)

# Generate TLS certificates for local development.
generate-cert: $(GENERATE_TLS_CERT) $(CERT_DIR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make the dependency on the cert dir target order-only

Suggested change
generate-cert: $(GENERATE_TLS_CERT) $(CERT_DIR)
generate-cert: $(GENERATE_TLS_CERT) | $(CERT_DIR)

mkdir -p $(CERT_DIR)

# Generate TLS certificates for local development.
generate-cert: $(GENERATE_TLS_CERT) $(CERT_DIR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a phony target

@squat
Copy link
Member

squat commented Sep 7, 2020

Closed in #329

@squat squat closed this Sep 7, 2020
@squat squat deleted the api-tls branch September 7, 2020 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants