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

Restrict Application.spec.project by Application.spec.source.repoURL #3045

Closed
dulltz opened this issue Jan 29, 2020 · 5 comments · Fixed by #5417
Closed

Restrict Application.spec.project by Application.spec.source.repoURL #3045

dulltz opened this issue Jan 29, 2020 · 5 comments · Fixed by #5417
Assignees
Labels
component:multi-tenancy Features related to app projects enhancement New feature or request type:usability Enhancement of an existing feature
Milestone

Comments

@dulltz
Copy link
Contributor

dulltz commented Jan 29, 2020

Summary

Allow restricting the value of Application.spec.project to control tenants' authority.
In my knowledge, Application.spec.project can be set any project name.

Motivation

Let me explain my use case.
We're using ArgoCD for multi-tenant K8s.
To allow tenants to add Applications by themselves, I prepared the following AppProject resources:

  • default: The project for the admin team. The apps belong to the project can deploy any kind of resources.
  • tenant: The project for tenants. The apps belong to the project can deploy the resources in specified namespaces only.
  • tenant-apps: The project for tenants' app-of-apps. The apps belong to the project can only deploy Application resources in argocd namespace.

Moreover, we prepared the app-of-apps that belongs to the tenant-apps project. The app's spec.source.repoURL points to the tenant's repository so that tenants can create their Applications by themselves.

However, in this system, tenants can create apps whose spec.project is default, so tenants can deploy pods with the admin's privilege.

Proposal

To solve this problem, we developed the admission webhook to validate app.spec.project according to app.spec.source.repoURL. Ref: neco-containers/validate_application.go

This validating webhook is working as expected, but in my opinion, this kind of validation feature should be support in upstream of ArgoCD.

This is the example configuration YAML for the webhook.
In this configuration, App whose spec.source.repoURL is https://github.com/example/tenant-apps.git can be set only tenant or tenant-apps as spec.project.

ArgoCDApplicationValidator:
    rules:
      - repository: https://github.com/example/tenant-apps.git
        projects:
          - tenant
          - tenant-apps
@dulltz dulltz added the enhancement New feature or request label Jan 29, 2020
@jkleinlercher
Copy link
Contributor

We plan to do these kind of validations as part of our gitlab pipeline to get rid of a manual merge of the app-of-apps repo by the platform team. There we will also check for some naming rules and so on. Maybe this would also help you in your situation.

@pbecotte
Copy link

There are definitely ways to work around it, but it seems silly to allow restricting the resources, namespaces, and clusters that a project can deploy... but allow it to just use a different set of permissions :)

@jannfis jannfis added component:multi-tenancy Features related to app projects type:usability Enhancement of an existing feature labels May 14, 2020
@Woland2k
Copy link

This would be a great feature to add, as it will allow multi-tenancy with apps of apps approach.

@HumairAK
Copy link

+1 Our case is nearly identical, would love this feature.

@jessesuen
Copy link
Member

This use case is intended to be solved by the "global project" feature. However, it currently does not merge allowed repositories.

https://github.com/argoproj/argo-cd/blob/master/docs/user-guide/projects.md#configuring-global-projects-v18

I think we can simply improve global projects to also merge the global allowed repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:multi-tenancy Features related to app projects enhancement New feature or request type:usability Enhancement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants