knative revision最终创建的deploy,会在pod中启用一个sidecar容器,即queue-proxy。
下图展示了queue-proxy的用途,业务流量首先进入 Istio Gateway,然后会转发到 Queue-Proxy 的 8012 端口,Queue-Proxy 8012 再把请求转发到业务容器的监听端口。
queue-proxy用途
- 应用请求数等指标统计。
- Pod健康检查(k8s探针)
- 代理转发流量
- 判断Ingress是否ready需要通过访问queue-proxy实现
queue-proxy预留的端口
knative的组件预留了一些端口作为服务端口,例如8012端口默认是给queue使用的,因此应用的端口应该避开这些预留的端口。
- 8012,queue-proxy代理的http端口,一般访问应用流量的入口。
- 8013,http2端口,用于grpc流量的转发。
- 8022,queue-proxy管理端口。
- 9090,queue-proxy容器的监控端口,图中的端口已过时。数据由Autoscaler采集,用于kpa。
- 9091,queue-proxy采集到的应用监控指标(req请求数,响应市场等),图中的端口已过时。由prometheus采集,用于计费。
serving/pkg/apis/networking/ports.go
// The ports we setup on our services.
const (
// ServiceHTTPPort is the port that we setup our Serving and Activator K8s services for
// HTTP/1 endpoints.
ServiceHTTPPort = 80
// ServiceHTTP2Port is the port that we setup our Serving and Activator K8s services for
// HTTP/2 endpoints.
ServiceHTTP2Port = 81
// BackendHTTPPort is the backend, i.e. `targetPort` that we setup for HTTP services.
BackendHTTPPort = 8012
// BackendHTTP2Port is the backend, i.e. `targetPort` that we setup for HTTP services.
BackendHTTP2Port = 8013
// QueueAdminPort specifies the