8.3. 自动触发 Kubernetes 资源

您可以通过更新镜像流标签自动触发 Kubernetes 资源。

在以下示例中,当 example:latest 镜像流标签被更新时,触发器会触发。触发后,web 容器的 pod 模板镜像引用会使用对象的新镜像值更新。如果 pod 模板是部署定义的一部分,则对 pod 模板的更改会自动触发部署,以推出新镜像。

流程

  • 通过更新与本例中所示的镜像流标签来触发 Kubernetes 资源:

    image.openshift.io/triggers=[{"from":{"kind":"ImageStreamTag","name":"example:latest"},"fieldPath":"spec.template.spec.containers[?(@.name='web')].image"}]

除非部署暂停,否则此 pod 模板更新自动导致使用新镜像值进行部署。