mirror of
https://github.com/dsx-ai-factory/nvke.git
synced 2026-12-07 04:35:58 +08:00
* feat(controller): adopt the cluster the controller runs on behind a flag
Add POST /clusters/self-adopt, which records the cluster the controller runs
on as a cluster NVKE manages, without running kubeadm init. The endpoint is
served only when clusterSelfAdoptionEnabled is set in nvke-controller-config
(chart value clusterSelfAdoptionEnabled, default false). Otherwise it answers
400.
The controller reads the cluster with its own service account: the
control-plane Nodes, each with an InternalIP, and the Kubernetes version and
pod and service CIDRs from kube-system/kubeadm-config. The request carries
only what NVKE cannot read: name, NICo site and VPC (orgID optional), CNI
plugin and version, and etcdEncrypted. While the flag is on, the chart grants
that service account list on Nodes and get on kube-system/kubeadm-config.
Self-adopt returns 400 for no control-plane node, a node without an
InternalIP, a kubelet that differs from kubeadm-config, a version that is not
X.Y.Z, no or unsupported pod or service CIDRs, a second adoption, or an
existing Cluster API Cluster of the same name.
The adopted control plane stays with its operator, outside NVKE. Adoption
marks the cluster and its control-plane nodes as adopted, records desiredCount
as their number with no control-plane machine settings, and turns off
recycling, automatic scale-down and rebalancing:
- PATCH /clusters/{id} refuses turning those back on, controlPlaneConfig.nico,
controlPlaneKubernetesVersion, any desiredCount change and any control-plane
rollout field.
- DELETE /nodes/{id} on an adopted node returns 409, refused in the handler.
- The node-status sync never marks an adopted node for recycling, so
control-plane remediation never replaces it.
DELETE /clusters/{id} on an adopted cluster removes only NVKE's records and
leaves the cluster running. It returns 409 while the cluster has node pools,
so their workers are drained and released through the node pool delete first.
TeardownCluster then deletes the Cluster API Cluster and NicoCluster and the
adopted node and cluster rows, and never tears down a node.
An adopted cluster gets OIDCAuthEnabled false, since NVKE cannot configure its
API servers. Its provisioning workflow applies only the Cluster API scaffold:
node-local DNS and the Pod Security namespace labels stay with the operator.
Signed-off-by: Abhinav Pandey <abhinavmpandey08@gmail.com>
* fix(controller): keep maintenance off an adopted cluster and serialize self-adopt
Address review on the self-adopt change.
Keep NVKE from changing an adopted control plane in place:
- PATCH /clusters/{id} refuses turning on enableEtcdEncryption or enableOidc
for an adopted cluster, alongside the existing control-plane refusals.
- Scheduled certificate renewal skips an adopted cluster.
- stableControlPlane refuses an adopted control plane, which keeps on-demand
certificate renewal and etcd key rotation off it.
Make "adopts at most one cluster" hold across concurrent requests:
SelfAdoptCluster takes a transaction-scoped advisory lock (LockSelfAdoption)
and checks for an adopted cluster again inside the transaction that records
it, so a second adoption gets a 400. Also fix a stale comment that said an
adopted record cannot be deleted.
Signed-off-by: Abhinav Pandey <abhinavmpandey08@gmail.com>
---------
Signed-off-by: Abhinav Pandey <abhinavmpandey08@gmail.com>