build/ script helps automating usage of docker build container using

Script usage

Currently the script supports the following commands:

  • ./build/ build
  • ./build/ test
  • ./build/ copy
  • ./build/ copy-dind
  • ./build/ start-dind
  • ./build/ vsh
  • ./build/ stop
  • ./build/ clean
  • ./build/ update-bindata
  • ./build/ update-generated-docs
  • ./build/ gotest [TEST_ARGS...]
  • ./build/ gobuild [BUILD_ARGS...]
  • ./build/ run CMD...
  • ./build/ release TAG
  • ./build/ serve-docs
  • ./build/ build-docs
  • ./build/ sync

build, test, integration, run, gobuild, gotest, copy, copy-back and prepare-vendor commands check whether the build container image and data volumes are available before proceeding. They build the image if necessary and create the data volumes if they don't exist, then, on each run they copy the local sources into virtlet_src data volume.

The build container used by build/ needs to be able to access Docker socket inside it. By default it mounts /var/run/docker.sock inside the container but you can override the path by setting DOCKER_SOCKET_PATH environment variable.


Performs a full build of Virtlet. Also builds mirantis/virtlet:latest image.


Runs the unit tests inside a build container.


Runs the integration tests. KVM is disabled for these so as to make them run inside limited CI environments that don't support kernel virtualization. You need to invoke build/ build before running this command.


Extracts output binaries from build container into _output/ in the current directory.


Syncs local _output_ contents to the build container. This is used by CI for passing build artifacts between the jobs in a workflow.


Copies the binaries into kube-node-1 of kubeadm-dind-cluster (or kube-master if VIRTLET_ON_MASTER environment variable is set to a non-empty value). You need to do up to be able to use this command.


Starts Virtlet on kube-node-1 of kubeadm-dind-cluster (or kube-master if VIRTLET_ON_MASTER environment variable is set to a non-empty value). You need to do up and build/ copy-dind to be able to use this command. This command copies locally-built mirantis/virtlet image to the DIND node that will run Virtlet if it doesn't exist there or if FORCE_UPDATE_IMAGE is set to a non-empty value. This command requires kubectl.


Makes all the worker nodes in the kubeadm-dind-cluster ready for Virtlet pod, but doesn't start Virtlet pod on them (it doesn't apply extraRuntime=virtlet label). This is done automatically for the Virtlet node during start-dind, but it's necessary to do so for all the worker nodes for Virtlet e2e config test to pass.


Starts an interactive shell using build container. Useful for debugging.


Removes the build container.


Removes the build container and image along with data volumes as well as the binaries in local _output directory.


Updates generated binary assets. Currently needed if you edit files under deploy/data directory.


Updates generated documentation (source markdown files). This currently includes virtletctl and config documentation.


Runs unit tests suite in build container - suitable for use with IDEs/editors.


Runs go build in the build container. This command can be used for syntax checking in IDEs/editors. It assumes that build command was invoked at least once since the last clean.


Runs the specified command inside the build container. This command can be used to debug the build scripts.


Populates vendor/ directory inside the build container. This is used by CI.


Starts the build container. This is done automatically by other build/ commands that need the build container.


Updates the generated bindata. Run this command if you modify anything under deploy/data.


Updates the generated Go files except for bindata. Run this command if you modify Virtlet CRD structs.


Runs Virtlet e2e tests against the currently running DIND cluster. You can also pass test options to this command:

build/ e2e -test.v

You can also pass Ginkgo options to this command, e.g. the following command will run only the tests that have Should have default route in their description:

build/ e2e -test.v -ginkgo.focus="Should have default route"

This command requires kubectl.

Virtlet e2e tests can produce JUnit-style XML output if asked to do so:

build/ e2e -test.v -junitOutput /tmp/junit.xml
build/ run 'cat /tmp/junit.xml' >junit.xml


Starts serving the MkDocs-built documentation on the port specified by MKDOCS_SERVE_ADDRESS environment variable (default 8042). In order to update the docs from the current Virtlet working copy, you need to run build/ sync.


Builds the documentation using MkDocs and puts the result into docs branch. The copy of MkDocs output is stored under _docs/ subdirectory of the working copy. The build is done only if the docs changed since they were last build and stored under gh-docs branch or if the current working copy is dirty (i.e. has uncommitted changes).


Synchronizes the working copy with the build container, starting the build container if it's not present. This command is handy with conjunction with build/

Control flags

Some of the script commands also be customized by using environment variables:

  • VIRTLET_SKIP_RSYNC=1 disables syncing of sources in the build docker container. If set, changes made to the sources on the host machine will not be included into the build.

  • VIRTLET_RSYNC_PORT=18730 - port to use for rsync.

  • VIRTLET_ON_MASTER=1 - start virtlet on the master (API) k8s node rather than on the worker.

  • DOCKER_SOCKET_PATH=/var/run/docker.sock - docker Unix socket path to mount into the build container.

  • DOCKER_HOST - docker server to be used in the build server (when it differs from the default Unix socket).

  • FORCE_UPDATE_IMAGE=1 - always propagate virtlet docker image from the host into DinD cluster (by default, it is done when no such image exist).

  • IMAGE_REGEXP_TRANSLATION=1 enables regexp syntax in image name translation rules. See Image Name Translation for more details.