-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat(agent): add nginx proxy for agent communication #957
Conversation
/build_test |
@andrewazores I think even after this is merged, we'll need some work on the agent to provide client certificates. I think the key/cert pair is used for the HTTP server, but not client. |
|
Yes, I think you're right. All the work done in and around cryostatio/cryostat-agent#138 was just focused on getting the Cryostat server and agent to know how to get each of their HTTPS clients to trust the certificates presented by each of their own webservers, so there will need to be a bit more done so that the agent's client also knows how to pass a client certificate for authentication. |
Does the So far in cryostatio/cryostat-agent#491 I have something working and tested at least for getting the Agent to send its client cert along to the new proxy as authentication, but I haven't checked that the |
I may be misunderstanding the question, but the ca cert is the same self-signed CA used by all Cryostat components. So from the agent's perspective, the server CA and client CA are the exact same certificates. |
I think that clears up most of what I'm unsure of (because I still don't fully understand how the Operator interacts with cert-manager). So the two CAs are the same actual object, there are just two copies of it in two different Secrets (ex. So then, the existing code and configuration options that we have for setting up the Agent truststore to be able to validate the OAuth proxy would not need any changes to validate the TLS-auth proxy. The (identical) ca.crt from the new Secret has to be mounted/copied in instead, and the existing configuration options would just be set to tell the Agent to load this one into its client truststore instead. Does that sound right? |
I guess to make that a little more concrete: IIRC the plan is for this Operator feature to work by doing something like watching for changes to Deployments (or Pods?), and checking if some "Cryostat Agent automatic" annotation is set. If it is, then the Operator will go ahead and edit the Deployment so that this So that "somehow configured and launched" step is where the |
That sounds right to me. cert-manager adds a copy of the CA certificate into each secret it creates to make a certificate chain. When using the agent auto-configuration, we'd set up the agent with I was also thinking we may want to remove support for the agent to use the OAuth Proxy, IIRC, this would allow us to remove the |
Hmm... the Agent does that by just passing the It'd still be possible to use curl using I think it's worth considering anyway. Just wanted to highlight that removing that support doesn't affect only the Agent. |
/build_test |
|
This probably has to do with the V4 API changes. |
Looks to me like the target was nil. Does the create target response no longer look like this? "data": {
"result": {
"id": 123,
"connectUrl": "foo",
"alias": "bar"
}
} |
That'd do it. The
|
/build_test |
|
@andrewazores looks like that last commit fixed it, mind approving again? |
Welcome to Cryostat! 👋
Before contributing, make sure you have:
main
branch[chore, ci, docs, feat, fix, test]
git commit -S -m "YOUR_COMMIT_MESSAGE"
Fixes: #952
Description of the change:
Motivation for the change:
How to manually test:
make create_cryostat_cr
make sample-app
SAMPLE_POD="$(kubectl get pod -l app=quarkus-test -o jsonpath='{$.items[0].metadata.name}'")
Add key/certs to pod
kubectl get secret cryostat-agent-c44e3ce7d8452282f4cf1ab14d08cfda2875fa727912e41595c6979bffe0f693 -o json | jq -r '.data["tls.key"] | @base64d' > /tmp/tls.key
kubectl get secret cryostat-agent-c44e3ce7d8452282f4cf1ab14d08cfda2875fa727912e41595c6979bffe0f693 -o json | jq -r '.data["tls.crt"] | @base64d' > /tmp/tls.crt
kubectl get secret cryostat-agent-c44e3ce7d8452282f4cf1ab14d08cfda2875fa727912e41595c6979bffe0f693 -o json | jq -r '.data["ca.crt"] | @base64d' > /tmp/ca.crt
kubectl cp /tmp/tls.key "${SAMPLE_POD}":/tmp/tls.key
kubectl cp /tmp/tls.crt "${SAMPLE_POD}":/tmp/tls.crt
kubectl cp /tmp/ca.crt "${SAMPLE_POD}":/tmp/ca.crt
Check the proxy
No client cert:
kubectl exec "${SAMPLE_POD}" -- curl -sS --cacert /tmp/ca.crt -L https://cryostat-sample-agent.cryostat-operator-system.svc:8282/health
With client cert:
kubectl exec "${SAMPLE_POD}" -- curl -sS --key /tmp/tls.key --cert /tmp/tls.crt --cacert /tmp/ca.crt -L https://cryostat-sample-agent.cryostat-operator-system.svc:8282/health
With bad path:
kubectl exec "${SAMPLE_POD}" -- curl -sS --key /tmp/tls.key --cert /tmp/tls.crt --cacert /tmp/ca.crt -L https://cryostat-sample-agent.cryostat-operator-system.svc:8282/api/v1/recordings/
Disable cert-manager
kubectl patch --type=merge -p '{"spec": {"enableCertManager": false}}' cryostat/cryostat-sample
No cert needed:
kubectl exec "${SAMPLE_POD}" -- curl -sS -L http://cryostat-sample-agent.cryostat-operator-system.svc:8282/health
Still restricts paths:
kubectl exec "${SAMPLE_POD}" -- curl -sS -L http://cryostat-sample-agent.cryostat-operator-system.svc:8282/api/v1/recordings/
Re-enable cert-manager
kubectl patch --type=merge -p '{"spec": {"enableCertManager": true}}' cryostat/cryostat-sample
Correct usage still works:
kubectl exec "${SAMPLE_POD}" -- curl -sS --key /tmp/tls.key --cert /tmp/tls.crt --cacert /tmp/ca.crt -L https://cryostat-sample-agent.cryostat-operator-system.svc:8282/health
HTTP doesn't work:
kubectl exec "${SAMPLE_POD}" -- curl -sS -L http://cryostat-sample-agent.cryostat-operator-system.svc:8282/health
Re-create the Cryostat CR (and its CA)
make create_cryostat_cr
kubectl exec "${SAMPLE_POD}" -- curl -sS --key /tmp/tls.key --cert /tmp/tls.crt -k -L https://cryostat-sample-agent.cryostat-operator-system.svc:8282/health