Skip to content
Snippets Groups Projects
Commit 340b6118 authored by yangalicace1's avatar yangalicace1
Browse files

Deployed 4be9976f to develop in public with MkDocs 1.6.1 and mike 2.1.3

parent 32e986d0
No related branches found
No related tags found
No related merge requests found
Showing with 242 additions and 2 deletions
......@@ -833,7 +833,247 @@ sudo apt-get dist-upgrade -y
<li>Restart the VM when the installation is completed.</li>
</ul>
<h3 id="115-vagrant-box"><strong>1.1.5. Vagrant Box</strong></h3>
<p><TBD_LONG></p>
<p>This section describes how to create a Vagrant Box, using the base virtual machine configured in <a href="#112-oracle-virtual-box">Oracle Virtual Box</a>.</p>
<h3><u>Virtual Machine specifications</h3>
<p></u>
Most of the specifications can be as specified in the <a href="#112-oracle-virtual-box">Oracle Virtual Box</a> page, however, there are a few particularities to Vagrant that must be accommodated, such as:</p>
<ul>
<li>Virtual Hard Disk</li>
<li>Size: 60GB (at least)</li>
<li><strong>Type</strong>: VMDK</li>
</ul>
<p><img alt="spaces_huDzAu5hmjUdNzCGBBbL_uploads_jrerlmLyZWi5f2Tzb7xY_Screenshot_from_2023-07-10_18-13-43" src="/documentation/doc/images/deployment_guide/01_vagrant_box.jpg" /></p>
<p>Also, before initiating the VM and installing the OS, we'll need to:</p>
<ul>
<li>Disable Floppy in the 'Boot Order'</li>
<li>Disable audio</li>
<li>Disable USB</li>
<li>Ensure Network Adapter 1 is set to NAT</li>
</ul>
<h3><u>Network configurations</h3>
<p></u>
At Network Adapt 1, the following port-forwarding rule must be set.</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Protocol</th>
<th>Host IP</th>
<th>Host Port</th>
<th>Guest IP</th>
<th>Guest Port</th>
</tr>
</thead>
<tbody>
<tr>
<td>SSH</td>
<td>TCP</td>
<td></td>
<td><strong>2222</strong></td>
<td></td>
<td>22</td>
</tr>
</tbody>
</table>
<p><img alt="Screenshot_from_2023-07-10_18-25-18" src="uploads/ced8e7b1133d6831e0c203801b6ba448/Screenshot_from_2023-07-10_18-25-18.png" /></p>
<h3><u>Installing the OS</h3>
<p></u></p>
<p>For a Vagrant Box, it is generally suggested that the ISO's server version is used, as it is intended to be used via SSH, and any web GUI is expected to be forwarded to the host.</p>
<p><img alt="Screenshot_from_2023-07-10_18-41-49" src="/documentation/doc/images/deployment_guide/02_vagrant_box.jpg" /></p>
<p><img alt="Screenshot_from_2023-07-10_18-42-30" src="/documentation/doc/images/deployment_guide/03_vagrant_box.jpg" /></p>
<p><img alt="Screenshot_from_2023-07-10_18-42-45" src="/documentation/doc/images/deployment_guide/04_vagrant_box.jpg" /></p>
<p>Make sure the disk is not configured as an LVM group!</p>
<p><img alt="Screenshot_from_2023-07-10_18-43-16" src="/documentation/doc/images/deployment_guide/05_vagrant_box.jpg" /></p>
<h3><u>Vagrant ser</h3>
<p></u>
Vagrant expects by default, that in the box's OS exists the user <code>vagrant</code> with the password also being <code>vagrant</code>.</p>
<p><img alt="Screenshot_from_2023-07-10_18-54-12" src="/documentation/doc/images/deployment_guide/06_vagrant_box.jpg" /></p>
<h3><u>SSH</h3>
<p></u></p>
<p>Vagrant uses SSH to connect to the boxes, so installing it now will save the hassle of doing it later.</p>
<p><img alt="Screenshot_from_2023-07-10_18-54-48" src="/documentation/doc/images/deployment_guide/07_vagrant_box.jpg" /></p>
<h3><u>Features server snaps</h3>
<p></u></p>
<p>Do not install featured server snaps. It will be done manually <a href="#12-install-microk8s">later</a> to illustrate how to uninstall and reinstall them in case of trouble with.</p>
<h3><u>Updates</h3>
<p></u></p>
<p>Let the system install and upgrade the packages. This operation might take some minutes depending on how old is the Optical Drive ISO image you use and your Internet connection speed.</p>
<h3><u>Upgrade the Ubuntu distribution</h3>
<p></u></p>
<pre><code class="language-bash">sudo apt-get update -y
sudo apt-get dist-upgrade -y
</code></pre>
<ul>
<li>If asked to restart services, restart the default ones proposed.</li>
<li>Restart the VM when the installation is completed.</li>
</ul>
<h3><u>Install VirtualBox Guest Additions</h3>
<p></u>
On VirtualBox Manager, open the VM main screen. If you are running the VM in headless
mode, right-click over the VM in the VirtualBox Manager window, and click "Show".
If a dialog informing about how to leave the interface of the VM is shown, confirm
by pressing the "Switch" button. The interface of the VM should appear.</p>
<p>Click the menu "Device &gt; Insert Guest Additions CD image..."</p>
<p>On the VM terminal, type:</p>
<pre><code class="language-bash">sudo apt-get install -y linux-headers-$(uname -r) build-essential dkms
# This command might take some minutes depending on your VM specs and your Internet access speed.
sudo mount /dev/cdrom /mnt/
cd /mnt/
sudo ./VBoxLinuxAdditions.run
# This command might take some minutes depending on your VM specs.
sudo reboot
</code></pre>
<h3><u>ETSI TFS Installation</h3>
<p></u>
After this, proceed to <a href="#12-install-microk8s">1.2. Install Microk8s</a>, after which, return to this wiki to finish the Vagrant Box creation.</p>
<h3><u>Box configuration and creation</h3>
<p></u>
Make sure the ETSI TFS controller is correctly configured. <strong>You will not be able to change it after!</strong></p>
<p>It is advisable to do the next configurations from a host's terminal, via a SSH connection.</p>
<pre><code class="language-bash">ssh -p 2222 vagrant@127.0.0.1
</code></pre>
<h3><u>Set root password</h3>
<p></u>
Set the root password to <code>vagrant</code>.</p>
<pre><code class="language-bash">sudo passwd root
</code></pre>
<h3><u>Set the superuser</h3>
<p></u>
Set up the Vagrant user so that it’s able to use sudo without being prompted for a password.
Anything in the <code>/etc/sudoers.d/*</code> directory is included in the sudoers privileges when created by the root user.
Create a new sudo file.</p>
<pre><code class="language-bash">sudo visudo -f /etc/sudoers.d/vagrant
</code></pre>
<p>and add the following lines</p>
<pre><code class="language-text"># add vagrant user
vagrant ALL=(ALL) NOPASSWD:ALL
</code></pre>
<p>You can now test that it works by running a simple command.</p>
<pre><code class="language-bash">sudo pwd
</code></pre>
<p>Issuing this command should result in an immediate response without a request for a password.</p>
<h3><u>Install the Vagrant key</h3>
<p></u>
Vagrant uses a default set of SSH keys for you to directly connect to boxes via the CLI command <code>vagrant ssh</code>, after which it creates a new set of SSH keys for your new box. Because of this, we need to load the default key to be able to access the box after created.</p>
<pre><code class="language-bash">chmod 0700 /home/vagrant/.ssh
wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.ssh
</code></pre>
<h3><u>Configure the OpenSSH Server</h3>
<p></u>
Edit the <code>/etc/ssh/sshd_config</code> file:</p>
<pre><code class="language-bash">sudo vim /etc/ssh/sshd_config
</code></pre>
<p>And uncomment the following line:</p>
<pre><code class="language-bash">AuthorizedKeysFile %h/.ssh/authorized_keys
</code></pre>
<p>Then restart SSH.</p>
<pre><code class="language-bash">sudo service ssh restart
</code></pre>
<h3><u>Package the box</h3>
<p></u>
Before you package the box, if you intend to make your box public, it is best to clean your bash history with:</p>
<pre><code class="language-bash">history -c
</code></pre>
<p>Exit the SSH connection, and <strong>at you're host machine</strong>, package the VM:</p>
<pre><code class="language-bash">vagrant package --base teraflowsdncontroller --output teraflowsdncontroller.box
</code></pre>
<h3><u>Test run the box</h3>
<p></u>
Add the base box to you local Vagrant box list:</p>
<pre><code class="language-bash">vagrant box add --name teraflowsdncontroller ./teraflowsdncontroller.box
</code></pre>
<p>Now you should try to run it, for that you'll need to create a <strong>Vagrantfile</strong>. For a simple run, this is the minimal required code for this box:</p>
<pre><code class="language-ruby"># -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(&quot;2&quot;) do |config|
config.vm.box = &quot;teraflowsdncontroller&quot;
config.vm.box_version = &quot;1.1.0&quot;
config.vm.network :forwarded_port, host: 8080 ,guest: 80
end
</code></pre>
<p>Now you'll be able to spin up the virtual machine by issuing the command:</p>
<pre><code class="language-bash">vagrant up
</code></pre>
<p>And connect to the machine using:</p>
<pre><code class="language-bash">vagrant ssh
</code></pre>
<h3><u>Pre-configured boxes</h3>
<p></u>
If you do not wish to create your own Vagrant Box, you can use one of the existing ones created by TFS contributors.
- <a href="https://app.vagrantup.com/davidjosearaujo/boxes/teraflowsdncontroller">davidjosearaujo/teraflowsdncontroller</a>
- ... <!-- Should create and host one at ETSI!! --></p>
<p>To use them, you simply have to create a Vagrantfile and run <code>vagrant up controller</code> in the same directory. The following example Vagrantfile already allows you to do just that, with the bonus of exposing the multiple management GUIs to your <code>localhost</code>.</p>
<pre><code class="language-ruby">Vagrant.configure(&quot;2&quot;) do |config|
config.vm.define &quot;controller&quot; do |controller|
controller.vm.box = &quot;davidjosearaujo/teraflowsdncontroller&quot;
controller.vm.network &quot;forwarded_port&quot;, guest: 80, host: 8080 # WebUI
controller.vm.network &quot;forwarded_port&quot;, guest: 8084, host: 50750 # Linkerd Viz Dashboard
controller.vm.network &quot;forwarded_port&quot;, guest: 8081, host: 8081 # CockroachDB Dashboard
controller.vm.network &quot;forwarded_port&quot;, guest: 8222, host: 8222 # NATS Dashboard
controller.vm.network &quot;forwarded_port&quot;, guest: 9000, host: 9000 # QuestDB Dashboard
controller.vm.network &quot;forwarded_port&quot;, guest: 9090, host: 9090 # Prometheus Dashboard
# Setup Linkerd Viz reverse proxy
## Copy config file
controller.vm.provision &quot;file&quot; do |f|
f.source = &quot;./reverse-proxy-linkerdviz.sh&quot;
f.destination = &quot;./reverse-proxy-linkerdviz.sh&quot;
end
## Execute configuration file
controller.vm.provision &quot;shell&quot; do |s|
s.inline = &quot;chmod +x ./reverse-proxy-linkerdviz.sh &amp;&amp; ./reverse-proxy-linkerdviz.sh&quot;
end
# Update controller source code to the desired branch
if ENV['BRANCH'] != nil
controller.vm.provision &quot;shell&quot; do |s|
s.inline = &quot;cd ./tfs-ctrl &amp;&amp; git pull &amp;&amp; git switch &quot; + ENV['BRANCH']
end
end
end
end
</code></pre>
<p>This Vagrantfile also allows for <strong>optional repository updates</strong> on startup by running the command with a specified environment variable <code>BRANCH</code></p>
<pre><code class="language-bash">BRANCH=develop vagrant up controller
</code></pre>
<h3><u>Linkerd DNS rebinding bypass</h3>
<p></u>
Because of Linkerd's security measures against DNS rebinding, a reverse proxy, that modifies the request's header <code>Host</code> field, is needed to expose the GUI to the host. The previous Vagrantfile already deploys such configurations, for that, all you need to do is create the <code>reverse-proxy-linkerdviz.sh</code> file in the same directory. The content of this file is displayed below.</p>
<pre><code class="language-bash"># Install NGINX
sudo apt update &amp;&amp; sudo apt install nginx -y
# NGINX reverse proxy configuration
echo 'server {
listen 8084;
location / {
proxy_pass http://127.0.0.1:50750;
proxy_set_header Host localhost;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}' &gt; /home/vagrant/expose-linkerd
# Create symlink of the NGINX configuration file
sudo ln -s /home/vagrant/expose-linkerd /etc/nginx/sites-enabled/
# Commit the reverse proxy configurations
sudo systemctl restart nginx
# Enable start on login
echo &quot;linkerd viz dashboard &amp;&quot; &gt;&gt; .profile
# Start dashboard
linkerd viz dashboard &amp;
echo &quot;Linkerd Viz dashboard running!&quot;
</code></pre>
<h2 id="12-install-microk8s"><strong>1.2. Install MicroK8s</strong></h2>
<p>This section describes how to deploy the MicroK8s Kubernetes platform and configure it to be used with ETSI TeraFlowSDN controller. Besides, Docker is installed to build docker images for the ETSI TeraFlowSDN controller.</p>
<p>The steps described in this section might take some minutes depending on your internet connection speed and the resources assigned to your VM, or the specifications of your physical server.</p>
......
public/develop/images/deployment_guide/01_vagrant_box.jpg

58.4 KiB

public/develop/images/deployment_guide/02_vagrant_box.jpg

20.6 KiB

public/develop/images/deployment_guide/03_vagrant_box.jpg

25.3 KiB

public/develop/images/deployment_guide/04_vagrant_box.jpg

28 KiB

public/develop/images/deployment_guide/05_vagrant_box.jpg

25.2 KiB

public/develop/images/deployment_guide/06_vagrant_box.jpg

24.9 KiB

public/develop/images/deployment_guide/07_vagrant_box.jpg

25.7 KiB

public/develop/images/deployment_guide/08_vagrant_box.jpg

24.4 KiB

This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment