Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请给出一份完整的k8s可以运行http3.0配置文件 #1826

Closed
clywm520 opened this issue Jul 25, 2023 · 20 comments
Closed

请给出一份完整的k8s可以运行http3.0配置文件 #1826

clywm520 opened this issue Jul 25, 2023 · 20 comments
Assignees

Comments

@clywm520
Copy link

@drawing 请提供一份,完整的K8S配置么.试了好多遍,还是没有部署成功,http3.0协议未体现出来,前端的提供的是本地编译的配置,现需要完整的k8s.yml配置  。 同类产品traefik一次成功

@chobits chobits assigned drawing and unassigned chobits Jul 25, 2023
@drawing drawing added this to the 3.0.1 milestone Jul 25, 2023
drawing added a commit to drawing/tengine that referenced this issue Jul 26, 2023
@drawing
Copy link
Collaborator

drawing commented Jul 26, 2023

目前 Tenigne-Ingress 镜像在 HTTP3 证书匹配上存在一些问题,会在 1.0.1 Bugfix 版本修复,如果期望提前验一下可以用镜像 tengine-ingress-registry.cn-hangzhou.cr.aliyuncs.com/tengine/tengine-ingress:1.0.1-beta,参考文档:k8s环境下使用 HTTP3

我们会在近期 release

@clywm520
Copy link
Author

@drawing 可以在生产环境使用不,什么时候release呢

@drawing
Copy link
Collaborator

drawing commented Jul 27, 2023

@clywm520 release之前最好不要生产环境使用,这次修改只是修复一些bug,会在8月份 release,另外可以在你们场景下提前验证一下,不同场景下可能遇到的问题不同,如有其他问题我们也可以一起修复后release

@clywm520
Copy link
Author

@drawing tengine-ingress-registry.cn-hangzhou.cr.aliyuncs.com/tengine/tengine-ingress:1.0.1-beta 在centos7 k3s1.21.7环境 测试还是无法试出HTTP3.0出来。 改为hostNetWork也不行

apiVersion: apps/v1
kind: Deployment
metadata:
name: tengine-deployment
spec:
selector:
matchLabels:
app: tengine
replicas: 1
template:
metadata:
labels:
app: tengine
spec:
hostNetwork: true
containers:
- name: tengine
image: tengine-ingress-registry.cn-hangzhou.cr.aliyuncs.com/tengine/tengine-ingress:1.0.1-beta
ports:
- containerPort: 80
command: ["/usr/bin/dumb-init"]
args:
- "--"
- "/tengine-ingress-controller"
- "--configmap=default/tengine-ingress-configuration"
- "--annotations-prefix=nginx.ingress.kubernetes.io"
- "--v=1"
env:
- name: log_level
value: "1"
- name: "POD_NAME"
valueFrom:
fieldRef:
fieldPath: "metadata.name"
- name: "POD_NAMESPACE"
valueFrom:
fieldRef:
fieldPath: "metadata.namespace"

apiVersion: v1
kind: ConfigMap
metadata:
name: tengine-ingress-configuration
namespace: default
data:
http3-xquic-default-port: "2443"

@drawing
Copy link
Collaborator

drawing commented Jul 31, 2023

