Lab 2.2 - Deploy Hello-World Using Ingress

Now that CIS is up and running, let’s deploy an application and leverage CIS.

For this lab we’ll use a simple pre-configured docker image called “f5-hello-world”. It can be found on docker hub at f5devcentral/f5-hello-world

App Deployment

On kube-master1 we will create all the required files:

  1. Create a file called deployment-hello-world.yaml

    Tip

    Use the file in ~/agilitydocs/docs/class1/kubernetes

    deployment-hello-world.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
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: f5-hello-world-web
      namespace: default
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: f5-hello-world-web
      template:
        metadata:
          labels:
            app: f5-hello-world-web
        spec:
          containers:
          - env:
            - name: service_name
              value: f5-hello-world-web
            image: f5devcentral/f5-hello-world:latest
            imagePullPolicy: IfNotPresent
            name: f5-hello-world-web
            ports:
            - containerPort: 8080
              protocol: TCP
    
  2. Create a file called clusterip-service-hello-world.yaml

    Tip

    Use the file in ~/agilitydocs/docs/class1/kubernetes

    clusterip-service-hello-world.yaml
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    apiVersion: v1
    kind: Service
    metadata:
      name: f5-hello-world-web
      namespace: default
      labels:
        app: f5-hello-world-web
        cis.f5.com/as3-tenant: AS3
        cis.f5.com/as3-app: A1
        cis.f5.com/as3-pool: web_pool
    spec:
      ports:
      - name: f5-hello-world-web
        port: 8080
        protocol: TCP
        targetPort: 8080
      type: ClusterIP
      selector:
        app: f5-hello-world-web
    
  3. Create a file called ingress-hello-world.yaml

    Tip

    Use the file in ~/agilitydocs/docs/class1/kubernetes

    ingress-hello-world.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
    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: f5-hello-world-web
      namespace: default
      annotations:
        virtual-server.f5.com/partition: "kubernetes"
        virtual-server.f5.com/ip: 10.1.1.4
        virtual-server.f5.com/http-port: "80"
        virtual-server.f5.com/ssl-redirect: "false"
        virtual-server.f5.com/balance: "round-robin"
        virtual-server.f5.com/health: |
          [
            {
              "path":     "f5.hello.world/",
              "send":     "HTTP GET /",
              "interval": 5,
              "timeout":  10
            }
          ]
    spec:
      rules:
      - http:
          paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: f5-hello-world-web
                port:
                  number: 8080
    
  4. We can now launch our application:

    kubectl create -f deployment-hello-world.yaml
    kubectl create -f clusterip-service-hello-world.yaml
    kubectl create -f ingress-hello-world.yaml
    
    ../../_images/f5-container-connector-launch-app-ingress2.png
  5. To check the status of our deployment, you can run the following commands:

    kubectl get pods -o wide
    
    ../../_images/f5-hello-world-pods3.png
    kubectl describe svc f5-hello-world
    
    ../../_images/f5-cis-describe-clusterip-service2.png

    Attention

    To understand and test the new app pay attention to the Endpoints value, this shows our 2 instances (defined as replicas in our deployment file) and the flannel IP assigned to the pod.

  6. Now that we have deployed our application sucessfully, we can check the configuration on bigip1. Switch back to the open management session on firefox.

    Warning

    Don’t forget to select the “kubernetes” partition or you’ll see nothing.

    GoTo: Local Traffic ‣ Virtual Servers

    Here you can see a new Virtual Server, “ingress_10.1.1.4_80” was created, listening on 10.1.1.4:80 in partition “kubernetes”.

    ../../_images/f5-container-connector-check-app-ingress2.png
  7. Check the Pools to see a new pool and the associated pool members.

    GoTo: Local Traffic ‣ Pools and select the “ingress_default_f5-hello-world-web” pool. Click the Members tab.

    ../../_images/f5-container-connector-check-app-ingress-pool2.png

    Note

    You can see that the pool members IP addresses are assigned from the overlay network (ClusterIP mode)

  8. Access your web application via firefox on the jumpbox.

    Note

    Select the “Hello, World” shortcut or type http://10.1.1.4 in the URL field.

    ../../_images/f5-container-connector-access-app1.png
  9. To check traffic distribution, hit Refresh many times on your open browser session. Then go back to the open management console on firefox.

    GoTo: Local Traffic ‣ Pools ‣ Pool list ‣ ingress_default_f5-hello-world-web ‣ Statistics

    ../../_images/f5-container-connector-check-app-bigip-stats-ingress-clusterip.png

    Note

    Are you seeing traffic distribution as shown in the image above? If not why? (HINT: Check the virtual server settings.)

  10. Delete Hello-World

    Important

    Do not skip this step. Instead of reusing some of these objects, the next lab we will re-deploy them to avoid conflicts and errors.

    kubectl delete -f ingress-hello-world.yaml
    kubectl delete -f clusterip-service-hello-world.yaml
    kubectl delete -f deployment-hello-world.yaml
    

    Attention

    Validate the objects are removed via the management console. Local Traffic ‣ Virtual Servers