Skip to content

Instantly share code, notes, and snippets.

@srkama
Forked from kenanhancer/MiniKubeVagrantfile
Created August 19, 2021 13:03
Show Gist options
  • Save srkama/7781dac73264ea694d7f68fea350d4e4 to your computer and use it in GitHub Desktop.
Save srkama/7781dac73264ea694d7f68fea350d4e4 to your computer and use it in GitHub Desktop.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.network "private_network", ip: "192.168.33.23"
# To access Dashboard from your local workstation you must create a secure channel to your Kubernetes cluster.
config.vm.network "forwarded_port", guest: 8001, host: 8001, auto_correct: true
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "2048"
end
config.vm.provision "shell", privileged: true, inline: <<-SHELL
# Minikube Installation
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube
# To use minikube commands as your own user
chown -R vagrant:vagrant ./minikube
mv minikube /usr/local/bin/minikube
# Kubectl Installation
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
# To use kubectl commands as your own user
chown -R vagrant:vagrant ./kubectl
# Make the kubectl binary executable
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
# Docker Installation
apt-get update
apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
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
apt-get install docker-ce -y
# Allow regular user to run docker commands
usermod -aG docker vagrant
newgrp - docker
SHELL
config.vm.provision "shell", privileged: false, inline: <<-SHELL
sudo minikube start --vm-driver none
# To use kubectl or minikube commands as your own user
sudo chown -R vagrant:vagrant /home/vagrant/.kube /home/vagrant/.minikube
# Now access Dashboard at
# http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
# Deploy Dashboard in kubernetes
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
# Creating Dashboard Proxy
# kubectl proxy --address 0.0.0.0 --port=8001 --accept-hosts '.*'
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment