【问题标题】:Istio: How to modify the h2UpgradePolicy globally?Istio:如何全局修改 h2UpgradePolicy?
【发布时间】:2020-10-11 05:46:57
【问题描述】:

我想在 Istio 中将所有传入的 http 1.1 连接升级到 http2。我了解如何通过特定命名空间和 pod 的目标规则来实现这一点。

但是,我想将服务网格中的所有连接都从 http1.1 升级为 http2。如果自动注入 Istio sidecar here,即使文档也建议这样做。

如果网格中的所有 pod 上都安装了 sidecar,则应将其设置为 UPGRADE。

我可以更新“Istio-system”命名空间下的“istio”ConfigMap吗?

如果是,该条目会是什么样子?

如果不是,请建议我如何以最少的努力实现这一目标?

【问题讨论】:

    标签: kubernetes-ingress http2 istio istio-kiali


    【解决方案1】:

    确实,您将在configMap istio 中设置它,它会是这样的:

    apiVersion: v1
    data:
      mesh: |-
        accessLogEncoding: TEXT
        accessLogFile: /dev/stdout
        accessLogFormat: ""
        h2UpgradePolicy: UPGRADE        #<- here
        defaultConfig:
          concurrency: 2
          configPath: ./etc/istio/proxy
    

    现在,要查看它是否有效有点棘手。我发送了四个请求;其中两个没有h2UpgradePolicy 参数,其中两个带有h2UpgradePolicy: UPGRADE。但是我从客户那里收到的所有四个请求都是这样的:

    $ kubectl exec -it curler -- curl -I demo.istio
    Defaulting container name to curler.
    Use 'kubectl describe pod/curler -n default' to see all of the containers in this pod.
    HTTP/1.1 200 OK
    server: envoy
    date: Mon, 22 Jun 2020 13:05:53 GMT
    content-type: text/html
    content-length: 612
    last-modified: Tue, 26 May 2020 15:00:20 GMT
    etag: "5ecd2f04-264"
    accept-ranges: bytes
    x-envoy-upstream-service-time: 1
    

    我从网格外部发送请求,因为默认情况下我从内部获取 HTTP2。因此,在我的情况下,mTLS 被禁用,但这无关紧要。

    要查看它是否有效,您需要检查下游代理的日志:

    ...
    [2020-06-22T13:03:03.942Z] "HEAD / HTTP/1.1" 200 - "-" "-" 0 0 0 0 "-" "curl/7.59.0" "a7c32d21-dcea-95da-b7c1-67c5783a1641" "demo.istio" "127.0.0.1:80" inbound|80|http|demo.istio.svc.cluster.local 127.0.0.1:33180 192.168.72.186:80 192.168.66.168:34814 outbound_.80_._.demo.istio.svc.cluster.local default
    [2020-06-22T13:03:05.245Z] "HEAD / HTTP/1.1" 200 - "-" "-" 0 0 0 0 "-" "curl/7.59.0" "409b3432-365f-94fe-87cd-8a85b586b42d" "demo.istio" "127.0.0.1:80" inbound|80|http|demo.istio.svc.cluster.local 127.0.0.1:60952 192.168.72.186:80 192.168.66.168:34830 outbound_.80_._.demo.istio.svc.cluster.local default
    [2020-06-22T13:03:36.732Z] "HEAD / HTTP/2" 200 - "-" "-" 0 0 0 0 "-" "curl/7.59.0" "45dd94e5-6f29-9114-b09f-bda065dfd1eb" "demo.istio" "127.0.0.1:80" inbound|80|http|demo.istio.svc.cluster.local 127.0.0.1:33180 192.168.72.186:80 192.168.66.168:35120 outbound_.80_._.demo.istio.svc.cluster.local default
    [2020-06-22T13:03:38.743Z] "HEAD / HTTP/2" 200 - "-" "-" 0 0 0 0 "-" "curl/7.59.0" "79e72286-f247-9ed0-b510-2819a886c7f9" "demo.istio" "127.0.0.1:80" inbound|80|http|demo.istio.svc.cluster.local 127.0.0.1:33180 192.168.72.186:80 192.168.66.168:35120 outbound_.80_._.demo.istio.svc.cluster.local default
    

    非常重要:要使其工作,前面的服务如果下游对等点,必须有命名端口,并且必须调用http

    apiVersion: v1
    kind: Service
    metadata:
      name: demo
    spec:
      ports:
      - name: http      #<- this parameter is mandatory to upgrade to HTTP2
        port: 80
        protocol: TCP
        targetPort: 80
      selector:
        app: nginx
    

    【讨论】:

    猜你喜欢
    • 2019-09-24
    • 1970-01-01
    • 2017-08-15
    • 2017-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多