Service Mesh (Resilience, Dynamic Routing, Load-Balancing)(Part 3)

  1. Resilience.
  2. Dynamic-Routing.
  3. Load-balancing and Canary Rollout.

Resilience:

Timeout

Kubectl apply -f - <<EOF 
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings
spec:
hosts:
- ratings
http:
- route:
- destination:
host: ratings
subset: v1
timeout: 10s
EOF

Retries

Kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings
spec:
hosts:
- ratings
http:
- route:
- destination:
host: ratings
subset: v1
retries:
attempts: 3
perTryTimeout: 2s
EOF
Kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: reviews
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
trafficPolicy:
connectionPool:
tcp:
maxConnections: 100
EOF

Dynamic Routing

Kubctl apply -f - <<EOF 
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: tracing-dashboard
namespace: istio-system
spec:
hosts:
- <Your host here>
gateways:
- tracing-gateway
http:
- name: "my-first-cluster"
match:
- uri:
prefix: /my-first-cluster
route:
- destination:
host: <Path to dashboard in my-first-cluster>
- name: "my-second-cluster"
match:
- uri:
prefix: /my-second-cluster
route:
- destination:
host: <Path to dashboard in my-second-cluster>
EOF
kubectl apply -f - <<EOF 
apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
name: external-svc-wikipedia
spec:
hosts:
- wikipedia.org
location: MESH_EXTERNAL
ports:
- number: 80
name: example-http
protocol: HTTP
resolution: DNS
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: my-wiki-rule
spec:
hosts:
- wikipedia.org
http:
- timeout: 5s
route:
- destination:
host: wikipedia.org
EOF

Load-balancing and Canary Rollout

kubectl apply -f - <<EOF  
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: bookinfo-ratings
spec:
host: ratings.prod.svc.cluster.local
trafficPolicy:
loadBalancer:
simple: LEAST_CONN
EOF
# You can replace LEAST_CONN with ROUND_ROBIN. More Info
kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v1
weight: 90
- destination:
host: reviews
subset: v2
weight: 10
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: helloworld
spec:
host: helloworld
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
EOF

Summary

--

--

--

Bikes, Tea, Sunset, IndieMusic in that order. Software Engineer who fell in love with cloud-native infrastructure.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Implementing Cart Service with DDD & Hexagonal ( Port & Adapter) architecture — Part 2

(12) Making Sense of All Product Canvases Under the Sun

Create JupytrHub project on Google Cloud — step by step.

Flutter Core libraries

How To Create And LaunchYour First EC2 Instance

Manually Delete Snapshots Parallels

Manually delete snapshots parallels app

How to add a .bashrc equivalent to the windows cmd terminal

Implementing Cart Service with DDD & Hexagonal ( Port & Adapter) architecture — Part 1

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ADIL RAFIQ

ADIL RAFIQ

Bikes, Tea, Sunset, IndieMusic in that order. Software Engineer who fell in love with cloud-native infrastructure.

More from Medium

Eliminate Hidden Costs by using multi-cloud RedHat OpenShift

UPDATED. Gitlab runner on EKS. How to run tests and do not go bankrupt.

Kubernetes Architecture: An Overview

My journey as an individual contributor to Cloud-Native projects