首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在tekton任务中使用图像PipelineResource进行输入

如何在tekton任务中使用图像PipelineResource进行输入
EN

Stack Overflow用户
提问于 2020-01-30 11:59:27
回答 1查看 835关注 0票数 0

正如https://github.com/tektoncd/pipeline/blob/master/docs/resources.md中记录的那样,我配置了一个图像PipelineResource:

代码语言:javascript
复制
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作为任务的输入时:

代码语言:javascript
复制
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)"

我无法列出图像的内容,因为我得到了错误。

代码语言:javascript
复制
[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任务中访问容器数据映像的内容?

EN

回答 1

Stack Overflow用户

发布于 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资源创建操作符来实现等效的任务。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59985583

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档