This is a super basic repo that creates a VM based on Fedora 35 for development of the stackrox collector.
Some people might argue Docker Desktop to be a simpler solution, I just like having my own VMs.
The repo is based around Vagrantfile and the provision.yml file. You will
need to install both vagrant as
well as a VM client , I use virtualbox,
but the main Fedora image being used also supports libvirt. ansible is also
required in your host, so go over to Installing Ansible
and get it setup.
Running vagrant up fedora in the root of the directory will download and spin
up the Fedora 35 VM. Once it's done, the provision.yml playbook will be
executed and you will have docker and k3s installed in them,
congratulations!
Easiest way to access the docker instance running in the VM is to install the
docker CLI on your host and create a context for it to SSH into the VM on its
own. First, run vagrant ssh-config to get the ssh configuration for your VM
and paste it into ~/.ssh/config, you could also just:
vagrant ssh-config >> ~/.ssh/configRun the following commands from inside the root of this repository in the host:
docker context create collector-devenv --description "Context used for collector development" --docker host=ssh://vagrant@fedora
docker context use collector-devenvIf all went well, close the ssh session and run docker ps on the host, you
should be greeted with something looking like this:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESYou can find the configuration for accessing the cluster under
/etc/rancher/k3s/k3s.yaml, I would advice you copy that file somewhere like
~/.kube/k3s.yaml. Once copied, edit the line defining the server to use the
public IP of your VM:
- cluster:
server: https://192.168.56.10:6443You can then access the cluster by doing something like this:
$ export KUBECONFIG=~/.kube/k3s.yaml
$ kubectl get node
NAME STATUS ROLES AGE VERSION
fedora Ready control-plane,master 19h v1.23.6+k3s1Right now the only VM I'm supporting is the Fedora one, but if you wanted to
use something like Ubuntu, copying the vagrant configuration and changing to
use something like the ubuntu/focal64 box should kinda work, though some
tinkering with the provisioning playbook may be required.
If you find it a little annoying to always have to go back to the directory
were the Vagrantfile is stored, consider adding an alias to always run
vagrant from that same place:
alias beggar="VAGRANT_CWD=<path-to-repo> vagrant"