Repository navigation
feat: CNPG deployed namespaced - #9350
maxlengdell wants to merge 16 commits into
Conversation
|
❗ By default, the pull request is configured to backport to all release branches.
|
9dcc79d to
99a36c6
Compare
68c886a to
fe6e973
Compare
d9ff042 to
3f46d72
Compare
|
Sorry for the force push. Had issues with my gpg key. Should be sorted now. Will resolve merge conflicts once reviews are made to not cause further messy branch |
3f46d72 to
d72b2c9
Compare
jsilvela
left a comment
There was a problem hiding this comment.
It's good overall, but I've left a bunch of comments, mostly on documentation and the use of Context within the Ginkgo tests.
| cluster.Status.TargetPrimary == cluster.Status.CurrentPrimary { | ||
| isPrimaryOnUnschedulableNode, err := r.isNodeUnschedulableOrBeingDrained(ctx, primary.Node) | ||
| if err != nil { | ||
| contextLogger.Error(err, "while checking if current primary is on an unschedulable node") |
There was a problem hiding this comment.
It was already complex when you came here, but now it's a 3-level conditional.
There was a problem hiding this comment.
Indeed, would it make more sense to break out everything in step 1?
// First step: check if the current primary is running in an unschedulable node
// and issue a switchover if that's the case
// Can not check node settings in namespaced deployment
if !configuration.Current.Namespaced {
checkSchedulableNodes()
}
|
Sorry @maxlengdell , I see that dosu removed the "lgtm" label because of my request for changes. |
b54886f to
db5e446
Compare
Fixing minor test changes and documentation updates
One minor change left is to address the comments in
cluster_status_test.go
Signed-off-by: Max Lengdell <[email protected]>
db5e446 to
c210bba
Compare
Signed-off-by: maxLengdell <[email protected]>
eb30270 to
1f552e0
Compare
1f552e0 to
418d885
Compare
Fix comments so cluster_status_test getPodsTopology is in its own describe bracket Signed-off-by: Max Lengdell <[email protected]>
418d885 to
80cca7b
Compare
There was a problem hiding this comment.
One optional comment on the use of context in the E2E.
Another one, a suggestion but not a blocker, is to add some content in the document docs/src/e2e.md. Flaunt your E2E!
EDIT: come to think of it, you should also strongly consider adding some text in the security.md file.
Fix the context comment in the namespaced test. Add some description to the cluster-role dependencies when namespaced mode is enabled. Signed-off-by: Max Lengdell <[email protected]>
| #### Why Are ClusterRole Permissions Needed? | ||
|
|
||
| The operator currently requires `ClusterRole` permissions to read `nodes` and | ||
| In cluster-wide mode, the operator requires `ClusterRole` permissions to read `nodes` and |
There was a problem hiding this comment.
Worth mentioning that cluster-wide is the default mode.
|
There's a couple of things that I've notice here while reviewing this PR and also I would like to give my opinion on the overall related to this: The operator currently does have the capability to watch over one namespace, that it could be his own namespace, when you set the I'm not against the patch but more against the intention and implementation, I think that:
The final intention here is to allow the operator to run without access to global objects inside a Kubernetes cluster, that it's half managed here, and should be a PR explicitly to that, one for Node access and another for ClusterImageCatalog, that will split the work and also make it easy to review. The e2e tests here are amazing and I think it should be preserved but distributed in a new work that will allow having these two options. The deployment of the operator it's something that must and can be managed externally with other tools like ArgoCD or FluxCD or Helm, the permission for the ServiceAccount used by the operator, along side with the roles, should be managed there, the operator will be configure to run without access to those permissions. In general, I think we should proceed with a work related to allow the operator to run without these privileges as an option (or self detect that, which can be more difficult but not impossible) and not depend on a configuration that it will be valid for some environments Those are my two cents. |
|
Hi @sxd, I see your point on that "namespaced deployment" already exist. The PR was probably misdirected. Indeed the only goal for this PR is to make the operator work without dependency on rbac to nodes or ClusterImageCatalog. Agree with your points in the rest of the comment as well. I'll create 3 new pull requests:
Glad you liked the e2e tests. I'll port those to the separate PRs. This PR can stay open to preserve the state for now and once the new PRs are open we can take it from there if that's ok 😃 I'll update the feature request so that "namespaced deployment" isnt used, since indeed that's already existing. Thanks for the review! |
|
But just to be clear; there's nothing in the code which prevents setting |
I think it's worth pointing out that there's no way around needing to manage CRDs as global objects. So we can never eliminate all global requirements. This seems more to me about "what are the minimum global requirements we can get away with" - and will users fully understand the implications of disabling other global requirements (webhooks/certs, node access, clusterimagecatalog) |
|
Indeed CRDs are still cluster resources, and there's no way around that at the moment. |
|
Closing this in favor of #10135, which carries forward the Node-watching work (and the runtime RBAC-splitting package) split out of here, as we discussed above. The "namespaced" framing is being dropped since namespaced operation already exists through I know you'd asked to keep this open as a reference until the split PRs landed. It's been a few months and the branch has since drifted into merge conflicts, so I think it's cleaner to close it and track the work in #10135. The diff and the e2e tests stay fully visible here for the ClusterImageCatalog follow-up. Thanks for the work, the e2e coverage especially. |
|
❗ By default, the pull request is configured to backport to all release branches.
|
CNPG currently relies on the access to cluster nodes. Such ClusterRole should be limited and avoided to harden the CNPG operator deployment. CNPG still relies on webhooks, but that will be addressed in a separate feature request.
With the namespaced deployment of CNPG, the early switchover during a node drain will not be possible. Meaning if someone does a node drain where the primary is deployed, the primary will become unavailable and a replica will be promoted. This is slower than the automatically initiated promotion, but can be mitigated with PodDistruptionBudget settings and topology deployment constraints. So it would be a reasonable trade-off, which should be documented.
Feature request: #9346
Changes
Only watch Nodes and ClusterImageCatalog when deployed with namespaced disabled (default)
Signed-off-by: Max Lengdell [email protected]