赞
踩
一、理解熔断
熔断(Circuit Breaker),原是指当电流超过规定值时断开电路,进行短路保护或严重过载时的一种保护机制。后来熔断也广泛应用于金融领域,指当股指波幅达到规定的熔断点时,交易所为控制风险采取的暂停交易措施。而在软件领域,熔断则是指当服务达到系统负载阈值时,为避免整个软件系统不可用,而采取的一种主动保护措施。对于微服务系统而言,熔断尤为重要,它可以使系统在遭遇某些模块故障时,通过服务降级等方式来提高系统核心功能的可用性,得以应对来自故障、潜在峰值或其他未知网络因素的影响。
二、配置熔断
1)部署httpbin服务
➜ kubectl apply -f ../../samples/httpbin/httpbin.yaml serviceaccount/httpbin unchanged service/httpbin unchanged deployment.apps/httpbin unchanged ➜ kubectl describe pods httpbin-74fb669cc6-vn897 Name: httpbin-74fb669cc6-vn897 Namespace: default Priority: 0 Node: docker-desktop/192.168.65.4 Start Time: Sat, 03 Jul 2021 17:23:17 +0800 Labels: app=httpbin istio.io/rev=default pod-template-hash=74fb669cc6 security.istio.io/tlsMode=istio service.istio.io/canonical-name=httpbin service.istio.io/canonical-revision=v1 version=v1 Annotations: kubectl.kubernetes.io/default-container: httpbin kubectl.kubernetes.io/default-logs-container: httpbin prometheus.io/path: /stats/prometheus prometheus.io/port: 15020 prometheus.io/scrape: true sidecar.istio.io/status: { "initContainers":["istio-init"],"containers":["istio-proxy"],"volumes":["istio-envoy","istio-data","istio-podinfo","istiod-ca-cert"],"ima... Status: Running IP: 10.1.8.151 IPs: IP: 10.1.8.151 Controlled By: ReplicaSet/httpbin-74fb669cc6 Init Containers: istio-init: Container ID: docker://538c2e169bfedaf636a942bee92183c59f79b47bea25a286f242e74c22abddad Image: docker.io/istio/proxyv2:1.10.1 Image ID: docker-pullable://istio/proxyv2@sha256:d9b295da022ad826c54d5bb49f1f2b661826efd8c2672b2f61ddc2aedac78cfc Port: <none> Host Port: <none> Args: istio-iptables -p 15001 -z 15006 -u 1337 -m REDIRECT -i * -x -b * -d 15090,15021,15020 State: Terminated Reason: Completed Exit Code: 0 Started: Sat, 24 Jul 2021 17:03:16 +0800 Finished: Sat, 24 Jul 2021 17:03:17 +0800 Ready: True Restart Count: 1 Limits: cpu: 2 memory: 1Gi Requests: cpu: 10m memory: 40Mi Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from httpbin-token-qk94s (ro) Containers: httpbin: Container ID: docker://3a3e8c32b05eb6f022ef6f660bad99128a7459452949bf3d43c0693dac5c82b1 Image: docker.io/kennethreitz/httpbin Image ID: docker-pullable://kennethreitz/httpbin@sha256:599fe5e5073102dbb0ee3dbb65f049dab44fa9fc251f6835c9990f8fb196a72b Port: 80/TCP Host Port: 0/TCP State: Running Started: Sat, 24 Jul 2021 17:03:22 +0800 Last State: Terminated Reason: Error Exit Code: 255 Started: Sat, 03 Jul 2021 17:26:41 +0800 Finished: Sat, 24 Jul 2021 16:41:32 +0800 Ready: True Restart Count: 1 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from httpbin-token-qk94s (ro) istio-proxy: Container ID: docker://fce4a591308062ef5f4c6aebb1e738e2fc79a4c8cfcc2498f6481a31d7ddb7aa Image: docker.io/istio/proxyv2:1.10.1 Image ID: docker-pullable://istio/proxyv2@sha256:d9b295da022ad826c54d5bb49f1f2b661826efd8c2672b2f61ddc2aedac78cfc Port: 15090/TCP Host Port: 0/TCP Args: proxy sidecar --domain $(POD_NAMESPACE).svc.cluster.local --serviceCluster httpbin.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。