██╗███████╗████████╗██╗ ██████╗ ██╗ █████╗ ██████╗
██║██╔════╝╚══██╔══╝██║██╔═══██╗ ██║ ██╔══██╗██╔══██╗
██║███████╗ ██║ ██║██║ ██║█████╗██║ ███████║██████╔╝
██║╚════██║ ██║ ██║██║ ██║╚════╝██║ ██╔══██║██╔══██╗
██║███████║ ██║ ██║╚██████╔╝ ███████╗██║ ██║██████╔╝
╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═════╝
This aims to be a simple intro to what istio is capable of, this the demo of a talk given in the Barcelona Kubernetes Meetup of June.
Most of the content has been extracted from https://istio.io/docs Some specific commands for openshift have been extracted from https://github.com/debianmaster/openshift-examples/tree/master/istio
you can contact me at:
- jmprusi@(redhat.com|keepalive.io)
- twitter @jmprusi
A high level overview of istio and some basic functionality
- Start an Openshift cluster
- Install Istio Service Mesh and addons
- Deploy a sample app (BookInf)
- Creating a default rule in istio
- Look at metrics provided by Istio
- Example of how to do some A/B testing or Beta testing
- Adding Failures to a service and migrating traffic
- Adding a rate limit
- Showing retry capabilities of istio
Linux 32bit:
- https://github.com/openshift/origin/releases/download/v1.5.1/openshift-origin-client-tools-v1.5.1-7b451fc-linux-32bit.tar.gz
linux 64bit:
- https://github.com/openshift/origin/releases/download/v1.5.1/openshift-origin-client-tools-v1.5.1-7b451fc-linux-64bit.tar.gz
macOS:
- https://github.com/openshift/origin/releases/download/v1.5.1/openshift-origin-client-tools-v1.5.1-7b451fc-mac.zip
Windows:
- https://github.com/openshift/origin/releases/download/v1.5.1/openshift-origin-client-tools-v1.5.1-7b451fc-windows.zip
We are using docker for mac. Make sure your docker daemon has this parameter: "--insecure-registry 172.30.0.0/16" and "docker.io"
Then run:
oc cluster up --version="v1.5.1" --routing-suffix="apps.127.0.0.1.nip.io"
oc login -u system:admin
oc adm policy add-cluster-role-to-user cluster-admin admin
oc project default
oc adm policy add-scc-to-user anyuid -z default
oc adm policy add-scc-to-user privileged -z default
oc patch scc/privileged --patch '{"allowedCapabilities":["NET_ADMIN"]}'
oc adm policy add-cluster-role-to-user cluster-admin -z default
oc adm policy add-cluster-role-to-user cluster-admin -z istio-pilot-service-account
oc adm policy add-cluster-role-to-user cluster-admin -z istio-ingress-service-account
oc adm policy add-scc-to-user anyuid -z istio-ingress-service-account
oc adm policy add-scc-to-user privileged -z istio-ingress-service-account
oc adm policy add-scc-to-user anyuid -z istio-pilot-service-account
oc adm policy add-scc-to-user privileged -z istio-pilot-service-account
git clone https://github.com/istio/istio
cd istio && git checkout 0.1.6
oc apply -f install/kubernetes/istio.yaml
vi install/kubernetes/addons/servicegraph.yaml
Modify the line that states:
image: gcr.io/istio-testing/servicegraph:latest
to:
image: gcr.io/istio-testing/servicegraph:0.1.6
oc apply -f install/kubernetes/addons/prometheus.yaml
oc apply -f install/kubernetes/addons/grafana.yaml
oc apply -f install/kubernetes/addons/servicegraph.yaml
oc apply -f install/kubernetes/addons/zipkin.yaml
You will need to modify the yml template for servicegraph, changing the TAG from latest to 0.1.6
oc expose svc servicegraph
oc expose svc grafana
oc expose svc prometheus
oc expose svc zipkin
curl -L https://git.io/getIstio | sh -
export PATH="$PATH:$(pwd)/istio-0.1.6/bin"
cd istio-0.1.6
oc apply -f <(istioctl kube-inject -f samples/apps/bookinfo/bookinfo.yaml)
colordiff samples/apps/bookinfo/bookinfo.yaml <(istioctl kube-inject -f samples/apps/bookinfo/bookinfo.yaml)
Note: colordiff can be found here: https://www.colordiff.org/
oc expose svc istio-ingress
open http://istio-ingress-default.apps.127.0.0.1.nip.io/productpage
while true; do curl -o /dev/null -s -w "%{http_code}\n" http://istio-ingress-default.apps.127.0.0.1.nip.io/productpage; done
open http://grafana-default.apps.127.0.0.1.nip.io/dashboard/db/istio-dashboard
open http://servicegraph-default.apps.127.0.0.1.nip.io/dotviz
istioctl create -f samples/apps/bookinfo/route-rule-all-v1.yaml
istioctl get route-rules -o yaml
open http://grafana-default.apps.127.0.0.1.nip.io/dashboard/db/istio-dashboard
istioctl create -f samples/apps/bookinfo/route-rule-reviews-test-v2.yaml
open http://istio-ingress-default.apps.127.0.0.1.nip.io/productpage
login as the user "jason" and refresh.
open http://grafana-default.apps.127.0.0.1.nip.io/dashboard/db/istio-dashboard
istioctl create -f samples/apps/bookinfo/destination-ratings-test-delay.yaml
istioctl replace -f samples/apps/bookinfo/route-rule-reviews-50-v3.yaml
istioctl delete route-rule reviews-test-v2
istioctl delete route-rule ratings-test-delay
open http://grafana-default.apps.127.0.0.1.nip.io/dashboard/db/istio-dashboard
istioctl replace -f samples/apps/bookinfo/route-rule-reviews-v3.yaml
open http://grafana-default.apps.127.0.0.1.nip.io/dashboard/db/istio-dashboard
istioctl mixer rule create global ratings.default.svc.cluster.local -f samples/apps/bookinfo/mixer-rule-ratings-ratelimit.yaml
istioctl mixer rule get global ratings.default.svc.cluster.local
open http://grafana-default.apps.127.0.0.1.nip.io/dashboard/db/istio-dashboard
istioctl mixer rule delete global ratings.default.svc.cluster.local
cat <<EOF | istioctl replace
type: route-rule
name: ratings-default
spec:
destination: ratings.default.svc.cluster.local
precedence: 1
route:
- tags:
version: v1
httpFault:
abort:
percent: 25
httpStatus: 503
EOF
cat <<EOF | istioctl create
type: route-rule
name: retries
spec:
destination: ratings.default.svc.cluster.local
match:
source: reviews.default.svc.cluster.local
precedence: 10
httpReqRetries:
simpleRetry:
attempts: 5
perTryTimeout: 2s
EOF
http://zipkin-default.apps.127.0.0.1.nip.io/
You can query for: response_code=503
Or just stop the traffic generation, wait a minute and try again.
https://www.istio.io
https://www.istio.io/docs/reference/commands/istioctl.html
https://www.istio.io/docs/reference/config/traffic-rules/routing-rules.html
https://www.istio.io/docs/reference/config/traffic-rules/destination-policies.html