This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.5.11.2. 使用 Knative CLI 创建频道
使用 Knative (kn
) 创建频道提供了比直接修改 YAML 文件更精简且直观的用户界面。您可以使用 kn channel create
命令创建频道。
先决条件
- 在集群中安装了 OpenShift Serverless Operator 和 Knative Eventing。
-
已安装 Knative (
kn
) CLI。 - 您已创建了一个项目,或者具有适当的角色和权限访问项目,以便在 OpenShift Container Platform 中创建应用程序和其他工作负载。
流程
创建频道:
kn channel create <channel_name> --type <channel_type>
$ kn channel create <channel_name> --type <channel_type>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 频道类型是可选的,但如果指定,则必须使用
Group:Version:Kind
格式。例如,您可以创建一个InMemoryChannel
对象:kn channel create mychannel --type messaging.knative.dev:v1:InMemoryChannel
$ kn channel create mychannel --type messaging.knative.dev:v1:InMemoryChannel
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
Channel 'mychannel' created in namespace 'default'.
Channel 'mychannel' created in namespace 'default'.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
验证
要确认该频道现在存在,请列出现有频道并检查输出:
kn channel list
$ kn channel list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
kn channel list NAME TYPE URL AGE READY REASON mychannel InMemoryChannel http://mychannel-kn-channel.default.svc.cluster.local 93s True
kn channel list NAME TYPE URL AGE READY REASON mychannel InMemoryChannel http://mychannel-kn-channel.default.svc.cluster.local 93s True
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
删除频道
删除频道:
kn channel delete <channel_name>
$ kn channel delete <channel_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow