Timofei Larkin 64cd55a161 feat(kubernetes): run tenant clusters inside a cozyplane VPC (#5337)
## What this PR does

Stacked on #4508 (VMs in a cozyplane VPC). This layer runs a whole
tenant Kubernetes cluster inside a VPC: the control plane, its etcd and
the worker VMs. The `Kubernetes` cluster and each of its
`KubernetesNodes` pools set the same `network: {name: <VPC catalog
name>}`.

A VPC refuses cluster-internal destinations, so the workers, the
tenant's own pods and the konnectivity agents all need an apiserver
address inside the VPC. The platform side keeps working unchanged: it
reaches VPC pods by their fabric IPs and through ClusterIPs that resolve
to them. That covers Kamaji, CAPI, kccm, the cluster autoscaler, the
chart's Jobs, the ingress passthrough, and the `super-admin.svc`
kubeconfig Flux installs the tenant addons with.

**Control plane.** `network.name` on the `Kubernetes` cluster does three
things:
- puts the apiserver pods in the VPC
(`deployment.podAdditionalMetadata`);
- attaches their Service to it (`network.serviceAnnotations`), so that
inside the VPC the resolver answers the Service's name with a VIP from
the VPC's own range;
- stamps the cluster's own etcd through the `annotations` key of
`cozy-lib.etcd.cluster`. etcd-operator copies that annotation onto the
member Pods and both etcd Services, so the apiserver reaches its
DataStore entirely inside the VPC.

**Advertise address.** Kamaji's `advertiseAddress` is what the tenant's
`kubernetes` endpoints and the konnectivity agents dial, and its CRD
requires an IP. The right IP is the apiserver Service's VIP, which only
a pod inside the VPC can learn. In VPC mode each pool's talos-reconcile
Job starts a short-lived probe pod in the VPC. The probe resolves the
Service's FQDN and writes the answer to its termination message. The Job
reads that back with a namespaced pod `get`, patches `advertiseAddress`
(Kamaji adds it to the apiserver certificate itself), and uses the VIP
for the workers' `extraHostEntries` in place of the ClusterIP. This
happens before the pool's TalosConfigTemplate is applied, so Kamaji's
one rollout runs while the cluster has no workers yet. The Job's Role
gains `create` on pods plus `get`/`delete` on the probe pod by name, in
VPC mode only.

**Workers.** Each pool stamps `sdn.cozystack.io/vpc` on its worker VM
template, only when set, because the KubevirtMachineTemplate is
content-hash named.

**Route table.** A pool can also name a cozyplane RouteTable with
`routeTable` (a DNS-1123 name, empty by default), the same contract as
`vm-instance`'s value in #4508. When it is set, the pool renders
`sdn.cozystack.io/route-table: <routeTable>` on its worker VM template
next to `sdn.cozystack.io/vpc`, and setting or changing it rolls the
pool's workers, as `network` does. Empty renders nothing, which leaves
the VPC's default table in effect. The render fails with `routeTable` on
a cluster that does not serve `sdn.cozystack.io`, on `substrate:
proxmox`, or without `network.name`. The control plane keeps the VPC's
default table.

**Guards**, all unit-tested. The cluster refuses `network.name`:
- where `sdn.cozystack.io` is not served;
- on the proxmox substrate;
- on the tenant's shared DataStore;
- on a running cluster outside that VPC, in either direction, because
etcd-operator never re-stamps a running member.

A pool refuses a network that differs from its control plane's, again in
either direction, checked against the live apiserver Service.

Design notes:
- **The probe is interim.** A request for cozyplane to report an
attached Service's VIP on the Service itself (`sdn.cozystack.io/vpc-ip`,
the same annotation the CNI stamps on pods) is going to upstream. Once
it ships, the Job reads the annotation and the probe goes away.
- **The rejected alternative is a LoadBalancer.** Publishing the
apiserver Service and reaching it through the VPC gateway's NAT spends a
published address per cluster and makes NAT a dependency of the control
path.

Not verified on a live stand yet:
- the probe's resolution through the VPC resolver;
- worker bootstrap and konnectivity through the VIP;
- etcd member peering inside the VPC;
- OIDC mode, where the apiserver dials Keycloak's internal URL from
inside the VPC.

### Screenshots

Not a UI change.

### Downstream repositories

Walked the trigger map against the diff. terraform-provider-cozystack
models app fields by hand, so the new `network` (both apps) and
`routeTable` (KubernetesNodes) fields need its schema, model and
expand/flatten; that is cozystack/terraform-provider-cozystack#90. The
website's reference pages for kubernetes and kubernetes-nodes are
regenerated from their READMEs on release, and both apps are in the
website's app lists, so no follow-up is needed there. Nothing else in
the map is touched.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#90
- [ ]
[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:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
feat(kubernetes): on the cozyplane networking variant, a tenant Kubernetes cluster can run entirely inside a VPC — network.name puts its control plane, its own etcd and its worker VMs in the VirtualPrivateCloud
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Kubernetes clusters now use dedicated etcd by default, with
configurable one- or three-member setups and storage options. Existing
clusters using shared etcd retain their current configuration.
* Clusters and worker pools can join a cozyplane VPC, subject to
platform and compatibility requirements. Changing a worker pool’s
network rolls its worker VMs.
  * Cluster status notes now identify the etcd configuration in use.

* **Bug Fixes**
* Enabled Kubernetes add-ons and supporting services can render
independently of tenant-shared etcd availability.
  * Cluster cleanup now handles dedicated etcd resources.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-26 16:24:28 +03:00
2026-11-04 00:56:56 +01:00
2025-10-08 09:43:34 +05:00
2024-02-08 12:04:32 +01:00

Cozystack Cozystack

GitHub Release Apache-2.0 License Commit activity OpenSSF Best Practices OpenSSF Scorecard CLOMonitor Support

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.

Cozystack user interface

Use-Cases

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.

Languages
Go 53.1%
Shell 33%
TypeScript 6.8%
Go Template 4.6%
Makefile 1.3%
Other 1.1%