Skip to content

Instantly share code, notes, and snippets.

@olberger
Last active January 25, 2022 07:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save olberger/f21fa08d97267a64a074909af429f921 to your computer and use it in GitHub Desktop.
Save olberger/f21fa08d97267a64a074909af429f921 to your computer and use it in GitHub Desktop.
"Rapidly spinning up a VM with Ubuntu, Docker and Minikube (using the –vm-driver=none option) on my Windows laptop using Vagrant and Oracle VirtualBox" by Marc Lameriks - Source: https://technology.amis.nl/2019/02/12/rapidly-spinning-up-a-vm-with-ubuntu-docker-and-minikube-using-the-vm-drivernone-option-on-my-windows-laptop-using-vagrant-and-ora…
#!/bin/bash
echo "**** Begin installing Docker CE"
#Uninstall old versions
sudo apt-get remove docker docker-engine docker.io containerd runc
#Set up the repository
##Update the apt package index
sudo apt-get update
##Install packages to allow apt to use a repository over HTTPS
sudo apt-get install apt-transport-https
sudo apt-get install ca-certificates
sudo apt-get install curl
sudo apt-get install gnupg-agent
sudo apt-get install software-properties-common
##Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
##Set up the stable repository
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
#Install Docker CE
##Update the apt package index
sudo apt-get update
#Install a specific version of Docker CE
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu
#Verify that Docker CE is installed correctly by running the hello-world image
sudo docker run hello-world
#use Docker as a non-root user
usermod -aG docker vagrant
echo "**** End installing Docker CE"
#!/bin/bash
echo "**** Begin installing kubectl"
#Install kubectl binary
sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
#Check the kubectl configuration
kubectl cluster-info
#Make kubectl work for your non-root user named vagrant
mkdir -p /home/vagrant/.kube
sudo cp -i /etc/kubernetes/admin.conf /home/vagrant/.kube/config
sudo chown vagrant:vagrant /home/vagrant/.kube/config
echo "**** End installing kubectl"
echo "**** Begin preparing dashboard"
kubectl proxy --address='0.0.0.0'
echo "**** End preparing dashboard"
#!/bin/bash
echo "**** Begin downloading minikube"
#Download a static binary
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.32.0/minikube-linux-amd64
chmod +x minikube
#Add the Minikube executable to your path
sudo cp minikube /usr/local/bin/
rm minikube
echo "**** End downloading minikube"
echo "**** Begin starting a Cluster"
#Start a Cluster
minikube start --vm-driver=none
echo "**** End starting a Cluster"
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.define "ubuntu_minikube" do |ubuntu_minikube|
config.vm.network "forwarded_port",
guest: 8001,
host: 8001,
auto_correct: true
config.vm.provider "virtualbox" do |vb|
vb.name = "Ubuntu Minikube"
vb.memory = "4096"
vb.cpus = "4"
args = []
config.vm.provision "shell",
path: "scripts/docker.sh",
args: args
args = []
config.vm.provision "shell",
path: "scripts/minikube.sh",
args: args
args = []
config.vm.provision "shell",
path: "scripts/kubectl.sh",
args: args
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment