blob: a8fe16aa4ce9a8b22d6cf684ba7f417f5e3ee1e0 [file] [log] [blame]
John DeNiscoc4c72d22018-08-16 13:50:02 -04001.. _settingupenvironment:
2
3Setting up your environment
4===========================
5
Elod Illes078a3602024-03-21 15:12:59 +01006All of these exercises are designed to be performed on an Ubuntu 22.04 (Jammy) box.
John DeNiscoc4c72d22018-08-16 13:50:02 -04007
Elod Illes078a3602024-03-21 15:12:59 +01008* 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 DeNiscoc4c72d22018-08-16 13:50:02 -040010
Elod Illes078a3602024-03-21 15:12:59 +010011Install Libvirt and Vagrant
John DeNiscoc4c72d22018-08-16 13:50:02 -040012-------------------------------
13
Elod Illes078a3602024-03-21 15:12:59 +010014You will need to install Libvirt and Vagrant.
John DeNiscoc4c72d22018-08-16 13:50:02 -040015
16Create a Vagrant Directory
17---------------------------
18
19To get started create a directory for vagrant
20
21.. code-block:: console
22
23 $ mkdir vpp-tutorial
24 $ cd vpp-tutorial
25
26Create a file called **Vagrantfile** with the following contents:
27
28.. code-block:: ruby
29
30 # -*- mode: ruby -*-
31 # vi: set ft=ruby :
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020032
John DeNiscoc4c72d22018-08-16 13:50:02 -040033 Vagrant.configure(2) do |config|
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020034
Elod Illes078a3602024-03-21 15:12:59 +010035 config.vm.box = "generic/ubuntu2204"
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020036
John DeNiscoc4c72d22018-08-16 13:50:02 -040037 vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
38 vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096)
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020039
John DeNiscoc4c72d22018-08-16 13:50:02 -040040 config.ssh.forward_agent = true
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020041
Elod Illes078a3602024-03-21 15:12:59 +010042 config.vm.provider "libvirt" do |vb|
John DeNiscoc4c72d22018-08-16 13:50:02 -040043 vb.memory = "#{vmram}"
44 vb.cpus = "#{vmcpu}"
John DeNiscoc4c72d22018-08-16 13:50:02 -040045 end
46 end
47
48
49Running Vagrant
50---------------
51
52VPP runs in userspace. In a production environment you will often run it with
53DPDK to connect to real NICs or vhost to connect to VMs.mIn those circumstances
54you usually run a single instance of VPP.
55
56For purposes of this tutorial, it is going to be extremely useful to run multiple
57instances of vpp, and connect them to each other to form a topology. Fortunately,
58VPP supports this.
59
60When running multiple VPP instances, each instance needs to have specified a 'name'
61or 'prefix'. In the example below, the 'name' or 'prefix' is "vpp1". Note that only
62one instance can use the dpdk plugin, since this plugin is trying to acquire a lock
63on a file.
64
65Setting up VPP environment with Vagrant
66---------------------------------------------
67
68After 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 DeNiscob0464872020-07-28 12:15:16 -040074 $ sudo bash
75 # apt-get update
76 # reboot -n
John DeNiscoc4c72d22018-08-16 13:50:02 -040077 $ # Wait for the VM to reboot
78 $ vagrant ssh
79
80Install VPP
81------------
82
83Now that the VM is updated, we will install the VPP packages.
84
85For more on installing VPP please refer to :ref:`installingVPP`.
86
John DeNiscob0464872020-07-28 12:15:16 -040087For this tutorial we will install VPP by modifying the file
John DeNiscoc4c72d22018-08-16 13:50:02 -040088**/etc/apt/sources.list.d/99fd.io.list**.
89
John DeNiscob0464872020-07-28 12:15:16 -040090We write this file with the following contents:
John DeNiscoc4c72d22018-08-16 13:50:02 -040091
92.. code-block:: console
93
John DeNiscob0464872020-07-28 12:15:16 -040094 $ sudo bash
Elod Illes078a3602024-03-21 15:12:59 +010095 # echo "deb https://packagecloud.io/fdio/release/ubuntu jammy main" > /etc/apt/sources.list.d/99fd.io.list
John DeNiscob0464872020-07-28 12:15:16 -040096 #
97
98Get the key.
99
100.. code-block:: console
101
102 # curl -L https://packagecloud.io/fdio/release/gpgkey | sudo apt-key add -
103 #
John DeNiscoc4c72d22018-08-16 13:50:02 -0400104
105Then execute the following commands.
106
107.. code-block:: console
108
John DeNiscoc4c72d22018-08-16 13:50:02 -0400109 # apt-get update
John DeNiscob0464872020-07-28 12:15:16 -0400110 # apt-get install vpp vpp-plugin-core vpp-plugin-dpdk
John DeNiscoc4c72d22018-08-16 13:50:02 -0400111 #
112
113Stop 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
121Create some startup files
122--------------------------
123
124We will create some startup files for the use of this tutorial. Typically you will
125modify the startup.conf file found in /etc/vpp/startup.conf. For more information
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200126on this file refer to :ref:`configuration_reference`.
John DeNiscoc4c72d22018-08-16 13:50:02 -0400127
128When running multiple VPP instances, each instance needs to have
129specified a 'name' or 'prefix'. In the example below, the 'name' or 'prefix'
130is "vpp1". Note that only one instance can use the dpdk plugin, since this
131plugin is trying to acquire a lock on a file. These startup files we create will
132disable the dpdk plugin.
133
134Also in our startup files notice **api-segment**. **api-segment {prefix vpp1}**
135tells FD.io VPP how to name the files in /dev/shm/ for your VPP instance
136differently from the default. **unix {cli-listen /run/vpp/cli-vpp1.sock}**
137tells vpp to use a non-default socket file when being addressed by vppctl.
138
139Now create 2 files named startup1.conf and startup2.conf with the following
140content. These files can be located anywhere. We specify the location when we
141start VPP.
142
143startup1.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
151startup2.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 } }