To enable Kubernetes resources, such as Deployments and StatefulSets, to seamlessly consume new image versions, configure image stream change triggers in OKD. This ensures your application deployments are automatically updated when the associated image stream detects a change.
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 OKD to request triggering.
The annotation is defined as follows:
apiVersion: v1
kind: Pod
metadata:
annotations:
image.openshift.io/triggers:
[
{
"from": {
"kind": "ImageStreamTag",
"name": "example:latest",
"namespace": "myapp"
},
"fieldPath": "spec.template.spec.containers[?(@.name==\"web\")].image",
"paused": false
},
# ...
]
# ...
kind
-
Specifies the resource to trigger from, and must have the value ImageStreamTag.
name
-
Specifies the name of an image stream tag.
namespace
-
Specifies the namespace of the object. This field is optional.
fieldPath
-
Specifies 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.
paused
-
Specifies whether or not the trigger is paused. This field is optional, and defaults to the value false. Set the value to true to temporarily disable this trigger.
When one of the core Kubernetes resources contains both a pod template and this annotation, OKD 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