diff --git a/kubernetes/test-infra/minikube-on-packet/10-install-kvm.sh b/kubernetes/test-infra/minikube-on-packet/10-install-kvm.sh new file mode 100644 index 0000000000..ca870b7fd7 --- /dev/null +++ b/kubernetes/test-infra/minikube-on-packet/10-install-kvm.sh @@ -0,0 +1,16 @@ +#!/usr/bin/bash + +yum install -y curl yum-utils libvirt qemu-kvm virt-install libguestfs-tools libvirt-client qemu-kvm-tools + +systemctl enable libvirtd.service +systemctl restart libvirtd.service + +# Install docker-machine +curl -Lo docker-machine https://github.com/docker/machine/releases/download/v0.15.0/docker-machine-Linux-x86_64 +chmod +x docker-machine +cp -f docker-machine /usr/local/bin/ + +# Install KVM2 driver for docker-machine +curl -Lo docker-machine-driver-kvm2 https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2 +chmod +x docker-machine-driver-kvm2 +cp -f docker-machine-driver-kvm2 /usr/local/bin/ diff --git a/kubernetes/test-infra/minikube-on-packet/10-install-virtualbox.sh b/kubernetes/test-infra/minikube-on-packet/10-install-virtualbox.sh deleted file mode 100644 index 943fc80bd8..0000000000 --- a/kubernetes/test-infra/minikube-on-packet/10-install-virtualbox.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Add CentOS ol7_addons repo with VirtualBox -cat << EOF | sudo tee /etc/yum.repos.d/ol7_addons.repo -[ol7_addons] -name=Oracle Linux $releasever Add ons (\$basearch) -baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/\$basearch/ -gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle -gpgcheck=1 -enabled=1 -EOF -rpm --import http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -yum makecache - -# Install dependencies -yum install -y gcc make perl kernel-devel kernel-devel-3.10.0-693.17.1.el7.x86_64 - -yum install -y VirtualBox-5.2 diff --git a/kubernetes/test-infra/minikube-on-packet/20-install-minikube.sh b/kubernetes/test-infra/minikube-on-packet/20-install-minikube.sh index df2f980e82..cdedb834fb 100644 --- a/kubernetes/test-infra/minikube-on-packet/20-install-minikube.sh +++ b/kubernetes/test-infra/minikube-on-packet/20-install-minikube.sh @@ -1,10 +1,23 @@ +#!/usr/bin/bash + # Install kubectl + KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl \ - && chmod +x kubectl && mv kubectl /usr/local/bin/ + && chmod a+x kubectl && mv kubectl /usr/local/bin/ kubectl version # Install minikube curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \ - && chmod +x minikube && mv minikube /usr/local/bin/ + && chmod a+x minikube && mv minikube /usr/local/bin/ minikube version + +# Setting WantReportErrorPrompt to false prevents minikube from interactively prompting the user +# for consent on sending diagnostic information back home in case of failure. +minikube config set WantReportErrorPrompt false +minikube config set vm-driver kvm2 + +# These settings allocate half of the host's CPU cores and memory to the minikube virtual machine. +# The proportion can be adjusted by chaning the '/ 2' factor in the expressions below. +minikube config set cpus $(($(lscpu -p | grep -cv '#') / 2)) +minikube config set memory $(($(free --mega -tw | grep Mem: | cut -d' ' -f12) / 2)) diff --git a/kubernetes/test-infra/minikube-on-packet/main.tf b/kubernetes/test-infra/minikube-on-packet/main.tf index e73a9774eb..3ecece9354 100644 --- a/kubernetes/test-infra/minikube-on-packet/main.tf +++ b/kubernetes/test-infra/minikube-on-packet/main.tf @@ -75,8 +75,8 @@ resource "packet_device" "minikube" { user = "root" private_key = "${tls_private_key.ssh.private_key_pem}" } - source = "${path.module}/10-install-virtualbox.sh" - destination = "/tmp/10-install-virtualbox.sh" + source = "${path.module}/10-install-kvm.sh" + destination = "/tmp/10-install-kvm.sh" } provisioner "file" { connection { @@ -95,13 +95,13 @@ resource "packet_device" "minikube" { private_key = "${tls_private_key.ssh.private_key_pem}" } inline = [ - "chmod a+x /tmp/10-install-virtualbox.sh && chmod a+x /tmp/20-install-minikube.sh", - "/tmp/10-install-virtualbox.sh | tee /var/log/provisioning-10-virtualbox.log", + "chmod a+x /tmp/10-install-kvm.sh && chmod a+x /tmp/20-install-minikube.sh", + "/tmp/10-install-kvm.sh | tee /var/log/provisioning-11-kvm.log", "/tmp/20-install-minikube.sh | tee /var/log/provisioning-20-minikube.log", - "minikube start --kubernetes-version=v${var.kubernetes_version}", + "/usr/local/bin/minikube start --kubernetes-version=v${var.kubernetes_version}", # Extract certs so they can be transfered back to client "mkdir -p /tmp/${var.dotminikube_path}", - "minikube ip | tr -d \"\n\" > /tmp/client/local-ip.txt", + "/usr/local/bin/minikube ip | tr -d \"\n\" > /tmp/client/local-ip.txt", "cp -r ~/.minikube/{ca.crt,client.crt,client.key} /tmp/${var.dotminikube_path}/", ] }