Skip to content

Commit b5eb1a3

Browse files
authored
feat: add grant policies for notes and core resource quotas (#193)
## Summary - Add GrantCreationPolicies for notes and core Kubernetes resources - Triggered on Project creation, allocates default quota amounts - Companion to datum-cloud/milo#523 which defines the registrations and claim policies in the milo repo ### Default quotas per project | Resource | apiGroup | Amount | |----------|----------|--------| | Note | `notes.miloapis.com` | 100 | | ClusterNote | `notes.miloapis.com` | 100 | | Secret | `core.miloapis.com` | 50 | | ConfigMap | `core.miloapis.com` | 50 | ## Test plan - [ ] Verify kustomize build succeeds - [ ] Deploy alongside milo registrations/claim policies and verify grant creation on project creation Ref: datum-cloud/enhancements#664 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents 4744f31 + 4f9633f commit b5eb1a3

9 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Component
3+
4+
sortOptions:
5+
order: fifo
6+
7+
components:
8+
- quota/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: quota.miloapis.com/v1alpha1
2+
kind: GrantCreationPolicy
3+
metadata:
4+
name: default-core-quota-policy
5+
labels:
6+
app.kubernetes.io/name: datum
7+
app.kubernetes.io/component: quota-system
8+
spec:
9+
trigger:
10+
resource:
11+
apiVersion: resourcemanager.miloapis.com/v1alpha1
12+
kind: Project
13+
target:
14+
parentContext:
15+
apiGroup: "resourcemanager.miloapis.com"
16+
kind: "Project"
17+
nameExpression: "trigger.metadata.name"
18+
resourceGrantTemplate:
19+
metadata:
20+
name: "default-core-quota-{{ trigger.metadata.name }}"
21+
namespace: milo-system
22+
annotations:
23+
kubernetes.io/description: "Core resource quota allocation for project"
24+
spec:
25+
consumerRef:
26+
apiGroup: resourcemanager.miloapis.com
27+
kind: Project
28+
name: "{{ trigger.metadata.name }}"
29+
allowances:
30+
- resourceType: core.miloapis.com/secrets
31+
buckets:
32+
- amount: 50
33+
- resourceType: core.miloapis.com/configmaps
34+
buckets:
35+
- amount: 50
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Component
3+
4+
sortOptions:
5+
order: fifo
6+
7+
resources:
8+
- default-project-grant-policy.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Component
3+
4+
sortOptions:
5+
order: fifo
6+
7+
components:
8+
- grant-policies/

config/services/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ components:
1313
- iam.miloapis.com/
1414
- dns.networking.miloapis.com/
1515
- networking.datumapis.com/
16+
- notes.miloapis.com/
17+
- core.miloapis.com/
1618
- search.miloapis.com/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Component
3+
4+
sortOptions:
5+
order: fifo
6+
7+
components:
8+
- quota/
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: quota.miloapis.com/v1alpha1
2+
kind: GrantCreationPolicy
3+
metadata:
4+
name: default-notes-quota-policy
5+
labels:
6+
app.kubernetes.io/name: datum
7+
app.kubernetes.io/component: quota-system
8+
spec:
9+
trigger:
10+
resource:
11+
apiVersion: resourcemanager.miloapis.com/v1alpha1
12+
kind: Project
13+
target:
14+
parentContext:
15+
apiGroup: "resourcemanager.miloapis.com"
16+
kind: "Project"
17+
nameExpression: "trigger.metadata.name"
18+
resourceGrantTemplate:
19+
metadata:
20+
name: "default-notes-quota-{{ trigger.metadata.name }}"
21+
namespace: milo-system
22+
annotations:
23+
kubernetes.io/description: "Notes quota allocation for project"
24+
spec:
25+
consumerRef:
26+
apiGroup: resourcemanager.miloapis.com
27+
kind: Project
28+
name: "{{ trigger.metadata.name }}"
29+
allowances:
30+
- resourceType: notes.miloapis.com/notes
31+
buckets:
32+
- amount: 100
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Component
3+
4+
sortOptions:
5+
order: fifo
6+
7+
resources:
8+
- default-project-grant-policy.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Component
3+
4+
sortOptions:
5+
order: fifo
6+
7+
components:
8+
- grant-policies/

0 commit comments

Comments
 (0)