Last active
April 11, 2019 02:04
-
-
Save jdforsythe/738754d19782fe2aa2641e4fb892096c to your computer and use it in GitHub Desktop.
Kubernetes on Minikube
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
#!/usr/bin/env bash | |
## | |
## download minikube, kubectl, and istio and add istioctl to path | |
## | |
## these steps only need performed one time | |
## | |
brew install kubernetes-cli | |
brew cask install minikube | |
kubectl version | |
minikube version | |
## get latest istio and extract it, then add it to the path | |
mkdir -p $HOME/istio && cd $HOME/istio | |
curl -L https://git.io/getLatestIstio | sh - | |
# go to the new istio-x.x.x directory | |
cd $(ls -d -1 * | head -n 1) | |
echo "## istioctl" >> ~/.bashrc | |
echo "export PATH=$PWD/bin:$PATH" >> ~/.bashrc | |
## | |
## Repeat the steps below to create and destroy a demo istio setup on minikube | |
## | |
## | |
## setup minikube cluster for istio | |
## | |
## https://istio.io/docs/setup/kubernetes/prepare/platform-setup/minikube/ | |
## | |
minikube config set vm-driver virtualbox | |
minikube start --memory=8192 --cpus=4 --kubernetes-version=v1.13.0 | |
## | |
## install istio in cluster | |
## | |
## https://istio.io/docs/setup/kubernetes/install/kubernetes/ | |
## | |
## custom resource definitions | |
for i in install/kubernetes/helm/istio-init/files/crd*yaml; do kubectl apply -f $i; done | |
## demo with strict mutual tls | |
kubectl apply -f install/kubernetes/istio-demo-auth.yaml | |
## demo with loose mutual tls | |
## kubectl apply -f install/kubernetes/istio-demo.yaml | |
## verify services are up | |
kubectl get svc -n istio-system | |
## wait for pods to be Complete or Running | |
kubectl get pod -n istio-system | |
## new pods automatically get istio sidecards injected | |
kubectl label namespace default istio-injection=enabled --overwrite | |
## deploy application | |
kubectl create -f samples/helloworld/helloworld.yaml | |
## deploy gateway | |
kubectl create -f samples/helloworld/helloworld-gateway.yaml | |
## get ip for cluster and NodePort for istio ingress gateway | |
export INGRESS_HOST=$(minikube ip) | |
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}') | |
## call multiple times to see load balance between v1 and v2 | |
curl http://$INGRESS_HOST:$INGRESS_PORT/hello | |
curl http://$INGRESS_HOST:$INGRESS_PORT/hello | |
curl http://$INGRESS_HOST:$INGRESS_PORT/hello | |
curl http://$INGRESS_HOST:$INGRESS_PORT/hello | |
## | |
## destroy everything | |
## | |
minikube stop | |
minikube delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment