Manage BIG-IP Objects

The BIG-IP Controller for Marathon watches the Mesos/Marathon API for Applications with associated F5 Application Labels. These Application Labels define the BIG-IP LTM objects BIG-IP Controller creates/manages.

The example JSON blob shown below tells BIG-IP Controller to create one (1) virtual server - with one (1) health monitor and one (1) pool - in the /mesos partition on the BIG-IP device.

Example F5 Application Labels defining a BIG-IP virtual server
    "mem": 10.0,
    "labels": {
      "F5_0_MODE": "http",
      "F5_0_PORT": "8080",
      "F5_0_BALANCE": "least-connections-member"
    }

Create a BIG-IP virtual server for a Marathon App

Note

The code samples below use the basic Hello Marathon App.

  1. Create a JSON file containing the App service definitions and F5 labels.

    Note

    This sample App definition shows labels that use the default port index (0).

    // See marathon-bigip-ctlr docs for information about all available configuration
    // options
    // http://clouddocs.f5.com/products/marathon-bigip-ctlr/latest
    {
        "id": "basic-0",
        "cmd": "while [ true ] ; do echo 'Hello Marathon' ; sleep 5 ; done",
        "cpus": 0.1,
        "mem": 10.0,
        "instances": 1,
        "labels": {
          // BIG-IP partition
          "F5_PARTITION": "mesos",
          "F5_0_BIND_ADDR": "10.10.10.10",
          "F5_0_MODE": "http",
          "F5_0_PORT": "8080",
          "F5_0_BALANCE": "least-connections-member"
        }
    }
    

    hello-marathon-example.json

  2. Deploy the application in Marathon via the REST API using the JSON file.

    curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' http://10.190.25.75:8080/v2/apps -d @hello-marathon-example.json
    
  3. Verify creation of the virtual server, pool, and member in the App’s BIG-IP partition via tmsh or the configuration utility.

    admin@(bigip)(cfg-sync Standalone)(Active)(/mesos)(tmos)$ show ltm virtual
    ------------------------------------------------------------------
    Ltm::Virtual Server: basic-0_8080
    ------------------------------------------------------------------
    Status
      Availability     : unknown
      State            : enabled
      Reason           : The children pool member(s) either don't have service checking enabled, or service check results are not available yet
      CMP              : enabled
      CMP Mode         : all-cpus
      Destination      : 10.190.25.70:8080
    ...
    

Tip

In the above example, the “Availability” is “unknown” because there are no health monitors associated with the virtual server. When you add health checks to the App in Marathon, the BIG-IP Controller creates corresponding BIG-IP health monitors.

Update a BIG-IP front-end virtual server

  1. Edit the Application’s JSON service definition.

  2. Send the updated file to the Marathon API server.

    curl -X PUT http://1.2.3.4:8080/v2/apps/basic-0 -d @hello-marathon-example.json -H "Content-type: application/json"
    {"version":"2017-02-21T21:48:12.755Z","deploymentId":"02529d16-258b-41d4-ba06-9765c4d1f8d3"}
    
  3. Verify your changes on the BIG-IP via tmsh or the configuration utility.

    tmsh show ltm virtual
    

Delete BIG-IP LTM objects

  1. Remove the F5 Application Labels from the Application’s service definition.

  2. Send the updated Application to the Marathon API server.

    curl -X PUT http://1.2.3.4:8080/v2/apps/basic-0 -d @hello-marathon-example.json -H "Content-type: application/json"
    {"version":"2017-02-21T21:58:11.111Z","deploymentId":"8bdf03d2-8568-46b3-a5a3-61cc397185a1"}
    
  3. Verify the BIG-IP LTM object(s) no longer exist.

    admin@(bigip)(cfg-sync Standalone)(Active)(/mesos)(tmos)$ show ltm virtual
    admin@(bigip)(cfg-sync Standalone)(Active)(/mesos)(tmos)$
    

Connectivity for down or replaced Applications

If you need to take down a Marathon Application temporarily and want to keep the associated BIG-IP LTM objects, keep the F5 Application Labels in the application’s service definition. The BIG-IP Controller will continue to manage the associated BIG-IP LTM objects when the App comes back up. If you deploy a new App with the same name as the one you took down, the BIG-IP Controller associates the existing BIG-IP LTM objects with the new Service.

If you take down an Application and want to remove its corresponding BIG-IP LTM objects, delete the F5 Application Labels from its service definition.

Pools without Virtual Servers

You can use the BIG-IP Controller to create BIG-IP pools that aren’t attached to a front-end virtual server (unattached pools). When you create unattached pools, the BIG-IP Controller for Marathon applies the following naming convention to BIG-IP pool members: <application-name>_<F5_{n}_PORT>. For example, pool-only-0_8080.

Important

The primary use case for unattached pools is to allow the use of an IPAM system to allocate IP addresses for your virtual servers.

If you create unattached pools and are not using IPAM, the BIG-IP system must have another way to route traffic to the pools (such as iRules or local traffic policies).

Use IPAM to assign IP addresses to BIG-IP virtual servers

The BIG-IP Controller for Marathon has a built-in hook that allows you to integrate an IPAM system using a custom plugin. The basic elements required are:

  1. Add the F5 application labels for unattached pools to the App definition. The BIG-IP Controller for Marathon creates a BIG-IP pool that isn’t attached to a virtual server.
  2. Set your IPAM system to add the F5_{n}_BIND_ADDR label and IP address to the Application definition. This tells the BIG-IP Controller for Marathon to create a BIG-IP virtual server with the designated IP address and attach the pool to it.

Create a pool without a virtual server

  1. Create a JSON file containing the App service definitions and F5 application labels, without the F5_{n}_BIND_ADDR application label.

    Note

    This sample App definition uses the default port index (0).

    // See marathon-bigip-ctlr docs for information about all available configuration
    // options
    // http://clouddocs.f5.com/products/marathon-bigip-ctlr/latest
    {
        "id": "pool-only-0",
        "cmd": "while [ true ] ; do echo 'Hello Marathon' ; sleep 5 ; done",
        "cpus": 0.1,
        "mem": 10.0,
        "instances": 1,
        "labels": {
          "F5_PARTITION": "mesos",
          "F5_0_MODE": "http",
          "F5_0_PORT": "8080",
          "F5_0_BALANCE": "weighted-least-connections-member"
        }
    }
    

    hello-marathon-pool-only-example.json

  2. Deploy the application in Marathon via the REST API.

    curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' http://1.2.3.4:8080/v2/apps -d @hello-marathon-pool-only-example.json
    

Delete an unattached pool

  1. Remove the F5 Application Labels from the Application’s service definition.
  2. POST the updated App to the Marathon REST API.
  3. Use the BIG-IP configuration utility to verify deletion of the pool (Local Traffic ‣ Pools).

Detach a pool from a virtual server

If you want to delete a front-end BIG-IP virtual server, but keep its associated pool(s)/pool member(s):

  1. Remove the F5_{n}_BIND_ADDR label from the App’s service definition.
  2. POST the updated App to the Marathon REST API.
  3. Use the BIG-IP configuration utility to verify the virtual server no longer exists (Local Traffic ‣ Virtual Servers).