From datum-platform
Covers resource quota integration using the Milo quota system. Use when implementing ResourceRegistration, ClaimCreationPolicy, or GrantCreationPolicy resources for quota enforcement and allocation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/datum-platform:capability-quotaThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill covers quota integration for Datum Cloud services using the Milo quota system.
This skill covers quota integration for Datum Cloud services using the Milo quota system.
The Milo quota system is a declarative, policy-driven, Kubernetes-native resource quota management system. It provides:
All quota resources use the quota.miloapis.com API group with version v1alpha1.
The quota system has six resource types that work together:
| Resource | Scope | Purpose |
|---|---|---|
| ResourceRegistration | Cluster | Defines what resource types can be quota'd |
| ResourceGrant | Namespaced | Allocates quota capacity to a consumer |
| AllowanceBucket | Namespaced | Aggregates grants and tracks consumption (auto-created) |
| ResourceClaim | Namespaced | Requests quota during resource creation |
| GrantCreationPolicy | Cluster | Automates grant creation on resource lifecycle events |
| ClaimCreationPolicy | Cluster | Automates claim creation during admission (enforcement) |
Read concepts.md for detailed explanations of each resource type and their relationships.
Services have two integration patterns depending on their needs:
Use this when resources should be rejected at creation if quota is exceeded. The admission webhook blocks the API request.
Use this when resources should be created but not provisioned until quota is available. The service manages claim lifecycle directly.
Example use case: Compute instances where auto-scaling creates the instance object, but the system waits for the quota claim to be granted before actually provisioning the VM.
Create a ResourceRegistration to define what resource type can be quota'd:
apiVersion: quota.miloapis.com/v1alpha1
kind: ResourceRegistration
metadata:
name: myservice-resources
spec:
resourceType: "myservice.miloapis.com/resources"
consumerType:
apiGroup: resourcemanager.miloapis.com
kind: Organization
type: Entity # or Allocation for capacity-based
baseUnit: "count"
displayUnit: "resources"
Create a ClaimCreationPolicy that automatically enforces quota when your resources are created:
apiVersion: quota.miloapis.com/v1alpha1
kind: ClaimCreationPolicy
metadata:
name: myservice-resource-quota
spec:
trigger:
resource:
apiVersion: myservice.miloapis.com/v1alpha1
kind: MyResource
target:
resourceClaimTemplate:
metadata:
generateName: "myresource-claim-"
namespace: "{{trigger.metadata.namespace}}"
spec:
requests:
- resourceType: "myservice.miloapis.com/resources"
amount: 1
Create a GrantCreationPolicy that automatically allocates quota when organizations are created:
apiVersion: quota.miloapis.com/v1alpha1
kind: GrantCreationPolicy
metadata:
name: myservice-default-grant
spec:
trigger:
resource:
apiVersion: resourcemanager.miloapis.com/v1alpha1
kind: Organization
target:
resourceGrantTemplate:
metadata:
name: "{{trigger.metadata.name}}-myservice-quota"
namespace: "{{trigger.metadata.namespace}}"
spec:
consumerRef:
apiGroup: resourcemanager.miloapis.com
kind: Organization
name: "{{trigger.metadata.name}}"
allowances:
- resourceType: "myservice.miloapis.com/resources"
buckets:
- amount: 100 # Default quota
For resources that need deferred provisioning, the service manages ResourceClaim lifecycle directly instead of using ClaimCreationPolicy.
Granted conditionfunc (r *InstanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
instance := &computev1alpha1.Instance{}
if err := r.Get(ctx, req.NamespacedName, instance); err != nil {
return ctrl.Result{}, client.IgnoreNotFound(err)
}
// Check if claim exists
claim := "av1alpha1.ResourceClaim{}
claimName := fmt.Sprintf("%s-quota", instance.Name)
err := r.Get(ctx, types.NamespacedName{
Name: claimName,
Namespace: "quota-system",
}, claim)
if apierrors.IsNotFound(err) {
// Create the claim
claim = "av1alpha1.ResourceClaim{
ObjectMeta: metav1.ObjectMeta{
Name: claimName,
Namespace: "quota-system",
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(instance, computev1alpha1.SchemeGroupVersion.WithKind("Instance")),
},
},
Spec: quotav1alpha1.ResourceClaimSpec{
ConsumerRef: quotav1alpha1.ConsumerRef{
APIGroup: "resourcemanager.miloapis.com",
Kind: "Organization",
Name: instance.Spec.Organization,
},
Requests: []quotav1alpha1.ResourceRequest{
{ResourceType: "myservice.miloapis.com/instances", Amount: 1},
{ResourceType: "myservice.miloapis.com/vcpus", Amount: int64(instance.Spec.VCPUs)},
},
ResourceRef: "av1alpha1.UnversionedObjectReference{
APIGroup: "myservice.miloapis.com",
Kind: "Instance",
Name: instance.Name,
Namespace: instance.Namespace,
},
},
}
if err := r.Create(ctx, claim); err != nil {
return ctrl.Result{}, err
}
// Update instance status
instance.Status.Phase = "PendingQuota"
return ctrl.Result{RequeueAfter: 5 * time.Second}, r.Status().Update(ctx, instance)
}
// Check claim status
if !isClaimGranted(claim) {
if isClaimDenied(claim) {
instance.Status.Phase = "QuotaExceeded"
instance.Status.Message = "Insufficient quota available"
return ctrl.Result{}, r.Status().Update(ctx, instance)
}
// Still pending, requeue
return ctrl.Result{RequeueAfter: 5 * time.Second}, nil
}
// Claim granted - proceed with provisioning
instance.Status.Phase = "Provisioning"
// ... actual provisioning logic ...
}
With service-managed claims, expose quota status to users:
status:
phase: PendingQuota # or Provisioning, Running, QuotaExceeded
conditions:
- type: QuotaGranted
status: "False"
reason: PendingEvaluation
message: "Waiting for quota claim to be granted"
Read implementation.md for:
Run scripts/validate-quota.sh to verify:
concepts.md — Quota domain model and resource type detailsimplementation.md — Integration guide with examplesscripts/validate-quota.sh — Validation scriptscripts/scaffold-quota.sh — Scaffolding scriptnpx claudepluginhub datum-cloud/claude-code-plugins --plugin datum-platformChecks organization and project quotas for CPU, memory, storage, pods, public IPv4, and object storage via kubectl. Use before creating VMs, apps, databases, clusters, or EIPs to avoid quota errors.
Tracks quotas, monitors thresholds, records usage, and enables graceful degradation for rate-limited API services with token/request limits.
Guides Azure capacity and quota management for SaaS ISVs in EA/MCA subscriptions. Covers VM quota increases, reservation groups, region access, alerts, AKS integration, and governance.