OpenShift Image and ImageStream Operations: Difference between revisions
(20 intermediate revisions by the same user not shown) | |||
Line 20: | Line 20: | ||
oc get image <''image-name''> | oc get image <''image-name''> | ||
oc get image/<''image-name''> | |||
oc get image sha256:41976593d219eb2008a533e7f6fbb17e1fc3391065e2d592cc0b05defe5d5562 | |||
Returns [[OpenShift Concepts#Image|image]] information. | |||
==Image Tagging== | |||
Tag an image from a project with a new tag in a different project (the service account of the process that does the tagging must have an "edit" role in the target project): | |||
oc tag <''source-project''>/<''image-name''>:latest <''target-project''>/<''different-image-name''>:<''version-tag''> | |||
More details: https://github.com/NovaOrdis/novaordis-session-servlet/blob/master/openshift/Jenkinsfile-Full.groovy | |||
=Image Stream Operations= | =Image Stream Operations= | ||
Line 39: | Line 53: | ||
===Create an Individual Image Stream with import-image=== | ===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. | 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. | ||
The command can be used repeatedly to pull from the remote repository the latest images corresponding to this stream. | |||
Also see: {{Internal|OpenShift_DeploymentConfig_Definition#imagePullPolicy|Deployment Configuration imagePullPolicy}} | |||
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. | If the image stream does not exist, a new image stream named "" is created if --confirm is provided. | ||
Line 53: | Line 73: | ||
====Image Available in an OpenShift Registry==== | ====Image Available in an OpenShift Registry==== | ||
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''] of the image. | |||
apiVersion: v1 | apiVersion: v1 | ||
kind: ImageStream | kind: ImageStream | ||
metadata: | metadata: | ||
name: | name: my-own-eap7-is | ||
spec: | spec: | ||
tags: | tags: | ||
- from: | - name: latest | ||
from: | |||
kind: DockerImage | kind: DockerImage | ||
name: | name: registry.access.redhat.com/jboss-eap-7/eap70-openshift:latest | ||
then: | then: | ||
oc create -f ./ | [[oc create]] -f ./my-own-eap7-is.yaml | ||
====Image Available in an Docker Hub==== | ====Image Available in an Docker Hub==== | ||
Line 80: | Line 102: | ||
spec: | spec: | ||
tags: | tags: | ||
- from: | - name: "1" | ||
from: | |||
kind: DockerImage | kind: DockerImage | ||
name: ovidiufeodorov/postgresql-95-debug:1 | name: ovidiufeodorov/postgresql-95-debug:1 | ||
ovidiufeodorov/postgresql-95-debug:1 will be resolved to [[Docker Concepts#Docker_Hub|Docker Hub]] automatically. | ovidiufeodorov/postgresql-95-debug:1 will be resolved to [[Docker Concepts#Docker_Hub|Docker Hub]] automatically. |
Latest revision as of 23:25, 25 January 2018
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 Tagging
Tag an image from a project with a new tag in a different project (the service account of the process that does the tagging must have an "edit" role in the target project):
oc tag <source-project>/<image-name>:latest <target-project>/<different-image-name>:<version-tag>
More details: https://github.com/NovaOrdis/novaordis-session-servlet/blob/master/openshift/Jenkinsfile-Full.groovy
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 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.
The command can be used repeatedly to pull from the remote repository the latest images corresponding to this stream.
Also see:
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
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-eap7-is spec: tags: - name: latest from: kind: DockerImage name: registry.access.redhat.com/jboss-eap-7/eap70-openshift:latest
then:
oc create -f ./my-own-eap7-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
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