10.6. Accessing a virtual machine by using its internal FQDN


You can access a virtual machine (VM) that is connected to the default internal pod network on a stable fully qualified domain name (FQDN) by using headless services. A Kubernetes headless service creates a DNS record for each pod associated with the service instead of providing a single virtual IP address for the service. You can expose a VM through its FQDN without having to expose a specific TCP or UDP port.

중요

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. For more information about connecting to the VM, see Connecting to a virtual machine by using its internal FQDN.

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

  1. Create a Service manifest to expose the VM, such as the following example:

    apiVersion: v1
    kind: Service
    metadata:
      name: mysubdomain 
    1
    
    spec:
      selector:
        expose: me 
    2
    
      clusterIP: None 
    3
    
      ports: 
    4
    
      - protocol: TCP
        port: 1234
        targetPort: 1234
    1
    The name of the service. This must match the spec.subdomain attribute in the VirtualMachine manifest file.
    2
    This service selector must match the expose:me label in the VirtualMachine manifest file.
    3
    Specifies a headless service.
    4
    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.
  2. Save the Service manifest file.
  3. Create the service by running the following command:

    $ oc create -f headless_service.yaml
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동