Module 4: Simplified configuration for load balancing

In most systems, load balancing virtual machiness typically requires multiple different tools and configurations to work properly. For example, to load balance two virtual machines internally and externally you might: . Create a private internal load balancer . Create an internet facing endpoint and route it to the internal load balancer . Create private DNS records for the internal load balancer . Create public DNS records for the public endpoint for external access . Register virtual machines with the load balancer . Configure the listening/forwarding port or port translation . Configure health check endpoints and tests . Configure health check timeouts and intervals

OpenShift trivializes networking and load balancing. In this module you will walk through the steps to setup internal and external load balancing within OpenShift.

Set up internal load balancing with Services

All resources in OpenShift can have labels applied to them to identify and group them. Services are internal load balancers in OpenShift. Services route traffic to resources identified by a label selector parameter in the definition of the Service. You will create a service and identify the virtual machines it services as a load balance by means of labels on the virtual machines.

  1. On the left bar, click the Virtualization → VirtualMachines and on the top bar select the Project: windowsnetworking-sample_username

  2. To find the label on the virtual machine that will identify it to the Service for selection, click on the winweb01 virtual machine. Click the YAML tab and search for "app: winnetworking". This is an arbitrary label assigned to both virtual machines.

    Find VM label app=winnetworking
  3. On the left side of the console, click to expand Networking → Services and on the top right corner, click Create Service.

    Create Service button
  4. Modify the Service to load balance between virtual machines

    1. On line 4, change the name to "windowsnetworking".

    2. Modify line 8 to read "app: winnetworking"

    3. Change the "targetPort:" value on line 12 to 80 then click "Create" in the bottom left corner

      Create Service YAML

  5. Click the Pods tab and notice that the two winweb virtual machines have already registered with the service object. This will allow applications within the OpenShift cluster to access these virtual machines through the windowsnetworking Service, aka "load balancer".

    Pods in Service

Set up external access to load balancing

OpenShift was the first to introduce the concept of Routes in the early days of Kubernetes. You’ll use a Route to provide external access to the virtuals machines through the internal Service, aka, load balancer.

  1. On the left side, Click Networking → Routes and then click Create Route.

    Create Route

  2. Use the form to create the Route.

    1. In the "Name" field put windowsnetworking.

    2. Click the drop down box below Service and select the windowsnetworking Service you just created.

    3. Click the drop down box below Target port and select port 80.

    4. Tick the Secure Route checkbox.

    5. Under TLS termination, select Edge.

    6. Under Insecure traffic, select Redirect

    7. Finally, click Create in the bottom left corner.

      Create Route form

  3. Test the Route. In the middle right, find the Location section. Click the link to view your load balanced virtual machines.

    Test Route

  4. A new browser window opens and accesses the web application.

    Web Application

Next Steps

Congratulations! You’ve implemented internal load balancing through kubernetes Services, and accessed them via the Internet through OpenShift Routes.

Move on to the next module, where you will set up a Network Egress Firewall.