Last active
July 4, 2018 00:38
-
-
Save jeefy/940e54dbce87a37d210de27809626608 to your computer and use it in GitHub Desktop.
Vagrantfile for Kubernetes development / testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$script = <<-SCRIPT | |
export DEBIAN_FRONTEND=noninteractive | |
export HOME=/root | |
apt-get update && apt-get install -y apt-transport-https | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
apt-get update | |
apt-get install -y docker-ce gcc make build-essential tzdata | |
timedatectl set-timezone US/Eastern | |
usermod -aG docker $1 | |
export GO_VERSION=1.10.2 | |
export GO_DOWNLOAD_URL=https://storage.googleapis.com/golang/go$GO_VERSION.linux-amd64.tar.gz | |
mkdir -p /usr/local/go/ | |
#GCP Fix | |
rm -rf /usr/local/go/* | |
wget "$GO_DOWNLOAD_URL" -O golang.tar.gz | |
tar -zxvf golang.tar.gz -C /usr/local/ | |
export GOPATH=~/go | |
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin:$GOPATH/src/k8s.io/kubernetes/third_party/etcd | |
echo "export HOME=/root" >> ~/.profile | |
echo "export GOPATH=~/go" >> ~/.profile | |
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin:~/go/src/k8s.io/kubernetes/third_party/etcd" >> ~/.profile | |
go version | |
cd ~/go/src/k8s.io/kubernetes | |
go get -u github.com/golang/lint/golint | |
go get github.com/tools/godep | |
hack/install-etcd.sh | |
time make &> ~/make.txt | |
time make verify &> ~/make-verify.txt | |
time make test &> ~/make-test.txt | |
time make test-integration &> ~/make-integration.txt | |
SCRIPT | |
Vagrant.configure("2") do |config| | |
user = "vagrant" | |
config.vm.box = "bento/ubuntu-16.04" | |
config.vm.define "virtualbox" do |virtualbox| | |
virtualbox.vm.provider :virtualbox do |vbox, override| | |
override.vm.provision "shell", inline: $script, args: [user] | |
override.vm.synced_folder ".", "/root/go/src/k8s.io/kubernetes", type: "rsync", | |
rsync__exclude: ["_output"], | |
rsync__args: ["--verbose", "--archive", "-z", "--links"] | |
vbox.customize [ | |
"modifyvm", :id, | |
"--memory", "8192", | |
"--cpus", "4", | |
] | |
end | |
end | |
config.vm.define "gcp" do |gcp| | |
gcp.vm.provider :google do |google, override| | |
user = "jeefy" | |
override.vm.synced_folder ".", "/root/go/src/k8s.io/kubernetes", type: "rsync", | |
rsync__exclude: ["_output"], | |
rsync__args: ["--verbose", "--archive", "-z", "--links"] | |
override.vm.provision "shell", inline: $script, args: [user] | |
override.vm.box = "google/gce" | |
google.image_family = 'ubuntu-1604-lts' | |
google.machine_type = "n1-standard-8" | |
google.preemptible = true | |
google.auto_restart = false | |
google.disk_type = "pd-standard" | |
google.disk_size = 20 | |
google.on_host_maintenance = "TERMINATE" | |
google.google_project_id = "ChangeMe" | |
google.google_client_email = "ChangeMe" | |
google.google_json_key_location = "~/ChangeMe" | |
google.instance_ready_timeout = 45 | |
override.ssh.username = "jeefy" | |
override.ssh.private_key_path = "~/.ssh/id_rsa" | |
end | |
end | |
config.vm.define "packet" do |pkt| | |
pkt.vm.provider :packet do |packet, override| | |
user = "root" | |
override.vm.provision "shell", inline: $script, args: [user] | |
override.vm.synced_folder ".", "/root/go/src/k8s.io/kubernetes", type: "rsync", | |
rsync__exclude: ["_output"], | |
rsync__args: ["--verbose", "--archive", "-z", "--links"] | |
override.vm.box = "packet.box" | |
packet.packet_token = "ChangeMe" | |
packet.project_id = "ChangeMe" | |
packet.plan = "c2.medium.x86" | |
packet.facility = "sjc1" | |
packet.operating_system = "ubuntu_16_04" | |
override.ssh.username = "root" | |
override.ssh.private_key_path = "~/.ssh/id_rsa" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment