美文网首页
demo4 - Ingress-gateway暴露demoap

demo4 - Ingress-gateway暴露demoap

作者: 程序员札记 | 来源:发表于2023-01-12 08:33 被阅读0次

    架构图

    • proxy-gateway -> virtualservices/proxy -> destinationrule/proxy (或者service/proxy) -> MESH
    image

    proxy-gateway.yaml

    apiVersion: networking.istio.io/v1beta1
    kind: Gateway
    metadata:
      name: proxy-gateway
      namespace: istio-system
    spec:
      selector:
        app: istio-ingressgateway
      servers:
      - port:
          number: 80
          name: http
          protocol: HTTP
        hosts:
        - "app.wgs.com"
    ---
    

    virtualservice-proxy.yaml

    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
      name: proxy
    spec:
      hosts:
      - "app.wgs.com"                 # 对应于gateways/proxy-gateway
      gateways:
      - istio-system/proxy-gateway    # 相关定义仅应用于Ingress Gateway上
      # - mesh                        # 启用该列表项,意味着该VS同时应用于各Sidecar上
      http:
      - name: default
        route:
        - destination:
            host: proxy
    

    创建资源

    # kubectl apply -f proxy-gateway.yaml -f proxy-virtualservice-proxy.yaml 
    gateway.networking.istio.io/proxy-gateway created
    virtualservice.networking.istio.io/proxy created
    

    查看Istio-ingress-gateway svc EXTERNAL-IP

    ~# kubectl get svc -n istio-system 
    NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)                                                                      AGE
    grafana                ClusterIP      10.100.124.243   <none>            3000/TCP                                                                     4d19h
    istio-egressgateway    ClusterIP      10.100.121.95    <none>            80/TCP,443/TCP                                                               4d19h
    istio-ingressgateway   LoadBalancer   10.100.145.112   192.168.174.250   15021:32417/TCP,80:46683/TCP,443:37652/TCP,31400:59146/TCP,15443:30622/TCP   4d19h
    istiod                 ClusterIP      10.100.149.76    <none>            15010/TCP,15012/TCP,443/TCP,15014/TCP                                        4d19h
    jaeger-collector       ClusterIP      10.100.122.235   <none>            14268/TCP,14250/TCP,9411/TCP                                                 4d19h
    kiali                  ClusterIP      10.100.48.203    <none>            20001/TCP,9090/TCP                                                           4d19h
    prometheus             ClusterIP      10.100.42.102    <none>            9090/TCP                                                                     4d19h
    tracing                ClusterIP      10.100.92.199    <none>            80/TCP,16685/TCP                                                             4d19h
    zipkin                 ClusterIP      10.100.29.132    <none>            9411/TCP                                                                     4d19h
    

    添加域名解析

    192.168.174.250  app.wgs.com
    

    访问v10子集

    ~# while true;do curl app.wgs.com; sleep 0.5; done
    Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-kdv4m, ServerIP: 172.20.154.244!
     - Took 7 milliseconds.
    Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-hq957, ServerIP: 172.20.44.255!
     - Took 7 milliseconds.
    Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-kdv4m, ServerIP: 172.20.154.244!
     - Took 4 milliseconds.
    Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-hq957, ServerIP: 172.20.44.255!
     - Took 7 milliseconds.
    Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-kdv4m, ServerIP: 172.20.154.244!
     - Took 9 milliseconds.
    Proxying value: iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.6, ServerName: demoappv10-78b6586d58-hq957, ServerIP: 172.20.44.255!
     - Took 5 milliseconds.
    

    查看kiali

    image image

    访问v11子集

    ~# while true;do curl app.wgs.com/canary; sleep 0.5; done
    Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
     - Took 7 milliseconds.
    Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
     - Took 5 milliseconds.
    Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
     - Took 4 milliseconds.
    Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
     - Took 4 milliseconds.
    Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
     - Took 11 milliseconds.
    Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-hckjf, ServerIP: 172.20.89.184!
     - Took 6 milliseconds.
    Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-hckjf, ServerIP: 172.20.89.184!
     - Took 7 milliseconds.
    Proxying value: iKubernetes demoapp v1.1 !! ClientIP: 127.0.0.6, ServerName: demoappv11-78bf898c74-sn9qp, ServerIP: 172.20.154.245!
     - Took 4 milliseconds.
    

    查看kiali

    image image

    参考文档

    https://istio.io/latest/zh/docs/reference/config/networking/gateway/#Gateway

    相关文章

      网友评论

          本文标题:demo4 - Ingress-gateway暴露demoap

          本文链接:https://www.haomeiwen.com/subject/hunicdtx.html