# Epic: https://issues.redhat.com/browse/BUILD-1571 Allow resource request/limits when running Builds Goal: Allow developers to configure CPU, memory, and storage resource requests/limits for their build pods. Ensure defaults, validations, and quota interactions are clear and safe. --- Story 1: Extend CRD Schema to Expose Resource Requirements Description: As a developer, I want to specify CPU/memory/storage requests and limits in my Build/BuildRun CR so that my pods run with the resources I need. Acceptance Criteria: * CRD spec includes `resources: corev1.ResourceRequirements`. * PodTemplate knobs (priorityClass, tolerations, nodeSelector) exposed. * OpenAPI schema validations present. Subtasks: * Add `Resources` field in API types. * Add CRD markers (kubebuilder annotations). * Generate & update CRDs with `make manifests`. * Add unit tests for API struct marshalling. --- Story 2: Implement Defaulting Webhook Description: As a platform, I want missing requests/limits to be defaulted to safe values, so builds always have resource requests set for quota evaluation. Acceptance Criteria: * If missing, CPU defaults to `250m`, memory to `512Mi`. * Limits mirror requests if not set. * Defaulting code covered by unit tests. Subtasks: * Add `Default()` method on CRD. * Write unit tests for default injection. * Update docs with default values. --- Story 3: Implement Validating Webhook Description: As a platform, I want to prevent invalid or policy-violating resources from being accepted, so cluster stability is preserved. Acceptance Criteria: * Reject unknown resources (only CPU, memory, ephemeral-storage, GPU). * Ensure `limits ≥ requests`. * Reject requests/limits above configured org caps (e.g., 8 CPU, 16Gi memory). * Clear error messages returned. Subtasks: * Add `ValidateCreate/Update()` hooks. * Add field validation helpers. * Unit tests for valid/invalid specs. --- Story 4: Reconciler – Apply Resources to Pods/TaskRuns Description: As a developer, I want my specified resources applied to the actual build pods, so they run with my requested/limited resources. Acceptance Criteria: * Resources injected into build container(s). * Works with both direct Pod creation and Tekton TaskRuns (StepTemplate/Steps). * Supports per-step overrides if provided. Subtasks: * Update reconciler to propagate Resources. * Add tests with fake clients to assert Pod specs contain correct values. * Update examples and docs. --- Story 5: Handle ResourceQuota & LimitRange Interactions Description: As a developer, I want clear feedback when my build fails due to exceeding ResourceQuota or LimitRange, so I know how to fix it. Acceptance Criteria: * Controller surfaces a `Condition` (e.g., `QuotaExceeded`) when Pod creation is denied by quota. * Event logged in namespace with reason. * Backoff retry implemented to avoid hot loop. Subtasks: * Add status condition updates. * Add requeue/backoff logic. * Add integration test with fake ResourceQuota. --- Story 6: Documentation & Examples Description: As a user, I want documentation and examples showing how to request resources, so I can adopt the feature easily. Acceptance Criteria: * Example YAML manifests with resources. * Default/validation rules explained in docs. * Added to release notes. Subtasks: * Update README/docs site. * Add sample CR YAML. * Add section in release changelog.