CentOS 7
Sponsored Link

OpenShift Origin (OKD) 3.10 : Deploy Applications2018/08/22

 
Deploy Applications.
This is the tutorial for common developper users who use Openshift System.
This example is based on the cluster environment like follows.
-----------+-----------------------------------------------------------+------------
           |10.0.0.25                    |10.0.0.51                    |10.0.0.52
+----------+-----------+      +----------+-----------+      +----------+-----------+
|  [ ctrl.srv.world ]  |      | [ node01.srv.world ] |      | [ node02.srv.world ] |
|     (Master Node)    |      |    (Compute Node)    |      |    (Compute Node)    |
|     (Infra Node)     |      |                      |      |                      |
|     (Compute Node)   |      |                      |      |                      |
+----------------------+      +----------------------+      +----------------------+

[1] Login with a user who has beed added as an Openshift user on Master Node.
[cent@ctrl ~]$
oc login

Authentication required for https://ctrl.srv.world:8443 (openshift)
Username:
cent

Password:
Login successful.

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

    oc new-project <projectname>

# create [test-project] project

[cent@ctrl ~]$
oc new-project test-project

Now using project "test-project" on server "https://ctrl.srv.world:8443".

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

    oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git

to build a new example application in Ruby.

# tag an application image from Docker Hub

[cent@ctrl ~]$
oc tag --source=docker openshift/deployment-example:v2 deployment-example:latest

Tag deployment-example:latest set to openshift/deployment-example:v2.
# deploy [deployment-example] application

[cent@ctrl ~]$
oc new-app deployment-example

--> Found image da61bb2 (3 years old) in image stream "test-project/deployment-example" under tag "latest" for "deployment-example"

    * This image will be deployed in deployment config "deployment-example"
    * Port 8080/tcp will be load balanced by service "deployment-example"
      * Other containers can access this service through the hostname "deployment-example"
    * WARNING: Image "test-project/deployment-example:latest" runs as the 'root' user which may not be permitted by your cluster administrator

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

# show status

[cent@ctrl ~]$
oc status

In project test-project on server https://ctrl.srv.world:8443

svc/deployment-example - 172.30.170.141:8080
  dc/deployment-example deploys istag/deployment-example:latest
    deployment #1 deployed about a minute ago - 1 pod


2 infos identified, use 'oc status -v' to see details.

# describe application

[cent@ctrl ~]$
oc describe svc/deployment-example

Name:              deployment-example
Namespace:         test-project
Labels:            app=deployment-example
Annotations:       openshift.io/generated-by=OpenShiftNewApp
Selector:          app=deployment-example,deploymentconfig=deployment-example
Type:              ClusterIP
IP:                172.30.170.141
Port:              8080-tcp  8080/TCP
TargetPort:        8080/TCP
Endpoints:         10.130.0.6:8080
Session Affinity:  None
Events:            <none>

# show Pods status

[cent@ctrl ~]$
oc get pods

NAME                         READY     STATUS    RESTARTS   AGE
deployment-example-1-8hmfg   1/1       Running   0          1m

# access to the ClusterIP to verify working

[cent@ctrl ~]$
curl 172.30.170.141:8080

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Deployment Demonstration</title>
  .....
  .....
</head>
<body>
<div class="box"><h1>v2</h1><h2></h2></div>
</body>

# if delete application, run like follows

[cent@ctrl ~]$
oc delete all -l app=deployment-example

deploymentconfig "deployment-example" deleted
pod "deployment-example-1-dv2fh" deleted
service "deployment-example" deleted
[cent@ctrl ~]$
oc get pods

No resources found.
[2] It's also possible to verify status of application on OpenShift admin console.
Matched Content