測試環境版本:
> istio: 1.13.1
> kubernetes: v1.23.4
本次測試使用istio提供的httpsbin example
circuit_breaking.yaml
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: httpbin
spec:
host: httpbin
trafficPolicy:
connectionPool:
tcp:
maxConnections:: 1
http:
http1MaxPendingRequests: 1
maxRequestsPerConnection: 1
outlierDetection:
consecutive5xxErrors: 1
interval: 1s
baseEjectionTime: 3m
maxEjectionPercent: 100
建立熔斷規則
kubectl apply -f circuit_breaking.yaml -n sample
驗證是否建立規則
kubectl get destinationrule httpbin -o yaml -n sample
kubectl apply -f samples/httpbin/sample-client/fortio-deploy.yaml -n sample
export FORTIO_POD=$(kubectl get pods -n sample -l app=fortio -o 'jsonpath={.items[0].metadata.name}')
kubectl exec -n sample "$FORTIO_POD" -c fortio -- /usr/bin/fortio load -c 2 -qps 0 -n 20 -loglevel Warning http://httpbin:8000/get