<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, security (a fix that comes through a security advisory), docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list — pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Fixes merged to `main` reach the release lines the backport batch runs for automatically, so do not open backport PRs by hand: https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md --> ## What this PR does Second phase of the accepted [tenant quotas as reservation limits](https://github.com/cozystack/community/pull/48) design, after the evaluator in #4983. An `ApplicationDefinition` can now declare what an application of its kind reserves from its tenant's budget, as CEL over its defaulted values, and the four IaaS kinds (`vm-instance`, `vm-disk`, `kubernetes`, `kubernetes-nodes`) declare theirs. Nothing reads the declarations yet: the usage oracle and the generalized admission gate are the next phase, behind a flag. - `fix(api)`: the evaluator could not sum quantities. The Kubernetes CEL library returns a pointer from `add` and `sub`, which the evaluator did not recognize, so any declaration summing components failed. Found while writing the `kubernetes` declaration, which sums four control-plane components. - `fix(api)`: the evaluator refused exact products. `resource.Quantity.Mul` returns false once the product leaves an int64 coefficient, not when it is wrong, so any fractional binary size above about 8.5Gi (`20.5Gi × 3`) failed as an overflow. - `fix(api)`: a null value stayed present wherever the schema had no default to replace it, so `has()` saw a key Helm deletes, and evaluation failed on a spec the chart renders. - `feat(api)`: `spec.consumption` on `ApplicationDefinition` (`exempt`, ordered `let` bindings, `resources` per quota key), owned as a whole so that a binding and the expressions reading it are replaced together. The evaluator's `Declaration` is now an alias of the API type. The CRD rejects an exempt declaration that still carries expressions and a non-exempt one that names no resource. - `refactor(extra)`: ComputePlane's default `md0` pool now writes its ceiling, instance type and disk size into its release instead of relying on the pool chart's schema defaults, so the release alone says what the pool can reserve. The rendered pool does not change. - `feat(api, kubernetes, virtual-machine)`: the four declarations, each following its chart's own precedence, plus a test that evaluates the shipped declarations against the shipped instance types and preset table, with the failures that must stay errors. Validated locally: `go test ./pkg/reservation/` with each commit built and tested on its own, `helm unittest` on computeplane and the touched `-rd` charts, the four definitions plus three invalid ones validated against the generated CRD schema and its CEL rules, and `make generate` in the touched packages left the tree unchanged (with `cozyvalues-gen` v1.7.0, the version CI pins). Decisions worth a reviewer's look: - **Proxmox worker pools reserve nothing.** Their VMs and disks run on the external hypervisor, so they draw nothing from this cluster's capacity. The `kubernetes` kind reserves one `services.loadbalancers` on Proxmox, for its published apiserver Service, and one on KubeVirt when the ingress addon is exposed by a load balancer, which the tenant cluster's cloud controller realizes in the tenant namespace. - **GPUs are not declared.** Their quota key is the device name (`nvidia.com/<model>`), and `resources` keys are fixed strings. Expressing them needs either a dynamic-key form in the declaration or a class key for GPUs; I would rather settle that in its own change than guess here. Until then the namespace `ResourceQuota` keeps bounding them. - **A spec the chart refuses to render is refused, not estimated.** A partial `resources` block on a VM or a worker pool, a non-whole core count or a memory below 1M fails the evaluation with the declaration's reason, through a `fail(reason)` function the evaluator now offers, so the gate in the next phase can answer with the same reason the render would give. Two decisions left for the next phase, both about what values alone cannot see: - A `vm-disk` whose `storage` is lowered keeps its larger volume, because the chart only ever grows it, while its declaration reads the lowered value. The admission gate has to refuse a storage decrease on Update before it relies on this declaration. - A worker pool's rollout runs one surge worker and its disk next to the old ones (`maxUnavailable: 0` by default), which `maxReplicas` does not cover. Whether that overlap counts against the tenant's budget or is platform margin decides whether a tenant at its ceiling can roll a pool at all. Refs: cozystack/community#48 ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> ### Downstream repositories I walked the trigger map against the diff. Two repositories are affected, and each has a follow-up issue: - `cozystack/website`: the map lists "Change `ApplicationDefinition` semantics". This adds a field nothing reads yet; documenting it seems more useful once the gate in the next phase gives it an effect. - `cozystack/external-apps-example`: the map lists changes to the `ApplicationDefinition` CRD. The field is optional, so nothing breaks there now, but the next phase refuses orders of a kind that declares neither its consumption nor an exemption, so out-of-tree catalogs will need a declaration before that phase is switched on. - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#820 - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [x] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: cozystack/external-apps-example#6 - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note feat(api, kubernetes, virtual-machine): ApplicationDefinitions can declare the tenant quota reservation of their kind, and the VM, disk, Kubernetes and worker pool kinds declare theirs. Nothing enforces the declarations yet. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Application definitions can declare resource consumption for CPU, memory, storage, and load balancers, with reservations based on configured sizing and substrate choices. * Kubernetes worker-pool reservations reflect replica counts, resource overrides, instance types, and disk size; control-plane reservations reflect component sizing and replica counts. * VM instance and disk definitions report resource and storage consumption. * Default compute clusters now specify a node-pool limit of 10, an instance type, and a disk size. * **Validation** * Invalid or incomplete resource sizing and consumption declarations now produce errors, including mismatched CPU and memory settings. Consumption declarations also enforce limits on resource entries and bindings. * **Bug Fixes** * Null values are treated as absent when calculating reservations, and quantity calculations support larger and fractional results. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Cozystack
Cozystack is a free and open-source platform and framework for building clouds.
Cozystack is a CNCF Sandbox project that was originally built and sponsored by Ænix.
With Cozystack, you can transform a bunch of servers into an intelligent system with a simple REST API for spawning Kubernetes clusters, Database-as-a-Service, virtual machines, load balancers, HTTP caching services, and other services with ease.
Use Cozystack to build your own cloud or provide a cost-effective development environment.
Use-Cases
-
Using Cozystack to build a public cloud
You can use Cozystack as a backend for a public cloud -
Using Cozystack to build a private cloud
You can use Cozystack as a platform to build a private cloud powered by Infrastructure-as-Code approach -
Using Cozystack to build your own platform
You can install only the Cozystack components you need on an existing Kubernetes cluster
Documentation
The documentation is located on the cozystack.io website.
Read the Getting Started section for a quick start.
If you encounter any difficulties, start with the troubleshooting guide and work your way through the process that we've outlined.
Versioning
Versioning adheres to the Semantic Versioning principles.
A full list of the available releases is available in the GitHub repository's Release section.
Contributions
Contributions are highly appreciated and very welcomed!
In case of bugs, please check if the issue has already been opened by checking the GitHub Issues section. If it isn't, you can open a new one. A detailed report will help us replicate it, assess it, and work on a fix.
You are welcome to take on the fix yourself. Commits are used to generate the changelog, and their author will be referenced in it.
If you have a concrete feature request, open an issue. For a cross-cutting or architectural change, open a design proposal in the community repo. For questions or early ideas, use GitHub Discussions. See CONTRIBUTING.md for the full routing.
Community
You are welcome to join us in #cozystack, on either CNCF Slack (get an invite) or Kubernetes Slack (get an invite), in our Telegram group, and at our community meetings. Add them to your Google Calendar or iCal for convenience.
Project documents
| Document | What it covers |
|---|---|
| Governance | How decisions are made and who makes them |
| Contributor Ladder | How to grow from contributor to maintainer |
| Maintainers | Who maintains the project |
| Code of Conduct | What we expect of each other |
| Security Policy | Reporting a vulnerability, and which releases get fixes |
| Adopters | Who runs Cozystack in production |
| Roadmap | Where the project is going |
License
Cozystack is licensed under Apache 2.0.
The code is provided as-is with no warranties.
Commercial Support
A list of companies providing commercial support for this project can be found on official site.
