kubernetesopenshiftopenshift-client-tools

OpenShift - how to create a new image stream?


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.


Solution

  • 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