|
| 1 | +# Local testing |
| 2 | + |
| 3 | +## Testing in multi-node kubernetes |
| 4 | + |
| 5 | +In the repository there is a Vagrantfile with connected minimalistic playbook, which creates 3 |
| 6 | +locally hosted libvirt virtual machines, installes a k3s-kubernetes within these instances, |
| 7 | +configures and installes ainari in there and runs the sdk-api-test against the setup. This |
| 8 | +test-setup doesn't require docker-hub. At the beginning of the setup it build docker-images from the |
| 9 | +local source code and pushes these local images direcly into the k3s-kubernetes without any |
| 10 | +additional registry and also uses the local helm chart for the deployment within the kubernetes. |
| 11 | +That way the code, dockerfiles, helm-charts and sdk-lib are tested in single automated workflow in a |
| 12 | +virtual multi-node environment. |
| 13 | + |
| 14 | +### Minimal Requirements |
| 15 | + |
| 16 | +- **CPU**: 8 threads (better 16 threads to avoid cpu-overcommit) |
| 17 | +- **Memory**: 14 GiB |
| 18 | + |
| 19 | +### Installation |
| 20 | + |
| 21 | +This installation uses Vagrant with libvirt as provider to deploy the virtual machines. |
| 22 | + |
| 23 | +- Install apt-packages necessary for libvirt and the libvirt-provider |
| 24 | + |
| 25 | + ```bash |
| 26 | + sudo apt update |
| 27 | + sudo apt install -y \ |
| 28 | + qemu-kvm \ |
| 29 | + libvirt-daemon-system \ |
| 30 | + libvirt-clients \ |
| 31 | + virtinst \ |
| 32 | + bridge-utils \ |
| 33 | + cpu-checker |
| 34 | + build-essential \ |
| 35 | + ruby-dev \ |
| 36 | + pkg-config \ |
| 37 | + libvirt-dev \ |
| 38 | + libxml2-dev \ |
| 39 | + libxslt-dev \ |
| 40 | + zlib1g-dev \ |
| 41 | + rsync |
| 42 | + ``` |
| 43 | + |
| 44 | +- Enable and start libvirt: |
| 45 | + |
| 46 | + ```bash |
| 47 | + sudo systemctl enable --now libvirtd |
| 48 | + ``` |
| 49 | + |
| 50 | +- So you don’t need sudo every time |
| 51 | + |
| 52 | + ```bash |
| 53 | + sudo usermod -aG libvirt,kvm $USER |
| 54 | + ``` |
| 55 | + |
| 56 | + ( after this you have to logout and login again ) |
| 57 | + |
| 58 | +- Install the libvirt provider plugin |
| 59 | + |
| 60 | + ```bash |
| 61 | + vagrant plugin install vagrant-libvirt |
| 62 | + ``` |
| 63 | + |
| 64 | +- Update `/etc/hosts` by adding the content |
| 65 | + |
| 66 | + ```plain |
| 67 | + 192.168.56.10 local-vagrant-hanami |
| 68 | + 192.168.56.10 local-vagrant-miko |
| 69 | + 192.168.56.10 local-vagrant-ryokan |
| 70 | + 192.168.56.10 local-vagrant-sakura |
| 71 | + 192.168.56.10 local-vagrant-torii |
| 72 | + 192.168.56.10 local-vagrant-omamori |
| 73 | + 192.168.56.10 local-vagrant-onsen |
| 74 | + 192.168.56.10 local-vagrant-ainari |
| 75 | + ``` |
| 76 | + |
| 77 | +- Install local ansible required to execute the playbook |
| 78 | + |
| 79 | + ```bash |
| 80 | + python3 -m venv venv |
| 81 | + source venv/bin/activate |
| 82 | + pip3 install ansible |
| 83 | + ``` |
| 84 | + |
| 85 | +### Usage |
| 86 | + |
| 87 | +#### Vagrant-actions: |
| 88 | + |
| 89 | +- create a complete new test-installation |
| 90 | + |
| 91 | + `vagrant up` |
| 92 | + |
| 93 | +- in case a run failed and you want to run it again or with updated playbooks against the same |
| 94 | + already existing vagrant environment |
| 95 | + |
| 96 | + `vagrant provision` |
| 97 | + |
| 98 | +- ssh into server of the virtual machines |
| 99 | + |
| 100 | + `vagrant ssh server` |
| 101 | + |
| 102 | + with this you will enter the machine with the kubernetes api. It is only a minimalistic shell, so |
| 103 | + run `/bin/bash` at first in there to get a real bash shell. There you can also run `kubectl` and |
| 104 | + `helm` commands. |
| 105 | + |
| 106 | +- delete previous vagrant environment |
| 107 | + |
| 108 | + `vagrant destroy -f` |
| 109 | + |
| 110 | +#### access the dashboard |
| 111 | + |
| 112 | +After a finished `vagrant up`, enter the address `https://local-vagrant-ainari` into your browser |
| 113 | +and you should see the dashboard |
| 114 | + |
| 115 | +Login: |
| 116 | + |
| 117 | +- **user**: `asdf` |
| 118 | +- **password**: `asdfasdf` |
0 commit comments