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

Change Kustomize so that policies can be enforced as groups #141

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

galshi
Copy link
Contributor

@galshi galshi commented Nov 21, 2021

@michaelkotelnikov I'm still not sure about the design, I would like your input.
I haven't checked that everything works properly, I'll proceed once you approve.

@momoadc
Copy link

momoadc commented Nov 22, 2021

נראה טוב

@michaelkotelnikov michaelkotelnikov self-requested a review November 24, 2021 15:51
Copy link
Contributor

@michaelkotelnikov michaelkotelnikov left a comment

Choose a reason for hiding this comment

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

@galshi I like the changes -

  • It's more native to have a kustomization file per directory, instead of having a large one.
  • The way you can control the enforcementAction from the kustomization file.

Some points to think about -

  • I would tweak the docu a bit, it's not very clear atm. Maybe add another section for Applying all policies as well.
  • Note that the current state of the kustomization is not too native. If you apply the resources, all constraints will fail unless your GitOps tool is consistently syncing. The constraints.yaml depends on the template.yaml. If the ConstraintTemplate is not created, the resource at the constraints.yaml fails to create.
$ kustomize build ./ | oc apply -f -
constrainttemplate.templates.gatekeeper.sh/k8sdisallowemptydir created
error: unable to recognize "STDIN": no matches for kind "K8sDisallowEmptyDir" in version "constraints.gatekeeper.sh/v1beta1"

@galshi
Copy link
Contributor Author

galshi commented Nov 29, 2021

@michaelkotelnikov
I added a section about applying all policies, I don't think we can do something about your second point, OPA's CRs and CRDs aren't designed very well.
It also looks like removing policies isn't possible,
you can include multiple kustomization files for each policy-group instead of importing all of them through the main kustomization. You still can't disable individual policies though (you would have to clone this repo and remove undesired policies, like the flow described at the end of the paragraph in the link above).

I don't think there's anything better which can be done with native kustomize.

…fied the supported ways of using this repo in a gitops scenario
@galshi galshi marked this pull request as ready for review November 30, 2021 06:32
open-policy-agent/README.md Outdated Show resolved Hide resolved
open-policy-agent/README.md Outdated Show resolved Hide resolved
open-policy-agent/README.md Outdated Show resolved Hide resolved
open-policy-agent/README.md Outdated Show resolved Hide resolved
- op: replace
path: "/spec/enforcementAction"
value: deny
```
Copy link
Contributor

Choose a reason for hiding this comment

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

@galshi I'd add an example of implementation using ArgoCD at the end - which configurations should be applied in the Application for both template and constraint resources to be created and not result in constraint creation failure due to kustomization issues.

I know it might be an overkill, but as for now, if a simple user tries to use the examples we provide, it'll fail. The issue should be covered, and a solution needs to be provided for a complete GitOps solution.

@galshi
Copy link
Contributor Author

galshi commented Jan 3, 2022

Need to evaluate implementing this with Kustomize components.

@galshi galshi marked this pull request as draft January 10, 2022 11:44
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