kubernetes-retired / cluster-api-provider-nested

Cluster API Provider for Nested Clusters
Apache License 2.0
301 stars 67 forks source link

🌱Add validation plugin and add tenant quota validation before creating a pod #255

Closed weiling61 closed 2 years ago

weiling61 commented 2 years ago

What this PR does / why we need it:

Following is the proposal for this feature: https://github.com/kubernetes-sigs/cluster-api-provider-nested/blob/main/docs/proposals/20220206-quota.md

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged): Following issue was originally raised: Performance and Resource Contention in Multiple Tenant Environment #240

Fixes # Enhancement

weiling61 commented 2 years ago

@Fei-Guo @christopherhein

Fei-Guo commented 2 years ago

Can we just have ValidationPluginInterface defined with three methods

type ValidationPluginInterface interface {
    Validation(client.Object, string) bool
    GetTenantLocker(string) *sync.Mutex
    Enabled() bool
}

so the changes to the Pod dws are straightforward. You can put rest of the code in resources/validationplugin/validationplugin.go to a separate file called quotavalaidationPlugin which implements the interface. I would suggest to name the plugin as QuotaValidationPlugin explicitly.

Also, please consider to move the validationplugin directory under resources/pod/ since the plugin works for Pod resource only.

For the plugin definition, can you just reuse the one that has been added in the util package? sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/util/plugin/plugin.go

weiling61 commented 2 years ago

@Fei-Guo Thanks for the review. Updated according to your review comments

weiling61 commented 2 years ago

@Fei-Guo updated according to your review comments.

Fei-Guo commented 2 years ago

What happened to the virtualcluster/README.MD file?

Fei-Guo commented 2 years ago

/lgtm /ok-to-test

Fei-Guo commented 2 years ago

/approve

k8s-ci-robot commented 2 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Fei-Guo, weiling61

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[virtualcluster/OWNERS](https://github.com/kubernetes-sigs/cluster-api-provider-nested/blob/main/virtualcluster/OWNERS)~~ [Fei-Guo] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment