簡體   English   中英

Istio:如何全局修改 h2UpgradePolicy?

[英]Istio: How to modify the h2UpgradePolicy globally?

我想將所有傳入的 http 1.1 連接升級到 Istio 中的 http2。 我了解如何通過特定命名空間和 pod 的目標規則來實現這一點。

但是,我也想從 http1.1 升級服務網格中的所有連接 http2。 如果在此處自動注入 Istio sidecar,即使文檔也建議這樣做。

如果 sidecar 安裝在網格中的所有 pod 上,則應將其設置為 UPGRADE。

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

如果是,該條目會是什么樣子?

如果不是,請建議我如何以最少的努力實現這一目標?

實際上,您將在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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM