Skip to content

Instantly share code, notes, and snippets.

@p-le
Last active September 28, 2020 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p-le/c143ae7d25eed606bc4f5d2eeb7a3118 to your computer and use it in GitHub Desktop.
Save p-le/c143ae7d25eed606bc4f5d2eeb7a3118 to your computer and use it in GitHub Desktop.
Vagrant Ubuntu 18.04 + Docker + k3d Setting up
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# https://app.vagrantup.com/hashicorp/boxes/bionic64
config.vm.box = "hashicorp/bionic64"
config.vm.box_check_update = true
# Forwarded port mapping: 8052 -> 8502 for exposed service
config.vm.network "forwarded_port", guest: 8502, host: 8502
# Forwarded port mapping: 8052 -> 8502 for kubernetes dasboard
config.vm.network "forwarded_port", guest: 8503, host: 8503
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.15"
# Share an additional folder to the guest VM
config.vm.synced_folder "./shared", "/vagrant_data"
# Customize the disk size on the guest VM: (using vagrant-disksize plugin)
config.disksize.size = '50GB'
# Customize hostname of the guestVM
config.vm.hostname = "k3d-cluster"
config.vm.provider "virtualbox" do |vb|
# Customize the amount of memory on the guest VM:
vb.memory = "2048"
end
# Enable provisioning guest VM with shell script
config.vm.provision "shell", inline: <<-SHELL
apt-get update -y
# Install Docker
# Reference: https://docs.docker.com/engine/install/ubuntu/
apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update -y
apt-get install -y docker-ce docker-ce-cli containerd.io
# Install k3d
# Reference: https://github.com/rancher/k3d
wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
# Install kubectl
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
mv kubectl /usr/local/bin/
chmod +x /usr/local/bin/kubectl
# Add vagrant user to docker group (Running docker command without sudo)
addgroup -a vagrant docker
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment