John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 1 | .. _settingupenvironment: |
| 2 | |
| 3 | Setting up your environment |
| 4 | =========================== |
| 5 | |
Elod Illes | 078a360 | 2024-03-21 15:12:59 +0100 | [diff] [blame^] | 6 | All of these exercises are designed to be performed on an Ubuntu 22.04 (Jammy) box. |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 7 | |
Elod Illes | 078a360 | 2024-03-21 15:12:59 +0100 | [diff] [blame^] | 8 | * If you have an Ubuntu 22.04 box on which you have sudo or root access, you can feel free to use that. |
| 9 | * If you do not, a Vagrantfile is provided to setup a basic Ubuntu 22.04 box for you in the the steps below. |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 10 | |
Elod Illes | 078a360 | 2024-03-21 15:12:59 +0100 | [diff] [blame^] | 11 | Install Libvirt and Vagrant |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 12 | ------------------------------- |
| 13 | |
Elod Illes | 078a360 | 2024-03-21 15:12:59 +0100 | [diff] [blame^] | 14 | You will need to install Libvirt and Vagrant. |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 15 | |
| 16 | Create a Vagrant Directory |
| 17 | --------------------------- |
| 18 | |
| 19 | To get started create a directory for vagrant |
| 20 | |
| 21 | .. code-block:: console |
| 22 | |
| 23 | $ mkdir vpp-tutorial |
| 24 | $ cd vpp-tutorial |
| 25 | |
| 26 | Create a file called **Vagrantfile** with the following contents: |
| 27 | |
| 28 | .. code-block:: ruby |
| 29 | |
| 30 | # -*- mode: ruby -*- |
| 31 | # vi: set ft=ruby : |
Nathan Skrzypczak | 9ad39c0 | 2021-08-19 11:38:06 +0200 | [diff] [blame] | 32 | |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 33 | Vagrant.configure(2) do |config| |
Nathan Skrzypczak | 9ad39c0 | 2021-08-19 11:38:06 +0200 | [diff] [blame] | 34 | |
Elod Illes | 078a360 | 2024-03-21 15:12:59 +0100 | [diff] [blame^] | 35 | config.vm.box = "generic/ubuntu2204" |
Nathan Skrzypczak | 9ad39c0 | 2021-08-19 11:38:06 +0200 | [diff] [blame] | 36 | |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 37 | vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2) |
| 38 | vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096) |
Nathan Skrzypczak | 9ad39c0 | 2021-08-19 11:38:06 +0200 | [diff] [blame] | 39 | |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 40 | config.ssh.forward_agent = true |
Nathan Skrzypczak | 9ad39c0 | 2021-08-19 11:38:06 +0200 | [diff] [blame] | 41 | |
Elod Illes | 078a360 | 2024-03-21 15:12:59 +0100 | [diff] [blame^] | 42 | config.vm.provider "libvirt" do |vb| |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 43 | vb.memory = "#{vmram}" |
| 44 | vb.cpus = "#{vmcpu}" |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 45 | end |
| 46 | end |
| 47 | |
| 48 | |
| 49 | Running Vagrant |
| 50 | --------------- |
| 51 | |
| 52 | VPP runs in userspace. In a production environment you will often run it with |
| 53 | DPDK to connect to real NICs or vhost to connect to VMs.mIn those circumstances |
| 54 | you usually run a single instance of VPP. |
| 55 | |
| 56 | For purposes of this tutorial, it is going to be extremely useful to run multiple |
| 57 | instances of vpp, and connect them to each other to form a topology. Fortunately, |
| 58 | VPP supports this. |
| 59 | |
| 60 | When running multiple VPP instances, each instance needs to have specified a 'name' |
| 61 | or 'prefix'. In the example below, the 'name' or 'prefix' is "vpp1". Note that only |
| 62 | one instance can use the dpdk plugin, since this plugin is trying to acquire a lock |
| 63 | on a file. |
| 64 | |
| 65 | Setting up VPP environment with Vagrant |
| 66 | --------------------------------------------- |
| 67 | |
| 68 | After setting up Vagrant, use these commands on your Vagrant directory to boot the VM: |
| 69 | |
| 70 | .. code-block:: console |
| 71 | |
| 72 | $ vagrant up |
| 73 | $ vagrant ssh |
John DeNisco | b046487 | 2020-07-28 12:15:16 -0400 | [diff] [blame] | 74 | $ sudo bash |
| 75 | # apt-get update |
| 76 | # reboot -n |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 77 | $ # Wait for the VM to reboot |
| 78 | $ vagrant ssh |
| 79 | |
| 80 | Install VPP |
| 81 | ------------ |
| 82 | |
| 83 | Now that the VM is updated, we will install the VPP packages. |
| 84 | |
| 85 | For more on installing VPP please refer to :ref:`installingVPP`. |
| 86 | |
John DeNisco | b046487 | 2020-07-28 12:15:16 -0400 | [diff] [blame] | 87 | For this tutorial we will install VPP by modifying the file |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 88 | **/etc/apt/sources.list.d/99fd.io.list**. |
| 89 | |
John DeNisco | b046487 | 2020-07-28 12:15:16 -0400 | [diff] [blame] | 90 | We write this file with the following contents: |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 91 | |
| 92 | .. code-block:: console |
| 93 | |
John DeNisco | b046487 | 2020-07-28 12:15:16 -0400 | [diff] [blame] | 94 | $ sudo bash |
Elod Illes | 078a360 | 2024-03-21 15:12:59 +0100 | [diff] [blame^] | 95 | # echo "deb https://packagecloud.io/fdio/release/ubuntu jammy main" > /etc/apt/sources.list.d/99fd.io.list |
John DeNisco | b046487 | 2020-07-28 12:15:16 -0400 | [diff] [blame] | 96 | # |
| 97 | |
| 98 | Get the key. |
| 99 | |
| 100 | .. code-block:: console |
| 101 | |
| 102 | # curl -L https://packagecloud.io/fdio/release/gpgkey | sudo apt-key add - |
| 103 | # |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 104 | |
| 105 | Then execute the following commands. |
| 106 | |
| 107 | .. code-block:: console |
| 108 | |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 109 | # apt-get update |
John DeNisco | b046487 | 2020-07-28 12:15:16 -0400 | [diff] [blame] | 110 | # apt-get install vpp vpp-plugin-core vpp-plugin-dpdk |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 111 | # |
| 112 | |
| 113 | Stop VPP for this tutorial. We will be creating our own instances of VPP. |
| 114 | |
| 115 | .. code-block:: console |
| 116 | |
| 117 | # service vpp stop |
| 118 | # |
| 119 | |
| 120 | |
| 121 | Create some startup files |
| 122 | -------------------------- |
| 123 | |
| 124 | We will create some startup files for the use of this tutorial. Typically you will |
| 125 | modify the startup.conf file found in /etc/vpp/startup.conf. For more information |
Nathan Skrzypczak | 9ad39c0 | 2021-08-19 11:38:06 +0200 | [diff] [blame] | 126 | on this file refer to :ref:`configuration_reference`. |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 127 | |
| 128 | When running multiple VPP instances, each instance needs to have |
| 129 | specified a 'name' or 'prefix'. In the example below, the 'name' or 'prefix' |
| 130 | is "vpp1". Note that only one instance can use the dpdk plugin, since this |
| 131 | plugin is trying to acquire a lock on a file. These startup files we create will |
| 132 | disable the dpdk plugin. |
| 133 | |
| 134 | Also in our startup files notice **api-segment**. **api-segment {prefix vpp1}** |
| 135 | tells FD.io VPP how to name the files in /dev/shm/ for your VPP instance |
| 136 | differently from the default. **unix {cli-listen /run/vpp/cli-vpp1.sock}** |
| 137 | tells vpp to use a non-default socket file when being addressed by vppctl. |
| 138 | |
| 139 | Now create 2 files named startup1.conf and startup2.conf with the following |
| 140 | content. These files can be located anywhere. We specify the location when we |
| 141 | start VPP. |
| 142 | |
| 143 | startup1.conf: |
| 144 | |
| 145 | .. code-block:: console |
| 146 | |
| 147 | unix {cli-listen /run/vpp/cli-vpp1.sock} |
| 148 | api-segment { prefix vpp1 } |
| 149 | plugins { plugin dpdk_plugin.so { disable } } |
| 150 | |
| 151 | startup2.conf: |
| 152 | |
| 153 | .. code-block:: console |
| 154 | |
| 155 | unix {cli-listen /run/vpp/cli-vpp2.sock} |
| 156 | api-segment { prefix vpp2 } |
| 157 | plugins { plugin dpdk_plugin.so { disable } } |