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

fix: reload openshift csr-signer ca certificate in Operator trusted CA's #1742

Merged

Conversation

pjuarezd
Copy link
Member

@pjuarezd pjuarezd commented Aug 25, 2023

What is the problem?

In Openshift the certificates generated using CertificateSigningRequests (CSR) are signed by a Certificate Authority (CA) in the control plane. The CA is stored on csr-signer secret on openshift-kube-controller-manager-operator namespace, this CA certificate rotates every month.

The certificates generated for the minio tenants when the spec.requestAutocert: true is set, are generated using CSR's, hence signed by the csr-signer in the cluster.

Operator rotates the minio tenant certificates when they are about to expire (80% of usage), which is good and expected.

The problem consists in the Operator being unable to trust the certificate presented by the minio tenant on the healt check cycles because a newly rotated minio tenant certificate is signed by a new csr-signer CA, one that Operator doesn't know about.

Operator was only loading the certificate when the pod was launched, so when the csr-signer was rotated, Operator was not aware of it.

How the fix works

In the fix proposed in this PR, Operator will compare the certificate tls.crt in the csr-signer secret located in the openshift-kube-controller-manager-operator namespace with a copy of this certificate that we store in the openshift-csr-signer-ca secret in the operator namespace, if the certificate is different then we update the secret in the operator namespace.

A layover specific only for Openshift will mount this secret in the operator deployment as an Optional secret and operator controller will load the CA on the pod start.

This approach have some benefits:

  • Making this secret mount optional will avoid prevent the operator pods from fail to start if the secret doesn't exist yet.
  • Mounting the secret will make sure that the deployment will restart the pods whenever the secret gets updated, therefore Operator will load the latest CA always

Update: Turns out that in practice the pods seemly are not being restarted when the secret gets modified (weird), so a a reload of the CA certificates whenever the secret changed was implemented.

We are planning to stop using CSR's to generate the tenant certificates and instead use service-ca to generate certificates using annotations as suggested in Securing service traffic using service serving certificate secrets docs, however... load the latest csr-signer CA certificate in Operator will make sure that any certificate issued within the cluster using CSR can be trusted, either a different minio instance or third party services.

Closes #1688

harshavardhana
harshavardhana previously approved these changes Aug 25, 2023
harshavardhana
harshavardhana previously approved these changes Aug 27, 2023
shtripat
shtripat previously approved these changes Aug 28, 2023
Copy link
Contributor

@shtripat shtripat left a comment

Choose a reason for hiding this comment

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

LGTM. Few minor comments.

pkg/controller/operator.go Outdated Show resolved Hide resolved

install_operator "certified-operators" "minio-operator"

#destroy_crc
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we enable this line before merge?

Copy link
Member Author

Choose a reason for hiding this comment

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

not for the moment, it was just causing disruption during development running on a personal device, github actions do not have enough power to run this therefore not automated.

Once we automatize the Openshift tests on the DC probably.

testing/openshift-common.sh Show resolved Hide resolved
@pjuarezd pjuarezd dismissed stale reviews from shtripat and harshavardhana via 2c91aad August 28, 2023 21:05
…the certificate in a local secret and reload the CA certificates

* Add openshift test to deploy Operator from OperatorHub on minio-operator namespace

* Add empty `securityContext` and `containerSecurityContext` in the Openshift kustomization example.

* Fix to allow the tenant run with locally build operator image in crc test

Signed-off-by: pjuarezd <pjuarezd@users.noreply.github.com>
@pjuarezd
Copy link
Member Author

Thank you for your reviews @harshavardhana @shtripat, this is now ready to merge

Copy link
Contributor

@jiuker jiuker left a comment

Choose a reason for hiding this comment

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

LGTM

@harshavardhana harshavardhana merged commit 0f68876 into minio:master Aug 29, 2023
24 checks passed
@pjuarezd pjuarezd deleted the openshift-reload-controlplane-ca branch August 30, 2023 22:00
@pjuarezd
Copy link
Member Author

fixes #1671

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.

Rotate csr-signer certificate in Openshift
4 participants