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

Quota for user facing resources #1650

Closed
timuthy opened this issue Nov 23, 2019 · 10 comments · Fixed by #3072
Closed

Quota for user facing resources #1650

timuthy opened this issue Nov 23, 2019 · 10 comments · Fixed by #3072
Assignees
Labels
kind/enhancement Enhancement, improvement, extension lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@timuthy
Copy link
Contributor

timuthy commented Nov 23, 2019

What would you like to be added:
Gardener should have configurable, project scoped quotas for resources that end users (specifically project members) are permitted to create:

- apiGroups:
  - ""
  resources:
  - secrets
  - configmaps
  - serviceaccounts

- apiGroups:
  - garden.sapcloud.io
  - core.gardener.cloud
  resources:
  - shoots
  - secretbindings
  - quotas
  - plants

- apiGroups:
  - settings.gardener.cloud
  resources:
  - openidconnectpresets

- apiGroups:
  - garden.sapcloud.io
  - core.gardener.cloud
  resources:
  - projects

The list above contains all possible resources, although some of them might be negligible or aren't critical for the system stability (tbd).

A quota could look like:

apiVersion: core.gardener.cloud/v1alpha1
kind: ResourceQuota
metadata:
  name: standard-quota
  namespace: garden-project
spec:
- apiGroups:
  - garden.sapcloud.io
  - core.gardener.cloud
  resources:
  - shoots
  - secretbindings
  - quotas
  - plants
  limits:
    maxObjects: 200
    maxSizePerObject: 1m 

Unfortunately, k8s native ResourceQuotas don't cover all necessary API objects and uses cases:
https://kubernetes.io/docs/tasks/administer-cluster/quota-api-object/

Why is this needed:
Quotas are one countermeasure to prevent the Gardener- and Kube-Apiserver, it's backing etcds as well as involving controllers from being flooded.

/cc @petersutter @ThormaehlenFred

@timuthy timuthy added the kind/enhancement Enhancement, improvement, extension label Nov 23, 2019
@swilen-iwanow
Copy link
Contributor

I also think, that it is reasonable gardener admins to be able to specify a quota for creating projects. Otherwise the project API could be abused.

@ghost ghost added lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 11, 2020
@rfranzke
Copy link
Member

It might be interesting to look into whether ResourceQuotas are possible to be reused for object counts of our Gardener-managed resources (https://kubernetes.io/docs/concepts/policy/resource-quotas/#object-count-quota only states "custom resources"). Is it possible?

For the object size there is kubernetes/kubernetes#83261. We could revendor k8s.io/apiserver to v0.16.7 to get this 3MB limit: https://github.com/kubernetes/apiserver/blob/v0.16.7/pkg/server/config.go#L298-L311 (cc @ialidzhikov).

@timuthy
Copy link
Contributor Author

timuthy commented Mar 9, 2020

Thanks for the suggestion @rfranzke. I gave it a shoot and tested ResourceQuota but apparently it doesn't work with core.gardener.cloud resources out of the box. We need some further investigation if it'd work by adjusting the Gardener Apiserver.

@petersutter
Copy link
Contributor

with #2032 also roles and rolebindings need to be considered

@rfranzke
Copy link
Member

Thanks @timuthy for trying it out. Indeed, it won't work with custom API servers. How do we proceed here now? Shall we go ahead with your initial proposal and implement our own resource?

@timuthy
Copy link
Contributor Author

timuthy commented Apr 18, 2020

I tried out ResourceQuota a second time because I saw this PR kubernetes/kubernetes#72384 and partly managed to get the right quota count for shoots:
image

Unfortunately, it didn't work reliably in my local setup, e.g. outdated resource count or no admission denial after the quota exhaustion. I'll take some time to find out more and hope that this is still the way to go since it's a K8s standard feature.

@gardener-robot gardener-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 18, 2020
@rfranzke
Copy link
Member

/remove lifecycle/stale
/assign @timuthy
/in-progress

@gardener-robot gardener-robot added status/in-progress and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 22, 2020
@timuthy
Copy link
Contributor Author

timuthy commented Jul 23, 2020

We can use the ResourceQuota to restrict the number of resources. But for Gardener managed resources, i.e. API group core.gardener.cloud we need to implement our own resource quota admission plugin for the Gardener API server analogue to the one from the Kube API server.

@rfranzke
Copy link
Member

Thanks for the update @timuthy. Do you have more background? Why? Last time we talked about it you mentioned there was a problem with the resource quota controller that collects the current number of shoots, for example. Do you now also have observed issues in the admission plugin (even if the controller would compute the values correctly)?

@timuthy
Copy link
Contributor Author

timuthy commented Jul 23, 2020

The resource quota controller only updates the current or actual resource usage of Pods and Services as explained by the design doc and implemented here.

It's the admission plugin's task to check if any incoming object potentially violates the hard resource count as well as to update the ResourceQuota status. But the admission plugin is never invoked for API groups offered via the Gardener extension API server.

@gardener-robot gardener-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Enhancement, improvement, extension lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants