Skip to content

Commit ceb4f0a

Browse files
committed
OSDOCS-1006 Bring forward necessary managing images content
1 parent 8e34a9f commit ceb4f0a

5 files changed

+114
-2
lines changed

_topic_map.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,12 +1107,15 @@ Topics:
11071107
File: image-pull-policy
11081108
- Name: Using image pull secrets
11091109
File: using-image-pull-secrets
1110-
- Name: Managing imagestreams
1110+
- Name: Managing image streams
11111111
File: image-streams-manage
11121112
Distros: openshift-enterprise,openshift-webscale,openshift-origin
1113-
- Name: Using imagestreams with Kubernetes resources
1113+
- Name: Using image streams with Kubernetes resources
11141114
File: using-imagestreams-with-kube-resources
11151115
Distros: openshift-enterprise,openshift-webscale,openshift-origin
1116+
- Name: Triggering updates on image stream changes
1117+
File: triggering-updates-on-imagestream-changes
1118+
Distros: openshift-enterprise,openshift-webscale,openshift-origin
11161119
- Name: Image configuration resources
11171120
File: image-configuration
11181121
Distros: openshift-enterprise,openshift-webscale,openshift-origin
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * openshift_images/triggering-updates-on-imagestream-changes.adoc
4+
5+
6+
[id="images-triggering-updates-imagestream-changes-kubernetes-about_{context}"]
7+
= Triggering Kubernetes resources
8+
9+
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 {product-title} to request triggering.
10+
11+
The annotation is defined as follows:
12+
13+
[source,yaml]
14+
----
15+
Key: image.openshift.io/triggers
16+
Value:
17+
[
18+
{
19+
"from": {
20+
"kind": "ImageStreamTag", <1>
21+
"name": "example:latest", <2>
22+
"namespace": "myapp", <3>
23+
},
24+
"fieldPath": "spec.template.spec.containers[?(@.name='web')].image", <4>
25+
"paused": "false" <5>
26+
},
27+
...
28+
]
29+
----
30+
<1> Required: `kind` is the resource to trigger from must be `ImageStreamTag`.
31+
<2> Required: `name` must be the name of an image stream tag.
32+
<3> Optional: `namespace` defaults to the namespace of the object.
33+
<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".
34+
<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.
35+
36+
When one of the core Kubernetes resources contains both a pod template and this annotation, {product-title} 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.
37+
38+
Examples of core Kubernetes resources that can contain both a pod template and annotation include:
39+
40+
* `CronJobs`
41+
* `Deployments`
42+
* `StatefulSets`
43+
* `DaemonSets`
44+
* `Jobs`
45+
* `ReplicationControllers`
46+
* `Pods`
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * openshift_images/triggering-updates-on-imagestream-changes.adoc
4+
5+
6+
[id="images-triggering-updates-imagestream-changes-kubernetes-cli_{context}"]
7+
= Triggering Kubernetes resources manually
8+
9+
You can manually trigger Kubernetes resources by entering the `oc set triggers` command.
10+
11+
When adding an image trigger to deployments, you can use the `oc set triggers` command. For example, the example command in this procedure adds an image change trigger to the deployment named `example` so that when the `example:latest` image stream tag is updated, the `web` container inside the deployment updates with the new image value.
12+
13+
.Procedure
14+
15+
* Trigger Kubernetes resources by entering the `oc set triggers` command:
16+
+
17+
[source,terminal]
18+
----
19+
$ oc set triggers deploy/example --from-image=example:latest -c web
20+
----
21+
22+
Unless the deployment is paused, this pod template update automatically causes a deployment to occur with the new image value.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * openshift_images/triggering-updates-on-imagestream-changes.adoc
4+
5+
6+
[id="images-triggering-updates-imagestream-changes-kubernetes_{context}"]
7+
= Triggering Kubernetes resources automatically
8+
9+
You can automatically trigger Kubernetes resources by updating the image stream tag.
10+
11+
In the following example, the trigger fires when the `example:latest` image stream tag is updated. Upon firing, the pod template image reference for the `web` container is updated with a new image value for the object. If the pod template is part of a deployment definition, the change to the pod template automatically triggers a deployment, which rolls out the new image.
12+
13+
.Procedure
14+
15+
* Trigger Kubernetes resources by updating the image stream tag similar to the one in this example:
16+
+
17+
[source,yaml]
18+
----
19+
image.openshift.io/triggers=[{"from":{"kind":"ImageStreamTag","name":"example:latest"},"fieldPath":"spec.template.spec.containers[?(@.name='web')].image"}]
20+
----
21+
22+
Unless the deployment is paused, this pod template update automatically causes a deployment to occur with the new image value.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[id="triggering-updates-on-imagestream-changes"]
2+
= Triggering updates on image stream changes
3+
include::modules/common-attributes.adoc[]
4+
:context: triggering-updates-on-imagestream-changes
5+
6+
toc::[]
7+
8+
9+
When an image stream tag is updated to point to a new image, {product-title} can automatically take action to roll the new image out to resources that were using the old image. You configure this behavior in different ways depending on the type of resource that references the image stream tag.
10+
11+
[id="openshift-resources"]
12+
== {product-title} resources
13+
{product-title} Deployment configurations and Build configurations can be automatically triggered by changes to image stream tags. The triggered action can be run using the new value of the image referenced by the updated image stream tag.
14+
15+
include::modules/images-triggering-updates-imagestream-changes-kubernetes-about.adoc[leveloffset=+1]
16+
17+
include::modules/images-triggering-updates-imagestream-changes-kubernetes.adoc[leveloffset=+1]
18+
19+
include::modules/images-triggering-updates-imagestream-changes-kubernetes-cli.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)