mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
52 lines
1.8 KiB
Plaintext
52 lines
1.8 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * virt/vm_networking/virt-accessing-vm-internal-fqdn.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="virt-discovering-vm-internal-fqdn_{context}"]
|
|
= Mapping a virtual machine to a headless service by using the CLI
|
|
|
|
[role="_abstract"]
|
|
To connect to a virtual machine (VM) from within the cluster by using its internal fully qualified domain name (FQDN), you must first map the VM to a headless service. Set the `spec.hostname` and `spec.subdomain` parameters in the VM configuration file.
|
|
|
|
If a headless service exists with a name that matches the subdomain, a unique DNS A record is created for the VM in the form of `<vm.spec.hostname>.<vm.spec.subdomain>.<vm.metadata.namespace>.svc.cluster.local`.
|
|
|
|
.Prerequisites
|
|
|
|
* You have installed the {oc-first}.
|
|
|
|
.Procedure
|
|
|
|
. Edit the `VirtualMachine` manifest to add the service selector label and subdomain by running the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc edit vm <vm_name>
|
|
----
|
|
+
|
|
Example `VirtualMachine` manifest file:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: kubevirt.io/v1
|
|
kind: VirtualMachine
|
|
metadata:
|
|
name: vm-fedora
|
|
spec:
|
|
template:
|
|
metadata:
|
|
labels:
|
|
expose: me # <1>
|
|
spec:
|
|
hostname: "myvm" # <2>
|
|
subdomain: "mysubdomain" # <3>
|
|
# ...
|
|
----
|
|
<1> The `expose:me` label must match the `spec.selector` attribute of the `Service` manifest that you previously created.
|
|
<2> If this attribute is not specified, the resulting DNS A record takes the form of `<vm.metadata.name>.<vm.spec.subdomain>.<vm.metadata.namespace>.svc.cluster.local`.
|
|
<3> The `spec.subdomain` attribute must match the `metadata.name` value of the `Service` object.
|
|
|
|
. Save your changes and exit the editor.
|
|
|
|
. Restart the VM to apply the changes.
|