9.6. 迁移消费者应用程序,以使用 PTP 或裸机事件的 HTTP 传输
如果您之前部署了 PTP 或裸机事件消费者应用程序,您需要更新应用程序以使用 HTTP 消息传输。
先决条件
-
已安装 OpenShift CLI(
oc
)。 -
您已以具有
cluster-admin
权限的用户身份登录。 - 您已将 PTP Operator 或 Bare Metal Event Relay 更新至使用 HTTP 传输的版本 4.13+。
流程
更新您的事件消费者应用以使用 HTTP 传输。为云事件 sidecar 部署设置
http-event-publishers
变量。例如,在配置了 PTP 事件的集群中,以下 YAML 片断演示了一个云事件 sidecar 部署:
containers: - name: cloud-event-sidecar image: cloud-event-sidecar args: - "--metrics-addr=127.0.0.1:9091" - "--store-path=/store" - "--transport-host=consumer-events-subscription-service.cloud-events.svc.cluster.local:9043" - "--http-event-publishers=ptp-event-publisher-service-NODE_NAME.openshift-ptp.svc.cluster.local:9043" 1 - "--api-port=8089"
- 1
- PTP Operator 会自动将
NODE_NAME
解析为正在生成 PTP 事件的主机。例如,compute-1.example.com
。
在配置了裸机事件的集群中,在云事件 sidecar 部署 CR 中将
http-event-publishers
字段设置为hw-event-publisher-service.openshift-bare-metal-events.svc.cluster.local:9043
。将
consumer-events-subscription-service
服务与事件消费者应用程序一起部署。例如:apiVersion: v1 kind: Service metadata: annotations: prometheus.io/scrape: "true" service.alpha.openshift.io/serving-cert-secret-name: sidecar-consumer-secret name: consumer-events-subscription-service namespace: cloud-events labels: app: consumer-service spec: ports: - name: sub-port port: 9043 selector: app: consumer clusterIP: None sessionAffinity: None type: ClusterIP