Openshift原始作业是否需要图像的硬编码内部注册表URL?

Openshift原始作业是否需要图像的硬编码内部注册表URL?,openshift,openshift-origin,Openshift,Openshift Origin,如果不在作业配置中硬编码内部注册表URL,我无法找到一种名称空间可移植的方法来将图像构建到imagestream中,然后将其用于OpenShift项目名称空间中的作业 与部署配置不同,作业配置不会为内部注册表自动生成具有正确映像URL的pod配置。生成的作业从未运行,因为无法提取图像 Failed to pull image "is-copy-adaptermappings": Error: image library/is-copy-adaptermappings:latest not fou

如果不在作业配置中硬编码内部注册表URL,我无法找到一种名称空间可移植的方法来将图像构建到imagestream中,然后将其用于OpenShift项目名称空间中的作业

与部署配置不同,作业配置不会为内部注册表自动生成具有正确映像URL的pod配置。生成的作业从未运行,因为无法提取图像

Failed to pull image "is-copy-adaptermappings": Error: image library/is-copy-adaptermappings:latest not found
工作示例生成deployconfig生成的pod 失败的示例生成了job pod摘录 作业配置(json)
有没有一种很好的方法可以引用或生成内置本地注册表映像的URL?

据我所知,这种方法是因为您使用的实际上是Kubernetes作业对象。无论何时在Kubernetes级别执行操作,都必须引用图像注册表中的图像。Kubernetes中不存在图像流的概念。这就是OpenShift对象(如构建和部署配置)更智能的地方,因为它们通过映像流对象工作,映像流对象充当索引或间接指针的形式。当使用OpenShift时,使用图像流作为中介使事情变得更容易

总而言之,我被告知OpenShift 3.6中可能有一些东西使这变得更容易。不过,目前还没有关于其工作原理的文档。有一个人可能会告诉我有关细节的情况,他正在休假,直到月底,我想看看是否能找到更多细节,当我知道后会更新


更新1

如果您使用的是OpenShift 3.6,并且
是当前项目中的复制适配器映射
是图像流,请尝试以下操作:

{
  "apiVersion": "batch/v1",
  "kind": "Job",
  "metadata": {
    "name": "configpod"
    "annotations": {
      "alpha.image.policy.openshift.io/resolve-names": "*"
    },
  },
  "spec": {
    "parallelism": 1,
    "completions": 1,
    "template": {
      "metadata": {
        "name": "copy-config-to-pv"
      },
      "spec": {
        "containers": [
          {
            "name": "copy-config-to-pv",
            "image": "is-copy-adaptermappings",
            "imagePullPolicy": "Always",
            "volumeMounts": [
              {
                "mountPath": "/dest",
                "name": "volume-config"
              }
            ]
          }
        ],
        "restartPolicy": "OnFailure",
        "volumes": [
          {
            "name": "volume-config",
            "persistentVolumeClaim": {
              "claimName": "pvc-configs"
            }
          }
        ]
      }
    }
  }
}
添加的是作业元数据中名为
alpha.image.policy.openshift.io/resolve names
的注释

image
的值可以是imagestream名称,在这种情况下,可以使用
latest
标记,也可以是
name:tag
并引用特定标记

使用注释是因为这种方式具有alpha状态,因此注释的名称最终将更改。通常,他们会尝试自动迁移包含alpha/beta标签的名称,但要注意,一旦状态发生变化,它就会停止工作


更新2

使用现在可能存在的注释的另一种方法似乎是设置
is.spec.lookupPolicy
并启用
local
查找

$ oc explain is.spec.lookupPolicy
RESOURCE: lookupPolicy <Object>

DESCRIPTION:
     lookupPolicy controls how other resources reference images within this
     namespace.

    ImageLookupPolicy describes how an image stream can be used to override the image references used by pods, builds, and other resources in a namespace.

FIELDS:
   local    <boolean> -required-
     local will change the docker short image references (like "mysql" or
     "php:latest") on objects in this namespace to the image ID whenever they
     match this image stream, instead of reaching out to a remote registry. The
     name will be fully qualified to an image ID if found. The tag's
     referencePolicy is taken into account on the replaced value. Only works
     within the current namespace.
