Skip to content

Instantly share code, notes, and snippets.

@ssaraswati
Last active November 20, 2018 08:04
Show Gist options
  • Save ssaraswati/8d6fda9ded158dd832a8e6d20f079e27 to your computer and use it in GitHub Desktop.
Save ssaraswati/8d6fda9ded158dd832a8e6d20f079e27 to your computer and use it in GitHub Desktop.
Istio Notes that worked with Docker For Desktop Mac and Windows
cd ~/Dowloads/istio-*

add istioctl to path

export PATH=$PWD/bin:$PATH

Dashboard localhost:8001/api/v1/namespaces/kube-system/services/https%3Akubernetes-dashboard%3A/proxy/#!/namespace?namespace=default

kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

Install helm

kubectl apply -f install/kubernetes/helm/helm-service-account.yaml
helm init --service-account tiller

Install istio

kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml
helm upgrade --install istio install/kubernetes/helm/istio --namespace istio-system -f install/kubernetes/helm/istio/values-istio-demo.yaml  --set kiali.enabled=true

kubectl label namespace default istio-injection=enabled

Ingress env

export GATEWAY_URL=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
# Or for desktop
export GATEWAY_URL=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')

Install sample app

kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml

Networking

kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
kubectl apply -f samples/bookinfo/networking/destination-rule-all.yaml
kubectl describe virtualservice

review v1-v2

kubectl describe virtualservice reviews
kubectl apply -f samples/bookinfo/networking/virtual-service-all-v1.yaml
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-90-10.yaml
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-80-20.yaml
kubectl delete virtualservice reviews

review v2-v3

kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-v2-v3.yaml
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-v3.yaml

mysql ratings v2

kubectl apply -f samples/bookinfo/platform/kube/bookinfo-mysql.yaml
kubectl apply -f samples/bookinfo/platform/kube/bookinfo-ratings-v2-mysql.yaml
kubectl apply -f samples/bookinfo/networking/virtual-service-ratings-mysql.yaml

mongo ratings v2

kubectl apply -f samples/bookinfo/platform/kube/bookinfo-db.yaml
kubectl apply -f samples/bookinfo/platform/kube/bookinfo-ratings-v2.yaml
kubectl apply -f samples/bookinfo/networking/virtual-service-ratings-db.yaml

traffic fault v1 ratings

kubectl apply -f samples/bookinfo/networking/virtual-service-ratings-test-abort.yaml
kubectl apply -f samples/bookinfo/networking/virtual-service-ratings-test-delay.yaml

Traffic routing - ratings

cat <<EOF | kubectl apply -f -
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ratings
spec:
  hosts:
  - ratings
  http:
  - route:
    - destination:
        host: ratings
        subset: v1
EOF

Traffic delay - ratings

cat <<EOF | kubectl apply -f -
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ratings
spec:
  hosts:
  - ratings
  http:
  - fault:
      delay:
        percent: 100
        fixedDelay: 2s
    route:
    - destination:
        host: ratings
        subset: v1
EOF

Traffic timeout - reviews

cat <<EOF | kubectl apply -f -
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: reviews
spec:
  hosts:
  - reviews
  http:
  - route:
    - destination:
        host: reviews
        subset: v3
    timeout: 0.5s
EOF

Traffic routing - reviews

cat <<EOF | kubectl apply -f -
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: reviews
spec:
  hosts:
    - reviews
  http:
  - route:
    - destination:
        host: reviews
        subset: v3
EOF

Load (vegeta)

brew update && brew install vegeta
echo "GET http://localhost/productpage" | vegeta attack -connections 2 -rate=10 -duration=30s | vegeta report -type='hist[0,10ms,50ms,100ms,1000ms,10000ms]'
echo "GET http://localhost/productpage" | vegeta attack -connections 2 -rate=10 -duration=10s | vegeta plot > ~/vegeta.html
GET http://localhost/api/v1/products
GET http://localhost/api/v1/products/0
GET http://localhost/api/v1/products/0/ratings
GET http://localhost/api/v1/products/0/reviews
vegeta attack -connections 5 -rate=15 -duration=100s -targets targets.txt | vegeta plot > vegeta-output.html

Monitoring

kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=servicegraph -o jsonpath='{.items[0].metadata.name}') 7001:8088 &
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 7002:3000 &
kubectl -n istio-system port-forward $(kubectl get pod -n istio-system -l app=jaeger -o jsonpath='{.items[0].metadata.name}') 7003:16686 &
kubectl -n istio-system port-forward $(kubectl get pod -n istio-system -l app=kiali -o jsonpath='{.items[0].metadata.name}') 7004:20001 &
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=prometheus -o jsonpath='{.items[0].metadata.name}') 7005:9090 &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment