3.2.2. 使用 YAML 安装 Knative Serving
安装 OpenShift Serverless Operator 后,您可以使用默认设置安装 Knative Serving,或者在 KnativeServing
自定义资源(CR)中配置更高级的设置。您可以使用 YAML 文件和 oc
CLI 安装 Knative Serving。
先决条件
- 您可以访问具有集群管理员权限的 OpenShift Container Platform 帐户。
- 已安装 OpenShift Serverless Operator。
-
安装 OpenShift CLI(
oc
)。
流程
创建名为
serving.yaml
的文件并将以下示例 YAML 复制到其中:apiVersion: operator.knative.dev/v1alpha1 kind: KnativeServing metadata: name: knative-serving namespace: knative-serving
应用
service.yaml
文件:$ oc apply -f serving.yaml
验证
使用以下命令校验安装是否完成:
$ oc get knativeserving.operator.knative.dev/knative-serving -n knative-serving --template='{{range .status.conditions}}{{printf "%s=%s\n" .type .status}}{{end}}'
输出示例
DependenciesInstalled=True DeploymentsAvailable=True InstallSucceeded=True Ready=True
注意创建 Knative Serving 资源可能需要几秒钟时间。
如果条件状态为
Unknown
或False
,请等待几分钟,然后在确认已创建资源后再重新检查。检查是否已创建 Knative Serving 资源:
$ oc get pods -n knative-serving
输出示例
NAME READY STATUS RESTARTS AGE activator-67ddf8c9d7-p7rm5 2/2 Running 0 4m activator-67ddf8c9d7-q84fz 2/2 Running 0 4m autoscaler-5d87bc6dbf-6nqc6 2/2 Running 0 3m59s autoscaler-5d87bc6dbf-h64rl 2/2 Running 0 3m59s autoscaler-hpa-77f85f5cc4-lrts7 2/2 Running 0 3m57s autoscaler-hpa-77f85f5cc4-zx7hl 2/2 Running 0 3m56s controller-5cfc7cb8db-nlccl 2/2 Running 0 3m50s controller-5cfc7cb8db-rmv7r 2/2 Running 0 3m18s domain-mapping-86d84bb6b4-r746m 2/2 Running 0 3m58s domain-mapping-86d84bb6b4-v7nh8 2/2 Running 0 3m58s domainmapping-webhook-769d679d45-bkcnj 2/2 Running 0 3m58s domainmapping-webhook-769d679d45-fff68 2/2 Running 0 3m58s storage-version-migration-serving-serving-0.26.0--1-6qlkb 0/1 Completed 0 3m56s webhook-5fb774f8d8-6bqrt 2/2 Running 0 3m57s webhook-5fb774f8d8-b8lt5 2/2 Running 0 3m57s
检查所需的网络组件是否已安装到自动创建的
knative-serving-ingress
命名空间:$ oc get pods -n knative-serving-ingress
输出示例
NAME READY STATUS RESTARTS AGE net-kourier-controller-7d4b6c5d95-62mkf 1/1 Running 0 76s net-kourier-controller-7d4b6c5d95-qmgm2 1/1 Running 0 76s 3scale-kourier-gateway-6688b49568-987qz 1/1 Running 0 75s 3scale-kourier-gateway-6688b49568-b5tnp 1/1 Running 0 75s