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.

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 では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る