diff --git a/Documentation/dev/libvirt-howto.md b/Documentation/dev/libvirt-howto.md index 82539eb80bf..e79fe453a13 100644 --- a/Documentation/dev/libvirt-howto.md +++ b/Documentation/dev/libvirt-howto.md @@ -7,16 +7,44 @@ for operator development. ### 1. One-time setup It's expected that you will create and destroy clusters often in the course of development. These steps only need to be run once (or once per RHCOS update). -#### 1.1 Pick a name and ip range +#### 1.1 Install Dependencies and Enable Libvirt +First install some dependencies needed to complete these instructions and then +enable the libvirt daemon. + +```sh +sudo dnf copr enable vbatts/bazel +sudo dnf install bazel golang-bin gcc-c++ libvirt-daemon +sudo systemctl start libvirtd +sudo systemctl enable libvirtd +``` + +Check to see if a default storage pool has been defined in Libvirt by running +`sudo virsh pool-list`. If it does not exist, create it: + +```sh +sudo virsh pool-define /dev/stdin < + default + + /var/lib/libvirt/images + + +EOF + +sudo virsh pool-start default +sudo virsh pool-autostart default +``` + +#### 1.2 Pick a name and ip range In this example, we'll set the baseDomain to `tt.testing`, the name to `test1` and the ipRange to `192.168.124.0/24` -#### 1.2 Clone the repo +#### 1.3 Clone the repo ```sh git clone https://github.com/openshift/installer.git cd installer ``` -#### 1.3 (Optional) Download and prepare the operating system image +#### 1.4 (Optional) Download and prepare the operating system image *By default, the installer will download the latest RHCOS image every time it is invoked. This may be problematic for users who create a large number of clusters or who have limited network bandwidth. The installer allows a local image to be used instead.* @@ -27,10 +55,10 @@ wget http://aos-ostree.rhev-ci-vms.eng.rdu2.redhat.com/rhcos/images/cloud/latest gunzip rhcos-qemu.qcow2.gz ``` -#### 1.4 Get a pull secret +#### 1.5 Get a pull secret Go to https://account.coreos.com/ and obtain a Tectonic *pull secret*. -#### 1.5 Make sure you have permisions for `qemu:///system` +#### 1.6 Make sure you have permisions for `qemu:///system` You may want to grant yourself permissions to use libvirt as a non-root user. You could allow all users in the wheel group by doing the following: ```sh cat <> /etc/polkit-1/rules.d/80-libvirt.rules @@ -42,7 +70,7 @@ polkit.addRule(function(action, subject) { EOF ``` -#### 1.6 Configure libvirt to accept TCP connections +#### 1.7 Configure libvirt to accept TCP connections The Kubernetes [cluster-api](https://github.com/kubernetes-sigs/cluster-api) components drive deployment of worker machines. The libvirt cluster-api @@ -112,9 +140,10 @@ sudo firewall-cmd --zone=FedoraWorkstation --list-sources NOTE: When the firewall rules are no longer needed, `sudo firewalld-cmd --reload` will remove the changes made as they were not permanently added. For persistence, -include the `--permanent` to the commands that add-source and add-port. +add `--permanent` to the commands that add-source and add-port and run them a +second time. -#### 1.7 Prepare the configuration file +#### 1.8 Prepare the configuration file 1. `cp examples/libvirt.yaml ./` 2. Edit the configuration file: 1. Set an email and password in the `admin` section @@ -123,9 +152,9 @@ include the `--permanent` to the commands that add-source and add-port. 4. Set the `name` (e.g. test1) 5. Look at the `podCIDR` and `serviceCIDR` fields in the `networking` section. Make sure they don't conflict with anything important. 6. Set the `pullSecret` to your JSON pull secret. - 7. (Optional) Change the `image` to the file URL of the operating system image you downloaded (e.g. `file:///home/user/Downloads/rhcos.qcow`). This will allow the installer to re-use that image instead of having to download it every time. + 7. (Optional) Change the `image` to the file URL of the operating system image you downloaded (e.g. `file:///home/user/Downloads/rhcos-qemu.qcow2`). This will allow the installer to re-use that image instead of having to download it every time. -#### 1.8 Set up NetworkManager DNS overlay +#### 1.9 Set up NetworkManager DNS overlay This step is optional, but useful for being able to resolve cluster-internal hostnames from your host. 1. Edit `/etc/NetworkManager/NetworkManager.conf` and set `dns=dnsmasq` in section `[main]` 2. Tell dnsmasq to use your cluster. The syntax is `server=//`. For this example: @@ -134,7 +163,7 @@ echo server=/tt.testing/192.168.124.1 | sudo tee /etc/NetworkManager/dnsmasq.d/t ``` 3. `systemctl restart NetworkManager` -#### 1.9 Install the terraform provider +#### 1.10 Install the terraform provider 1. Make sure you have the `virsh` binary installed: `sudo dnf install libvirt-client libvirt-devel` 2. Install the libvirt terraform provider: ```sh @@ -163,7 +192,7 @@ alias tectonic="${PWD}/tectonic-dev/installer/tectonic" Initialize (the environment variables are a convenience): ```sh -tectonic init --config=../libvirt.yaml +tectonic init --config=libvirt.yaml export CLUSTER_NAME= export BASE_DOMAIN= ```