Forked from jacobtomlinson/minikube-update-hosts.sh
Created
February 19, 2019 18:04
-
-
Save boskiv/6113e920e3b0d882fe59a187966d8032 to your computer and use it in GitHub Desktop.
A script to update your /etc/hosts file from minikube ingest records
This file contains hidden or 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/bash | |
# | |
# A script to update your /etc/hosts file from minikube ingest records | |
# | |
# Installation | |
# ------------ | |
# curl -L https://gist.github.com/jacobtomlinson/4b835d807ebcea73c6c8f602613803d4/raw/minikube-update-hosts.sh > /usr/local/bin/minikube-update-hosts | |
# chmod +x /usr/local/bin/minikube-update-hosts | |
INGRESSES=$(kubectl --context=minikube --all-namespaces=true get ingress | grep -v NAMESPACE | awk '{ print $2 }' | tr '\r\n' ' ') | |
MINIKUBE_IP=$(minikube ip) | |
HOSTS_ENTRY="$MINIKUBE_IP $INGRESSES" | |
if grep -Fq "$MINIKUBE_IP" /etc/hosts > /dev/null | |
then | |
sudo sed -i '' "s/^$MINIKUBE_IP.*/$HOSTS_ENTRY/" /etc/hosts | |
echo "Updated hosts entry" | |
else | |
echo "$HOSTS_ENTRY" | sudo tee -a /etc/hosts | |
echo "Added hosts entry" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment