mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
45 lines
1.3 KiB
Plaintext
45 lines
1.3 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * virt/vm_networking/virt-accessing-vm-internal-fqdn.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="virt-creating-headless-services_{context}"]
|
|
= 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 `Service` manifest to expose the VM, such as the following example:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
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.
|
|
|
|
. Save the `Service` manifest file.
|
|
|
|
. Create the service by running the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc create -f headless_service.yaml
|
|
---- |