Last active
August 1, 2018 13:10
-
-
Save AntonFriberg/ead5a5e65aeabd18277c3b6e9762476a to your computer and use it in GitHub Desktop.
Minikube install using kvm2 behind coorporate proxy on Debian stretch
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
#!/bin/sh | |
set -e | |
KUBECTL_VERSION="v1.11.1" | |
MINIKUBE_VERSION="v0.28.2" | |
echo "Installing kubectl $KUBECTL_VERSION and minikube $MINIKUBE_VERSION" | |
echo "Setting proxy settings including minikube ip range" | |
export no_proxy=localhost,127.0.0.1,192.168.0.0/16,.internaldomain.biz | |
export NO_PROXY=$no_proxy | |
export http_proxy=http://proxy.internaldomain.biz:1234 | |
export https_proxy=$http_proxy | |
export ftp_proxy=$http_proxy | |
export HTTP_PROXY=$http_proxy | |
export HTTPS_PROXY=$http_proxy | |
export FTP_PROXY=$http_proxy | |
sudo apt install curl -y | |
echo "Downloading and installing kubectl" | |
curl -Lo /tmp/kubectl "https://storage.googleapis.com/kubernetes-release/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl" \ | |
&& chmod +x /tmp/kubectl \ | |
&& sudo mv /tmp/kubectl /usr/local/bin/kubectl | |
echo "Installing kvm2 packages" | |
sudo apt install libvirt-clients libvirt-daemon-system qemu-kvm -y | |
echo "Adding $USER to libvirt group" | |
sudo usermod -a -G libvirt "$USER" | |
echo "Reinitialize the kvm and kvm_intel kernel modules" | |
sudo rmmod kvm_intel && sudo rmmod kvm | |
sudo modprobe kvm && sudo modprobe kvm_intel | |
echo "Downloading and installing docker-machine-driver-kvm2" | |
curl -Lo /tmp/docker-machine-driver-kvm2 "https://github.com/kubernetes/minikube/releases/download/$MINIKUBE_VERSION/docker-machine-driver-kvm2" \ | |
&& chmod +x /tmp/docker-machine-driver-kvm2 \ | |
&& sudo mv /tmp/docker-machine-driver-kvm2 /usr/local/bin/docker-machine-driver-kvm2 | |
echo "Downloading and installing minikube" | |
curl -Lo /tmp/minikube "https://github.com/kubernetes/minikube/releases/download/$MINIKUBE_VERSION/minikube-linux-amd64" \ | |
&& chmod +x /tmp/minikube \ | |
&& sudo mv /tmp/minikube /usr/local/bin/minikube | |
set +e | |
echo "Making sure virsh net configured correctly before minikube start" | |
sudo virsh net-destroy default | |
sudo virsh net-define /etc/libvirt/qemu/networks/default.xml | |
sudo virsh net-autostart default | |
sudo virsh net-start default | |
echo "Starting minikube with kvm2 driver" | |
minikube start \ | |
--vm-driver=kvm2 \ | |
--kubernetes-version=v1.11.0 \ | |
--docker-env NO_PROXY=$no_proxy \ | |
--docker-env HTTP_PROXY=$http_proxy \ | |
--docker-env HTTPS_PROXY=$http_proxy |
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
#!/bin/sh | |
echo "Running minikube stop" | |
minikube config set WantReportErrorPrompt false | |
minikube stop | |
echo "Running minikube delete" | |
minikube delete | |
echo "Deleting local .minikube and .kube folders" | |
rm -rf ~/.minikube ~/.kube | |
echo "Uninstalling local minikube and kubectl" | |
sudo apt purge kubectl minikube -y | |
sudo rm /usr/local/bin/localkube /usr/local/bin/minikube /usr/local/bin/kubectl | |
echo "Uninstalling kvm2 and minikube kvm2 driver" | |
sudo rm /usr/bin/docker-machine-driver-kvm2 | |
sudo apt purge libvirt-clients libvirt-daemon qemu-kvm -y | |
sudo rm -rf /var/lib/libvirt /etc/libvirt | |
echo "Cleaning up unused dependencies" | |
sudo apt autoremove -y |
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
# Kubectl and minikube autocomplete | |
if [ $commands[minikube] ]; then | |
source <(minikube completion zsh) | |
fi | |
if [ $commands[kubectl] ]; then | |
source <(kubectl completion zsh) | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment