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

feature/add-quota #644

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/apps/tenant/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ description: Separated tenant namespace
icon: /logos/tenant.svg

type: application
version: 1.7.0
version: 1.8.0
17 changes: 9 additions & 8 deletions packages/apps/tenant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ tenant-u1

### Common parameters

| Name | Description | Value |
| ------------ | --------------------------------------------------------------------------------------------------------------------------- | ------- |
| `host` | The hostname used to access tenant services (defaults to using the tenant name as a subdomain for it's parent tenant host). | `""` |
| `etcd` | Deploy own Etcd cluster | `false` |
| `monitoring` | Deploy own Monitoring Stack | `false` |
| `ingress` | Deploy own Ingress Controller | `false` |
| `seaweedfs` | Deploy own SeaweedFS | `false` |
| `isolated` | Enforce tenant namespace with network policies | `false` |
| Name | Description | Value |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------- | ------- |
| `host` | The hostname used to access tenant services (defaults to using the tenant name as a subdomain for it's parent tenant host). | `""` |
| `etcd` | Deploy own Etcd cluster | `false` |
| `monitoring` | Deploy own Monitoring Stack | `false` |
| `ingress` | Deploy own Ingress Controller | `false` |
| `seaweedfs` | Deploy own SeaweedFS | `false` |
| `isolated` | Enforce tenant namespace with network policies | `false` |
| `resourceQuotas` | Define resource quotas for the tenant | `{}` |
27 changes: 27 additions & 0 deletions packages/apps/tenant/templates/quota.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.resourceQuotas }}
apiVersion: v1
kind: ResourceQuota
metadata:
name: tenant-quota
namespace: {{ include "tenant.name" . }}
spec:
hard:
{{- if .Values.resourceQuotas.hard}}
{{- if .Values.resourceQuotas.hard.resources.requests }}
{{- if .Values.resourceQuotas.hard.resources.requests.cpu }}
requests.cpu: {{ .Values.resourceQuotas.hard.resources.requests.cpu }}
{{- end }}
{{- if .Values.resourceQuotas.hard.resources.requests.memory }}
requests.memory: {{ .Values.resourceQuotas.hard.resources.requests.memory }}
{{- end }}
{{- end }}
{{- if .Values.resourceQuotas.hard.resources.limits }}
{{- if and .Values.resourceQuotas.hard.resources.limits.cpu }}
limits.cpu: {{ .Values.resourceQuotas.hard.resources.limits.cpu }}
{{- end }}
{{- if .Values.resourceQuotas.hard.resources.limits.memory }}
limits.memory: {{ .Values.resourceQuotas.hard.resources.limits.memory }}
{{- end }}
{{- end }}
{{- end }}
Comment on lines +7 to +26
Copy link
Member

Choose a reason for hiding this comment

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

It might be way more easier to do:

Suggested change
spec:
hard:
{{- if .Values.resourceQuotas.hard}}
{{- if .Values.resourceQuotas.hard.resources.requests }}
{{- if .Values.resourceQuotas.hard.resources.requests.cpu }}
requests.cpu: {{ .Values.resourceQuotas.hard.resources.requests.cpu }}
{{- end }}
{{- if .Values.resourceQuotas.hard.resources.requests.memory }}
requests.memory: {{ .Values.resourceQuotas.hard.resources.requests.memory }}
{{- end }}
{{- end }}
{{- if .Values.resourceQuotas.hard.resources.limits }}
{{- if and .Values.resourceQuotas.hard.resources.limits.cpu }}
limits.cpu: {{ .Values.resourceQuotas.hard.resources.limits.cpu }}
{{- end }}
{{- if .Values.resourceQuotas.hard.resources.limits.memory }}
limits.memory: {{ .Values.resourceQuotas.hard.resources.limits.memory }}
{{- end }}
{{- end }}
{{- end }}
spec:
hard:
{{- toYaml .Values.resourceQuotas | nindent 4 }}

{{- end }}
5 changes: 5 additions & 0 deletions packages/apps/tenant/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"type": "boolean",
"description": "Enforce tenant namespace with network policies",
"default": false
},
"resourceQuotas": {
"type": "object",
"description": "Define resource quotas for the tenant",
"default": {}
}
}
}
11 changes: 11 additions & 0 deletions packages/apps/tenant/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@
## @param ingress Deploy own Ingress Controller
## @param seaweedfs Deploy own SeaweedFS
## @param isolated Enforce tenant namespace with network policies
## @param resourceQuotas Define resource quotas for the tenant
host: ""
etcd: false
monitoring: false
ingress: false
seaweedfs: false
isolated: false
resourceQuotas: {}
# resourceQuotas:
# hard:
# resources:
# limits:
# cpu: "2"
# memory: "2Gi"
# requests:
# cpu: "1"
# memory: "1Gi"
Comment on lines +16 to +25
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep it in sync with official Kubernetes format
https://kubernetes.io/docs/concepts/policy/resource-quotas/

Suggested change
resourceQuotas: {}
# resourceQuotas:
# hard:
# resources:
# limits:
# cpu: "2"
# memory: "2Gi"
# requests:
# cpu: "1"
# memory: "1Gi"
resourceQuotas: {}
# resourceQuotas:
# requests.cpu: "1"
# requests.memory: "1Gi"
# limits.cpu: "2"
# limits.memory: "2Gi"
# requests.nvidia.com/gpu: 4
# requests.storage: 100Gi

3 changes: 2 additions & 1 deletion packages/apps/versions_map
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ tenant 1.6.5 f1e11451
tenant 1.6.6 d4634797
tenant 1.6.7 06afcf27
tenant 1.6.8 4cc48e6f
tenant 1.7.0 HEAD
tenant 1.7.0 6c73e3f3
tenant 1.8.0 HEAD
virtual-machine 0.1.4 f2015d6
virtual-machine 0.1.5 7cd7de7
virtual-machine 0.2.0 5ca8823
Expand Down