1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/nw-metallb-configure-svc.adoc

79 lines
2.6 KiB
Plaintext

// Module included in the following assemblies:
//
// * networking/metallb/nw-metalb-configure-svc.adoc
:_mod-docs-content-type: PROCEDURE
[id="nw-metallb-configure-svc_{context}"]
= Configuring a service with MetalLB
[role="_abstract"]
To expose an application to external network traffic, configure a load-balancing service. MetalLB assigns an external IP address from a configured address pool, ensuring that your application is reachable from outside the cluster.
.Prerequisites
* Install the {oc-first}.
* Install the MetalLB Operator and start MetalLB.
* Configure at least one address pool.
* Configure your network to route traffic from the clients to the host network for the cluster.
.Procedure
. Create a `<service_name>.yaml` file. In the file, set the `spec.type` parameter to `LoadBalancer`.
+
Refer to the examples for information about how to request the external IP address that MetalLB assigns to the service.
. Create the service:
+
[source,terminal]
----
$ oc apply -f <service_name>.yaml
----
+
.Example output
[source,terminal]
----
service/<service_name> created
----
.Verification
* Describe the service:
+
[source,terminal]
----
$ oc describe service <service_name>
----
+
.Example output
----
Name: <service_name>
Namespace: default
Labels: <none>
Annotations: metallb.io/address-pool: doc-example
Selector: app=service_name
Type: LoadBalancer
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.105.237.254
IPs: 10.105.237.254
LoadBalancer Ingress: 192.168.100.5
Port: <unset> 80/TCP
TargetPort: 8080/TCP
NodePort: <unset> 30550/TCP
Endpoints: 10.244.0.50:8080
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal nodeAssigned 32m (x2 over 32m) metallb-speaker announcing from node "<node_name>"
----
+
where:
+
`Annotations`:: Specifies the annotation that is present if you request an IP address from a specific pool.
`Type`:: Specifies the service type that must indicate `LoadBalancer`.
`LoadBalancer Ingress`:: Specifies the indicates the external IP address if the service is assigned correctly.
`Events`:: Specifies the events parameter that indicates the node name that is assigned to announce the external IP address. If you experience an error, the events parameter indicates the reason for the error.