$oc explain is.spec.lookupPolicy
资源:lookupPolicy
说明:
lookupPolicy控制其他资源如何引用此资源中的图像
命名空间。
ImageLookupPolicy描述了如何使用映像流覆盖命名空间中的POD、构建和其他资源使用的映像引用。
领域:
本地要求-
local将更改docker短图像引用(如“mysql”或
此名称空间中的对象上的“php:latest”)在
匹配此图像流,而不是访问远程注册表。这个
如果找到,名称将完全限定为图像ID。标签是
在替换的值上考虑引用策略。只起作用
在当前命名空间中。

也就是说,在图像字段中要引用的图像流对象上设置此选项。

谢谢Graham。我想我的问题更简洁的版本是,是否有一个特定于OpenShift的高阶对象,它从图像流中为作业注入图像URL,就像部署配置为常规/Kubernetes吊舱所做的那样。根据我部署到的集群,我可以手动更新作业,但如果作业与DCs一致,那就太好了。请确保您在添加评论时阅读了我发布的更新。答案是,从3.6开始(虽然处于alpha状态),是的,有一种方法可以更新Kubernetes级别对象的图像细节。该注释是其中一种方法,并且可能是在本例中最有意义的方法。感谢更新
minishift开始--openshift version=v3.6.0-rc.0
在我键入时正在VPN上拖动层…它工作了<代码>拉取图像“172.30.1.1:5000/c2/is复制适配器文件:最新”。如果保留该功能,这是一个很好的临时措施。我将监控OpenShift Origin&RH OCP,了解它的情况。目前,它将用于开发和准备阶段,我将不得不与RH讨论何时能够升级我们的生产RH OCP 3.5集群。
{
  "apiVersion": "batch/v1",
  "kind": "Job",
  "metadata": {
    "name": "configpod"
  },
  "spec": {
    "parallelism": 1,
    "completions": 1,
    "template": {
      "metadata": {
        "name": "copy-config-to-pv"
      },
      "spec": {
        "containers": [
          {
            "name": "copy-config-to-pv",
            "image": "is-copy-adaptermappings",
            "imagePullPolicy": "Always",
            "volumeMounts": [
              {
                "mountPath": "/dest",
                "name": "volume-config"
              }
            ]
          }
        ],
        "restartPolicy": "OnFailure",
        "volumes": [
          {
            "name": "volume-config",
            "persistentVolumeClaim": {
              "claimName": "pvc-configs"
            }
          }
        ]
      }
    }
  }
}
{
  "apiVersion": "batch/v1",
  "kind": "Job",
  "metadata": {
    "name": "configpod"
    "annotations": {
      "alpha.image.policy.openshift.io/resolve-names": "*"
    },
  },
  "spec": {
    "parallelism": 1,
    "completions": 1,
    "template": {
      "metadata": {
        "name": "copy-config-to-pv"
      },
      "spec": {
        "containers": [
          {
            "name": "copy-config-to-pv",
            "image": "is-copy-adaptermappings",
            "imagePullPolicy": "Always",
            "volumeMounts": [
              {
                "mountPath": "/dest",
                "name": "volume-config"
              }
            ]
          }
        ],
        "restartPolicy": "OnFailure",
        "volumes": [
          {
            "name": "volume-config",
            "persistentVolumeClaim": {
              "claimName": "pvc-configs"
            }
          }
        ]
      }
    }
  }
}
$ oc explain is.spec.lookupPolicy
RESOURCE: lookupPolicy <Object>

DESCRIPTION:
     lookupPolicy controls how other resources reference images within this
     namespace.

    ImageLookupPolicy describes how an image stream can be used to override the image references used by pods, builds, and other resources in a namespace.

FIELDS:
   local    <boolean> -required-
     local will change the docker short image references (like "mysql" or
     "php:latest") on objects in this namespace to the image ID whenever they
     match this image stream, instead of reaching out to a remote registry. The
     name will be fully qualified to an image ID if found. The tag's
     referencePolicy is taken into account on the replaced value. Only works
     within the current namespace.