8.2. 触发 Kubernetes 资源
Kubernetes 资源没有用于触发的字段,这与部署和构建配置不同(在部署和构建配置中包括作为 API 定义的一组控制触发器字段)。您可以使用 OpenShift Container Platform 中的注解请求触发器。
该注解定义如下:
Key: image.openshift.io/triggers
Value:
[
{
"from": {
"kind": "ImageStreamTag", 1
"name": "example:latest", 2
"namespace": "myapp" 3
},
"fieldPath": "spec.template.spec.containers[?(@.name==\"web\")].image", 4
"paused": false 5
},
...
]
当其中一个核心 Kubernetes 资源同时包含 pod 模板和此注解时,OpenShift Container Platform 会尝试使用当前与触发器引用的镜像流标签关联的镜像来更新对象。更新针对指定的 fieldPath 进行。
可以包含 pod 模板和注解的核心 Kubernetes 资源示例包括:
-
CronJobs -
部署 -
StatefulSets -
DaemonSets -
Jobs -
ReplicationController -
Pods