Lab 2.1 - ConfigMap - Basic

Note

You will use the same Windows jumpbox as you used in the previous sections to complete the exercises in this section.

Unless otherwise noted, all the resource definition yaml files have been pre-created and can be found on the ose-master1 server under /home/centos/agilitydocs/openshift/advanced/apps/module2

An OpenShift ConfigMap is one of the resource types that the F5 Container Connector watches for. The Container Connector will read the ConfigMap and create a virtual server, node(s), a pool, pool member(s) and a pool health monitor.

In this lab, you will create a ConfigMap that defines the objects that the Container Connector should configure on the BIG-IP.

  1. Deploy demo application.

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

     1apiVersion: extensions/v1beta1
     2kind: Deployment
     3metadata:
     4  name: f5-demo-app
     5  namespace: f5demo
     6spec:
     7  replicas: 1
     8  template:
     9    metadata:
    10      labels:
    11        app: f5-demo-app
    12    spec:
    13      containers:
    14      - name: f5-demo-app
    15        image: chen23/f5-demo-app:openshift
    16        ports:
    17         - containerPort: 8080
    18           protocol: TCP
    

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

    From ose-master1 server, run the following command:

    Attention

    Be sure to change the proper working directory on ose-master1:

    /home/centos/agilitydocs/openshift/advanced/apps/module2

    oc create -f f5-demo-app-deployment.yaml
    
  2. Create Service to expose application.

    In order for an application to be accessible outside of the OpenShift cluster, a Service must be created. The Service uses a label selector to reference the application to be exposed. Additionally, the service also specifies the container port (8080) that the application is listening on.

    From ose-master1, review the following Service: f5-demo-app-service.yaml

     1apiVersion: v1
     2kind: Service
     3metadata:
     4  name: f5-demo-app
     5  labels:
     6    name: f5-demo-app
     7  namespace: f5demo
     8spec:
     9  type: ClusterIP
    10  ports:
    11  - port: 8080
    12    targetPort: 8080
    13  selector:
    14    app: f5-demo-app
    

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

    From ose-master1 server, run the following command:

    oc create -f f5-demo-app-service.yaml
    
  3. Create ConfigMap

    A ConfigMap is used to define the BIG-IP objects that need to be created to enable access to the application via the BIG-IP.

    The label, f5type: virtual-server, in the ConfigMap definition is what triggers the F5 Container Connector to process this ConfigMap.

    In addition to the label, there are several F5-specific sections defined:

    • virtualServer: Beginning of F5-specific configuration
    • backend: Represents the server-side of the virtual server definition
    • healthMonitors: Health monitor definition for the pool
    • frontend: Represents the client-side of the virtual server
    • virtualAddress: IP address and port of virtual server

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

    From ose-master1, review the ConfigMap resource f5-demo-app-configmap.yaml

     1kind: ConfigMap
     2apiVersion: v1
     3metadata:
     4  # name of the resource to create on the BIG-IP
     5  name: f5-demo-app
     6  # The namespace to create the object in.
     7  # The k8s-bigip-ctlr watches all namespaces by default (as of v1.1).
     8  # If the k8s-bigip-ctlr is watching a specific namespace(s),
     9  # this setting must match the namespace of the Service you want to proxy
    10  # -AND- the namespace(s) the k8s-bigip-ctlr watches.
    11  namespace: f5demo
    12  labels:
    13    # tells the k8s-bigip-ctlr to watch this ConfigMap
    14    f5type: virtual-server
    15data:
    16  # NOTE: schema v0.1.4 is required as of k8s-bigip-ctlr v1.3.0
    17  schema: "f5schemadb://bigip-virtual-server_v0.1.7.json"
    18  data: |
    19    {
    20      "virtualServer": {
    21        "backend": {
    22          "servicePort": 8080,
    23          "serviceName": "f5-demo-app",
    24          "healthMonitors": [{
    25            "interval": 30,
    26            "protocol": "http",
    27            "send": "GET /\r\n",
    28            "timeout": 120
    29          }]
    30        },
    31        "frontend": {
    32          "virtualAddress": {
    33            "port": 80,
    34            "bindAddr": "10.3.10.130"
    35          },
    36          "partition": "ocp",
    37          "balance": "least-connections-node",
    38          "mode": "http"
    39        }
    40      }
    41    }
    

    Attention

    Knowledge Check: How does the BIG-IP know which pods make up the application?*

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

    oc create -f f5-demo-app-configmap.yaml
    
  4. Review BIG-IP configuration. Examine the BIG-IP configuration that was created by the Container Connector when it processed the ConfigMap created in the previous step.

    Launch the Chrome browser and click on the bookmark named bigip1.agility-labs.io to access the BIG-IP GUI:

    ../../../_images/bigip01-bookmark.png

    From the BIG-IP login page, enter username=admin and password=admin and click the Log in button:

    ../../../_images/bigip01-login-page.png

    Navigate to Local Traffic ‣ Network Map and change the partition to ocp using the dropdown in the upper right. The network map view shows a virtual server, pool and pool member. All of these objects were created by the Container Connector using the declarations defined in the ConfigMap.

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

    Attention

    Knowledge Check: In the network map view, what OpenShift object type does the pool member IP address represent? How was the IP address assigned?

    To view the IP address of the virtual server, hover your cursor over the name of the virtual server:

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

    Attention

    Knowledge Check: What OpenShift resource type was used to define the virtual server IP address?

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

    Open a new browser tab and enter the IP address assigned to the virtual server in to the address bar:

    ../../../_images/f5-demo-app-url.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. Scale the application. The application deployed in step #1 is a single replica (instance). Now we’ll increase the number of replicas and then check the BIG-IP configuration to see what’s changed.

    When the deployment replica count is scaled up or scaled down, an OpenShift event is generated and the Container Connector sees the event and adds or removes pool members as appropriate.

    To scale the number of replicas, you will use the OpenShift oc scale command. You will be scaling the demo app deployment and so You first need to get the name of the deployment.

    From ose-master1, issue the following command:

    oc get deployment -n f5demo
    

    You can see from the output that the deployment is named f5-demo-app. You will use that name for the next command.

    ../../../_images/oc-get-deployment1.png

    From the ose-master1 host, entering the following command to set the replica count for the deployment to 10 instances:

    oc scale --replicas=10 deployment/f5-demo-app -n f5demo
    
  7. Review the BIG-IP configuration. Examine the BIG-IP configuration for changes that occured after the application was scaled up.

    Navigate to Local Traffic ‣ Network Map and change the partition to ocp using the dropdown in the upper right.

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

    Attention

    Knowledge Check: How many pool members are shown in the network map view? What do you think would happen if you scaled the deployment back to one replica?

  8. Test the scaled application. Use the Chrome browser to access the application that you scaled to 10 replicas in the previous step.

    Open a new Chrome browser tab and enter the IP address assigned to the virtual server in to the address bar:

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

    If you reload the page every few seconds, you should see the Server IP address change. Because there is more than one instance of the application running, the BIG-IP load balances the application traffic amongst multiple pods.

  9. Cleanup deployed resources. Remove the OpenShift Deployment, Service and ConfigMap 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-configmap.yaml
    oc delete -f f5-demo-app-deployment.yaml
    oc delete -f f5-demo-app-service.yaml