是浏览器直连pod么?xquic监听的是2443端口,说期望 H2 的 443 切 H3 的 2443 么,麻烦做一些诊断

  1. 浏览器是否开启 QUIC 访问(如访问 https://quic.nginx.org 检查是否开启 quic)
  2. 判断 xquic 监听端口是否正常,使用 netstat 工具,查看 2443 端口是否监听 UDP 端口,ps 进程查看 nginx worker进程是否启动
sudo yum install -y net-tools
netstat -anop | grep 2443
  1. 证书是否受信,如证书不受信,浏览器无法切换成功
  2. 使用 curl 等工具强制访问 H3 是否能连通,如本地没有编译,可以使用 ymuski/curl-http3 镜像
docker run -it --rm ymuski/curl-http3 curl https://test.com:2443 --resolve "test.com:2443:11.11.11.11" --http3 -v
  1. 查看进程是否有crash,如登录镜像 /etc/nginx 目录下是否有core文件(core位置可由内核参数决定,可以通过命令 sysctl -q kernel.core_pattern 查看,如出现crash,可通过gdb bt命令查看堆栈贴一下
yum install -y gdb
gdb /usr/local/tengine/sbin/tengine core.xxx

@clywm520
Copy link
Author

  1. edge浏览器 版本 115.0.1901.188 (正式版本) (64 位) 访问 https://log.openjad.com 能出现http3.0
  2. udp监听2443端口
  3. 证书受信
  4. docker run -it --rm ymuski/curl-http3 curl https://log.openjad.com:2443 --http3 -v
    能出现http3.0协议
  • Trying 106.55.35.79:2443...
  • Connect socket 5 over QUIC to 106.55.35.79:2443
  • Sent QUIC client Initial, ALPN: h3-29,h3-28,h3-27
  • Connected to log.openjad.com () port 2443 (#0)
  • h3 [:method: GET]
  • h3 [:path: /]
  • h3 [:scheme: https]
  • h3 [:authority: log.openjad.com:2443]
  • h3 [user-agent: curl/7.76.1-DEV]
  • h3 [accept: /]
  • Using HTTP/3 Stream ID: 0 (easy handle 0x55ce11e951c0)

GET / HTTP/3
Host: log.openjad.com:2443
user-agent: curl/7.76.1-DEV
accept: /

5.未crash

经过测试 curl能出现H3协议。然而
为什么 edge浏览器 版本 115.0.1901.188 (正式版本) (64 位) 、chrome访问也不会出h3协议。
切换 traefik没有这个问题。
希望能修正好哈.毕竟traefik 没有tengine配置灵活。还能希望容器能以root用户运行。

3 similar comments
@clywm520
Copy link
Author

  1. edge浏览器 版本 115.0.1901.188 (正式版本) (64 位) 访问 https://log.openjad.com 能出现http3.0
  2. udp监听2443端口
  3. 证书受信
  4. docker run -it --rm ymuski/curl-http3 curl https://log.openjad.com:2443 --http3 -v
    能出现http3.0协议
  • Trying 106.55.35.79:2443...
  • Connect socket 5 over QUIC to 106.55.35.79:2443
  • Sent QUIC client Initial, ALPN: h3-29,h3-28,h3-27
  • Connected to log.openjad.com () port 2443 (#0)
  • h3 [:method: GET]
  • h3 [:path: /]
  • h3 [:scheme: https]
  • h3 [:authority: log.openjad.com:2443]
  • h3 [user-agent: curl/7.76.1-DEV]
  • h3 [accept: /]
  • Using HTTP/3 Stream ID: 0 (easy handle 0x55ce11e951c0)

GET / HTTP/3
Host: log.openjad.com:2443
user-agent: curl/7.76.1-DEV
accept: /

5.未crash

经过测试 curl能出现H3协议。然而
为什么 edge浏览器 版本 115.0.1901.188 (正式版本) (64 位) 、chrome访问也不会出h3协议。
切换 traefik没有这个问题。
希望能修正好哈.毕竟traefik 没有tengine配置灵活。还能希望容器能以root用户运行。

@clywm520
Copy link
Author

  1. edge浏览器 版本 115.0.1901.188 (正式版本) (64 位) 访问 https://log.openjad.com 能出现http3.0
  2. udp监听2443端口
  3. 证书受信
  4. docker run -it --rm ymuski/curl-http3 curl https://log.openjad.com:2443 --http3 -v
    能出现http3.0协议
  • Trying 106.55.35.79:2443...
  • Connect socket 5 over QUIC to 106.55.35.79:2443
  • Sent QUIC client Initial, ALPN: h3-29,h3-28,h3-27
  • Connected to log.openjad.com () port 2443 (#0)
  • h3 [:method: GET]
  • h3 [:path: /]
  • h3 [:scheme: https]
  • h3 [:authority: log.openjad.com:2443]
  • h3 [user-agent: curl/7.76.1-DEV]
  • h3 [accept: /]
  • Using HTTP/3 Stream ID: 0 (easy handle 0x55ce11e951c0)

GET / HTTP/3
Host: log.openjad.com:2443
user-agent: curl/7.76.1-DEV
accept: /

5.未crash

经过测试 curl能出现H3协议。然而
为什么 edge浏览器 版本 115.0.1901.188 (正式版本) (64 位) 、chrome访问也不会出h3协议。
切换 traefik没有这个问题。
希望能修正好哈.毕竟traefik 没有tengine配置灵活。还能希望容器能以root用户运行。

@clywm520
Copy link
Author

  1. edge浏览器 版本 115.0.1901.188 (正式版本) (64 位) 访问 https://log.openjad.com 能出现http3.0
  2. udp监听2443端口
  3. 证书受信
  4. docker run -it --rm ymuski/curl-http3 curl https://log.openjad.com:2443 --http3 -v
    能出现http3.0协议
  • Trying 106.55.35.79:2443...
  • Connect socket 5 over QUIC to 106.55.35.79:2443
  • Sent QUIC client Initial, ALPN: h3-29,h3-28,h3-27
  • Connected to log.openjad.com () port 2443 (#0)
  • h3 [:method: GET]
  • h3 [:path: /]
  • h3 [:scheme: https]
  • h3 [:authority: log.openjad.com:2443]
  • h3 [user-agent: curl/7.76.1-DEV]
  • h3 [accept: /]
  • Using HTTP/3 Stream ID: 0 (easy handle 0x55ce11e951c0)

GET / HTTP/3
Host: log.openjad.com:2443
user-agent: curl/7.76.1-DEV
accept: /

5.未crash

经过测试 curl能出现H3协议。然而
为什么 edge浏览器 版本 115.0.1901.188 (正式版本) (64 位) 、chrome访问也不会出h3协议。
切换 traefik没有这个问题。
希望能修正好哈.毕竟traefik 没有tengine配置灵活。还能希望容器能以root用户运行。

@drawing
Copy link
Collaborator

drawing commented Aug 1, 2023

@clywm520 这个问题的原因应该是浏览器出于安全性考虑,小于 1024 端口的 H2 协议没办法通过 Alt-Svc 切换到大于 1024 端口的 H3 上,稍后我再打个镜像,可以通过 Configmap 配置 worker 进程运行的用户,允许以 root 方式启动 worker 进程,这样 xquic 可以直接监听443端口,避免此问题。不过如果网关前有负载均衡设备,最好是做一个 UDP 443 到 UDP 2443 的转换,如果以 root 方式启动 worker,会降低安全水位。

@clywm520
Copy link
Author

clywm520 commented Aug 1, 2023

@drawing 镜像好了么,等着切换哈。

@drawing
Copy link
Collaborator

drawing commented Aug 1, 2023

@clywm520 今天改完明天我打个镜像

@lianglli
Copy link
Member

lianglli commented Aug 1, 2023

@clywm520

Rebuild your tengine-ingress image based on latest master branch of https://github.com/alibaba/tengine-ingress.

Then, upgrade you deployment / statefulset with new image.

HTTP/3 will be listened on port 443 which is same as the HTTP2.

You will not need to change any config anymore.

@drawing
Copy link
Collaborator

drawing commented Aug 2, 2023

@clywm520 可以使用镜像tengine-ingress-registry-vpc.cn-hangzhou.cr.aliyuncs.com/tengine/tengine-ingress:1.0.1-beta2 测一下,这个镜像默认quic使用443端口,configmap中的 http3-xquic-default-port 也不需要配置

@clywm520
Copy link
Author

clywm520 commented Aug 2, 2023

tengine-ingress-registry-vpc.cn-hangzhou.cr.aliyuncs.com/tengine/tengine-ingress:1.0.1-beta2 这个镜像验证OK

chobits pushed a commit to chobits/tengine that referenced this issue Aug 4, 2023
chobits pushed a commit to chobits/tengine that referenced this issue Aug 4, 2023
@clywm520
Copy link
Author

clywm520 commented Aug 5, 2023

@drawing 请教一下,使用了tengine-ingress-registry-vpc.cn-hangzhou.cr.aliyuncs.com/tengine/tengine-ingress:1.0.1-beta2这个镜像后,

ingress配置如下双向认证无效了。 还有 ingress指定配置 nginx.ingress.kubernetes.io/server-snippet: 也无效了。例如:

kind: Ingress
metadata:
name: log
namespace: default
annotations:
nginx.ingress.kubernetes.io/auth-tls-verify-client: "on"
nginx.ingress.kubernetes.io/auth-tls-secret: "default/ca-secret"
nginx.ingress.kubernetes.io/auth-tls-verify-depth: "1"

====
nginx.ingress.kubernetes.io/server-snippet: |
add_header nginxingress 888;
gzip_static on;
gzip_proxied expired no-cache no-store private auth;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 9;
gzip_types text/plain application/javascript text/css application/xml text/javascript application/json font/woff image/jpeg image/gif image/png;
gzip_vary on;

@drawing 请帮忙给出https双向认证的配置写法,以及指定nginx.conf server位置的写法哈。或者指定 配置前端html指定目录也行

@lianglli
Copy link
Member

lianglli commented Aug 6, 2023

@drawing 请教一下,使用了tengine-ingress-registry-vpc.cn-hangzhou.cr.aliyuncs.com/tengine/tengine-ingress:1.0.1-beta2这个镜像后,

ingress配置如下双向认证无效了。 还有 ingress指定配置 nginx.ingress.kubernetes.io/server-snippet: 也无效了。例如:

kind: Ingress metadata: name: log namespace: default annotations: nginx.ingress.kubernetes.io/auth-tls-verify-client: "on" nginx.ingress.kubernetes.io/auth-tls-secret: "default/ca-secret" nginx.ingress.kubernetes.io/auth-tls-verify-depth: "1"

==== nginx.ingress.kubernetes.io/server-snippet: | add_header nginxingress 888; gzip_static on; gzip_proxied expired no-cache no-store private auth; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 9; gzip_types text/plain application/javascript text/css application/xml text/javascript application/json font/woff image/jpeg image/gif image/png; gzip_vary on;

@drawing 请帮忙给出https双向认证的配置写法,以及指定nginx.conf server位置的写法哈。或者指定 配置前端html指定目录也行

因为,Tengine-Ingress是动态生效,不会reload worker processes。
auth相关的注解暂不支持动态生效,如果需要使用这个功能,在Configmap里增加配置:

  tengine-reload: 'true'
  tengine-static-service-cfg: 'true'

这个问题与HTTP/3无关,而且对于auth相关的注解,Tengine-Ingress暂不支持动态生效;
因此,如果需要默认动态无损生效,到 https://github.com/alibaba/tengine-ingress/issues 提个issue。

@clywm520
Copy link
Author

clywm520 commented Aug 6, 2023

还有一个问题哈 。
不支持配置 哈。估计是tengine不自带brotli_static 模块么。
brotli_static on;
brotli_comp_level 9;
brotli_buffers 4 16k;

@drawing
Copy link
Collaborator

drawing commented Aug 7, 2023

还有一个问题哈 。 不支持配置 哈。估计是tengine不自带brotli_static 模块么。 brotli_static on; brotli_comp_level 9; brotli_buffers 4 16k;

@clywm520 镜像里是有编译此模块的,只是以动态模块的方式编译,需要 load_module指令加载一下,configmap 增加配置即可使用

  main-snippet: |
    load_module /etc/nginx/modules/ngx_http_brotli_static_module.so;
    load_module /etc/nginx/modules/ngx_http_brotli_filter_module.so;
  http-snippet: |
    brotli_static on;
    brotli_comp_level 9;
    brotli_buffers 4 16k;

@drawing
Copy link
Collaborator

drawing commented Aug 8, 2023

此问题已关闭,如有新的问题麻烦提交一个新的issue讨论

@drawing drawing closed this as completed Aug 8, 2023
jizhuozhi pushed a commit to jizhuozhi/tengine that referenced this issue Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants