Create a project and an app in Openshift

0 / 139
You will work with OpenShift in the context of a project at all times. This is a walled namespace for storing information on a group of applications. When you create a project, you become the owner and administrator of that project.
Unless you choose to make it public outside the OpenShift cluster, each application you deploy within the project is only visible to other applications running in the same project. In a single project, you can deploy many applications.
If they have a tight coupling, you would normally do this. Alternatively, you could always build a distinct project for each application and set up access between them selectively if they needed to connect with each other.

Refer above article for learning on how to install crc openshift on your laptop/desktop

Quick steps –

$ oc new-project ruby-hello-world --description="Ruby Hello World Project" --display-name="Ruby Hello World"
$ oc projects
$ oc project ruby-hello-world
$ oc new-app
$ oc get pods
$ oc get all
$ oc projects

Login as developer in openshift

[prayag@openshift ~]$ oc login -u developer
Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.

You don't have any projects. You can try to create a new project, by running

    oc new-project <projectname>

Create new ruby hello world project

[prayag@openshift ~]$ oc new-project ruby-hello-world --description="Ruby Hello World Project" --display-name="Ruby Hello World"

Now using project "ruby-hello-world" on server "https://api.crc.testing:6443".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app rails-postgresql-example

to build a new example application in Ruby. Or use kubectl to deploy a simple Kubernetes application:

    kubectl create deployment hello-node -- /agnhost serve-hostname

[prayag@openshift ~]$
No alt text provided for this image

Create new app for ruby using github url –

[prayag@openshift ~]$ oc project
You have one project on this server: "Ruby Hello World (ruby-hello-world)".

Using project "ruby-hello-world" on server "https://api.crc.testing:6443".

[prayag@openshift ~]$ oc new-app
--> Found container image 88b6cf4 (2 weeks old) from for ""

    Ruby 2.7
    Ruby 2.7 available as container is a base platform for building and running various Ruby 2.7 applications and frameworks. Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, and extensible.

    Tags: builder, ruby, ruby27, ruby-27

    * An image stream tag will be created as "ruby-27:latest" that will track the source image
    * A Docker build using source code from will be created
      * The resulting image will be pushed to image stream tag "ruby-hello-world:latest"
      * Every time "ruby-27:latest" changes a new build will be triggered

--> Creating resources ... "ruby-27" created "ruby-hello-world" created "ruby-hello-world" created
    deployment.apps "ruby-hello-world" created
    service "ruby-hello-world" created
--> Success
    Build scheduled, use 'oc logs -f buildconfig/ruby-hello-world' to track its progress.
    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
     'oc expose service/ruby-hello-world'
    Run 'oc status' to view your app.
[prayag@openshift ~]$

No alt text provided for this image

List the pod

[prayag@openshift ~]$ oc get pod
NAME                                READY   STATUS      RESTARTS   AGE
ruby-hello-world-1-build            0/1     Completed   0          5m50s
ruby-hello-world-598f6d995b-567rn   1/1     Running     0          108s

[prayag@openshift ~]$ oc get all
NAME                                    READY   STATUS      RESTARTS   AGE
pod/ruby-hello-world-1-build            0/1     Completed   0          5m55s
pod/ruby-hello-world-598f6d995b-567rn   1/1     Running     0          113s

NAME                       TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
service/ruby-hello-world   ClusterIP   <none>        8080/TCP   5m57s

NAME                               READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/ruby-hello-world   1/1     1            1           5m57s

NAME                                          DESIRED   CURRENT   READY   AGE
replicaset.apps/ruby-hello-world-598f6d995b   1         1         1       114s
replicaset.apps/ruby-hello-world-77966dc655   0         0         0       5m57s

NAME                                              TYPE     FROM   LATEST   Docker   Git    1

NAME                                          TYPE     FROM          STATUS     STARTED         DURATION   Docker   Git@0c607af   Complete   5 minutes ago   4m5s

NAME                                              IMAGE REPOSITORY                                                                            TAGS     UPDATED            default-route-openshift-image-registry.apps-crc.testing/ruby-hello-world/ruby-27            latest   5 minutes ago   default-route-openshift-image-registry.apps-crc.testing/ruby-hello-world/ruby-hello-world   latest   About a minute ago
[prayag@openshift ~]$

Get the project details

[prayag@openshift ~]$ oc get projects
NAME               DISPLAY NAME       STATUS
ruby-hello-world   Ruby Hello World   Active
[prayag@openshift ~]$
No alt text provided for this image

I hope you found this article to be useful in some way. I’ll be back with some more interesting new DevOps articles soon.



***Linux, Cloud & Devops Architect & Technical Content Writer*** I am a Linux Enthusiast and Supporter/Promoter of Open Source Technology with over 12+ years of experience in Linux, Cloud and Devops. I am A Technical Content writer for various sites like : Hostbread & Golibrary

Related Posts