首页 > 解决方案 > OpenShift:构建失败,“输出参考无效”

问题描述

我正在使用以下 YAML 创建构建配置。然后,我使用oc. 因此,运行以下命令。

oc create -f mybuildconfig.yaml
oc start-build bc/ns-bc-myproject --wait

构建配置 YAML:

apiVersion: v1
kind: BuildConfig
metadata:
  labels:
    build: myproject
  name: ns-bc-myproject
  namespace: ns
spec:
  output:
    to:
      kind: ImageStreamTag
      name: 'ns-is-myproject:latest'
  postCommit: {}
  resources: {}
  runPolicy: Serial
  source:
    git:
      ref: dev_1.0
      uri: 'https://github.com/ns/myproject.git'
    type: Git
  strategy:
    sourceStrategy:
      from:
        kind: ImageStreamTag
        name: 'nodejs:10'
        namespace: openshift
    type: Source
  successfulBuildsHistoryLimit: 5

构建永远不会通过;它一直失败,消息为无效的输出参考。什么不见​​了?

标签: buildconfigurationyamlopenshift

解决方案


您需要在构建配置将图像推送到的命名空间中创建一个图像流

像这样的东西会为你工作:

- apiVersion: v1
  kind: ImageStream
  metadata:
    labels:
      application: ns-is-myproject
    name: ns-is-myproject
    namespace: ns-is-myproject

推荐阅读