OpenShift Image and ImageStream Operations: Difference between revisions
Line 49: | Line 49: | ||
Inspect the [[OpenShift_Concepts#Integrated_Registry_Console|integrated registry console]] for a suitable image and create a YAML file similar to the one specified below. | Inspect the [[OpenShift_Concepts#Integrated_Registry_Console|integrated registry console]] for a suitable image and create a YAML file similar to the one specified below. | ||
The Docker image name is found under the "Pull repository" section and represents the <''repository-name''>[:''tag''] | The Docker image name is found under the "Pull repository" section and represents the <''repository-name''>[:''tag''] of the image. | ||
apiVersion: v1 | apiVersion: v1 |
Revision as of 22:45, 6 December 2017
Internal
Overview
Image Operations
List Images available to the Cluster
oc get images
The command lists all images averrable in the cluster. The images are not project-scoped, but cluster-scoped, so any user from any project that has sufficient cluster-level privileges can get information about any image available to any project. One role that permits inspecting image information is /cluster-reader. On the other hand, a user that only has project-level privileges cannot inspect images.
Image Information
oc get image <image-name>
oc get image/<image-name>
oc get image sha256:41976593d219eb2008a533e7f6fbb17e1fc3391065e2d592cc0b05defe5d5562
Returns image information.
Image Stream Operations
Get Image Streams Available to a Project
oc project <project-name>
oc get imagestreams oc get is oc get is -n openshift
Get Information about an Image Stream
oc describe is jboss-eap64-openshift
Create an Image Stream
Create an Individual Image Stream from YAML/JSON
Image Available in an OpenShift Registry
Inspect the integrated registry console for a suitable image and create a YAML file similar to the one specified below.
The Docker image name is found under the "Pull repository" section and represents the <repository-name>[:tag] of the image.
apiVersion: v1 kind: ImageStream metadata: name: my-own-is spec: tags: - name: latest from: kind: DockerImage name: registry.access.redhat.com/jboss-eap-7/eap70-openshift:latest
then:
oc create -f ./green-is.yaml
Image Available in an Docker Hub
postgresql-95-debug.yaml:
apiVersion: v1 kind: ImageStream metadata: name: postgresql-95-debug spec: tags: - name: "1" from: kind: DockerImage name: ovidiufeodorov/postgresql-95-debug:1
ovidiufeodorov/postgresql-95-debug:1 will be resolved to Docker Hub automatically.
then:
oc create -f ./postgresql-95-debug.yaml
Create an Individual Image Stream with import-image
This command fetches the latest version of an image from a remote repository and updates the image stream tag if it does not match the previous value. It is idempotent, running the command multiple times will not create duplicate entries. When importing an image, only the image metadata is copied, not the image contents.
If the image stream does not exist, a new image stream named "" is created if --confirm is provided.
oc import-image <imagestream-name>[:tag] \ --from <registry/image> [--confirm]
oc import-image local-redhat-openjdk-18/openjdk18-openshift \ --from=registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift --confirm
Import Image Streams in Bulk
The following procedure will create a set of image streams in the "openshift" project. An example of image stream definition file is available at https://raw.githubusercontent.com/jboss-openshift/application-templates/master/jboss-image-streams.json. A version is also available here: OpenShift JBoss ImageStream Definition Example.
oc login -u system:admin oc create -f ./jboss-image-streams.json -n openshift
The output is similar to:
imagestream "jboss-webserver31-tomcat7-openshift" created imagestream "jboss-webserver31-tomcat8-openshift" created imagestream "jboss-eap71-openshift" created imagestream "jboss-decisionserver64-openshift" created imagestream "jboss-processserver64-openshift" created imagestream "jboss-datagrid71-openshift" created imagestream "jboss-datagrid65-client-openshift" created imagestream "jboss-datagrid71-client-openshift" created imagestream "jboss-datavirt63-driver-openshift" created imagestream "jboss-amq-63" created imagestream "redhat-sso71-openshift" created Error from server (AlreadyExists): imagestreams "jboss-webserver30-tomcat7-openshift" already exists Error from server (AlreadyExists): imagestreams "jboss-webserver30-tomcat8-openshift" already exists Error from server (AlreadyExists): imagestreams "jboss-eap64-openshift" already exists Error from server (AlreadyExists): imagestreams "jboss-eap70-openshift" already exists Error from server (AlreadyExists): imagestreams "jboss-decisionserver62-openshift" already exists Error from server (AlreadyExists): imagestreams "jboss-decisionserver63-openshift" already exists Error from server (AlreadyExists): imagestreams "jboss-processserver63-openshift" already exists Error from server (AlreadyExists): imagestreams "jboss-datagrid65-openshift" already exists Error from server (AlreadyExists): imagestreams "jboss-datavirt63-openshift" already exists Error from server (AlreadyExists): imagestreams "jboss-amq-62" already exists Error from server (AlreadyExists): imagestreams "redhat-sso70-openshift" already exists Error from server (AlreadyExists): imagestreams "redhat-openjdk18-openshift" already exists