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

The most effective approach to business operations

Using secrets in AWS ECS

Connecting existing user database to AWS Cognito

How to use Auto-Tune as a Pro

Protecting Sensitive PII data in Azure SQL Databases

Running Virtual Machines within Virtual Machine on Oracle VirtualBox

Triggers in MySQL

My Preparation Journey for Twitter Interviews

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

Service mesh at scale: How Xbox Cloud Gaming secures 22k pods with Linkerd | Cloud Native Computing…

Full setup of a Kubernetes K3D cluster managed by Flux on a local Git server

Youtube recording of the live session on the interactive mode

How to deploy your Red Hat Fuse service to OpenShift

Modern File Transfer Solution on Azure — SFTP