1

I am building an OpenShift s2i image. And to help streamline development I would like to create an image stream based on this s2i image, so that I can quickly test if changes to the s2i - and if changes in the source code base - works.

I cannot find any oc command to create a new image stream.

I tried to create an image stream using the below yml.

kind: "BuildConfig"
apiVersion: "v1"
metadata:
  name: "s2i-cpp" 
  annotations:
    openshift.io/build-config.name: s2i-cpp
  labels:
    build: s2i-cpp
    buildconfig: s2i-cpp
    openshift.io/build-config.name: s2i-cpp
    openshift.io/build.start-policy: Serial
spec:
  source:
    contextDir: "dockerfiles/builder"
    git:
      ref: master
      uri: 'https://gitlab.com/myrepo/s2i-cpp-wine.git'
    sourceSecret:
      name: gitlab-priceinsight
    type: Git
  strategy:
   type: Docker
   dockerStrategy:
    dockerfilePath: dockerfiles/builder/
  output: 
    to:
      kind: "ImageStreamTag"
      name: "s2i-cpp:latest"

While I am able to create this using oc create -f imagestream.yml, when I try to run this, it immediately errors with Invalid output reference. My expectation was that it would create a new image.

Magick
  • 4,603
  • 22
  • 66
  • 103
  • 1
    Where are you building the S2I image in the first place? If building the S2I image in OpenShift itself as a ``docker`` build strategy, an image stream would be created for you. If you have pushed your image up to Docker Hub, you can use ``oc import-image``. You can also push direct into the internal image registry of OpenShift if that is accessible and you login first. – Graham Dumpleton Sep 25 '17 at 05:53
  • Thanks Graham. Yes I *was* able to push to the internal registry but something broke. And yes, I am building the s2i in OS. And just realized that I therefore already have an image stream. Thanks – Magick Sep 26 '17 at 00:26
  • so what was the issue at the end? and what's wrong with the @Rameez answer? – Ewoks Dec 01 '20 at 19:11

1 Answers1

1

Move to project namescape or use -n

oc project <your namespace>

Create a imagestream using cli

oc create imagestream <image-name>

Image streamname should be same as in yaml file

output:
    to:
      kind: ImageStreamTag
      name: 'image-name:latest'

Create build using yaml file

oc create -f <build>.yaml
Rameez
  • 564
  • 5
  • 11