From f17cd76d5e37175a84ff4f0b57eec6d41f305d96 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Sun, 22 Nov 2026 21:31:41 +0100 Subject: [PATCH 1/2] feat(cozyplane): bump to the v0.1.5 release v0.1.5 adds the PortClaim kind: a pod naming a claim in its sdn.cozystack.io/port-claim annotation keeps the claim's IP and MAC across launcher pods. A claim that adopts a running VM's Port keeps it bound to the pod already holding it and reports Bound=True with reason PreClaimPod. Without a claim a VM now gets a new IP and MAC on every launcher pod, live migration included, so vm-instance claims one in the next commit. The aggregated apiserver now sets metadata.generation, and the controllers stamp observedGeneration, so a retargeted FloatingIP no longer keeps its old target's status. The vendored charts pin a main build, so the wrappers keep pinning the release images by tag and digest. Assisted-by: LLM Signed-off-by: Timofei Larkin --- packages/system/cozyplane-apiserver/Makefile | 2 +- .../charts/cozyplane-apiserver/values.yaml | 2 +- .../system/cozyplane-apiserver/values.yaml | 2 +- packages/system/cozyplane-kpr/Makefile | 2 +- packages/system/cozyplane-kpr/values.yaml | 2 +- packages/system/cozyplane/Makefile | 2 +- .../charts/cozyplane/templates/agent.yaml | 4 ++++ .../charts/cozyplane/templates/controller.yaml | 18 +++++++++--------- .../cozyplane/templates/tenant-rbac.yaml | 3 +++ .../cozyplane/charts/cozyplane/values.yaml | 2 +- packages/system/cozyplane/values.yaml | 2 +- 11 files changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/system/cozyplane-apiserver/Makefile b/packages/system/cozyplane-apiserver/Makefile index 555fc51d2..f02a82028 100644 --- a/packages/system/cozyplane-apiserver/Makefile +++ b/packages/system/cozyplane-apiserver/Makefile @@ -7,7 +7,7 @@ include ../../../hack/package.mk # The lllamnyp/cozyplane ref charts/cozyplane-apiserver is vendored from, verbatim. Keep the # three cozyplane packages on the same ref; Cozystack's settings live in this # wrapper, never in the vendored chart. -COZYPLANE_REF=ce771d6122df1a296ea1bfec372ddb44b5b439fc +COZYPLANE_REF=b99171ea7c33319dad4f2b401898c1ddb089d85b test: helm unittest . diff --git a/packages/system/cozyplane-apiserver/charts/cozyplane-apiserver/values.yaml b/packages/system/cozyplane-apiserver/charts/cozyplane-apiserver/values.yaml index a895267b6..5eaeea2df 100644 --- a/packages/system/cozyplane-apiserver/charts/cozyplane-apiserver/values.yaml +++ b/packages/system/cozyplane-apiserver/charts/cozyplane-apiserver/values.yaml @@ -1,7 +1,7 @@ # Container image (shared with the cozyplane chart โ€” the apiserver binary lives # in the same image). Digest-pinned (no floating tag); keep it equal to # chart/cozyplane/values.yaml's pin. See docs/packaging.md. -image: ghcr.io/lllamnyp/cozyplane@sha256:0c0aff04cc029306942258a361223229766ff8fd9ae23167e7f003ce6ad5a53f +image: ghcr.io/lllamnyp/cozyplane@sha256:3233ef875fe220cdadd57ec6b138577b738fe61bec9a41051ed9a59d64973edf imagePullPolicy: IfNotPresent imagePullSecrets: [] diff --git a/packages/system/cozyplane-apiserver/values.yaml b/packages/system/cozyplane-apiserver/values.yaml index 71e1c1ca4..1576ede90 100644 --- a/packages/system/cozyplane-apiserver/values.yaml +++ b/packages/system/cozyplane-apiserver/values.yaml @@ -1,7 +1,7 @@ cozyplane-apiserver: # The cozyplane release's image by tag and digest, for mirroring and # promotion; the vendored chart pins a digest only. - image: ghcr.io/lllamnyp/cozyplane:v0.1.2@sha256:0fbf42fca2f65fc500a0b48738ee321c483246952fc013d249b6bb27445cc19f + image: ghcr.io/lllamnyp/cozyplane:v0.1.5@sha256:2cc55293000b64a4c4233910cbc3803b9bea7c16e9e7d44ddcc44fb4042cdd98 # The aggregated apiserver backs every tenant's SDN API. replicas: 2 etcd: diff --git a/packages/system/cozyplane-kpr/Makefile b/packages/system/cozyplane-kpr/Makefile index 8d577ebf5..82dd89b41 100644 --- a/packages/system/cozyplane-kpr/Makefile +++ b/packages/system/cozyplane-kpr/Makefile @@ -7,7 +7,7 @@ include ../../../hack/package.mk # The lllamnyp/cozyplane ref charts/cozyplane-kpr is vendored from, verbatim. Keep the # three cozyplane packages on the same ref; Cozystack's settings live in this # wrapper, never in the vendored chart. -COZYPLANE_REF=ce771d6122df1a296ea1bfec372ddb44b5b439fc +COZYPLANE_REF=b99171ea7c33319dad4f2b401898c1ddb089d85b test: helm unittest . diff --git a/packages/system/cozyplane-kpr/values.yaml b/packages/system/cozyplane-kpr/values.yaml index 3a5138719..3e2ec7373 100644 --- a/packages/system/cozyplane-kpr/values.yaml +++ b/packages/system/cozyplane-kpr/values.yaml @@ -1,4 +1,4 @@ cozyplane-kpr: # The cozyplane release's image by tag and digest, for mirroring and # promotion; the vendored chart pins a digest only. - image: ghcr.io/lllamnyp/cozyplane-kpr:v0.1.2@sha256:39cd8391952c951c050fe818e4e9a0f83deb10caef20741093e39cea54f4ce01 + image: ghcr.io/lllamnyp/cozyplane-kpr:v0.1.5@sha256:28254bdc0283b3797ea8c5f26146932c46b0be98a15cdd660cb42330963cb01c diff --git a/packages/system/cozyplane/Makefile b/packages/system/cozyplane/Makefile index e5ee9f825..456dcda13 100644 --- a/packages/system/cozyplane/Makefile +++ b/packages/system/cozyplane/Makefile @@ -7,7 +7,7 @@ include ../../../hack/package.mk # The lllamnyp/cozyplane ref charts/cozyplane is vendored from, verbatim. Keep the # three cozyplane packages on the same ref; Cozystack's settings live in this # wrapper, never in the vendored chart. -COZYPLANE_REF=ce771d6122df1a296ea1bfec372ddb44b5b439fc +COZYPLANE_REF=b99171ea7c33319dad4f2b401898c1ddb089d85b test: helm unittest . diff --git a/packages/system/cozyplane/charts/cozyplane/templates/agent.yaml b/packages/system/cozyplane/charts/cozyplane/templates/agent.yaml index bcb0dabdb..72ac8a02f 100644 --- a/packages/system/cozyplane/charts/cozyplane/templates/agent.yaml +++ b/packages/system/cozyplane/charts/cozyplane/templates/agent.yaml @@ -88,6 +88,10 @@ rules: - apiGroups: ["sdn.cozystack.io"] resources: ["hostfirewalls"] verbs: ["get", "list", "watch"] + # PortClaims: the CNI plugin binds a pod to the claim its annotation names. + - apiGroups: ["sdn.cozystack.io"] + resources: ["portclaims"] + verbs: ["get"] # FloatingIPs: the agent programs the floating map and advertises the address # for those whose target Port is on this node. - apiGroups: ["sdn.cozystack.io"] diff --git a/packages/system/cozyplane/charts/cozyplane/templates/controller.yaml b/packages/system/cozyplane/charts/cozyplane/templates/controller.yaml index 6c156adab..f53435005 100644 --- a/packages/system/cozyplane/charts/cozyplane/templates/controller.yaml +++ b/packages/system/cozyplane/charts/cozyplane/templates/controller.yaml @@ -60,6 +60,14 @@ rules: - apiGroups: ["sdn.cozystack.io"] resources: ["vpcpeerings/status"] verbs: ["get", "update", "patch"] + # PortClaims: bind each claim's Port to its lifetime and publish the pinned + # identity in status; the finalizer holds the claim until its Port is gone. + - apiGroups: ["sdn.cozystack.io"] + resources: ["portclaims"] + verbs: ["get", "list", "watch", "update", "patch"] + - apiGroups: ["sdn.cozystack.io"] + resources: ["portclaims/status", "portclaims/finalizers"] + verbs: ["get", "update", "patch"] # FloatingIPs: own the delegated LoadBalancer Service that sources the address # and gate readiness on a live target Port (docs/external-addresses.md). - apiGroups: ["sdn.cozystack.io"] @@ -87,13 +95,6 @@ rules: - apiGroups: ["discovery.k8s.io"] resources: ["endpointslices"] verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] - # VirtualMachineInstances: the migration controller reads status.nodeName / - # status.migrationState as the cutover signal (the Kube-OVN model). Optional โ€” - # only present when KubeVirt is installed; the controller degrades to the - # launcher-pod signal without it. - - apiGroups: ["kubevirt.io"] - resources: ["virtualmachineinstances"] - verbs: ["get", "list", "watch"] # Gateway Deployments for a VPCGateway family with no eBPF identity yet # (one with addresses for every family is pure eBPF โ€” docs/north-south.md ยง6a). # Read-only cluster-wide because the manager's informer cache is not namespace @@ -106,8 +107,7 @@ rules: resources: ["deployments"] verbs: ["get", "list", "watch"] # Severed-gateway heal: recreate a Ready gateway pod whose .1 Port is gone. - # watch: the persistent-Port controller watches virt-launcher pods to drive - # live-migration cutover (kubevirt.io/nodeName) and GC. + # watch: the PortClaim controller follows the pods that bind each claim. - apiGroups: [""] resources: ["pods"] verbs: ["get", "list", "watch", "delete"] diff --git a/packages/system/cozyplane/charts/cozyplane/templates/tenant-rbac.yaml b/packages/system/cozyplane/charts/cozyplane/templates/tenant-rbac.yaml index 53bd87b6e..c5e160b89 100644 --- a/packages/system/cozyplane/charts/cozyplane/templates/tenant-rbac.yaml +++ b/packages/system/cozyplane/charts/cozyplane/templates/tenant-rbac.yaml @@ -23,6 +23,7 @@ rules: - vpcpeerings - securitygroups - floatingips + - portclaims - natgateways - routetables - routes @@ -34,6 +35,7 @@ rules: - vpcpeerings/status - securitygroups/status - floatingips/status + - portclaims/status - natgateways/status - routetables/status - routes/status @@ -67,6 +69,7 @@ rules: - vpcpeerings - securitygroups - floatingips + - portclaims - natgateways - routetables - routes diff --git a/packages/system/cozyplane/charts/cozyplane/values.yaml b/packages/system/cozyplane/charts/cozyplane/values.yaml index 5332a2f72..21e0f246e 100644 --- a/packages/system/cozyplane/charts/cozyplane/values.yaml +++ b/packages/system/cozyplane/charts/cozyplane/values.yaml @@ -2,7 +2,7 @@ # Digest-pinned (no floating tag). Built and published by .github/workflows/ # release.yml on every push to main; see docs/packaging.md for how the digest is # refreshed and why pinning it does not change it. -image: ghcr.io/lllamnyp/cozyplane@sha256:0c0aff04cc029306942258a361223229766ff8fd9ae23167e7f003ce6ad5a53f +image: ghcr.io/lllamnyp/cozyplane@sha256:3233ef875fe220cdadd57ec6b138577b738fe61bec9a41051ed9a59d64973edf imagePullPolicy: IfNotPresent imagePullSecrets: [] diff --git a/packages/system/cozyplane/values.yaml b/packages/system/cozyplane/values.yaml index 6c6d7dfe1..36c806858 100644 --- a/packages/system/cozyplane/values.yaml +++ b/packages/system/cozyplane/values.yaml @@ -1,4 +1,4 @@ cozyplane: # The cozyplane release's image by tag and digest, for mirroring and # promotion; the vendored chart pins a digest only. - image: ghcr.io/lllamnyp/cozyplane:v0.1.2@sha256:0fbf42fca2f65fc500a0b48738ee321c483246952fc013d249b6bb27445cc19f + image: ghcr.io/lllamnyp/cozyplane:v0.1.5@sha256:2cc55293000b64a4c4233910cbc3803b9bea7c16e9e7d44ddcc44fb4042cdd98 From f7a52ed4f60a983098b89f452e772d417754f4dd Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Sun, 22 Nov 2026 21:33:05 +0100 Subject: [PATCH 2/2] feat(vm-instance): keep a VPC VM's IP and MAC From cozyplane v0.1.3 a pod without a PortClaim gets a new Port, and so a new IP and MAC, on every launcher pod, live migration included. A guest whose network config is pinned to its MAC then loses its network after a restart. A VM in a VPC now renders a PortClaim named after the VM and binds its launcher pods to it, so the address survives restarts and migrations and stays reserved while the VM is stopped. The name matches the VM so cozyplane adopts the Port a running VM already has. Assisted-by: LLM Signed-off-by: Timofei Larkin --- .../apps/vm-instance/templates/portclaim.yaml | 16 +++ packages/apps/vm-instance/templates/vm.yaml | 1 + .../vm-instance/tests/portclaim_test.yaml | 98 +++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 packages/apps/vm-instance/templates/portclaim.yaml create mode 100644 packages/apps/vm-instance/tests/portclaim_test.yaml diff --git a/packages/apps/vm-instance/templates/portclaim.yaml b/packages/apps/vm-instance/templates/portclaim.yaml new file mode 100644 index 000000000..bd1f1bb31 --- /dev/null +++ b/packages/apps/vm-instance/templates/portclaim.yaml @@ -0,0 +1,16 @@ +{{- $networks := .Values.networks | default .Values.subnets }} +{{- if and (.Capabilities.APIVersions.Has "sdn.cozystack.io/v1alpha1/VPC") (gt (len ($networks | default list)) 0) }} +{{- /* Named after the VM: cozyplane adopts the Port a VM had before + PortClaims existed by the VM's name, so a running VM keeps its IP + and MAC through the upgrade. The spec is immutable. */}} +apiVersion: sdn.cozystack.io/v1alpha1 +kind: PortClaim +metadata: + name: {{ include "virtual-machine.fullname" . }} + labels: + {{- include "virtual-machine.labels" . | nindent 4 }} +spec: + vpcRef: + namespace: {{ .Release.Namespace }} + name: {{ printf "virtualprivatecloud-%s" (index $networks 0).name | quote }} +{{- end }} diff --git a/packages/apps/vm-instance/templates/vm.yaml b/packages/apps/vm-instance/templates/vm.yaml index 319fafcc8..d7288a61e 100644 --- a/packages/apps/vm-instance/templates/vm.yaml +++ b/packages/apps/vm-instance/templates/vm.yaml @@ -75,6 +75,7 @@ spec: {{- /* The VPC lives in the VM's own namespace, so the bare release name resolves; / is only for foreign VPCs. */}} sdn.cozystack.io/vpc: {{ printf "virtualprivatecloud-%s" (index $networks 0).name | quote }} + sdn.cozystack.io/port-claim: {{ include "virtual-machine.fullname" . }} {{- with $routeTable }} sdn.cozystack.io/route-table: {{ . | quote }} {{- end }} diff --git a/packages/apps/vm-instance/tests/portclaim_test.yaml b/packages/apps/vm-instance/tests/portclaim_test.yaml new file mode 100644 index 000000000..425268507 --- /dev/null +++ b/packages/apps/vm-instance/tests/portclaim_test.yaml @@ -0,0 +1,98 @@ +suite: a cozyplane VPC VM keeps its IP and MAC through a PortClaim + +# The VM's launcher pods come and go; the PortClaim holds the Port between +# them. It is named after the VM so cozyplane adopts the Port a running VM +# had before PortClaims existed. +release: + name: test-vm + namespace: tenant-test +templates: + - templates/vm.yaml + - templates/portclaim.yaml +set: + fullnameOverride: test-vm + instanceType: "" + instanceProfile: "" + resources: + cpu: 1 + sockets: 1 + memory: 1Gi + _cluster: + scheduling: + dedicatedNodesForWindowsVMs: "false" +tests: + - it: claims a Port in the VM's VPC, named after the VM + template: templates/portclaim.yaml + capabilities: + apiVersions: + - sdn.cozystack.io/v1alpha1/VPC + set: + networks: + - name: mynet + asserts: + - hasDocuments: + count: 1 + - isKind: + of: PortClaim + - equal: + path: metadata.name + value: test-vm + - equal: + path: spec.vpcRef + value: + namespace: tenant-test + name: virtualprivatecloud-mynet + - notExists: + path: spec.mac + + - it: binds the VM's launcher pods to the claim + template: templates/vm.yaml + capabilities: + apiVersions: + - sdn.cozystack.io/v1alpha1/VPC + set: + networks: + - name: mynet + asserts: + - equal: + path: spec.template.metadata.annotations["sdn.cozystack.io/port-claim"] + value: test-vm + + - it: claims nothing without a VPC + capabilities: + apiVersions: + - sdn.cozystack.io/v1alpha1/VPC + asserts: + - hasDocuments: + count: 0 + template: templates/portclaim.yaml + - notExists: + path: spec.template.metadata.annotations["sdn.cozystack.io/port-claim"] + template: templates/vm.yaml + + - it: claims nothing on kube-ovn + set: + networks: + - name: mynet + asserts: + - hasDocuments: + count: 0 + template: templates/portclaim.yaml + - notExists: + path: spec.template.metadata.annotations["sdn.cozystack.io/port-claim"] + template: templates/vm.yaml + + - it: keeps a network name with a newline inside the claim's VPC reference + template: templates/portclaim.yaml + capabilities: + apiVersions: + - sdn.cozystack.io/v1alpha1/VPC + set: + networks: + - name: "mynet\n---\nkind: ClusterRoleBinding" + asserts: + - hasDocuments: + count: 1 + - equal: + path: spec.vpcRef.name + value: "virtualprivatecloud-mynet\n---\nkind: ClusterRoleBinding"