正如https://github.com/tektoncd/pipeline/blob/master/docs/resources.md中记录的那样,我配置了一个图像PipelineResource:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: my-data-image
spec:
type: image
params:
- name: url
value: image-registry.openshift-image-registry.svc:5000/default/my-data现在,当我使用上面的PipelineResource作为任务的输入时:
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: my-task
spec:
inputs:
resources:
- name: my-data-image
type: image
steps:
- name: print-info
image: image-registry.openshift-image-registry.svc:5000/default/my-task-runner-image:latest
imagePullPolicy: Always
command: ["/bin/sh"]
args:
- "-c"
- >
echo "List the contents of the input image" &&
ls -R "$(inputs.resources.my-data-image.path)"我无法列出图像的内容,因为我得到了错误。
[test : print-info] List the contents of the input image
[test : print-info] ls: cannot access '/workspace/my-data-image': No such file or directory文档(https://github.com/tektoncd/pipeline/blob/master/docs/resources.md)指出,图像PipelineResource是,通常用于生成映像的任务的任务输出。
如何从tekton任务中访问容器数据映像的内容?
发布于 2020-01-31 10:19:22
目前Tekton并不像OpenShift的构建所支持的那样支持图像输入:https://docs.openshift.com/container-platform/4.2/builds/creating-build-inputs.html#image-source_creating-build-inputs
图像输入仅适用于变量插值,例如,“$(inputs.resources es.my-Image.url)”,而‘`ls“(inputs.resources es.my-Image.path)”将始终打印空内容。
访问图像内容的方法有几种,包括:
将映像导出到tar: podman导出$(podman创建$(inputs.resources es.my-Image.url)-验证=假)>图像中的contents.tar
尽管如此,我决定简单地使用OpenShift的内置BuildConfig资源为我的管道创建一个链式构建。OpenShift out- The box支持的各种构建策略对于我的管道场景来说已经足够了,与Tekton管道(https://docs.openshift.com/container-platform/4.2/builds/creating-build-inputs.html#image-source_creating-build-inputs)相比,图像输入得到了支持,这使得构建策略变得更加容易。Tekton管道的唯一优势似乎是能够轻松地重用任务,但是,可以通过为OpenShift资源创建操作符来实现等效的任务。
https://stackoverflow.com/questions/59985583
复制相似问题