1、通过镜像部署应用
#登录,用户名developer密码任意 ./oc login -u developer ./oc whoami #部署应用 #方法1 ./oc tag --source=docker openshift/deployment-example:v1 deployment-example:latest #方法2 ./oc tag docker.io/openshift/deployment-example:v1 deployment-example:latest ./oc new-app deployment-example:latest ./oc status curl http://172.30.192.169:8080 #更新应用 #方法1 ./oc tag --source=docker openshift/deployment-example:v2 deployment-example:latest #方法2 oc tag docker.io/openshift/deployment-example:v2 deployment-example:latest curl http://172.30.192.169:8080 #查看情况 ./oc get all NAME READY STATUS RESTARTS AGE pod/deployment-example-3-4wk9x 1/1 Running 0 3m NAME DESIRED CURRENT READY AGE replicationcontroller/deployment-example-1 0 0 0 18m replicationcontroller/deployment-example-2 0 0 0 15m replicationcontroller/deployment-example-3 1 1 1 4m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/deployment-example ClusterIP 172.30.82.203 <none> 8080/TCP 18m</none> NAME REVISION DESIRED CURRENT TRIGGERED BY deploymentconfig.apps.openshift.io/deployment-example 3 1 1 config,image(deployment-example:latest) NAME DOCKER REPO TAGS UPDATED imagestream.image.openshift.io/deployment-example 172.30.1.1:5000/myproject/deployment-example latest 4 minutes ago
2、构建镜像并部署应用
#登录 ./oc login https://IP:8443 -u developer #部署应用 ./oc new-app openshift/nodejs-010-centos7~https://github.com/sclorg/nodejs-ex.git --> Found Docker image b3b1ce7 (2 years old) from Docker Hub for "openshift/nodejs-010-centos7" Node.js 0.10 ------------ Platform for building and running Node.js 0.10 applications Tags: builder, nodejs, nodejs010 * An image stream tag will be created as "nodejs-010-centos7:latest" that will track the source image * A source build using source code from https://github.com/sclorg/nodejs-ex.git will be created * The resulting image will be pushed to image stream tag "nodejs-ex:latest" * Every time "nodejs-010-centos7:latest" changes a new build will be triggered * This image will be deployed in deployment config "nodejs-ex" * Port 8080/tcp will be load balanced by service "nodejs-ex" * Other containers can access this service through the hostname "nodejs-ex" --> Creating resources ... imagestream.image.openshift.io "nodejs-010-centos7" created imagestream.image.openshift.io "nodejs-ex" created buildconfig.build.openshift.io "nodejs-ex" created deploymentconfig.apps.openshift.io "nodejs-ex" created service "nodejs-ex" created --> Success Build scheduled, use 'oc logs -f bc/nodejs-ex' 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 svc/nodejs-ex' Run 'oc status' to view your app. #暴露服务 ./oc expose svc/nodejs-ex route.route.openshift.io/nodejs-ex exposed #查看状态 ./oc status In project My Project (myproject) on server https://IP:8443 http://nodejs-ex-myproject.IP.nip.io to pod port 8080-tcp (svc/nodejs-ex) dc/nodejs-ex deploys istag/nodejs-ex:latest <- bc/nodejs-ex source builds https://github.com/sclorg/nodejs-ex.git on istag/nodejs-010-centos7:latest build #1 pending for about a minute deployment #1 waiting on image or update 2 infos identified, use 'oc status --suggest' to see details. #访问服务 curl http://nodejs-ex-myproject.127.0.0.1.nip.io