Simple TLS controller - #347
Conversation
Why can't we use the existing certificate-y stuff? Also, any chance this could be used for IPsec? |
|
hey @deads2k, this uses the CertRotationController from library-go. Would you mind giving it a look-over to see that we're using it in an expected manner? |
Because the existing certificate managers all rely on the network to be up. The exception to this is the kube CA / CSR endpoint itself, but I don't want to use that for two reasons. First of all, it doesn't really save us a ton of effort, because it doesn't handle rotation. Second of all, I'd rather not issue certificates that have any sort of kube API identity.
Definitely. We may need to get a change in to library-go that allows us to set the ciphers. |
| // +k8s:openapi-gen=true | ||
| type PKISpec struct { | ||
| // caCert is information about the CA certificate and key. | ||
| CACert CertSpec `json:"caCert"` |
There was a problem hiding this comment.
Is this information that the user provides or information that the controller fills in? If the former, what gets done with that information?
|
Thanks, as always, for the excellent review, updated. I renamed PKI to OperatorPKI. Updated the documentation extensively. I also added in kubebuilder struct -> CRD conversion. |
danwinship
left a comment
There was a problem hiding this comment.
New docs are great.
I don't really understand most of the actual certificate stuff but I'll trust you're using the library correctly...
| // commonName is the value in the certificate's CN | ||
| // | ||
| // +kubebuilder:validation:MinLength=1 | ||
| CommonName string `json:"commonName"` |
There was a problem hiding this comment.
Is the CertSpec type still useful? Could we just put TargetCertCommonName in OperatorPKISpec?
There was a problem hiding this comment.
I suspect we'll be adding more properties (e.g. validity), so I decided to keep it.
|
|
||
| // toClientCert is a certificate "decorator" that adds ClientAuth to the | ||
| // list of ExtendedKeyUsages. This allows the generated certificate to be | ||
| // used for both client and server auth. |
There was a problem hiding this comment.
Oh, yeah, you didn't answer why you were doing this. Are you going to have the client and server using the same cert? Why not just make two certificates? That seems way more sane...
There was a problem hiding this comment.
for OVN, we have to use the same cert, since the databases will be either servers or clients depending on the replication state.
Also, the internal library-go code currently only allows creating a single cert. Eventually we could improve this, but it's not necessary now.
|
@squeed Your comment at the top says it creates 1 cert. Are we using the same cert/ca for both sdb and ndb, or are there two of these? |
Yup. The intended use case for this is OVN. We're creating a single cert for all users. |
|
/retest (aws flake) |
|
I'm vaguely worried that there may be some cryptographic reason why it would be bad to have the client and server using the same keys, but the only discussion of that I can find is https://crypto.stackexchange.com/questions/7874/client-and-server-using-same-ssl-certificate-any-issues which suggests it's fine other than the obvious issues we don't care about. |
|
Establishing a mTLS channel consists of the client sending Note: the |
|
Nice, the CVO is failing to apply the CRD: Looking. |
|
Oh, right, the client certificate doesn't actually play any role in establishing the encryption. (I was worrying that if both sides started with the same secrets then some of the math might "cancel out" and result in a predictable symmetric encryption key being generated.) |
|
Yeah, it's a good question. I suspect it might be a consideration for DH, though I don't actually think it's possible in TLS. |
|
/hold |
|
hurray, kube-builder doesn't create creatable CRDs:
|
This also updates the update-codegen plumbing to generate the CRD directly from the type, via kubebuilder.
This uses the existing PKI implementation in library-go, wiring it up to the OperatorPKI CRD. Creating a OperatorPKI CR will create a CA and a single certificate.
|
Needed to pick up the latest (unreleased) controller-tools version. |
|
/hold cancel |
|
aws flake |
|
registry flake |
|
/test e2e-aws-upgrade |
|
/lgtm |
|
/refresh |
|
hey @danwinship looks like the event got lost - would you mind re-tagging? |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: danwinship, squeed The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
This adds a PKI CRD and a controller to implement it. Given a simple request for a PKI, it creates a CA and a single certificate. It delegates this to library-go's CertificateRotationController.
A bit of ugliness is needed to duct-tape a typed and untyped controller library, but it works well enough.
This will be used for implementing TLS for OVN.