mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
feat(vm-instance): keep a cozyplane VM's IP and MAC (#5389)
## What this PR does It bumps cozyplane to v0.1.5 and has a cozyplane `vm-instance` VM hold its Port through a `PortClaim`, so the VM keeps its IP and MAC across restarts and live migrations. Without a claim, a VM's Port is garbage-collected when its launcher pod goes away, and the next launcher pod gets a new IP and a random MAC. A guest whose network config is pinned to the old MAC then matches no interface and loses its network. lllamnyp/cozyplane#79 (released in v0.1.3) fixes this without special-casing KubeVirt. A namespaced `PortClaim` in `sdn.cozystack.io` holds a cluster-scoped `Port` the way a PVC holds a PV, and a pod binds it with the annotation `sdn.cozystack.io/port-claim: <name>`, resolved in the pod's own namespace. The claim keeps its IP and MAC for as long as it exists: a stopped VM keeps its address reserved, and deleting the claim frees it. - **cozyplane v0.1.5.** `cozyplane`, `cozyplane-kpr` and `cozyplane-apiserver` are re-vendored with `make update` at `b99171ea7` (tag `v0.1.5`). Beyond v0.1.3's PortClaim, it carries lllamnyp/cozyplane#80, so a PortClaim that adopts a running VM's Port keeps it bound to the pod already holding it and reports `Bound=True` with reason `PreClaimPod`. It also carries lllamnyp/cozyplane#81: the aggregated apiserver sets `metadata.generation` and the controllers stamp `observedGeneration`, so a retargeted FloatingIP no longer keeps its old target's status. The wrappers pin the release images by tag and digest: - `ghcr.io/lllamnyp/cozyplane:v0.1.5@sha256:2cc55293000b64a4c4233910cbc3803b9bea7c16e9e7d44ddcc44fb4042cdd98` - `ghcr.io/lllamnyp/cozyplane-kpr:v0.1.5@sha256:28254bdc0283b3797ea8c5f26146932c46b0be98a15cdd660cb42330963cb01c` The aggregated apiserver serves `PortClaim` from the same binary, and its chart changes only in the image pin. The CNI chart gains the agent's and controller's PortClaim RBAC, and its tenant roles gain `portclaims`. - **`vm-instance`.** A VM that joins a VPC through `networks` renders a `PortClaim` named after the VM, with `spec.vpcRef` set to the VM's VPC, and annotates its pod template with `sdn.cozystack.io/port-claim: <VM name>` next to `sdn.cozystack.io/vpc`. The name matters: cozyplane adopts a running VM's existing Port into a claim named after that VM, so running VMs keep their IP and MAC through the upgrade. Without a VPC, or on kube-ovn, nothing changes. - **RBAC.** No change is needed. Releases are applied by the same identity that already applies the VPC application's `sdn.cozystack.io` objects. Tenants reach `portclaims` through cozyplane's own tenant roles, which `cozy:tenant:cozyplane-edit` and `-view` (#3149) already aggregate into the `cozy:tenant*` tiers: every access level can read claims, and admins can manage them. ### Compatibility The bump and the chart change have to land together. From v0.1.3 a VM with no claim gets a new IP and MAC on every launcher pod, live migration included. **Upgrading running VMs.** A VM adopted while it was running gets a new IP and loses its network if it is live-migrated before a restart. Such a VM's claim shows `Bound=True` with reason `PreClaimPod`, and the VM is marked `RestartRequired`; restart it before migrating it. **Tenant Kubernetes worker VMs are not covered.** `kubernetes-nodes` is unchanged, so from v0.1.3 a tenant cluster's worker VMs keep no IP or MAC across restarts or live migrations. A PortClaim's spec is immutable. Changing `networks[0].name` on an existing VM therefore fails the release upgrade at the claim, instead of moving the VM to another VPC as it did before. ### Tests The new helm-unittest suite `vm-instance/tests/portclaim_test.yaml` covers a VPC VM (one claim named after the VM, its `vpcRef`, no `mac`, and the pod-template annotation), cozyplane with no VPC (no claim, no annotation), and kube-ovn (no claim, no annotation). The `vm-instance`, cozyplane wrapper, kubernetes, kubernetes-nodes and platform suites pass. ### Downstream repositories - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: Boxes left unticked so a human decides. ### Release note ```release-note feat(vm-instance): on the cozyplane networking variant, a VM in a VPC keeps its IP and MAC across restarts and live migrations through a PortClaim; cozyplane is bumped to v0.1.5 ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * VMs configured with supported VPC networks now receive a port claim that launcher pods can use to bind to the selected network. * Tenant roles now support viewing and managing port claims, with access appropriate to each role. * **Updates** * Cozyplane components are updated to version 0.1.4, including the API server and Kubernetes provider. These updates include revised support for port claims. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
14 files changed
+139
-17
No files matched your search
@@ -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 }}
|
||||
@@ -75,6 +75,7 @@ spec:
|
||||
{{- /* The VPC lives in the VM's own namespace, so the bare release name
|
||||
resolves; <owner-ns>/<vpc> 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 }}
|
||||
|
||||
@@ -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"
|
||||
@@ -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 .
|
||||
|
||||
@@ -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: []
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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 .
|
||||
|
||||
@@ -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
|
||||
@@ -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 .
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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: []
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user