K8SPG-1017 leaf cert function needs to check whether the existing secret is already managed by internal PKI before switching to cert-manager#1578
K8SPG-1017 leaf cert function needs to check whether the existing secret is already managed by internal PKI before switching to cert-manager#1578
Conversation
…ret is already managed by internal PKI before switching to cert-manager
| err = r.Client.Get(ctx, client.ObjectKeyFromObject(rootSecret), rootSecret) | ||
| if err != nil { | ||
| if k8serrors.IsNotFound(err) { | ||
| return true, nil |
There was a problem hiding this comment.
should we really return true here?
There was a problem hiding this comment.
There's no pre-existing internally-managed secret to conflict with. Since cert-manager is available and no secret has been created yet, it's safe to let cert-manager create and manage the root CA from scratch. That's the idea.
hors
left a comment
There was a problem hiding this comment.
Do we have a plan to add e2e test?
We are about to add an improvement. The issue was that we needed to refactor the flow on the existing test because initially the cluster should start without cert-manager installed, then make assertions, then install cert-manager and ensure that nothing happens. And then destroy it and recreate it while cert-manager is installed. |
…i certs and cert manager is installed afterwards
commit: 29e346e |

CHANGE DESCRIPTION
Problem:
Each leaf cert function needs to check whether the existing secret is already managed by internal PKI before switching to cert-manager. If the root CA secret lacks the cert-manager.io/certificate-name annotation, all leaf certs should stay on internal PKI regardless of whether cert-manager is installed.
Cause:
Short explanation of the root cause of the issue if applicable.
Solution:
Short explanation of the solution we are providing with this PR.
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
Config/Logging/Testability