Giter Site home page Giter Site logo

Build Status

Vmck

Vmck is a virtual machine service that runs QEMU and Docker images in a Nomad cluster.

It can be used as a provider for Vagrant:

vagrant plugin install vagrant-vmck
curl -OL https://github.com/mgax/vagrant-vmck/raw/master/example_box/Vagrantfile
vagrant up
vagrant ssh

And it has its own CLI:

pipenv run ./manage.py createjob
pipenv run ./manage.py ssh 1
pipenv run ./manage.py kill 1

Installation

Using docker

docker run --detach --restart always \
  --name cluster \
  --volume /opt/cluster/var:/opt/cluster/var \
  --volume /opt/vmck/var:/opt/vmck/var \
  --volume /var/run/docker.sock:/var/run/docker.sock:ro \
  --privileged \
  --net host \
  --env NOMAD_CLIENT_INTERFACE=wg0 \
  --env HOSTNAME=127.0.0.1 \
  --env SECRET_KEY=foo \
  mgax/vmck

Here you can add different --env options with arguments matching {root}/vmck/settings.py and {root}/vmck/base_settings.py to suit your preferences.

Then go to consul (http://localhost:8500/ui/dc1/services) and wait for the health check lights to turn green.

Running locally

  • Needs a Nomad instance alongside Consul(liquidinvestigations/cluster is easy to set-up and has both Nomad and Consul)
  • If you are using the above mentioned cluster you can skip this step if not add the following to your .env file:
SECRET_KEY=change_me
CONSUL_URL=your_consul_url
NOMAD_URL=your_nomad_url
  • By default the docker backend is selected. You can choose qemu by adding BACKEND=qemu to your .env file
  • Then install dependencies and run migrations:
pipenv install
pipenv run ./manage.py migrate
  • Then you can run the server:
pipenv run ./manage.py runserver

Running VMCK on your cluster

You need Nomad cluster with Consul. To start vmck in your Nomad cluster:

export NOMAD_URL='your_nomad_url' # skip this line if you are using liquidinvestigations/cluster
cd examples
./cluster.py

Now VMCK is a job in your Nomad cluster.

Qemu VM images

Now all images are built using vmck/image-builder. Please refer to it on how to build, provision and test your image.

Testing

Requirements

  • Nomad instance alongside Consul(liquidinvestigations/cluster is easy to set-up and has both Nomad and Consul)
  • If you are using the above mentioned cluster you can skip this step if not add the following to your .env file:
TESTING_CONSUL_URL=your_consul_url
TESTING_NOMAD_URL=your_nomad_url
  • By default the docker backend is selected. You can choose qemu by adding TESTING_BACKEND=qemu to your .env file

Docker backend

The docker backend uses vmck/mock as it's default image. The only way to change that is to modify {root}/vmck/backends/docker.py docker_vm_task.config.image. We do not recommend it as the docker backend is for testing purposes only. Check vmck/vagrant-vmck and Vagrant on how to provision, test and use the job that vmck will start.

Qemu backend

This requires a bit more configuration. Qemu images are retrieved through a nginx server. You need to have one. Here is an example of a .hcl job specification that you can use to start the server on your Nomad cluster. You need to set TESTING_QEMU_IMAGE_PATH_PREFIX in .env file to the url of your nginx server. To use the image of your choosing set image_path option in your POST request to the name of your desired image.

Doing tests

With a Nomad cluster up and running, run pipenv run pytest, and enjoy.

Troubleshooting

  • QEMU fails to start with error qemu-system-x86_64: Invalid host forwarding rule 'tcp:${attr.unique.network.ip-address}:10674-:22' (Bad host address): the host address has changed (e.g. because it moved to a different WiFi hotspot). Restart Nomad and it should pick up the new address.

vmck's Projects

aboutus icon aboutus

Weekly discussion and project roadmap

cluster icon cluster

Cluster - spin up Consul + Vault + Nomad + friends

mock icon mock

Mock docker image for vmck/vmck

vmck icon vmck

Web API for launching VMs on a cluster

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.