Skip to content

Instantly share code, notes, and snippets.

@Tedezed
Last active July 9, 2019 13:57
Show Gist options
  • Save Tedezed/3c19eccaef22b7edb2d00db16adec213 to your computer and use it in GitHub Desktop.
Save Tedezed/3c19eccaef22b7edb2d00db16adec213 to your computer and use it in GitHub Desktop.
Install minikube Kubevirt Ubuntu 16
rm -rf ~/.minikube \
&& minikube delete -p kubevirt \
&& minikube config -p kubevirt set cpus 4 \
&& minikube config -p kubevirt set memory 8192 \
&& minikube config -p kubevirt set vm-driver kvm2 \
&& minikube delete

curl -LO https://storage.googleapis.com/minikube/releases/v0.30.0/docker-machine-driver-kvm2
chmod +x docker-machine-driver-kvm2
sudo mv docker-machine-driver-kvm2 /usr/local/bin/

minikube start -p kubevirt --vm-driver kvm2

export KUBEVIRT_VERSION="v0.18.0"
export KUBEVIRT_VERSION=$(curl -s https://api.github.com/repos/kubevirt/kubevirt/releases|grep tag_name|sort -V | tail -1 | awk -F':' '{print $2}' | sed 's/,//' | xargs)
echo $KUBEVIRT_VERSION

kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-operator.yaml

minikube ssh -p kubevirt "egrep 'svm|vmx' /proc/cpuinfo"
kubectl create configmap kubevirt-config -n kubevirt --from-literal debug.useEmulation=true

kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-cr.yaml

curl -L -o virtctl https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/virtctl-${KUBEVIRT_VERSION}-linux-amd64
chmod +x virtctl && sudo cp virtctl /bin

cat <<EOF | kubectl apply -f -
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
  name: debian
spec:
  running: false
  template:
    metadata:
      labels: 
        kubevirt.io/size: small
        kubevirt.io/domain: debian
    spec:
      domain:
        cpu:
          cores: 2
        devices:
          disks:
            - name: containervolume
              disk:
                bus: virtio
            - name: cloudinitvolume
              disk:
                bus: virtio
          interfaces:
          - name: default
            bridge: {}
        resources:
          requests:
            memory: 1024M
      networks:
      - name: default
        pod: {}
      volumes:
        - name: containervolume
          containerDisk:
            image: tedezed/debian-container-disk:10.0
        - name: cloudinitvolume
          cloudInitNoCloud:
            userData: |-
              #cloud-config
              chpasswd:
                list: |
                  debian:debian
                  root:toor
                expire: False
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment