Skip to content

Instantly share code, notes, and snippets.

@yogeek
Last active May 12, 2018 10:54
Show Gist options
  • Select an option

  • Save yogeek/de99d097a173e82e881c4875ae0e46fe to your computer and use it in GitHub Desktop.

Select an option

Save yogeek/de99d097a173e82e881c4875ae0e46fe to your computer and use it in GitHub Desktop.
Kubernetes
git clone https://github.com/saturnism/gcp-live-k8s-visualizer.git
cd gcp-live-k8s-visualizer
kubectl proxy --www=. &
# Label objects to visualize them
kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080 -l visualize=true,run=hello-minikube
kubectl expose deployment hello-minikube --type=NodePort -l visualize=true,run=hello-minikube
# Check Visualiser !
kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080
# deployment "hello-minikube" created
kubectl expose deployment hello-minikube --type=NodePort
# service "hello-minikube" exposed
# We have now launched an echoserver pod
kubectl get pod
# Wait until it is running...
# We are now able to curl it
curl $(minikube service hello-minikube --url)
# Open Dashboard
minikube dashboard
# https://kubernetes.io/docs/tasks/tools/install-kubectl/
# Install kubectl binary via curl
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
# Autocompletion
echo "source <(minikube completion bash)" >> ~/.bashrc
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl
export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false
export MINIKUBE_HOME=$HOME
export CHANGE_MINIKUBE_NONE_USER=true
mkdir $HOME/.kube || true
touch $HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config
sudo -E ./minikube start --vm-driver=none
# Autocompletion
echo "source <(minikube completion bash)" >> ~/.bashrc
# this for loop waits until kubectl can access the api server that Minikube has created
for i in {1..150}; do # timeout for 5 minutes
./kubectl get po &> /dev/null
if [ $? -ne 1 ]; then
break
fi
sleep 2
done
# kubectl commands are now able to interact with Minikube cluster
kubectl cluster-info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment