Spike: Improve package linting process
Currently package pipelines have a policies folder that consists of rego
policies that are used for linting. In addition each package can have a tests/policy
folder with additional rego policies that are only evaluated on that package.
The goal of adding this linting was originally to run the same checks that gatekeeper would be doing in package pipelines. Some of the limitations with how this is currently implemented:
- Rego policies live in the pipeline repo and can easily get out of date with what gatekeeper is checking
- Since policies are run as "linting" they don't properly evaluate packages that use operators (ex: the yaml location for image in a
Kiali
object is not the same as in aPod
/Deployment
, and the rego tests are designed to check based on "vanilla k8s objects")
Things to look at:
- Dynamically getting rego from gatekeeper constraints to keep these policies up to date - this would solve
#1
- Dynamically controlling which policies are in "enforcing mode" for linting
- Evaluate how to properly lint packages with operators (do we need custom rego for each package? is there something that we can leverage to do this dynamically?)
- Is it better to remove "linting" and use gatekeeper at runtime in the pipelines? This would handle both of the limitations above, but also gets rid of linting which can be valuable to catch issues before doing full installs. Maybe do both and live with some of the limitations of linting?
Edited by Micah Nagel