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

feat: support managing cluster resources in a namespaced mode #6581

Merged
merged 1 commit into from
Jul 19, 2021

Conversation

alexmt
Copy link
Collaborator

@alexmt alexmt commented Jun 28, 2021

Signed-off-by: Alexander Matyushentsev AMatyushentsev@gmail.com

Closes #4502
Depends on argoproj/gitops-engine#297


PR introduces an additional setting that enables managing cluster-level resources of a cluster in a namespace mode.
The main use case is k8s cluster addons management when one Argo CD deploys platform level app (e.g. ingress controller, argo rollouts/workflows ) into multiple clusters. In this case, Argo needs to manage resources in 2~3 namespaces and CRDs. So it is beneficial to "watch" only some namespaces instead of whole cluster + cluster level resources.

Three additional CLI commands had been added to argocd-util:

  • argocd-util cluster namespaces - prints list of clusters and namespaces managed in each cluster
argocd-util cluster namespaces
CLUSTER                         NAMESPACES
https://kubernetes.default.svc  dex,argo,argocd,default (total 15)
  • argocd-util cluster namespaces enable-namespaced-mode - switches clusters into namespaced mode
# switch all clusters with 2 or less managed namespaces into namespaced mode
argocd-util cluster namespaces enable-namespaced-mode '*' --cluster-resources --max-namespace-count 2
  • argocd-util cluster namespaces disable-namespaced-mode - disables namespaced mode
# disable namespaced mode for all clusters
argocd-util cluster namespaces disable-namespaced-mode '*'

@codecov
Copy link

codecov bot commented Jun 28, 2021

Codecov Report

Merging #6581 (04e2782) into master (8030f42) will decrease coverage by 0.31%.
The diff coverage is 2.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6581      +/-   ##
==========================================
- Coverage   41.30%   40.98%   -0.32%     
==========================================
  Files         156      156              
  Lines       20702    20865     +163     
==========================================
+ Hits         8550     8552       +2     
- Misses      10944    11103     +159     
- Partials     1208     1210       +2     
Impacted Files Coverage Δ
cmd/argocd-util/commands/cluster.go 0.00% <0.00%> (ø)
cmd/argocd/commands/cluster.go 2.59% <0.00%> (ø)
controller/cache/cache.go 10.62% <0.00%> (-0.12%) ⬇️
pkg/apis/application/v1alpha1/types.go 57.71% <0.00%> (-0.18%) ⬇️
server/cluster/cluster.go 17.54% <0.00%> (-0.32%) ⬇️
util/db/cluster.go 59.52% <33.33%> (-0.48%) ⬇️
cmd/util/cluster.go 40.00% <80.00%> (+0.31%) ⬆️
util/settings/settings.go 47.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8030f42...04e2782. Read the comment docs.

@alexmt alexmt added this to the v2.1 milestone Jun 28, 2021
@alexmt alexmt self-assigned this Jun 28, 2021
@alexmt
Copy link
Collaborator Author

alexmt commented Jun 28, 2021

@jessesuen can you take a look please?

@jannfis
Copy link
Member

jannfis commented Jul 6, 2021

I'm wondering what exactly is the benefit of this mode? Will Argo CD still have to have full cluster level permission for this to work? Is the only benefit that we'd need to watch for changes on less namespaces, as opposed to watch for changes on all namespaces in the cluster?

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
@alexmt alexmt marked this pull request as ready for review July 9, 2021 01:00
@alexmt
Copy link
Collaborator Author

alexmt commented Jul 9, 2021

@jannfis , this change is mostly about performance: Argo CD might be configured to "watch" some namespaces and cluster level resources. This is beneficial if Argo CD is used to manage 1~2 namespaces + CRDs in hundreds of clusters.

Additionally full cluster permissions are not required. Admin can provide token that has permissions to required cluster level resources only and required namespaces. Other cluster level resources can be excluded using resource exclusions.

Copy link
Contributor

@mayzhang2000 mayzhang2000 left a comment

Choose a reason for hiding this comment

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

LGTM

@alexmt alexmt merged commit 58ac345 into argoproj:master Jul 19, 2021
@alexmt alexmt deleted the cluster-level-resources branch July 19, 2021 18:59
@alexmt alexmt added the needs-verification PR requires pre-release verification label Jul 19, 2021
@alexmt alexmt removed the needs-verification PR requires pre-release verification label Aug 11, 2021
@alswl
Copy link

alswl commented Oct 9, 2021

Great Job, Argo CD lister pager is using hundred of memory in my situation. But in the previous version, cluster namespaces cannot using because it ignores the white space(none namespaced namespace). I will try the 2.1 version.

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.

Allow control of cluster level resources independent of namespace options
4 participants