General Catalog Index: istio from getting started to giving up series
1. Introduction to network flexibility
Network elasticity, also known as operation and maintenance elasticity, refers to the ability of the network to quickly recover and continue to operate in the event of a disaster. The scope of disaster events is very wide, such as long-term power failure, network equipment failure, malicious, etc
2. Istio timeout instance
It is necessary to simulate the callee's slow response to requests in combination with Istio fault injection. The architecture of this example is as follows:
The architecture is described as follows. This example is a common function of simulating the client to call nginx, which forwards the request to tomcat. tomcat response request is set to 10s (implemented by fault injection, equivalent to sleep 10s logic), nginx sets the request timeout of client to 2s. Because nginx needs to return to the client within 2s, and nginx needs to request tomcat for 10s, simulate the situation that the client calls nginx out of time.
2.1 deploy client
apiVersion: apps/v1 kind: Deployment metadata: name: client spec: replicas: 1 selector: matchLabels: app: client template: metadata: labels: app: client spec: containers: - name: busybox image: busybox imagePullPolicy: IfNotPresent command: [ "/bin/sh", "-c", "sleep 3600" ]
2.2 deploy nginx and tomcat instances
apiVersion: v1 kind: Service metadata: name: nginx-svc spec: selector: server: nginx ports: - name: http port: 80 targetPort: 80 protocol: TCP --- apiVersion: apps/v1 kind: Deployment metadata: name: nginx labels: server: nginx spec: replicas: 1 selector: matchLabels: server: nginx template: metadata: labels: server: nginx spec: containers: - name: nginx image: nginx:1.14-alpine imagePullPolicy: IfNotPresent --- apiVersion: v1 kind: Service metadata: name: tomcat-svc spec: selector: server: tomcat ports: - name: http port: 8080 targetPort: 8080 protocol: TCP --- apiVersion: apps/v1 kind: Deployment metadata: name: tomcat labels: server: tomcat spec: replicas: 1 selector: matchLabels: server: tomcat template: metadata: labels: server: tomcat spec: containers: - name: tomcat image: docker.io/kubeguide/tomcat-app:v1 imagePullPolicy: IfNotPresent
2.3 Istio virtual service resources
apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: nginx-vs spec: hosts: - nginx-svc http: - route: - destination: host: nginx-svc timeout: 2s --- apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: tomcat-vs spec: hosts: - tomcat-svc http: - fault: delay: percentage: value: 100 fixedDelay: 10s route: - destination: host: tomcat-svc
2.4 deploy the above example and perform istio injection
istioctl kube-inject -f test-client.yaml | kubectl apply -f -
istioctl kube-inject -f test-deploy.yaml | kubectl apply -f -
3. Configure nginx to forward tomcat
kubectl exec -it nginx-579d7f7ff-9pspn /bin/sh
Make the configuration effective after modification
nginx -t
nginx -s reload
The modification is as follows
4. Client authentication
kubectl exec -it client-8496866cdf-vkmcw /bin/sh
wget -q -O - http://nginx-svc
wget -q -O - http://tomcat-svc:8080
For experimental results, the setting time is long, which is consistent with the setting of nginx 2s and tomcat 10s. The operation time is removed
Reference article: https://blog.51cto.com/14625168/2498209