Openshift:自动更新上游图像

Openshift: Automatically update upstream images

在 Openshift 中,我们有一个 BuildConfig,它依赖于来自 hub.docker.com (ubuntu:xenial) 的图像。

strategy:
  type: Docker
  dockerStrategy:
    from:
      kind: ImageStreamTag
      namespace: <my namespace>
      name: 'ubuntu:xenial'
    forcePull: true

为此,我创建了一个具有以下配置的 ImageStream:

apiVersion: v1
kind: ImageStream
metadata:
  name: ubuntu
  namespace: <my namespace>
spec:
  dockerImageRepository: registry.hub.docker.com/library/ubuntu

我现在想在上游 Ubuntu 图像发生变化时 运行 我的 BuildConfig。我可以通过 运行ning oc import-image ubuntu 手动更新 Ubuntu 图像。

除了创建外部 cron 作业之外,还有其他自动更新映像的方法吗?

版本

OpenShift Master: v1.3.1
Kubernetes Master: v1.3.0+52492b4

如文档中所述:

"Querying external registries to synchronize tag and image metadata is not currently an automated process. To resynchronize manually, run oc import-image . Within a short amount of time, OpenShift will communicate with the external registry to get up to date information about the Docker image repository associated with the image stream"

https://docs.openshift.com/enterprise/3.1/architecture/infrastructure_components/image_registry.html#third-party-registries

您始终可以利用 DockerHub Webhooks(它们在内置图像或添加新标签时触发):

https://docs.docker.com/docker-hub/webhooks/

查看与图像流标签关联的 importPolicyscheduled 字段。

$ oc explain is.spec.tags.importPolicy
RESOURCE: importPolicy <Object>

DESCRIPTION:
     Import is information that controls how images may be imported by the
     server.

    TagImportPolicy describes the tag import policy

FIELDS:
   insecure <boolean>
     Insecure is true if the server may bypass certificate verification or
     connect directly over HTTP during image import.

   scheduled    <boolean>
     Scheduled indicates to the server that this tag should be periodically
     checked to ensure it is up to date, and imported

在:

中提到了它