10.6. Accessing a virtual machine by using its internal FQDN
You can access a virtual machine on a stable, fully qualified domain name (FQDN) by using headless services. A headless service creates DNS records for each pod instead of a virtual IP, enabling FQDN access without exposing specific ports.
If you created a VM by using the OpenShift Container Platform web console, you can find its internal FQDN listed in the Network tile on the Overview tab of the VirtualMachine details page.
10.6.1. Creating a headless service in a project by using the CLI 링크 복사링크가 클립보드에 복사되었습니다!
To create a headless service in a namespace, add the clusterIP: None parameter to the service YAML definition.
Prerequisites
-
You have installed the OpenShift CLI (
oc).
Procedure
Create a
Servicemanifest to expose the VM, such as the following example:apiVersion: v1 kind: Service metadata: name: mysubdomain spec: selector: expose: me clusterIP: None ports: - protocol: TCP port: 1234 targetPort: 1234-
metadata.namedefines the name of the service. This must match thespec.subdomainattribute in theVirtualMachinemanifest file. -
spec.selectordefines the service selector that must match theexpose:melabel in theVirtualMachinemanifest file. -
spec.clusterIPdefines a headless service. -
spec.portsdefines the list of ports that are exposed by the service. You must define at least one port. This can be any arbitrary value as it does not affect the headless service.
-
-
Save the
Servicemanifest file. Create the service by running the following command:
$ oc create -f headless_service.yaml