Closed f1ames closed 1 year ago
I really think we should reconsider our approach on namespaced admission controllers. Or maybe i did not understand the code and I might be wrong, but the approach where the controller can have an one "active policy" at a time is not looking reliable to me.
A better aproach, on a quick thought, would be creating a Map, 1-1 between a namespace and a policy (at first, later we can map resources to policies better should we want that and if it is possible). Now the Controller would have knowledge of all the policies and would be able to validate namespaced manifests.
totally agree - this would be configured in cloud, i.e. which policies apply to which resources - the selection could be based on
Ok, discussed some technicalities with @murarustefaan to make sure I understand how admission controller should behave exactly, to summarize:
This PR fixes https://github.com/kubeshop/monokle-saas/issues/1839, fixes https://github.com/kubeshop/monokle-saas/issues/1845.
Implemented
MonoklePolicy
andMonoklePolicyBinding
according to https://github.com/kubeshop/monokle-saas/issues/1839#issuecomment-1738937312 and consistent (to some extend) with how VAP works.Changes
CRD
s forMonoklePolicy
andMonoklePolicyBinding
.Warn
only (see screenshot below). I already put it in the CRDs definition (as enum array so it can be extended and is the same format VAP has).PolicyManager
class which watches instances ofMonoklePolicy
andMonoklePolicyBinding
and is responsible for storing, updating and matching (policy-binding-resource) them (I think*Manager
class name is a bit of naming-antipattern so I'm open for suggestions).Informer
(high level watcher) mechanism.ValidatorManager
class which reacts to policy changes and creates/updates/deletes validator instances. It also provides matching validators for given resources when they need to be validated.monokle-admission-controller
namespace.resource-links
). See https://github.com/kubeshop/monokle-saas/issues/1845#issuecomment-1744412694 and https://github.com/kubeshop/monokle-admission-controller/pull/1/commits/586aeed14a9366e68d087de3a5be2586f6bd6aaa.Sample output (we can adjust wording there):
Fixes
To consider
pino
for logging and try to make it reasonable with different levels (so it's not to much with info and higher level while debug/trace will log a lot of data on each update, like resources content, polices content, etc). Still it might require some improvements to better help with debugging.I'm open for discussion/suggestions for any of the above.
Testing
See
README.md
with step-by-step instructions.Checklist