Skip to content

Commit

Permalink
start adding QEMU
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Roby committed Oct 9, 2023
1 parent 76ad692 commit b628a6c
Show file tree
Hide file tree
Showing 13 changed files with 680 additions and 197 deletions.
55 changes: 20 additions & 35 deletions docs/12-self-hosting/01-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,33 @@ This guide is tested on devics which meet the following requirements:
:::info Support for GPU-acceleration within containerized environments is limited to Nvidia hardware
only at this time. :::

## Host Creation Methods
## Host Creation Guides

### 1. Bare-Metal (Easiest)
"Host Creation" in this context is the process for installing an operating system onto a piece of
physical (also called "Bare Metal") or virtualized hardware. Instructions for installation on OS on
a bare-metal host and guides for creating virtual machines can be found in the
[Host Creation](./02-host-creation/01-overview.mdx) directory.

"Bare Metal" means that your host OS is running directly on a piece of hardware without any
virtulization. This reduces the complexity of deploymnet at the cost of increased time and effort
for re-provisioning the host. The following guides will walk you through the installation process on
a bare-metal host.
## Host Provisioning Guides

- Install Ubuntu 22.04 on a local machine
- Install Debian 12 on a local machine
"Provisioning" here refers to the process of installing additional resources onto, and the
configuration of your host beyond installing the base operating-system. Once you can sign into your
VM or Bare-Metal host, follow the appropriate guide to complete the provisioning process.

### 2. Virtual Machines (Intermediate)
- [Ubuntu 22.04 Setup](./03-host-provisioning/02-ubuntu-setup.mdx)

Virtual Machines are a software-defined layer of abstraction atop a Bare-Metal host which makes
deployments more consistent and easier to manage declaratively. This greaty reduces the difficulty
of re-deployment and creates the conditions required for securely running multiple guests within the
same physical host. Virtual Machines can also be used to create hosts that run different operating
systems (Windows, MacOS) or architectures (ARM) than the host machines. This added functionality
comes at the cost of added complexity, a slight performance penalty, and you need to already have a
Bare-Metal host on which to run the VMs.
- [Debian 12 Setup](./03-host-provisioning/01-debian-setup.mdx)

## Runner Application Installation

- Basic Virtual Machine creation with Multipass
- Advanced Virtual Machine creation with QEMU
Once your host has been provisioned, you will then need to install the appropriate runner
application. The guides below will walk you through that process.

### 3. Cloud-Init (Advanced)
- [Github Actions](./04-runner-application-installation/02-github-actions.mdx)

- [GitLab Pipelines](./04-runner-application-installation/01-gitlab-pipelines.mdx)

## Declarative workflow using Cloud-Init (Advanced)

Cloud-Init is a software package that automates the initialization of cloud instances during system
boot and has become the industry standard solution for operating system customization. Cloud-Init is
Expand All @@ -80,19 +81,3 @@ bare-metal systems running Ubuntu.
[PXEless](https://github.com/cloudymax/pxeless)
- Using cloud-init with Multipass for automated provisioning
- Use your cloud-init config to deploy VMs in the cloud

## Host Provisioning Methods

"Provisioning" here refers to the process of installing additional resources onto, and the
configuration of your host beyond installing the base operating-system. Once you can sign into your
VM or Bare-Metal host, follow the appropriate guide to complete the provisioning process.

- [Ubuntu 22.04 Setup](./ubuntu-setup)

- [Debian 12 Setup](./debian-setup)

## Runner Application Installation

- [Github Actions](./github-actions)

- [GitLab Pipelines](./gitlab-pipelines)
19 changes: 19 additions & 0 deletions docs/12-self-hosting/02-host-creation/01-overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Overview

## Types of Hosts

1. Bare-Metal

"Bare Metal" means that your host OS is running directly on a piece of hardware without any
virtulization. This reduces the complexity of deploymnet at the cost of increased time and effort
for re-provisioning the host.

2. Virtual Machines

Virtual Machines are a software-defined layer of abstraction atop a Bare-Metal host which makes
deployments more consistent and easier to manage declaratively. This greaty reduces the difficulty
of re-deployment and creates the conditions required for securely running multiple guests within the
same physical host. Virtual Machines can also be used to create hosts that run different operating
systems (Windows, MacOS) or architectures (ARM) than the host machine. This added functionality
comes at the cost of added complexity, a slight performance penalty, and you need to already have a
Bare-Metal host on which to run the VMs.
143 changes: 143 additions & 0 deletions docs/12-self-hosting/02-host-creation/02-multipass.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
toc_max_heading_level: 4
---

# Multipass

:::info Multipass only creates Ubuntu VMs :::

Multipass is a light-weight Virtual Machine Manager for Linux, Windows and MacOS. It's designed for
developers who want to quickly create a fresh Ubuntu environment with a single command. It uses the
native hypervisor for whichever platform it is installed on (KVM on Linux, Hyper-V on Windows and
HyperKit on MacOS) to run VMs with minimal overhead. It can also use VirtualBox on Windows and
MacOS.

- [Official Webite](https://multipass.run/)
- [Official Github Repo](https://github.com/canonical/multipass)

## installation

To install multipass on Linux use the commands below.

```bash
sudo apt-get install snapd
sudo snap install core
sudo snap install multipass
```

For installation on Windows and MacOS, refer to the official installation instructions:

- [How to install Multipass on Windows](https://multipass.run/docs/installing-on-windows)
- [How to install Multipass on macOS](https://multipass.run/docs/installing-on-macos)

## Creating a VM

1. Set values

```bash
# The name of the Virtual Machine
export VM_NAME="gameci"

# The name of the user to create
export VM_USER="vmadmin"

# Number of CPU cores to allocate to the VM
export VM_CPUS="2"

# Amount of Disk Space to allocate to the VM.
# Cannot exceed available on host.
export VM_DISK="32G"

# Amount of RAM to allocate to the VM.
# Cannot exceed available RAM on host.
export VM_MEM="8G"

# Set path on MacOS systems
export PATH="$PATH:/usr/local/bin/multipass"

# Set path on Linux system
export PATH="$PATH:/usr/local/bin/multipass"
```

2. Create an ssh-key for authenticating with the VM

```bash
ssh-keygen -C $VM_USER -f runner
```

3. Add the public ssh-key to a cloud-init file

See the [cloud init](https://cloudinit.readthedocs.io/en/latest/topics/examples.html) docs for more
examples.

```bash
VM_KEY=$(cat runner.pub)

cat << EOF > cloud-init.yaml
#cloud-config
groups:
- docker
users:
- default
- name: ${VM_USER}
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
groups: docker, admin, sudo, users
no_ssh_fingerprints: true
ssh-authorized-keys:
- ${VM_KEY}
packages:
- docker.io
runcmd:
- [ sed , -i , "s/#PermitRootLogin prohibit-password/PermitRootLogin no/g" , /etc/ssh/sshd_config ]
EOF
```

4. Start the VM

See the [multipass launch](https://multipass.run/docs/launch-command) command docs for more
information.

```bash
export VERBOSITY="-vvvvvv"

/snap/bin/multipass launch --name $VM_NAME \
--cpus $VM_CPUS \
--disk $VM_DISK \
--mem $VM_MEM \
--cloud-init cloud-init.yaml \
$VERBOSITY
```

4. Get the VM's IP address

```bash
VM_IP=$(/snap/bin/multipass list |grep "${VM_NAME}" |awk '{print $3}')
```

5. Connect to the VM via ssh or cli

ssh:

```bash
ssh -i runner $VM_USER@$VM_IP -o StrictHostKeyChecking=no -vvvv
```

CLI:

```bash
multipass shell $VM_NAME
```

6. Install the runner application using one of the guides below:

- [Github Actions](../04-runner-application-installation/02-github-actions.mdx)
- [Gitlab Pipelines](../04-runner-application-installation/01-gitlab-pipelines.mdx)

7. Cleanup when finished

```bash
/snap/bin/multipass stop $VM_NAME
/snap/bin/multipass delete $VM_NAME
/snap/bin/multipass purge
```
142 changes: 0 additions & 142 deletions docs/12-self-hosting/02-host-creation/02-virtual-machines-basic.mdx

This file was deleted.

Loading

0 comments on commit b628a6c

Please sign in to comment.