据我所知,它是这样的,因为您使用的实际上是Kubernetes作业对象。任何时候你在Kubernetes级别做事情,你都必须从图像注册表中引用一个图像。Kubernetes中不存在图像流的概念。这就是OpenShift对象(如构建和部署配置)更智能的地方,因为它们通过图像流对象工作,图像流对象充当索引或间接指针的形式。当使用OpenShift时,使用图像流作为中介使事情变得更容易。
尽管如此,我被告知OpenShift 3.6中可能有一些东西使这变得更容易。然而,目前显然没有关于其工作原理的文件。有一个人可能会告诉我有关细节的信息,他正在休假,直到月底,我想看看是否可以找到更多细节,并在知道后更新。
更新1
假设您使用的是OpenShift 3.6,并且
is-copy-adaptermappings
{
"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
latest
标签已使用,或可以
name:tag
使用注释的方式具有alpha状态,因此注释的名称最终会更改。通常他们会尝试自动迁移包含alpha/beta标签的名称,但要注意,如果状态发生变化,它就会停止工作。
使用现在可能存在的注释的另一种方法是设置
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.