第 4 章 配置 OpenShift Serverless 应用程序
4.1. 对 Serving 的多容器支持 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
您可以使用单个 Knative 服务部署多容器 pod。这个方法可用于将应用程序职责划分为较小的特殊部分。
4.1.1. 配置多容器服务 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
默认启用多容器支持。您可以通过指定服务中的多个容器来创建多容器 pod。
流程
修改您的服务使其包含其他容器。只有一个容器可以处理请求,因此为一个容器指定一个
端口。以下是有两个容器的示例配置:多容器配置
apiVersion: serving.knative.dev/v1 kind: Service ... spec: template: spec: containers: - name: first-container1 image: gcr.io/knative-samples/helloworld-go ports: - containerPort: 80802 - name: second-container3 image: gcr.io/knative-samples/helloworld-java
4.1.2. 探测多容器服务 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
您可以为多个容器指定就绪度和存活度探测。默认情况下不启用此功能,您必须使用 KnativeServing 自定义资源(CR)配置它。
流程
通过在
KnativeServingCR 中启用多容器代理功能,为您的服务配置多容器探测。多容器探测配置
... spec: config: features: "multi-container-probing": enabled1 ...- 1
- 启用多容器 -probing 功能
应用更新的
KnativeServingCR。$ oc apply -f <filename>修改您的多容器服务,使其包含指定的探测。
多容器探测
apiVersion: serving.knative.dev/v1 kind: Service ... spec: template: spec: containers: - name: first-container image: ghcr.io/knative/helloworld-go:latest ports: - containerPort: 8080 readinessProbe:1 httpGet: port: 8080 - name: second-container image: gcr.io/knative-samples/helloworld-java readinessProbe:2 httpGet: port: 8090
4.1.2.1. 其他资源 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!