From 9fd0071457af50f709db967922654f422b84edbf Mon Sep 17 00:00:00 2001 From: Anish Bista Date: Wed, 9 Oct 2024 12:10:43 +0530 Subject: [PATCH] Update VM instead of VMI when exposing service objects Signed-off-by: Anish Bista --- docs/network/service_objects.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/network/service_objects.md b/docs/network/service_objects.md index 80fe1119d..2fba41963 100644 --- a/docs/network/service_objects.md +++ b/docs/network/service_objects.md @@ -84,6 +84,15 @@ port inside the cluster network: ## Expose VirtualMachineInstance as a NodePort Service +To expose a VirtualMachineInstance via a NodePort service, you must ensure that the VirtualMachine (VM) resource includes the proper labels in the template section. This is crucial to allow the service to correctly associate with the VM's underlying pod. + +```yaml +template: + metadata: + labels: + kubevirt.io/domain: "VM_NAME" + vmName: "VM_NAME" +``` Expose the SSH port (22) of a VirtualMachineInstance running on KubeVirt by creating a `NodePort` service: @@ -101,7 +110,7 @@ spec: protocol: TCP targetPort: 22 selector: - special: key + vmName: "VM_NAME" type: NodePort ```