前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >12 Mar 2020 route方式访问ocp应用

12 Mar 2020 route方式访问ocp应用

作者头像
俊采
发布2023-10-17 10:41:40
1420
发布2023-10-17 10:41:40
举报
文章被收录于专栏:LEo的网络日志LEo的网络日志

创建project

代码语言:javascript
复制
$ oc new-project route-demo
Now using project "route-demo" on server "https://api.ssli-ocp1.os.fyre.ibm.com:6443".

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

    oc new-app django-psql-example

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

    kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node

部署应用

代码语言:javascript
复制
$ oc new-app openshift/hello-openshift
--> Found container image 7af3297 (23 months old) from Docker Hub for "openshift/hello-openshift"

    * An image stream tag will be created as "hello-openshift:latest" that will track this image
    * This image will be deployed in deployment config "hello-openshift"
    * Ports 8080/tcp, 8888/tcp will be load balanced by service "hello-openshift"
      * Other containers can access this service through the hostname "hello-openshift"

--> Creating resources ...
    imagestream.image.openshift.io "hello-openshift" created
    deploymentconfig.apps.openshift.io "hello-openshift" created
    service "hello-openshift" 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/hello-openshift'
    Run 'oc status' to view your app.
$ oc get po
NAME                       READY   STATUS      RESTARTS   AGE
hello-openshift-1-deploy   0/1     Completed   0          20s
hello-openshift-1-fb8wc    1/1     Running     0          12s
$ oc get svc
NAME              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)             AGE
hello-openshift   ClusterIP   172.30.92.136   <none>        8080/TCP,8888/TCP   27s

创建route暴露应用

代码语言:javascript
复制
$ oc expose svc/hello-openshift
route.route.openshift.io/hello-openshift exposed
$ oc get svc
NAME              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)             AGE
hello-openshift   ClusterIP   172.30.92.136   <none>        8080/TCP,8888/TCP   81s
$ oc get route
NAME              HOST/PORT                                                   PATH   SERVICES          PORT       TERMINATION   WILDCARD
hello-openshift   hello-openshift-route-demo.apps.ssli-ocp1.os.fyre.ibm.com          hello-openshift   8080-tcp                 None

这里需要注意,如果你是通过手动方式创建route,那么需要在你的/etc/hosts文件中添加相应的ip和host映射,例如:

代码语言:javascript
复制
192.168.0.125  www.your-host.com

然后就可以通过以下方式访问应用:

代码语言:javascript
复制
$ curl www.your-host.com
Hello OpenShift!

通过route访问应用

代码语言:javascript
复制
$ curl hello-openshift-route-demo.apps.ssli-ocp1.os.fyre.ibm.com
Hello OpenShift!

卸载应用

代码语言:javascript
复制
$ oc delete all -l app=hello-openshift

LEo at 12:12

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 创建project
  • 部署应用
  • 创建route暴露应用
  • 通过route访问应用
  • 卸载应用
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档