Difference between revisions of "Virtual Machine Management"

From CSLabsWiki
(Such ancient, very remove.)
(New instructions)
Line 1: Line 1:
  +
There are two possible things you want to do. Create a new virtual machine instance on the existing infrastructure ("spinning up a vm") or create a new base image suitable for use with the infrastructure.
Please document how to create a new VM here.
 
  +
  +
== Spinning up a VM ==
  +
  +
TODO
  +
  +
== Creating a new base image ==
  +
  +
To the largest extent possible, we use [[ansible]] to manage service configuration and machine bringup. Because ansible does all of the necessary configuration, the base images should be as stock as possible.
  +
  +
=== Creating a VM Environment ===
  +
  +
The easiest way to use virtualization on Linux is with virt-manager. On Ubuntu, follow [https://help.ubuntu.com/community/KVM/VirtManager]. It is packaged on most distros. Make sure to check your distro's documentation, as you likely need to add yourself to a certain group to get permissions to manage virtual machines. Download a setup ISO for the distro you are creating a base image for. Here's some screenshots of the steps to follow.
  +
  +
[[File:Virtual_Machine_Manager_003.png]]
  +
  +
[[File:New_VM_004.png]]
  +
  +
[[File:New_VM_005.png]
  +
  +
Select "browse local" and find the ISO you're using.
  +
  +
[[File:Locate_ISO_media_volume_007.png]]
  +
  +
[[File:New_VM_008.png]]
  +
  +
The settings you use here don't particularly matter, since only the resulting disk image will be used.
  +
  +
[[File:New_VM_009.png]]
  +
  +
Select 16GiB, which is our default base disk size.
  +
  +
[[File:New_VM_010.png]]
  +
  +
Click "finish"
  +
  +
=== Installing and Configuring Debian ===
  +
  +
Boot the new VM, and select "install".
  +
  +
[[File:VM_012.png]]
  +
  +
Select the locale.
  +
  +
[[File:VM_014.png]]
  +
  +
[[File:VM_015.png]]
  +
  +
[[File:VM_016.png]]
  +
  +
Wait...
  +
  +
[[File:VM_017.png]]
  +
  +
The default hostname is fine, Ansible will change it when necessary.
  +
  +
[[File:VM_018.png]]
  +
  +
Leave this empty.
  +
  +
[[File:VM_019.png]]
  +
  +
Enter the COSI Default Root Password.
  +
  +
[[File:VM_020.png]]
  +
  +
[[File:VM_021.png]]
  +
  +
Create the ansible user.
  +
  +
[[File:VM_022.png]]
  +
  +
[[File:VM_023.png]]
  +
  +
Use cspassword.
  +
  +
[[File:VM_024.png]]
  +
  +
[[File:VM_025.png]]
  +
  +
The defaults here are fine.
  +
  +
[[File:VM_026.png]]
  +
  +
[[File:VM_027.png]]
  +
  +
[[File:VM_028.png]]
  +
  +
[[File:VM_029.png]]
  +
  +
Finish partitioning.
  +
  +
[[File:VM_030.png]]
  +
  +
Write changes.
  +
  +
[[File:VM_031.png]]
  +
  +
Wait...
  +
  +
[[File:VM_032.png]]
  +
  +
Chose US.
  +
  +
[[File:VM_033.png]]
  +
  +
Chose the default.
  +
  +
[[File:VM_034.png]]
  +
  +
No proxy.
  +
  +
[[File:VM_035.png]]
  +
  +
Don't participte in the popularity contest.
  +
  +
[[File:VM_036.png]]
  +
  +
Use the arrow keys and spacebar to deselect everything and select SSH server, then continue.
  +
  +
[[File:VM_039.png]]
  +
  +
Use the defaults for GRUB.
  +
  +
[[File:VM_040.png]]
  +
  +
[[File:VM_041.png]]
  +
  +
Wait...
  +
  +
[[File:VM_042.png]]
  +
  +
Installation complete!
  +
  +
[[File:VM_043.png]]
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
Now that installation is complete, some additional setup is needed. Log in as root.
  +
  +
<pre>
  +
apt install ca-certificates sudo
  +
gpasswd -a ansible sudo
  +
systemctl enable getty@ttyS0
  +
su ansible
  +
mkdir .ssh
  +
cd .ssh
  +
wget https://raw.githubusercontent.com/COSI-Lab/ansible/master/authorized_keys
  +
</pre>
  +
  +
The first command installs TLS certificates (needed for the later wget) and sudo (so the ansible user can elevate permissions). The third command enables a login console on the ttyS0 device, which will be used for 'virsh console' later. The rest is setting up ansible's public key for configuration when a new VM is spinned up from this image.

Revision as of 16:25, 18 July 2015

There are two possible things you want to do. Create a new virtual machine instance on the existing infrastructure ("spinning up a vm") or create a new base image suitable for use with the infrastructure.

Spinning up a VM

TODO

Creating a new base image

To the largest extent possible, we use ansible to manage service configuration and machine bringup. Because ansible does all of the necessary configuration, the base images should be as stock as possible.

Creating a VM Environment

The easiest way to use virtualization on Linux is with virt-manager. On Ubuntu, follow [1]. It is packaged on most distros. Make sure to check your distro's documentation, as you likely need to add yourself to a certain group to get permissions to manage virtual machines. Download a setup ISO for the distro you are creating a base image for. Here's some screenshots of the steps to follow.

Virtual Machine Manager 003.png

New VM 004.png

[[File:New_VM_005.png]

Select "browse local" and find the ISO you're using.

Locate ISO media volume 007.png

New VM 008.png

The settings you use here don't particularly matter, since only the resulting disk image will be used.

New VM 009.png

Select 16GiB, which is our default base disk size.

New VM 010.png

Click "finish"

Installing and Configuring Debian

Boot the new VM, and select "install".

VM 012.png

Select the locale.

VM 014.png

VM 015.png

VM 016.png

Wait...

VM 017.png

The default hostname is fine, Ansible will change it when necessary.

VM 018.png

Leave this empty.

VM 019.png

Enter the COSI Default Root Password.

VM 020.png

VM 021.png

Create the ansible user.

VM 022.png

VM 023.png

Use cspassword.

VM 024.png

VM 025.png

The defaults here are fine.

VM 026.png

VM 027.png

VM 028.png

VM 029.png

Finish partitioning.

VM 030.png

Write changes.

VM 031.png

Wait...

VM 032.png

Chose US.

VM 033.png

Chose the default.

VM 034.png

No proxy.

VM 035.png

Don't participte in the popularity contest.

VM 036.png

Use the arrow keys and spacebar to deselect everything and select SSH server, then continue.

VM 039.png

Use the defaults for GRUB.

VM 040.png

VM 041.png

Wait...

VM 042.png

Installation complete!

VM 043.png









Now that installation is complete, some additional setup is needed. Log in as root.

apt install ca-certificates sudo
gpasswd -a ansible sudo
systemctl enable getty@ttyS0
su ansible
mkdir .ssh
cd .ssh
wget https://raw.githubusercontent.com/COSI-Lab/ansible/master/authorized_keys

The first command installs TLS certificates (needed for the later wget) and sudo (so the ansible user can elevate permissions). The third command enables a login console on the ttyS0 device, which will be used for 'virsh console' later. The rest is setting up ansible's public key for configuration when a new VM is spinned up from this image.