mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
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 <lllamnyp@gmail.com>
This commit is contained in:
1 parent
f17cd76d5e
commit
f7a52ed4f6
3 files changed
+115
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"
|
||||
Reference in new issue
Block a user