F5 to Avi Load Balancer Migration – Part 6: Migrate Complex L4 VS with Policies

Welcome to part 6 of the F5 to Avi migration series. The previous post in this series discussed the migration method for offline mode. In this post, I will demonstrate migrating complex L4 virtual services.

If you are not following along, I encourage you to read the earlier parts of this series from the links below:

1: Introduction to F5 to Avi Load Balancer Migration

2: F5 to Avi – Migration Strategy Framework

3: Avi Assessment Framework

4: F5 to Avi – Online Mode Migration

5: F5 to Avi – Offline Mode Migration

Not all F5 virtual services can be migrated to Avi using the Avi Conversion Tool. The tool currently has a limitation of migrating L4 virtual services configured for SNI-based routing policy. When you attempt to convert such a VS to AVI format using the conversion tool UI, the tool skips the policies.

Migration of such virtual services is not possible through ACT UI, and you have to do this manually using the converter Python script. It is a complex procedure, and I will walk you through the step-by-step configuration of such a migration.

Before diving into the procedure, let’s look at the virtual service F5 configuration. 

The VS “vs-dev5-party-ceas-443” is a standard VS, and it is listening on port 443. 

The VS type is L4 and is configured for SSL.

The VS has a policy named “dev5-party-url-based-pool-rdt” attached to it.

This policy is routing traffic to a specific pool based on the server name in the client header. As you can see in the screenshot below, different URLs are routed to individual pools listening on a specific port.

Now we have a baseline set; let’s look at an app selected for the migration.

VS Name: pmg_443

Policy Name: pc_pmg_443

Let’s investigate the VS/Policy configuration in the F5 bigip.conf file. The following rulesets are configured for the VS:

  1. The VS has a catch-all condition configured, and the traffic is going to pool pmg-8446 (yellow box).
  2. For individual FQDNs, the traffic is routed to a specific pool (red box).

These rulesets are handled using Avi datascripts in Avi configuration.

The datascript parses the Client Hello packet to extract the SNI name and then selects a pool based on a string group lookup.

Migration Steps

Step 1: Export the F5 Configuration

Using CLI/UI, export the F5 bigip.conf file and save it on your local system.

Step 2: Create String Group JSON

The string group acts as a key-value pair, with the SNI name as the key and the corresponding pool name as the value. A key-value pair is formed by combining the “sni-host-name” from a policy’s rule condition and the “pool-name” from its rule action.

These key-value pairs should then be added into a JSON format, as shown in the example below, to form a JSON object for string group configuration.

Note 1: The name “pmg_443_string_group” is just a friendly name. This name is referenced by the datascript that is generated in step 3 and should match. Any mismatch in the name, and the CLI tool will not generate the right data.

Note 2: The string group file is unique per VS (that has policies). You can’t combine two VS/policies in the same file.

Note 3: The ACT tool automatically prefixes the “Common-” partition to the pool name while converting, so this prefix is added to the value.

Step 2: Create Datascript JSON

The datascript file provides the data for the object that needs to be created. This datascript includes logic for pool selection based on sni-hostname and references the string group (pmg_443_string_group) in two locations.

For similar policies, create the datascript object using the same JSON, modifying the name of the referenced string group as needed.

Note 1: The name “pmg_443_datascript” is a friendly name and is referenced by the patch.yaml that is generated in step 4.

Note 2: The string group name is referenced in two places in the datascript file. Update the name at both places.

Step 4: Create the patch.yaml file for VS customization.

The patch file defines the changes to apply to that virtual service. Update the file to match the VS that needs to be migrated.

1: match_name: Common-<vs-name-in-f5>

2: vs_datascript_set_ref: Update the datascript name here.

3: enabled: true <– this flag enables the VS in Avi when the config is pushed.

4: traffic_enabled: false (for pre-build activity, keep this flag disabled). For the cutover day, this flag needs to be enabled, and the playbook needs to be regenerated manually.

