You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
== The {microshift-short} LoadBalancer service for workloads
38
+
39
+
{microshift-short} has a built-in implementation of network load balancers that you can use for your workloads and applications within the cluster. You can create a `LoadBalancer` service by configuring a pod to interpret ingress rules and serve as an ingress controller. The following procedure gives an example of a deployment-based `LoadBalancer` service.
{microshift-short} has a built-in implementation of network load balancers. The following example procedure uses the node IP address as the external IP address for the `LoadBalancer` service configuration file. You can use this example as guidance for how to deploy load balancers for your workloads.
9
+
The following example procedure uses the node IP address as the external IP address for the `LoadBalancer` service configuration file. Use this example as guidance for how to deploy load balancers.
10
10
11
11
.Prerequisites
12
12
13
13
* The OpenShift CLI (`oc`) is installed.
14
-
* You have access to the cluster as a user with the cluster administration role.
15
14
* You installed a cluster on an infrastructure configured with the OVN-Kubernetes network plugin.
16
15
* The `KUBECONFIG` environment variable is set.
17
16
18
17
.Procedure
19
18
20
-
. Verify that your pods are running by running the following command:
19
+
. Verify that your pods are running by entering the following command:
. Create the example namespace by running the following commands:
47
+
. Create a namespace by running the following commands:
28
48
+
29
49
[source,terminal]
30
50
----
31
-
$ NAMESPACE=nginx-lb-test
51
+
$ NAMESPACE=<nginx-lb-test> <1>
32
52
----
53
+
<1> Replace _<nginx-lb-test> with the application namespace that you want to create.
33
54
+
34
55
[source,terminal]
35
56
----
36
57
$ oc create ns $NAMESPACE
37
58
----
38
-
39
-
. The following example deploys three replicas of the test `nginx` application in your namespace:
59
+
+
60
+
.Example namespace
61
+
The following example deploys three replicas of the test `nginx` application in the created namespace:
40
62
+
41
63
[source,terminal]
42
64
----
43
-
$ oc apply -n $NAMESPACE -f - <<EOF
65
+
oc apply -n $NAMESPACE -f - <<EOF
44
66
apiVersion: v1
45
67
kind: ConfigMap
46
68
metadata:
@@ -97,11 +119,11 @@ EOF
97
119
$ oc get pods -n $NAMESPACE
98
120
----
99
121
100
-
. Create a `LoadBalancer` service for the `nginx` test application with the following sample commands:
122
+
. Create a `LoadBalancer` service for the `nginx` test application by running the following command:
101
123
+
102
124
[source,terminal]
103
125
----
104
-
$ oc create -n $NAMESPACE -f - <<EOF
126
+
oc create -n $NAMESPACE -f - <<EOF
105
127
apiVersion: v1
106
128
kind: Service
107
129
metadata:
@@ -118,7 +140,7 @@ EOF
118
140
+
119
141
[NOTE]
120
142
====
121
-
You must ensure that the `port` parameter is a host port that is not occupied by other `LoadBalancer` services or {product-title} components.
143
+
You must ensure that the `port` parameter is a host port that is not occupied by other `LoadBalancer` services or {microshift-short} components.
122
144
====
123
145
124
146
. Verify that the service file exists, that the external IP address is properly assigned, and that the external IP is identical to the node IP by running the following command:
* The following command forms five connections to the example `nginx` application using the external IP address of the `LoadBalancer` service configuration. The result of the command is a list of those server IP addresses. Verify that the load balancer sends requests to all the running applications with the following command:
162
+
The following command forms five connections to the example `nginx` application using the external IP address of the `LoadBalancer` service configuration. The result of the command is a list of those server IP addresses.
163
+
164
+
* Verify that the load balancer sends requests to all the running applications by running the following command:
The output of the previous command contains different IP addresses if the load balancer is successfully distributing the traffic to the applications, for example:
172
+
The output of the previous command contains different IP addresses if the `LoadBalancer` service is successfully distributing the traffic to the applications, for example:
0 commit comments