in container

Say Hello to OpenShift Origin

Objective

In the previous post OpenShift Origin Installation Guideline, I had share the installation process step by step. In this post, I’d like to represent how to set-up a helloworld level project on OpenShift Origin step by step.

Processes

Logging in OpenShift Origin

# You can change the account if neccasary
[root@master1 ~]# oc login -u <account>

# Double check which account you are using
[root@master1 ~]# oc whomai
system:admin

Create OpenShift Project – helloopenshift

# Create Project - helloopenshift
[root@master1 ~]# oc new-project helloopenshift
Now using project "helloopenshift" on server "https://ocp-internal.pichuang.local:8443".
...

Deploy OpenShift App – parksmap-katacoda

# Deploy app "openshiftroadshow/parksmap-katacoda:1.0.0" in project "helloopenshift"
[root@master1 ~]# oc new-app openshiftroadshow/parksmap-katacoda:1.0.0

--> Found Docker image 7722b79 (16 months old) from Docker Hub for "openshiftroadshow/parksmap-katacoda:1.0.0"

    Python 3.5 
    ---------- 
    Platform for building and running Python 3.5 applications

    Tags: builder, python, python35, rh-python35

    * An image stream will be created as "parksmap-katacoda:1.0.0" that will track this image
    * This image will be deployed in deployment config "parksmap-katacoda"
    * Port 8080/tcp will be load balanced by service "parksmap-katacoda"
      * Other containers can access this service through the hostname "parksmap-katacoda"

--> Creating resources ...
    imagestream "parksmap-katacoda" created
    deploymentconfig "parksmap-katacoda" created
    service "parksmap-katacoda" 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 svc/parksmap-katacoda' 
    Run 'oc status' to view your app.

List All of Status in the project

[root@master1 ~]# oc get all -owide
NAME                                  REVISION   DESIRED   CURRENT   TRIGGERED BY
deploymentconfigs/parksmap-katacoda   1          1         1         config,image(parksmap-katacoda:1.0.0)

NAME                             DOCKER REPO                                                         TAGS      UPDATED
imagestreams/parksmap-katacoda   docker-registry.default.svc:5000/helloopenshift/parksmap-katacoda   1.0.0     3 minutes ago

NAME                           READY     STATUS    RESTARTS   AGE       IP            NODE
po/parksmap-katacoda-1-qrdf6   1/1       Running   0          3m        10.131.0.43   node2.pichuang.local

NAME                     DESIRED   CURRENT   READY     AGE       CONTAINERS          IMAGES                                                                                                        SELECTOR
rc/parksmap-katacoda-1   1         1         1         3m        parksmap-katacoda   openshiftroadshow/parksmap-katacoda@sha256:adf4ce84b52e10c6e4ef8a9d71f99e9f1acaf16b89a4689c0ba84f35a1c37bf0   app=parksmap-katacoda,deployment=parksmap-katacoda-1,deploymentconfig=parksmap-katacoda

NAME                    TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE       SELECTOR
svc/parksmap-katacoda   ClusterIP   172.30.35.186   <none>        8080/TCP   3m        app=parksmap-katacoda,deploymentconfig=parksmap-katacoda

Expose New Route

The way that external clients are able to access applications running in OpenShift is through the OpenShift routing layer. And the data object behind that is a Route.

# Expose service route to outside
[root@master1 ~]# oc expose svc/parksmap-katacoda
route "parksmap-katacoda" exposed

# Check the host and port
[root@master1 ~]# oc get route
NAME                HOST/PORT                                              PATH      SERVICES            PORT       TERMINATION   WILDCARD
parksmap-katacoda   parksmap-katacoda-helloopenshift.apps.pichuang.local             parksmap-katacoda   8080-tcp                 None

Verify Services is Started

  • Via CLI
# Target: http://parksmap-katacoda-helloopenshift.apps.pichuang.local
[root@master1 ~]# curl -v http://parksmap-katacoda-helloopenshift.apps.pichuang.local
* About to connect() to parksmap-katacoda-helloopenshift.apps.pichuang.local port 80 (#0)
*   Trying 192.168.77.36...
* Connection refused
*   Trying 192.168.77.35...
* Connected to parksmap-katacoda-helloopenshift.apps.pichuang.local (192.168.77.35) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: parksmap-katacoda-helloopenshift.apps.pichuang.local
> Accept: */*
> 
< HTTP/1.1 302 Found
< Content-Type: text/plain; charset=utf-8
< Content-Length: 10
< Location: /index.html
< Date: Sat, 30 Jun 2018 09:09:08 GMT
< Server: Python/3.5 aiohttp/1.3.3
< Set-Cookie: b00ecd942f139c34f8c326da3330a63f=72d6fa3f666917f3916f09bdc2db0d7a; path=/; HttpOnly
< 
* Connection #0 to host parksmap-katacoda-helloopenshift.apps.pichuang.local left intact
302: Found
  • Via WEB

References