F5 Solutions for Containers > Class 5: Advanced Red Hat OpenShift > Module 2: Container Connector in Action Source | Edit on

Lab 2.2 - Route - Basic

An OpenShift Route is one of the resource types that the F5 Container Connector watches for. A Route defines a hostname or URI mapping to an application. For example, the hostname “customer.example.com” could map to the application “customer”, hostname “catalog.example.com”, might map to the application “catalog”, etc.

Similarly, a Route can refer to a URI path so, for example, the URI path “/customer” might map to the application called “customer” and URI path “/catalog”, might map to the application called “catalog”. If a Route only specifies URI paths, the Route applies to all HTTP request hostnames.

Additionally, a Route can refer to both a hostname and a URI path such as mycompany.com/customer or mycompany.com/catalog

The F5 Container Connector reads the Route resource and creates a virtual server, node(s), a pool per route path and pool members. Additionally, the Container Connector creates a layer 7 BIG-IP traffic policy and associates it with the virtual server. This layer 7 traffic policy evaluates the hostname or URI path from the request and forwards the traffic to the pool associated with that path.

A Route points to a Service which points to one or more Pods where the application is running.

Attention

All Route resources share two virtual servers:

  • ose-vserver for HTTP traffic, and
  • https-ose-vserver for HTTPS traffic

The Container Connector assigns the names shown above by default. To set custom names, define route-http-vserver and route-https-vserver in the BIG-IP Container Connector Deployment. Please see the documentation at: http://clouddocs.f5.com for more details.

  1. Deploy demo application and its associated Service.

    In the previous lab, you created the Deployment and Service separately. This step demonstrates creating both the Deployment and the Service from single configuration file. A separator of 3 dashes (---) is used to separate one resource definition from the next resource definition.

    From ose-master1, review the following deployment: f5-demo-app-route-deployment.yaml

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: f5-demo-app-route
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            app: f5-demo-app-route
        spec:
          containers:
          - name: f5-demo-app-route
            image: chen23/f5-demo-app:openshift
            ports:
             - containerPort: 8080
               protocol: TCP
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: f5-demo-app-route
      labels:
        name: f5-demo-app-route
      namespace: f5demo
    spec:
      type: ClusterIP
      ports:
      - port: 8080
        targetPort: 8080
      selector:
        app: f5-demo-app-route
    

    Now that you have reviewed the Deployment, you need to actually create it by deploying it to OpenShift by using the oc create command:

    oc create -f f5-demo-app-route-deployment.yaml -n f5demo
    
  2. Create OpenShift Route

    From ose-master1 server, review the following Route: f5-demo-app-route-route.yaml

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    apiVersion: v1
    kind: Route
    metadata:
      labels:
        name: f5-demo-app-route
      name: f5-demo-app-route
      namespace: f5demo
      annotations:
        # Specify a supported BIG-IP load balancing mode
        virtual-server.f5.com/balance: least-connections-node
        virtual-server.f5.com/health: |
          [
            {
              "path": "mysite.f5demo.com/",
              "send": "HTTP GET /",
              "interval": 5,
              "timeout": 10
            }
          ]
    spec:
      host: mysite.f5demo.com
      path: "/"
      port:
        targetPort: 8080
      to:
        kind: Service
        name: f5-demo-app-route
    

    Attention

    Knowledge Check: How does the Container Connector know what application the Route refers to?

    Now that you have reviewed the Route, you need to actually create it by deploying it to OpenShift by using the oc create command:

    oc create -f f5-demo-app-route-route.yaml -n f5demo
    
  3. Review the BIG-IP configuration. Examine the BIG-IP configuration for changes that occured after the the OpenShift Route was deployed.

    Using the Chrome browser, navigate to Local Traffic ‣ Network Map and change the partition to ocp using the dropdown in the upper right.

    ../../_images/bigip01-network-map-route.png

    The network map view shows two virtual servers that were created by the Container Connector when it procssed the Route resource created in the previous step. One virtual server is for HTTP client traffic and the other virtual server is for HTTPS client traffic.

    To view the IP address of the virtual server, hover your cursor over the virtual server named ocp-vserver

    ../../_images/bigip01-route-vs-hover.png

    Attention

    Knowledge Check: Which OpenShift resource type defines the names of the two virtual servers?

  4. View the traffic policy that was created by the Container Connector when it processed the OpenShift Route.

    Navigate to Local Traffic ‣ Policies ‣ Policy List and change the partition to ocp using the drop down in the upper right.

    ../../_images/bigip01-route-policy-list.png

    Click on the traffic policy listed uner Published Policies to view the policy page for the selected policy:

    ../../_images/bigip01-route-policy.png

    Click on the rule name listed under the Rules section of the policy page to view the rule page for the selected rule:

    ../../_images/bigip01-route-rule.png

    On the rule page, review the configuration of the rule and note the match condition and rule action settings.

    Attention

    Knowledge Check: Which OpenShift resource type defines the hostname to match against?

  5. Test the application. Use the Chrome browser to access the application you previously deployed.

    Important

    Because the Route resource you created specifies a hostname for the path, you will need to use a hostname instead of an IP address to access the demo application.

    Open a new Chrome browser tab and enter the hostname mysite.f5demo.com in to the address bar:

    ../../_images/f5-demo-app-route.png

    Note

    On the application page, the Server IP is the pool member (pod) IP address; the Server Port is the port of the virtual server; and the Client IP is the floating Self-IP address of the Big-IP.

  6. Remove the Deployment, Service and Route resources you created in the previous steps using the OpenShift oc delete command.

    From ose-master1 server, issue the following commands:

    oc delete -f f5-demo-app-route-route.yaml -n f5demo
    oc delete -f f5-demo-app-route-deployment.yaml -n f5demo