[root@master-01~]# kubectl exec -it busybox-2-7fd6c66cc6-7wqdv -- sh /# ping 100.67.79.136 PING100.67.79.136(100.67.79.136):56databytes 64 bytes from 100.67.79.136:seq=0ttl=63time=0.086ms 64 bytes from 100.67.79.136:seq=1ttl=63time=0.089ms 64 bytes from 100.67.79.136:seq=2ttl=63time=0.059ms 64 bytes from 100.67.79.136:seq=3ttl=63time=0.060ms 64 bytes from 100.67.79.136:seq=4ttl=63time=0.068ms 64 bytes from 100.67.79.136:seq=5ttl=63time=0.053ms 64 bytes from 100.67.79.136:seq=6ttl=63time=0.088ms 64 bytes from 100.67.79.136:seq=7ttl=63time=0.074ms 64 bytes from 100.67.79.136:seq=8ttl=63time=0.074ms 64 bytes from 100.67.79.136:seq=9ttl=63time=0.092ms ##此处seq 直接跳为15 64 bytes from 100.67.79.136:seq=15ttl=63time=0.075ms 64 bytes from 100.67.79.136:seq=16ttl=63time=0.065ms 64 bytes from 100.67.79.136:seq=17ttl=63time=0.087ms 64 bytes from 100.67.79.136:seq=18ttl=63time=0.075ms 64 bytes from 100.67.79.136:seq=19ttl=63time=0.070ms 64 bytes from 100.67.79.136:seq=20ttl=63time=0.058ms 64 bytes from 100.67.79.136:seq=21ttl=63time=0.087ms 64 bytes from 100.67.79.136:seq=22ttl=63time=0.070ms 64 bytes from 100.67.79.136:seq=23ttl=63time=0.079ms
Network Emulation (Netem) (网络仿真)
netem操作有4种情况,即loss(丢失), delay(延迟), duplicate(重复), and corrupt(损坏)。
/# ping 100.67.79.136 PING100.67.79.136(100.67.79.136):56databytes 64 bytes from 100.67.79.136:seq=0ttl=63time=0.075ms 64 bytes from 100.67.79.136:seq=1ttl=63time=0.075ms 64 bytes from 100.67.79.136:seq=2ttl=63time=0.059ms 64 bytes from 100.67.79.136:seq=3ttl=63time=0.045ms 64 bytes from 100.67.79.136:seq=6ttl=63time=0.071ms 64 bytes from 100.67.79.136:seq=7ttl=63time=0.049ms 64 bytes from 100.67.79.136:seq=9ttl=63time=0.058ms 64 bytes from 100.67.79.136:seq=10ttl=63time=0.080ms 64 bytes from 100.67.79.136:seq=11ttl=63time=0.073ms 64 bytes from 100.67.79.136:seq=12ttl=63time=0.054ms 64 bytes from 100.67.79.136:seq=13ttl=63time=0.114ms 64 bytes from 100.67.79.136:seq=14ttl=63time=0.074ms 64 bytes from 100.67.79.136:seq=15ttl=63time=0.063ms 64 bytes from 100.67.79.136:seq=16ttl=63time=0.068ms 64 bytes from 100.67.79.136:seq=17ttl=63time=0.073ms 64 bytes from 100.67.79.136:seq=19ttl=63time=0.076ms 64 bytes from 100.67.79.136:seq=24ttl=63time=0.114ms 64 bytes from 100.67.79.136:seq=26ttl=63time=0.080ms 64 bytes from 100.67.79.136:seq=27ttl=63time=0.053ms 64 bytes from 100.67.79.136:seq=28ttl=63time=0.088ms 64 bytes from 100.67.79.136:seq=35ttl=63time=0.075ms 64 bytes from 100.67.79.136:seq=41ttl=63time=0.072ms 64 bytes from 100.67.79.136:seq=42ttl=63time=0.068ms 64 bytes from 100.67.79.136:seq=43ttl=63time=0.053ms 64 bytes from 100.67.79.136:seq=44ttl=63time=0.058ms 64 bytes from 100.67.79.136:seq=46ttl=63time=0.062ms .... 64 bytes from 100.67.79.136:seq=143ttl=63time=0.052ms 64 bytes from 100.67.79.136:seq=145ttl=63time=0.050ms ^C ---100.67.79.136pingstatistics--- 146packetstransmitted,106packetsreceived,27%packetloss round-tripmin/avg/max=0.044/0.068/0.235ms /# command terminated with exit code 137
[root@master-01 network]# time curl 10.97.57.107:8082/item {"id":0,"name":"car","price":10000.0} real 0m0.006s user 0m0.001s sys 0m0.002s [root@master-01 network]# time curl 10.97.57.107:8082/item {"id":0,"name":"car","price":10000.0} real 0m0.006s user 0m0.001s sys 0m0.002s [root@master-01 network]# time curl 10.97.57.107:8082/item {"id":0,"name":"car","price":10000.0} real 0m0.005s user 0m0.002s sys 0m0.001s [root@master-01 network]# time curl 10.97.57.107:8082/item {"id":0,"name":"car","price":10000.0} real 0m0.006s user 0m0.000s sys 0m0.003s [root@master-01 network]# kubectl apply -f network-delay.yaml networkchaos.chaos-mesh.org/network-delay-example created [root@master-01 network]# time curl 10.97.57.107:8082/item {"id":0,"name":"car","price":10000.0} real 0m0.998s user 0m0.001s sys 0m0.002s [root@master-01 network]# time curl 10.97.57.107:8082/item {"id":0,"name":"car","price":10000.0} real 0m1.110s user 0m0.000s sys 0m0.003s [root@master-01 network]# time curl 10.97.57.107:8082/item {"id":0,"name":"car","price":10000.0} real 0m0.895s user 0m0.001s sys 0m0.002s [root@master-01 network]# time curl 10.97.57.107:8082/item {"id":0,"name":"car","price":10000.0} real 0m1.056s user 0m0.002s sys 0m0.002s [root@master-01 network]# time curl 10.97.57.107:8082/item {"id":0,"name":"car","price":10000.0} real 0m1.086s user 0m0.001s sys 0m0.002s
/ # ping 100.67.79.136 PING 100.67.79.136 (100.67.79.136): 56 data bytes 64 bytes from 100.67.79.136: seq=0 ttl=63 time=0.076 ms 64 bytes from 100.67.79.136: seq=1 ttl=63 time=0.086 ms 64 bytes from 100.67.79.136: seq=2 ttl=63 time=0.054 ms 64 bytes from 100.67.79.136: seq=3 ttl=63 time=0.087 ms 64 bytes from 100.67.79.136: seq=4 ttl=63 time=0.080 ms 64 bytes from 100.67.79.136: seq=4 ttl=63 time=0.102 ms (DUP!) 64 bytes from 100.67.79.136: seq=5 ttl=63 time=0.089 ms 64 bytes from 100.67.79.136: seq=5 ttl=63 time=0.107 ms (DUP!) 64 bytes from 100.67.79.136: seq=6 ttl=63 time=0.086 ms 64 bytes from 100.67.79.136: seq=7 ttl=63 time=0.081 ms 64 bytes from 100.67.79.136: seq=8 ttl=63 time=0.083 ms 64 bytes from 100.67.79.136: seq=9 ttl=63 time=0.093 ms 64 bytes from 100.67.79.136: seq=10 ttl=63 time=0.071 ms 64 bytes from 100.67.79.136: seq=11 ttl=63 time=0.082 ms 64 bytes from 100.67.79.136: seq=12 ttl=63 time=0.089 ms 64 bytes from 100.67.79.136: seq=13 ttl=63 time=0.093 ms 64 bytes from 100.67.79.136: seq=14 ttl=63 time=0.078 ms 64 bytes from 100.67.79.136: seq=15 ttl=63 time=0.068 ms 64 bytes from 100.67.79.136: seq=16 ttl=63 time=0.052 ms 64 bytes from 100.67.79.136: seq=17 ttl=63 time=0.073 ms 64 bytes from 100.67.79.136: seq=18 ttl=63 time=0.088 ms 64 bytes from 100.67.79.136: seq=18 ttl=63 time=0.116 ms (DUP!) 64 bytes from 100.67.79.136: seq=19 ttl=63 time=0.091 ms 64 bytes from 100.67.79.136: seq=20 ttl=63 time=0.066 ms 64 bytes from 100.67.79.136: seq=21 ttl=63 time=0.090 ms 64 bytes from 100.67.79.136: seq=22 ttl=63 time=0.086 ms 64 bytes from 100.67.79.136: seq=22 ttl=63 time=0.113 ms (DUP!) 64 bytes from 100.67.79.136: seq=23 ttl=63 time=0.083 ms 64 bytes from 100.67.79.136: seq=23 ttl=63 time=0.102 ms (DUP!) 64 bytes from 100.67.79.136: seq=24 ttl=63 time=0.079 ms 64 bytes from 100.67.79.136: seq=25 ttl=63 time=0.092 ms 64 bytes from 100.67.79.136: seq=26 ttl=63 time=0.083 ms 64 bytes from 100.67.79.136: seq=27 ttl=63 time=0.058 ms ^C --- 100.67.79.136 ping statistics --- 28 packets transmitted, 28 packets received, 5 duplicates, 0% packet loss round-trip min/avg/max = 0.052/0.084/0.116 ms
/ # ping 100.67.79.136 PING 100.67.79.136 (100.67.79.136): 56 data bytes #此时包已经损坏,故未收到seq=0 seq=1 64 bytes from 100.67.79.136: seq=2 ttl=63 time=0.056 ms 64 bytes from 100.67.79.136: seq=3 ttl=63 time=0.062 ms 64 bytes from 100.67.79.136: seq=4 ttl=63 time=0.053 ms 64 bytes from 100.67.79.136: seq=5 ttl=63 time=0.052 ms 64 bytes from 100.67.79.136: seq=6 ttl=63 time=0.055 ms 64 bytes from 100.67.79.136: seq=7 ttl=63 time=0.051 ms 64 bytes from 100.67.79.136: seq=8 ttl=63 time=0.076 ms 64 bytes from 100.67.79.136: seq=9 ttl=63 time=0.066 ms 64 bytes from 100.67.79.136: seq=10 ttl=63 time=0.073 ms 64 bytes from 100.67.79.136: seq=11 ttl=63 time=0.062 ms 64 bytes from 100.67.79.136: seq=12 ttl=63 time=0.084 ms 64 bytes from 100.67.79.136: seq=13 ttl=63 time=0.055 ms 64 bytes from 100.67.79.136: seq=14 ttl=63 time=0.066 ms 64 bytes from 100.67.79.136: seq=15 ttl=63 time=0.054 ms #此时包已经损坏,故未收到seq=16 64 bytes from 100.67.79.136: seq=17 ttl=63 time=0.062 ms #此时包已经损坏,故未收到seq=18 19 20 64 bytes from 100.67.79.136: seq=20 ttl=63 time=0.074 ms 64 bytes from 100.67.79.136: seq=21 ttl=63 time=0.058 ms 64 bytes from 100.67.79.136: seq=22 ttl=63 time=0.049 ms 64 bytes from 100.67.79.136: seq=23 ttl=63 time=0.048 ms 64 bytes from 100.67.79.136: seq=24 ttl=63 time=0.049 ms 64 bytes from 100.67.79.136: seq=25 ttl=63 time=0.087 ms ^C --- 100.67.79.136 ping statistics --- 26 packets transmitted, 21 packets received, 19% packet loss round-trip min/avg/max = 0.048/0.061/0.087 ms
[root@master-01 network]# kubectl exec -it go-7c9c5496fb-cbstm -- sh /app # date Wed Dec 9 08:37:06 UTC 2020 /app # date Wed Dec 9 08:37:07 UTC 2020 /app # date Wed Dec 9 08:37:08 UTC 2020 /app # date Wed Dec 9 08:37:09 UTC 2020 /app # date Wed Dec 9 08:37:10 UTC 2020 /app # date Wed Dec 9 08:37:11 UTC 2020 /app # date Wed Dec 9 08:37:12 UTC 2020 /app # date Wed Dec 9 08:37:12 UTC 2020 /app # date Wed Dec 9 08:37:13 UTC 2020 /app # date Wed Dec 9 08:37:14 UTC 2020 /app # date Wed Dec 9 08:37:15 UTC 2020 /app # date Wed Dec 9 08:37:16 UTC 2020 /app # date Wed Dec 9 08:37:16 UTC 2020 /app # date Wed Dec 9 08:37:17 UTC 2020 /app # date Wed Dec 9 08:37:18 UTC 2020 /app # date Wed Dec 9 08:37:20 UTC 2020 /app # date Wed Dec 9 08:37:21 UTC 2020 /app # date Wed Dec 9 08:37:22 UTC 2020