5: tenant=<avi-tenant>&cloud=<Avi-cloud-name>: This should match the tenant/cloud where VS will be created.

6: pool_refs: This section contains all the pools that are referenced by the policies. This should match the pool name in the string group file.

A sample patch.yaml file is shown below for reference.

Note: You need to prefix the pool name with “Common-” to match the partition name in F5

Step 5: Create VS Object Ref JSON File

This is just an empty file. The tool references this file for populating VS information.

You should have the following files on your local system now. Store the files in a folder named pmg_443

  • bigip.conf
  • string_group.json
  • datascript.json
  • vs_objs_refs.json
  • patch.yaml
Upload the pmg_443 folder to the ACT tool at the location /opt/avimigrationtools/uploads/ using WinSCP or a similar utility.

Note: You will need to adjust the permissions of the upload folder for the file transfer.

Create Terminal Sessions

Create 2 terminal sessions – one for ACT VM and another for the “avimigrationtools” container running on ACT VM. This is required so as to avoid switching between 2 for the subsequent commands.

  1. All the commands that are required to be executed from the VM terminal session are prefixed by [VM]
  2. For creating a Docker container terminal session using the sudo -i command. All the commands that are required to be executed from this terminal session are prefixed by [CONTAINER]

Create Ansible Playbooks for Migration

Step 1: [VM] SSH to the ACT VM and switch to the root user: sudo -i

Step 2: [VM] Open another terminal session and SSH to the ACT VM and create a container session: # docker exec -it migrationTools bash

Step 3: [CONTAINER] cd /server/uploads/pmg_443

3a: Execute the F5 converter with the following command

Note: The vrf name should match the vrf-context name in Avi.

The f5 converter script converts the VS objects and stores the config in yaml files.

The following files are created in the output directory specified in the converter command:

3b: Backup the generated Avi config json file

Step 4: Switch to another terminal session and execute the command to patch the generated Avi config output json with the datascript and string group objects.

The above commands create the bigip-Output_updated.json file in the output directory.

Step 5: Create a patched file that patches pools to datascript and datascript to virtual service.

The above command creates a patched output file named bigip-Output_updated-patched.json in the output directory.

Step 6: Create Playbooks

Execute the playbook generation script with the below command to create a final Ansible playbook for a particular VS

Note: In the below command, the –vs_filter flag should match the name as specified in the patch.yaml file (Common-<vs-name>)

Command output:

The above command creates 2 files

  1. avi_config.yml: which is an Ansible playbook that CREATES the objects on the Avi controller.
  2. avi_config_delete.yml: which is an Ansible playbook that DELETES the created objects from the Avi controller.

Note: The resulting playbooks must have the traffic_enabled flag set on the VS. Validate the same before pushing the config to the Avi controller.

Step 7: Execute Ansible Playbook

7a: Execute the create ansible-playbook command to push the configuration to the AVI controller. This playbook will create a VirtualService, Pool with Health Monitor, StringGroup, and a VSDatascript on the Avi controller.

7b: Update VS Certificate

The ACT tool doesn’t convert the VS original certificate. It creates a new self-signed certificate and attaches it to the VS. You need to manually import the certificate and update the VS to use this certificate. 

7c: If any created objects are to be deleted, then execute the delete ansible-playbook command to delete the configuration from the Avi controller.

This will delete the previously created VirtualService, Pool with Health Monitor, StringGroup, and VSDatascript from the Avi controller.

Verify that these objects are deleted from the AVI controller.

Note: If you need to update the VS configuration by enabling/disabling adding any parameter, then you need to regenerate the playbooks by running the commands in Steps 5 to 7

And that’s it for this post. In the next post of this series, I will demonstrate migrating an L7 app with policies. Stay tuned!!!

I hope you enjoyed reading this post. Feel free to share this on social media if it’s worth sharing.

Spread the Love

Leave a Reply