Network infrastructure migration
-
Select a project for migration.
-
Check which SDNs are connected in your project. If SDN Sprut is not connected, contact technical support.
-
Prepare an administrator workstation for performing the migration:
-
Create a VM in a subnet with internet access. Specify the following parameters:
- Operating system: select Ubuntu.
- Firewall settings: specify
sshfor CLI access to the VM. - Assign external IP: enable the option.
- Select the remaining parameters at your discretion.
-
Wait for the VM to be created and connect to it via SSH.
-
Update the package indexes by running the command:
sudo apt-get update -
Install the jq utility:
sudo apt-get install -y jq -
Install the OpenStack client and authenticate in the project.
-
Clone the repository containing the migration scripts:
git clone https://github.com/vk-cs/neutron-2-sprut.git -
Navigate to the
neutron-2-sprutdirectory. -
Run the command that will add execution permissions to all files with the
.shextension in this directory:chmod +x .sh
-
Assess the project's network infrastructure and identify the entities that need to be migrated:
-
Connect to the administrator VM via SSH.
-
Get the list of VMs:
openstack server listIn the response, find and save the following information:
- IDs of those virtual machines that have multiple network interfaces.
- IDs and IP addresses of those virtual machines that have assigned Floating IP addresses.
- IDs of all other VMs that need to be migrated.
-
Get the list of routers:
openstack router listSave the IDs of the routers that need to be migrated.
-
If your project has IPsec tunnels, save the IDs of the routers used to build the tunnel.
-
Get the list of security groups:
openstack security group listSave the names of all security groups except the default groups:
all,default,ssh+www. -
The default groups
all,default,ssh+wwwhave the same names in SDN Sprut and Neutron. Find and save the IDs of these groups:- Go to your VK Cloud account.
- Select the project.
- Navigate to the Virtual Networks → Firewall settings section.
- Find and save the IDs of the
all,default,ssh+wwwgroups in SDN Sprut and Neutron.
-
Connect to the administrator VM via SSH and navigate to the
neutron-2-sprutdirectory. -
Create a configuration file in CSV format with a list of routers. The file will be used to copy basic network entities using a script.
File format:
<ROUTER_1>,<COPY_TYPE><ROUTER_2>,<COPY_TYPE>Where:
-
<ROUTER_1>,<ROUTER_2>— router IDs. -
<COPY_TYPE>— type of the router copy in SDN Sprut:
Example of a configuration file for copying routers:
35fbfb7c-aaaa-aaaa-aaaa-c3fb4d833dee,adva2dd20ca-bbbb-bbbb-bbbb-7ea8b00a81a6,std -
-
Run the router migration script:
./copy-router-and-networks.sh <FILE_NAME>Where
<FILE_NAME>is the name of the configuration file with the list of routers.Example:
./copy-router-and-networks.sh config.csvAs a result of the script execution, the specified routers will be copied to SDN Sprut along with static routes, networks, and subnets they are connected to. The
-sprutpostfix will be added to the name of each copied entity.
Review the copied entities and make sure that all routers, networks, and subnets have been copied:
-
Check the list of networks:
openstack network list -
Check the list of subnets:
openstack subnet list -
Check the list of standard routers:
openstack router list -
Check the list of added advanced routers. To do this, go to your account or make a REST API request:
sprut_api_base="https://infra.mail.ru:9696/v2.0"token=$(openstack token issue -c id -f value)sprut_advanced_routers=$(curl -s -X GET "${sprut_api_base}/direct_connect/dc_routers" \-H "Content-Type: application/json" \-H "X-Auth-Token: $token" \-H "X-SDN:SPRUT")echo "Advanced routers collected:"echo "$sprut_advanced_routers" | jq .echo ""
If the project uses an IPsec tunnel, configure the advanced router created by the script and prepare it for connecting the IPsec tunnel.
Tunnels with the same selectors (source and target subnet ranges) cannot exist simultaneously, even if they are in different SDNs. Therefore, you cannot create a tunnel in SDN Sprut in advance that is similar to the tunnel in SDN Neutron, as this will cause issues with the original tunnel.
- Delete the original tunnel in SDN Neutron.
- Add a new VPN tunnel for the advanced router configured in SDN Sprut, and set the IPsec policy parameters.
-
Connect to the administrator VM via SSH.
-
Navigate to the
neutron-2-sprutdirectory. -
Copy the security groups to SDN Sprut:
./copy-security-group.sh \--group-mapping=<NEUTRON_GROUP_1>=<SPRUT_GROUP_1>,<NEUTRON_GROUP_2>=<SPRUT_GROUP_2>,... \--groups=<GROUP_3>,<GROUP_4>,...Where:
-
--group-mapping— this parameter allows you to map existing security groups of different SDNs to each other by ID. This is needed if the copied groups have rules where the source is not a CIDR but another security group. Typically, these are theall,default,ssh+wwwgroups. Parameter arguments:<NEUTRON_GROUP_1>,<NEUTRON_GROUP_2>— security group IDs in SDN Neutron;<SPRUT_GROUP_1>,<SPRUT_GROUP_2>— security group IDs in SDN Sprut;
-
--groups— this parameter specifies the names of security groups in SDN Neutron that need to be copied to SDN Sprut. Parameter arguments:<GROUP_3>,<GROUP_4>— names of the groups being copied.
Example command:
./copy-security-group.sh \--group-mapping=4a361c99-cccc-cccc-cccc-b59fb469d354=121a7574-dddd-dddd-dddd-66baa01400d6,14f303dc-aaaa-aaaa-aaaa-9637c9c342df=3371584a-bbbb-bbbb-bbbb-1cc9f3e89601 \--groups=web-server-security,spark-k8s-6681-master,ml_sec_groupSecurity groups will be copied with the
-sprutpostfix. -
Make sure that the security groups in SDN Sprut are identical to the security groups in SDN Neutron. SDN Sprut groups copied from SDN Neutron have the -sprut postfix.
-
Connect to the administrator VM via SSH and navigate to the
neutron-2-sprutdirectory. -
Run the script:
./check-if-all-sprut-sg-present.shIf all required groups are copied, the script will return the following message:
All security groups have corresponding '-sprut' groups.
Floating IP addresses cannot be migrated to another SDN. If your project infrastructure has Floating IP addresses, create new ones in SDN Sprut and write them down.
To move a VM to SDN Sprut, you need to connect its ports to new subnets. This is done in different ways depending on the number of VM ports and the type of connections:
-
Multiple VMs can be switched by running a single script, but these VMs must have only one network interface each and must not have direct connections to the
ext-netexternal network. -
A single VM can be switched by running a separate script. This method is suitable if your project has a VM with multiple network interfaces, that is, acting as a router, proxy, or edge firewall.
-
If in your configuration the VM is directly connected to the
ext-netexternal network, migrate it to SDN Sprut using any convenient method:
-
Connect to the administrator VM via SSH and navigate to the
neutron-2-sprutdirectory. -
Create a CSV file with a list of VMs to be migrated.
File format:
<VM_1>,<SPRUT_NETWORK_1>,<SPRUT_SUBNET_1>,<SPRUT_FLOATING-IP><VM_2>,<SPRUT_NETWORK_2>,<SPRUT_SUBNET_2>Where:
<VM_1>,<VM_2>— names of the VMs to be migrated to SDN Sprut.<SPRUT_NETWORK_1>,<SPRUT_NETWORK_2>— names of the networks in SDN Sprut to connect the VMs to.<SPRUT_SUBNET_1>,<SPRUT_SUBNET_2>— names of the subnets in SDN Sprut to connect the VMs to.- (Optional)
<SPRUT_FLOATING_IP>— Floating IP address in SDN Sprut to assign to the VM.
Example file with a list of VMs:
web-server-1,web-app-network-sprut,app-subnet-sprut,83.166.236.59web-server-2,web-app-network-sprut,app-subnet-sprut -
Schedule a maintenance window during which the migration will be performed. During the switch, the VM will lose network connectivity. Switching a single VM takes approximately 45 seconds.
-
Make sure the VMs are active:
openstack server listAll VMs that need to be migrated to SDN Sprut must have the
ACTIVEstatus. -
Run the migration script:
./migrator-multiple.sh <FILE_NAME> \--all-secgroup-sprut-id=<ALL_GROUP_ID> \--ssh-www-secgroup-sprut-id=<SSH+WWW_GROUP_ID>Where:
<FILE_NAME>— the name of the file with the list of VMs.- (Optional)
--all-secgroup-sprut-id— theallsecurity group is added to the project by default and has the same name in SDN Sprut and Neutron. If the group is used in a VM, specify the group ID in Sprut so that OpenStack CLI can distinguish the security group's SDN membership. Parameter argument:<ALL_GROUP_ID>— the ID of theallsecurity group in SDN Sprut. - (Optional)
--ssh-www-secgroup-sprut-id— thessh+wwwsecurity group is added to the project by default and has the same name in SDN Sprut and Neutron. If the group is used in a VM, specify the group ID in Sprut so that OpenStack CLI can distinguish the security group's SDN membership. Parameter argument:<SSH+WWW_GROUP_ID>— the ID of thessh+wwwsecurity group in SDN Sprut.
Example command:
./migrator-multiple.sh migrate-vm.csv \--all-secgroup-sprut-id=4a361c99-cccc-cccc-cccc-b59fb469d354=121a7574-eeee-eeee-eeee-66baa01400d6 \--ssh-www-secgroup-sprut-id=14f303dc-bbbb-bbbb-bbbb-9637c9c342df=3371584a-dddd-dddd-dddd-1cc9f3e89601 -
For each VM, open the console or connect via SSH and perform a DHCP server request to obtain an IP address for the added network interface:
LinuxWindowsdhclient
Check the availability of all VMs after migration.
If you no longer need SDN Neutron resources, delete them: