第 11 章 将功能订阅到 CloudEvents
			您可以将功能订阅到一组事件。这会将您的功能链接到您的过滤器定义的 CloudEvent 对象,并启用自动响应。
		
11.1. 将功能订阅到 CloudEvents
复制链接链接已复制到粘贴板!
				subscribe 命令将功能连接到一组事件,与 CloudEvent 元数据的一系列过滤器以及 Knative Broker 作为被消耗的事件源匹配。
			
先决条件
- 在集群中安装了 Knative Eventing。
- 已配置了 Knative Broker。
- 
						已安装 Knative (kn) CLI。
流程
- 运行以下命令,将功能订阅给定代理的事件: - 示例命令 - kn func subscribe --filter type=com.example.Hello --source my-broker - $ kn func subscribe --filter type=com.example.Hello --source my-broker- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 使用-- - source标志指定代理以及一个或多个--- filter标志来指定您的过滤器。- 您还可以省略 the- - -source标志以使用 default 代理:- 示例命令 - kn func subscribe --filter type=com.example --filter extension=my-extension-value - $ kn func subscribe --filter type=com.example --filter extension=my-extension-value- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- 使用 Knative Triggers 部署功能: - 示例命令 - kn func deploy - $ kn func deploy- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 输出示例 - 🙌 Function image built: <registry>/hello:latest 🎯 Creating Triggers on the cluster ✅ Function deployed in namespace "default" and exposed at URL: http://hello.default.my-cluster.example.com - 🙌 Function image built: <registry>/hello:latest 🎯 Creating Triggers on the cluster ✅ Function deployed in namespace "default" and exposed at URL: http://hello.default.my-cluster.example.com- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow