An image contains the code used to create a deployment. Then, a deployment can be created from an image, which should then create a replica set (which is the number of pods that should be created), and then the pods should be created.
If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.
The oc new-app command is used to deploy an application.
There are various ways to deploy an app.
- From GitHub (https://github.com)
- From Docker Hub (https://hub.docker.com)
- From an image
- From a build
- From a template
- From a JSON or YAML file (templates)
The oc get images command can be used to determine if the image has already been pulled down. Something like this should be returned. In this example, there are 6 Python images.
~]# oc get images | grep -i python
NAME IMAGE REFERENCE
sha256:0c2f708b4977469d090719d939778eb95b42c02c1da6476aa95f2e875920652b registry.redhat.io/ubi9/python-39@sha256:0c2f708b4977469d090719d939778eb95b42c02c1da6476aa95f2e875920652b
sha256:190ea81f2f64ccf7f7c8cb9dc4612eda59eb9e3d2e17f71727a270f078f5114a registry.redhat.io/ubi8/python-27@sha256:190ea81f2f64ccf7f7c8cb9dc4612eda59eb9e3d2e17f71727a270f078f5114a
sha256:4a1d451e1d513115ff54c6e80299e761f60454b5f2f091f3c9ddb9fc1d61f5c4 registry.redhat.io/ubi8/python-38@sha256:4a1d451e1d513115ff54c6e80299e761f60454b5f2f091f3c9ddb9fc1d61f5c4
sha256:971dcd27c3d53f58eb59c946f123223b95662841c1214a394a445380beb75f59 registry.redhat.io/ubi8/python-36@sha256:971dcd27c3d53f58eb59c946f123223b95662841c1214a394a445380beb75f59
sha256:d4e20aa826660f635fad77837b9c6aab8248f0560cd8c3c2283c12704359e9bb registry.redhat.io/rhscl/python-38-rhel7@sha256:d4e20aa826660f635fad77837b9c6aab8248f0560cd8c3c2283c12704359e9bb
sha256:e2a461928e82d7da8991f4fdf5496219f013a6e70c4ef30cf5fb93a4cc450eac registry.redhat.io/ubi8/python-39@sha256:e2a461928e82d7da8991f4fdf5496219f013a6e70c4ef30cf5fb93a4cc450eac
The following command can be used to deploy one of the images.
oc new-app registry.redhat.io/ubi9/python-39@sha256:0c2f708b4977469d090719d939778eb95b42c02c1da6476aa95f2e875920652b
The --as-deployment-config flag can be used to create the deployment as a deployment config instead of a regular "deployment".
oc new-app registry.redhat.io/ubi9/python-39@sha256:0c2f708b4977469d090719d939778eb95b42c02c1da6476aa95f2e875920652b --as-deployment-config
In this example, there was no image for the hello-world application, thus a call was made to Docker Hub for the image, which is like deploying the image from Docker Hub.
~]$ oc new-app hello-world
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
--> Found container image feb5d9f (8 months old) from Docker Hub for "hello-world"
* An image stream tag will be created as "hello-world:latest" that will track this image
--> Creating resources ...
imagestream.image.openshift.io "hello-world" created
deployment.apps "hello-world" created
--> Success
Run 'oc status' to view your app.
On the other hand, if the image exists, something like this should be displayed.
--> Found container image a9b24b9 (16 months old) from registry.redhat.io for "registry.redhat.io/ubi9/python-39@sha256:0c2f708b4977469d090719d939778eb95b42c02c1da6476aa95f2e875920652b"
Python 3.9
----------
Python 3.9 available as container is a base platform for building and running various Python 3.9 applications and frameworks. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
Tags: builder, python, python39, python-39, rh-python39
* An image stream tag will be created as "python-39:latest" that will track this image
--> Creating resources ...
imagestream.image.openshift.io "python-39" created
deployment.apps "python-39" created
service "python-39" created
--> Success
Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
'oc expose service/python-39'
Run 'oc status' to view your app.
If the --as-deployment-config flag was not used, the oc get deployments command can be used to list the deployments.
~]$ oc get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
python-39 1/1 1 1 70s
On the other hand, if the --as-deployment-config flag is used, the oc get deploymentconfigs command can be used to list the deployment configs.
~]$ oc get deploymentconfigs
NAME REVISION DESIRED CURRENT TRIGGERED BY
my-app 1 1 1 config,image(my-app:latest)
If the --as-deployment-config flag was used, the oc rollout history command can be used to see that the latet image was rolled out. In this example, revision 1 is the original deployment.
~]# oc rollout history deploymentconfig/my-app
deploymentconfig.apps.openshift.io/my-app
REVISION STATUS CAUSE
1 Complete config change
The oc get replicasets command can be used to see if replica sets were spawned from the deployment.
~]$ oc get replicasets
NAME DESIRED CURRENT READY AGE
python-39-6b5d67fb48 1 1 0 2m43s
python-39-7c9784cc98 1 1 0 2m43s
The oc get pods can be used to determine if the pod was spun up from the replica sets and if the pod is Running.
~]$ oc get pods
NAME READY STATUS RESTARTS AGE
python-39-7c9784cc98-ntr2p 1/1 Running 0 55s
The oc get imagestreams command can be used to display the image stream.
~]$ oc get imagestreams
NAME IMAGE REPOSITORY TAGS UPDATED
python-39 image-registry.openshift-image-registry.svc:5000/thrivent-openshift-access-checker/python-39 latest 5 minutes ago
Did you find this article helpful?
If so, consider buying me a coffee over at