# 部署测试POD[root@k8s-master-1 mirroring]# istioctl kube-inject -f deployment.yaml | kubectl apply -f -
namespace/mirror created
service/nginx created
configmap/nginx-html created
pod/nginx-v1 created
pod/nginx-v2 created
pod/busybox created
# 部署istio[root@k8s-master-1 mirroring]# kubectl apply -f istio.yaml
virtualservice.networking.istio.io/httpd created
destinationrule.networking.istio.io/httpd created
# 测试流量,可以发现目前流量全部到nginx-v1了[root@k8s-master-1 mirroring]# for i in `seq 1 5`; do kubectl exec busybox -c busybox -- wget -q -O - http://nginx.mirror.svc.cluster.local && echo ; done
this is nginx v1
this is nginx v1
this is nginx v1
this is nginx v1
this is nginx v1
# 查看nginx-v1流量[root@k8s-master-1 mirroring]# kubectl logs nginx-v1 -c nginx-v1 -n mirror | grep "^127"127.0.0.6 - - [25/Apr/2022:13:06:42 +0000]"GET / HTTP/1.1"20016"-""Wget""-"127.0.0.6 - - [25/Apr/2022:13:06:43 +0000]"GET / HTTP/1.1"20016"-""Wget""-"127.0.0.6 - - [25/Apr/2022:13:06:43 +0000]"GET / HTTP/1.1"20016"-""Wget""-"................................# 查看nginx-v2流量,未见访问流量[root@k8s-master-1 mirroring]# kubectl logs nginx-v2 -c nginx-v2 -n mirror | grep "^127"
You have new mail in /var/spool/mail/root