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

Create OCP project template and add organization label to projects #16

Merged
merged 3 commits into from
Sep 10, 2021

Conversation

simu
Copy link
Member

@simu simu commented Sep 8, 2021

This PR configures a custom OCP project template which only creates a Project resource and no rolebindings.

The PR also adds a mutate policy which adds the requesting user's default organization to the project based on the value of annotation
openshift.io/requester on the Project resource created by the OCP project template.

Additionally, we refactor the code a bit since this new mutate policy is mostly identical to the one which handles setting a default organization when users create projects with kubectl create ns.

Checklist

  • Keep pull requests small so they can be easily reviewed.
  • Categorize the PR by setting a good title and adding one of the labels:
    bug, enhancement, documentation, change, breaking, dependency
    as they show up in the changelog

@simu simu added the enhancement New feature or request label Sep 8, 2021
@simu simu force-pushed the feat/support-ocp-projects branch 4 times, most recently from 2dfa3cf to fc161ee Compare September 9, 2021 13:11
Change the OCP project template to only create a Project resource and no
rolebindings.
Add a mutate policy which adds the requesting user's default
organization to the project based on the value of annotation
`openshift.io/requester` on the Project resource created by the OCP
project template.

Refactor the code a bit since this mutate policy is mostly identical to
the one which handles setting a default organization when users create
projects with `kubectl create ns`.
@simu simu force-pushed the feat/support-ocp-projects branch from fc161ee to a49d361 Compare September 10, 2021 13:09
@simu simu marked this pull request as ready for review September 10, 2021 13:10
@simu simu requested review from ccremer and glrf September 10, 2021 13:10
Copy link
Contributor

@ccremer ccremer left a comment

Choose a reason for hiding this comment

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

Do these policies also work when using a Project spec from YAML (e.g. oc create -f project.yaml) ?
I ask because I'm not sure if a YAML spec is the same as oc create project because the oc binary might do more magic in the background (e.g. creating a ProjectRequest instead).

I really have no idea if there's a difference between the two, just asking here.

@simu
Copy link
Member Author

simu commented Sep 10, 2021

Do these policies also work when using a Project spec from YAML (e.g. oc create -f project.yaml) ?

They don't have to, because regular users cannot oc create -f project.yaml anyway.

@ccremer
Copy link
Contributor

ccremer commented Sep 10, 2021

They don't have to, because regular users cannot oc create -f project.yaml anyway.

How so? I could imagine some Kustomize or CI/CD use cases for this?

@simu
Copy link
Member Author

simu commented Sep 10, 2021

They don't have to, because regular users cannot oc create -f project.yaml anyway.

How so? I could imagine some Kustomize or CI/CD use cases for this?

In CI/CD, users can use the Namespace resource which they do have permissions to create. Out of the box, regular users don't have permissions to directly create Project resources on OpenShift.

@simu simu merged commit 17a7038 into master Sep 10, 2021
@simu simu deleted the feat/support-ocp-projects branch September 10, 2021 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants