Skip to content

Issue #523 - Use 'kubectl auth reconcile' for RBAC resources#600

Merged
alexmt merged 1 commit intoargoproj:masterfrom
alexmt:523-auth-reconcile
Sep 15, 2018
Merged

Issue #523 - Use 'kubectl auth reconcile' for RBAC resources#600
alexmt merged 1 commit intoargoproj:masterfrom
alexmt:523-auth-reconcile

Conversation

@alexmt
Copy link
Collaborator

@alexmt alexmt commented Sep 13, 2018

Closes #523

@alexmt alexmt requested a review from jessesuen September 13, 2018 21:34
@jessesuen
Copy link
Member

I'm not sure if this is important, but apparently this command only works with rbac.v1:
https://kubernetes.io/docs/setup/release/notes/
"kubectl auth reconcile only works with rbac.v1; all the core helpers have been switched over to use the external types. (#63967, @deads2k)"

Assuming we switch to kubectl auth reconcile from kubectl apply, can we:

  1. handle changes to RBAC lists correctly?
  2. render diffs properly?
  3. migrate from something previously kubectl apply'ed to kubectl auth reconcile?

util/kube/ctl.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

We should always do auth reconcile followed by auth apply.
Reconcile will ignore any non-role or rolebinding objects but does not set the previous config file. The subsequent apply is needed to set these fields so that subsequent applies will behave properly.

util/kube/ctl.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need this function if we always auth reconcile and then apply.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, based on Alex's comments we do need this function to check the api version.

@alexmt
Copy link
Collaborator Author

alexmt commented Sep 14, 2018

@jessesuen , @edlee2121 updated PR as we discussed . Now reconcile is followed by apply. PTAL

@alexmt alexmt merged commit 0b08bf4 into argoproj:master Sep 15, 2018
@alexmt alexmt deleted the 523-auth-reconcile branch September 15, 2018 03:38
leoluz pushed a commit to leoluz/argo-cd that referenced this pull request Mar 13, 2025
…#600] (argoproj#601)

* chore: More optimal IterateHierarchyV2 and iterateChildrenV2 [argoproj#600]

Closes argoproj#600

The existing (effectively v1) implementations are suboptimal since they don't construct a graph before the iteration. They search for children by looking at all namespace resources and checking `isParentOf`, which can give `O(tree_size * namespace_resources_count)` time complexity. The v2 algorithms construct the graph and have `O(namespace_resources_count)` time complexity. See more details in the linked issues.

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

* improvements to graph building

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* use old name

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* chore: More optimal IterateHierarchyV2 and iterateChildrenV2 [argoproj#600]

Closes argoproj#600

The existing (effectively v1) implementations are suboptimal since they don't construct a graph before the iteration. They search for children by looking at all namespace resources and checking `isParentOf`, which can give `O(tree_size * namespace_resources_count)` time complexity. The v2 algorithms construct the graph and have `O(namespace_resources_count)` time complexity. See more details in the linked issues.

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

* finish merge

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* chore: More optimal IterateHierarchyV2 and iterateChildrenV2 [argoproj#600]

Closes argoproj#600

The existing (effectively v1) implementations are suboptimal since they don't construct a graph before the iteration. They search for children by looking at all namespace resources and checking `isParentOf`, which can give `O(tree_size * namespace_resources_count)` time complexity. The v2 algorithms construct the graph and have `O(namespace_resources_count)` time complexity. See more details in the linked issues.

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

* discard unneeded copies of child resources as we go

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* remove unnecessary comment

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* make childrenByUID sparse

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* eliminate duplicate map

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* fix comment

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* add useful comment back

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* use nsNodes instead of dupe map

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* remove unused struct

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* skip invalid APIVersion

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

---------

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
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.

3 participants

Comments