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

Handle certificate rotation #7

Closed
12 of 13 tasks
flavio opened this issue Feb 26, 2021 · 4 comments
Closed
12 of 13 tasks

Handle certificate rotation #7

flavio opened this issue Feb 26, 2021 · 4 comments

Comments

@flavio
Copy link
Member

flavio commented Feb 26, 2021

Description

Our controller uses two different CA roots:

  1. the one generated by cert-manager, which generates the CRD webhook leaf certificate
  2. The one generated by the PolicyServerController reconciliation loop the first time a policy server is created, which is used to generate the policy servers' TLS certificate.

There are a few problems with this approach:

  1. it creates a dependency on cert-manager, see: Feature Request: make cert-manager optional #422
  2. we don't rotate policy server certificates, therefore they will eventually expire.
  3. both cert-manager and our implementation on the PolicyServer side do not rotate the CA root (see Allow CA issuer secret rotation cert-manager/cert-manager#2478)

Solution

We need to implement our certificate rotation logic inside the controller.
Specifically, we need to:

  • Generate a root CA and use it to configure the webhooks (CRD and policy validating/mutating webhooks)
  • Generate the CRD webhook TLS certificate to configure the controller webhook server.
  • Generate the TLS policy server certificates every time a new policy server is created
  • Implement a CertController that periodically checks if the certificates are expired and regenerates them using a lookahead interval. If a TLS certificate is expired we can re-generate it, and it will be picked up by the servers eventually. If the CA root is expired we need to regenerate all the leaf certificates and implement the logic needed to prevent downtime during this phase.

Tasks

@flavio
Copy link
Member Author

flavio commented Mar 9, 2021

Worth a look, something we could leverage: https://github.com/open-policy-agent/cert-controller

@kkaempf
Copy link
Contributor

kkaempf commented Mar 9, 2021

I always wonder why every project (like kucero for CaaSP) has to re-implement certificate handling. This should be built into Kubernetes.

@kkaempf kkaempf added the later label Mar 19, 2021
@fabriziosestito fabriziosestito added this to the 1.16 milestone Jul 22, 2024
@fabriziosestito fabriziosestito removed this from the 1.16 milestone Jul 22, 2024
@fabriziosestito
Copy link
Contributor

Worth a look, something we could leverage: https://github.com/open-policy-agent/cert-controller

We decided not to leverage https://github.com/open-policy-agent/cert-controller since it does not support zero-downtime CA rotation.
Also, we will need to fork it to adapt it to our use case, as we configure policy webhooks dynamically.
Finally, it does not fully support leader election due to this bug.

@flavio
Copy link
Member Author

flavio commented Sep 13, 2024

Closing, all the mandatory tasks have been done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants