|
| 1 | +# Basic usage |
| 2 | + |
| 3 | +This guide describes how to install and use Genesis Core on existing infrastructure. The existing infrastructure can be a local machine or several servers. |
| 4 | +It's assumed Linux(Ubuntu) is used as the OS on your machines. |
| 5 | + |
| 6 | +## Requirements |
| 7 | + |
| 8 | +Before you install and use genesis core you need to install several requirements: |
| 9 | + |
| 10 | +### Packages |
| 11 | + |
| 12 | +Install necessary packages: |
| 13 | + |
| 14 | +#### Ubuntu |
| 15 | + |
| 16 | +Install packages |
| 17 | + |
| 18 | +```bash |
| 19 | +sudo apt update |
| 20 | +sudo apt install qemu-kvm qemu-utils libvirt-daemon-system libvirt-dev mkisofs -y |
| 21 | +``` |
| 22 | + |
| 23 | +Add user to group |
| 24 | + |
| 25 | +```bash |
| 26 | +sudo adduser $USER libvirt |
| 27 | +sudo adduser $USER kvm |
| 28 | +``` |
| 29 | + |
| 30 | +### Libvirt |
| 31 | + |
| 32 | +Create a libvirt storage pool or use `default` if it already exists. |
| 33 | + |
| 34 | +Check pools: |
| 35 | + |
| 36 | +```bash |
| 37 | +sudo virsh pool-list --all |
| 38 | +``` |
| 39 | + |
| 40 | +Create a new pool if no one exists or you would like to use another one. |
| 41 | + |
| 42 | +```bash |
| 43 | +sudo virsh pool-define-as default dir --target "/var/lib/libvirt/images/" |
| 44 | +sudo virsh pool-build default |
| 45 | +sudo virsh pool-start default |
| 46 | +sudo virsh pool-autostart default |
| 47 | +``` |
| 48 | + |
| 49 | +Check the status with virsh-info: |
| 50 | + |
| 51 | +```bash |
| 52 | +sudo virsh pool-info default |
| 53 | +``` |
| 54 | + |
| 55 | +## Installation |
| 56 | + |
| 57 | +The simplest way to install Genesis Core is to get a prebuilt virtual machine image with all necessary dependencies. Take the the [latest image here](http://repository.genesis-core.tech:8081/genesis-core/latest/genesis-core.qcow2). |
| 58 | + |
| 59 | +### Local machine / Development |
| 60 | + |
| 61 | +Install Genesis DevTools first. For more information about it, see [Genesis DevTools](https://github.com/infraguys/genesis_devtools). The devtools allows to build and run the genesis core locally. Since we already downloaded the latest image, we don't need to build it from scratch but if you need to build an image from source look at the [instructions here](https://github.com/infraguys/genesis_devtools?tab=readme-ov-file#build). |
| 62 | + |
| 63 | +The devtools has `bootstrap` command that will start the Genesis Core locally. |
| 64 | + |
| 65 | +```bash |
| 66 | +genesis bootstrap -i genesis-core.raw -m core |
| 67 | +``` |
| 68 | + |
| 69 | +For more information about the `bootstrap` command, see [instructions here](https://github.com/infraguys/genesis_devtools?tab=readme-ov-file#bootstrap). |
| 70 | + |
| 71 | +The installation is ready at address `10.20.0.2` but at this time it's not very useful since it cannot run any workload. Let's add a local machine as a hypervisor to solve this problem. |
| 72 | + |
| 73 | +#### Get admin token |
| 74 | + |
| 75 | +Before we can add a hypervisor, we need to get an admin token. The command to get the token is: |
| 76 | + |
| 77 | +```bash |
| 78 | +curl --location 'http://10.20.0.2:11010/v1/iam/clients/00000000-0000-0000-0000-000000000000/actions/get_token/invoke' \ |
| 79 | + --header 'Content-Type: application/x-www-form-urlencoded' \ |
| 80 | + --data-urlencode 'grant_type=password' \ |
| 81 | + --data-urlencode 'username=<YOUR_ADMIN_USERNAME>' \ |
| 82 | + --data-urlencode 'password=<YOUR_ADMIN_PASSWORD>' \ |
| 83 | + --data-urlencode 'client_id=GenesisCoreClientId' \ |
| 84 | + --data-urlencode 'client_secret=GenesisCoreClientSecret' \ |
| 85 | + --data-urlencode 'scope=' \ |
| 86 | + --data-urlencode 'ttl=86400' |
| 87 | +``` |
| 88 | + |
| 89 | +The return value is `json` object with the `access_token` field. Copy the token and use it in the next steps. |
| 90 | + |
| 91 | +#### Add hypervisor |
| 92 | + |
| 93 | +##### Libvirt via SSH (preffered) |
| 94 | + |
| 95 | +Create key in genesis core's VM for root user: |
| 96 | + |
| 97 | +```console |
| 98 | +# ssh-keygen |
| 99 | +``` |
| 100 | + |
| 101 | +Copy public key to hypervisor (recommended user is `ubuntu`) |
| 102 | + |
| 103 | +##### Libvirt via TCP connect |
| 104 | + |
| 105 | +We need to get access to libvirt via a tcp connection. By default the tcp connection is closed, so we need to enable it. |
| 106 | + |
| 107 | +**NOTE:** For development purposes we can use raw tcp connection. Don't use it in production. |
| 108 | + |
| 109 | +Edit libvirt configuration file `/etc/libvirt/libvirtd.conf`, add these lines; |
| 110 | + |
| 111 | +```bash |
| 112 | +listen_tcp = 1 |
| 113 | +listen_addr = "0.0.0.0" |
| 114 | +auth_tcp = "none" |
| 115 | +``` |
| 116 | + |
| 117 | +Run commands to enable libvirt tcp connection: |
| 118 | + |
| 119 | +```bash |
| 120 | +sudo systemctl stop libvirtd |
| 121 | +sudo systemctl enable --now libvirtd-tcp.socket |
| 122 | +sudo systemctl start libvirtd |
| 123 | +``` |
| 124 | + |
| 125 | +Check the libvirt is listening the tcp socket: |
| 126 | + |
| 127 | +```bash |
| 128 | +sudo systemctl status libvirtd.service |
| 129 | +sudo systemctl status libvirtd.service | grep "libvirtd-tcp.socket" |
| 130 | +``` |
| 131 | + |
| 132 | +##### Configure ZFS for storage |
| 133 | + |
| 134 | +It's recommended to create distinct dataset for zvols: |
| 135 | + |
| 136 | +```bash |
| 137 | +zpool create rpool ... # create pool itself |
| 138 | +zfs create -o volmode=dev rpool/disks |
| 139 | +virsh pool-define-as --name rpool --source-name rpool/disks --type zfs |
| 140 | +virsh pool-start rpool |
| 141 | +virsh pool-autostart rpool |
| 142 | +``` |
| 143 | + |
| 144 | +##### Config hypervisor in core |
| 145 | + |
| 146 | +Add the machine as a hypervisor, replace `XXXX` with the token from the previous step.: |
| 147 | + |
| 148 | +```bash |
| 149 | +curl --location --globoff 'http://10.20.0.2:11010/v1/hypervisors/' \ |
| 150 | +--header 'Content-Type: application/json' \ |
| 151 | +--header 'Authorization: Bearer XXXX' \ |
| 152 | +--data '{ |
| 153 | + "driver_spec": { |
| 154 | + "driver": "libvirt", |
| 155 | + "iface_mtu": 1500, |
| 156 | + "network_type": "network", |
| 157 | + "network": "genesis-core-net", |
| 158 | + "storage_pool": "default", // for qcow |
| 159 | + "storage_pool": "rpool", // for ZFS |
| 160 | + "connection_uri": "qemu+tcp://10.20.0.1/system", // for TCP connect |
| 161 | + "connection_uri": "qemu+ssh://ubuntu@10.20.0.1:22/system?no_verify=1", // for SSH connect |
| 162 | + "machine_prefix": "dev-" |
| 163 | + }, |
| 164 | + "avail_cores": 4, |
| 165 | + "avail_ram": 4096, |
| 166 | + "all_cores": 4, |
| 167 | + "all_ram": 4096, |
| 168 | + "status": "ACTIVE" |
| 169 | +}' |
| 170 | +``` |
| 171 | + |
| 172 | +- storage_pool - name of the libvirt storage pool to use. |
| 173 | +- connection_uri - libvirt connection uri. If you need to add another machine use different ip address. |
| 174 | +- all_cores - total number of cores you would like to allocate to the hypervisor. |
| 175 | +- all_ram - total amount of ram you would like to allocate to the hypervisor. |
| 176 | +- avail_cores - use the same value as `all_cores`. |
| 177 | +- avail_ram - use the same value as `all_ram`. |
| 178 | + |
| 179 | +### Production |
| 180 | + |
| 181 | +The production installation guide will be added soon. |
| 182 | + |
| 183 | +## Usage |
| 184 | + |
| 185 | +Follow the [usage guide](https://github.com/infraguys/genesis_core/wiki/Usage) for more information. |
0 commit comments