Skip to content

Instantly share code, notes, and snippets.

@phoracek
Last active July 24, 2020 08:04
Show Gist options
  • Select an option

  • Save phoracek/8b67e795b9e57935a07d94e028d0dbf2 to your computer and use it in GitHub Desktop.

Select an option

Save phoracek/8b67e795b9e57935a07d94e028d0dbf2 to your computer and use it in GitHub Desktop.
Test KubeVirt with Calico.

Fetch KubeVirt sources:

git clone https://github.com/kubevirt/kubevirt
cd kubevirt

Bring up local virtualized Kubernetes 1.17 cluster with preinstalled Calico:

export KUBEVIRT_PROVIDER=k8s-1.17
make cluster-up

Install KubeVirt on the cluster:

make cluster-sync

Verify that Calico is present:

./cluster-up/kubectl.sh get pods -n kube-system | grep calico

Create two VMs connected to the primary network via masquerade binding:

cat <<EOF | ./cluster-up/kubectl.sh create -f -
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
  name: example1
spec:
  running: true
  template:
    spec:
      domain:
        devices:
          disks:
          - disk:
              bus: virtio
            name: containerdisk
          - disk:
              bus: virtio
            name: cloudinitdisk
          interfaces:
          - masquerade: {}
            name: default
        machine:
          type: ""
        resources:
          requests:
            memory: 1024M
      networks:
      - name: default
        pod: {}
      volumes:
      - containerDisk:
          image: kubevirt/fedora-cloud-container-disk-demo
        name: containerdisk
      - cloudInitNoCloud:
          userData: |-
            #cloud-config
            password: fedora
            chpasswd: { expire: False }
        name: cloudinitdisk
EOF
cat <<EOF | ./cluster-up/kubectl.sh create -f -
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
  name: example2
spec:
  running: true
  template:
    spec:
      domain:
        devices:
          disks:
          - disk:
              bus: virtio
            name: containerdisk
          - disk:
              bus: virtio
            name: cloudinitdisk
          interfaces:
          - masquerade: {}
            name: default
        machine:
          type: ""
        resources:
          requests:
            memory: 1024M
      networks:
      - name: default
        pod: {}
      volumes:
      - containerDisk:
          image: kubevirt/fedora-cloud-container-disk-demo
        name: containerdisk
      - cloudInitNoCloud:
          userData: |-
            #cloud-config
            password: fedora
            chpasswd: { expire: False }
        name: cloudinitdisk
EOF

Wait until both VMs turn Running and record their public IPs:

./cluster-up/kubectl.sh get vmis

Connect to one of the VMs (fedora:fedora):

./cluster-up/virtctl.sh console example1

Try to ping the other VM:

ping 10.244.196.150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment