istio流量分析

axing
2026-02-03 / 0 评论 / 6 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2026年02月03日,已超过12天没有更新,若内容或图片失效,请留言反馈。

一、流量走势

NodePort → ingressgateway Service → ingressgateway Pod(Envoy) → Gateway 筛选 → VirtualService 路由 → productpage Service:9080 → productpage Pod
#如果不是NodePort 就需要kubectl port-forward -n istio-system --address 0.0.0.0 svc/istio-ingressgateway 8080:80 进行端口暴露
只需要记住一点svc只是负责把流量转发到对应的pod 而网关和路由的匹配则是istio-ingressgateway进行处理

二、对应的yaml文件

cat gateway.yaml 
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: bookinfo-gateway
  namespace: default
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"


root@k8s-01:/woke/istio# kubectl get virtualservice bookinfo -n default -o yaml
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"networking.istio.io/v1beta1","kind":"VirtualService","metadata":{"annotations":{},"name":"bookinfo","namespace":"default"},"spec":{"gateways":["bookinfo-gateway"],"hosts":["*"],"http":[{"match":[{"uri":{"prefix":"/"}}],"route":[{"destination":{"host":"productpage","port":{"number":9080}}}]}]}}
  creationTimestamp: "2025-12-31T05:30:04Z"
  generation: 1
  name: bookinfo
  namespace: default
  resourceVersion: "8121204"
  uid: b0fd2c20-35ab-475c-8c1a-d6dc36749ce8
spec:
  gateways:
  - bookinfo-gateway
  hosts:
  - '*'
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: productpage
        port:
          number: 9080

三、对应svc和pod

root@k8s-01:/woke/istio# kubectl get pod
NAME                                      READY   STATUS    RESTARTS   AGE
bookinfo-gateway-istio-6c4c8d9b74-z7c4j   1/1     Running   0          18d
details-v1-7b88fb8889-5qt26               2/2     Running   0          33d
nginx-5fd58574d-2c9z9                     2/2     Running   0          13d
nginx-test-78b8db46d6-cfd98               2/2     Running   0          13d
productpage-v1-79d79d6-mktpd              2/2     Running   0          33d
ratings-v1-5b89cf4bbf-c9xdg               2/2     Running   0          33d
reviews-v1-ffd57b847-w9dkr                2/2     Running   0          33d
reviews-v2-8cc6fd8dc-q9bd9                2/2     Running   0          33d
reviews-v3-cf48455-znts5                  2/2     Running   0          33d
traefik-gw-istio-7867b4f544-hkknj         1/1     Running   0          18d
root@k8s-01:/woke/istio# kubectl get svc
NAME                     TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                          AGE
bookinfo-gateway-istio   ClusterIP      10.105.38.228    <none>        15021/TCP,80/TCP                 18d
details                  ClusterIP      10.100.97.40     <none>        9080/TCP                         35d
kubernetes               ClusterIP      10.96.0.1        <none>        443/TCP                          78d
nginx                    ClusterIP      10.110.220.61    <none>        80/TCP                           60d
nginx-svc                NodePort       10.108.4.45      <none>        80:32574/TCP                     77d
productpage              ClusterIP      10.111.145.105   <none>        9080/TCP                         35d
ratings                  ClusterIP      10.98.94.10      <none>        9080/TCP                         35d
reviews                  ClusterIP      10.97.19.38      <none>        9080/TCP                         35d
traefik-gw-istio         LoadBalancer   10.103.179.128   <pending>     15021:31055/TCP,8000:30447/TCP   18d
root@k8s-01:/woke/istio# kubectl get pod -n istio-system 
NAME                                    READY   STATUS      RESTARTS      AGE
istio-egressgateway-596f455c4f-7qh6w    1/1     Running     0             13d
istio-ingressgateway-796f5cf647-tcpph   1/1     Running     0             13d
istiod-5c84f8c79d-ddxkz                 1/1     Running     0             13d
kiali-68f9949bf5-8n4tk                  1/1     Running     6 (13d ago)   13d
prometheus-7f6bc65664-29c7c             0/2     Completed   0             18d
prometheus-7f6bc65664-llp2q             2/2     Running     0             5d
root@k8s-01:/woke/istio# kubectl get svc -n istio-system 
NAME                          TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                      AGE
istio-egressgateway           ClusterIP   10.106.183.187   <none>        80/TCP,443/TCP                                                               35d
istio-ingressgateway          NodePort    10.99.189.246    <none>        15021:31689/TCP,80:32241/TCP,443:30394/TCP,31400:31664/TCP,15443:32466/TCP   35d
istiod                        ClusterIP   10.104.189.5     <none>        15010/TCP,15012/TCP,443/TCP,15014/TCP                                        35d
istiod-revision-tag-default   ClusterIP   10.102.152.242   <none>        15010/TCP,15012/TCP,443/TCP,15014/TCP                                        35d
kiali                         NodePort    10.103.234.52    <none>        20001:30318/TCP,9090:30682/TCP                                               34d
prometheus                    ClusterIP   10.100.183.52    <none>        9090/TCP                                                                     34d
root@k8s-01:/woke/istio# 
0

评论 (0)

取消