Deploying Virtlet as a DaemonSet on kubeadm-dind-cluster

The steps described here are performed automatically by script.

  1. Start kubeadm-dind-cluster with Kubernetes version 1.12 (you're not required to download it to your home directory). The cluster script stores appropriate kubectl version in ~/.kubeadm-dind-cluster.

    wget -O ~/ \
    chmod +x ~/
    ~/ up
    export PATH="$HOME/.kubeadm-dind-cluster:$PATH"
  2. Label a node to accept Virtlet pod:

    kubectl label node kube-node-1 extraRuntime=virtlet
  3. Make several mounts shared inside the dind node that will run Virtlet:

    for p in /dind /dev /boot /sys/fs/cgroup; do
      docker exec kube-node-1 mount --make-shared $p
  4. Add virtlet image translation configmap:

    kubectl create configmap -n kube-system virtlet-image-translations \
      --from-file images.yaml
  5. Install CRI proxy on the node:

    docker exec kube-node-1 /bin/bash -c \
      "curl -sSL '${CRIPROXY_DEB_URL}' >/criproxy.deb && dpkg -i /criproxy.deb && rm /criproxy.deb"
  6. Download virtletctl binary for virtlet release you need (replace N.N.N in the command below accordingly). You can also use virtletctl from Virtlet image, see below.

    # for Linux
    curl -SL -o virtletctl \
    chmod +x virtletctl
    # for Mac OS X
    curl -SL -o virtletctl \
    chmod +x virtletctl
  7. Deploy Virtlet DaemonSet and related objects:

    ./virtletctl gen | kubectl apply -f -
    # or using latest Virtlet image:
    # (you can replace both occurences of 'latest' with an image tag you need)
    docker run --rm mirantis/virtlet:latest virtletctl gen --tag latest | kubectl apply -f -
  8. Wait for Virtlet pod to activate:

    kubectl get pods -w -n kube-system
  9. Go to examples/ directory and follow the instructions from there.

Configuring Virtlet

Virtlet can be customized through the virtlet-config ConfigMap Kuberenetes object. The following keys in the config map are honored by Virtlet when it's deployed using k8s yaml produced by virtletctl gen:

  • disable_kvm - disables KVM support and forces QEMU instead. Use "1" as a value.
  • download_protocol - default image download protocol - either http or https. The default is https.
  • loglevel - integer log level value for the virtlet written as a string (e.g. "3", "2", "1").
  • calico-subnet - netmask width for the Calico CNI. Default is "24".
  • image_regexp_translation - enables regexp syntax for the image name translation rules.
  • disable_logging - disables log streaming from VMs. Use "1" to disable.

It's also possible to set per-node configuration for Virtlet using CRDs.

Removing Virtlet

In order to remove Virtlet, first you need to delete all the VM pods.

You can remove Virtlet DaemonSet with the following command:

kubectl delete daemonset -R -n kube-system virtlet

After that you can remove CRI Proxy if you're not going to use the node for Virtlet again by undoing the steps you made to install it (see CRI Proxy documentation).