8.2. Triggering Kubernetes resources


Kubernetes resources do not have fields for triggering, unlike deployment and build configurations, which include as part of their API definition a set of fields for controlling triggers. Instead, you can use annotations in OpenShift Container Platform to request triggering.

The annotation is defined as follows:

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
 },
 ...
]
1
Required: kind is the resource to trigger from must be ImageStreamTag.
2
Required: name must be the name of an image stream tag.
3
Optional: namespace defaults to the namespace of the object.
4
Required: fieldPath is the JSON path to change. This field is limited and accepts only a JSON path expression that precisely matches a container by ID or index. For pods, the JSON path is "spec.containers[?(@.name='web')].image".
5
Optional: paused is whether or not the trigger is paused, and the default value is false. Set paused to true to temporarily disable this trigger.

When one of the core Kubernetes resources contains both a pod template and this annotation, OpenShift Container Platform attempts to update the object by using the image currently associated with the image stream tag that is referenced by trigger. The update is performed against the fieldPath specified.

Examples of core Kubernetes resources that can contain both a pod template and annotation include:

  • CronJobs
  • Deployments
  • StatefulSets
  • DaemonSets
  • Jobs
  • ReplicationControllers
  • Pods
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.