redhat部署rz_部署到redhat openshift

redhat部署rz

A quick walk-through on how to use Red Hat OpenShift to create and deploy a container image from a git project that contains a simple mood board REST service, deploy a redis container that acts as a backing service, and test.

快速演练如何使用Red Hat OpenShift从git项目创建和部署容器映像,该项目包含一个简单的情绪板REST服务,部署一个redis容器作为后备服务以及进行测试。

The source code lives at https://github.com/stehrn/mood-board.

源代码位于https://github.com/stehrn/mood-board

Sign up to OpenShift for free here to get:

在此处免费注册OpenShift即可获得:

  • 2GiB memory for your applications

    适用于您的应用程序的2GiB内存
  • 2GiB persistent storage for your applications

    2GiB持久存储为您的应用程序
  • 60-day duration

    60天

(at time of writing version 4.2 was used)

(在撰写本文时使用的是4.2版)

Log in to admin home page:

登录到管理员主页:

Click ‘Create Project’ and enter details:

点击“创建项目”并输入详细信息:

Image for post

Now switch to ‘Developer’ mode to create the application topology:

现在切换到“开发人员”模式以创建应用程序拓扑:

Image for post

Select ‘Topology’ and click ‘add other content’, you’ll be presented with:

选择“拓扑”,然后单击“添加其他内容”,将显示以下内容:

Image for post

Create the redis service from the ‘redis:6.0.3-alpine’ container image — select ‘Container Image’ and enter details:

从“ redis:6.0.3-alpine”容器映像创建redis服务-选择“容器映像”并输入详细信息:

Image for post

Things of note:

注意事项:

  • Change ‘Application Name’ to ‘mood-app’

    将“应用程序名称”更改为“ mood-app”
  • Change ‘Name’ to ‘mood-redis’, this will be used for the service name, and is part of the backing service name the mood service will be configured to use

    将“名称”更改为“ mood-redis”,这将用作服务名称,并且是心情服务将配置为使用的支持服务名称的一部分
  • Uncheck ‘Create a route to the application’ as we don’t want an external route to redis, just container container communication via service name

    取消选中“创建到应用程序的路由”,因为我们不希望外部路由重做,而只是通过服务名称进行容器容器通信

Hit ‘Create’ and once created click on ‘Resources’ tab, you’ll see one pod and a service exposed on port 6379:

点击“创建”,创建后单击“资源”选项卡,您将在端口6379上看到一个pod和一项服务:

Image for post

Now create the mood service from source code in GitHub, select ‘Add’ (from the right hand toolbar) and then choose ‘From Git’:

现在从GitHub中的源代码创建心情服务,选择“添加”(在右侧工具栏中),然后选择“从Git”:

Image for post

Enter following details:

输入以下详细信息:

Image for post

Things of note:

注意事项:

  • Once the https://github.com/stehrn/mood-board.git git repo is entered the UI will automatically select the correct builder image (Java)

    输入https://github.com/stehrn/mood-board.git git存储库后,UI会自动选择正确的构建器图像(Java)

  • ‘Application’ ‘mood-app’ is automatically selected, stick with it

    自动选择“应用程序”“ mood-app”,并坚持使用
  • Change ‘Name’ to ‘mood-service’

    将“名称”更改为“心情服务”
  • We do want a Route creating as want a public URL we can connect to, so stick with the default checked option

    我们确实希望创建一个路由,就像我们可以连接到公共URL一样,因此请坚持使用默认选中的选项

At the bottom of the form, click on advanced options for ‘Build Configuration’ and add env variable for redis backing service:

在表单的底部,单击“构建配置”的高级选项,然后为redis支持服务添加env变量:

Image for post

Hit ‘Create’ and once created click on ‘Resources’ tab, you’ll see one pod and a service that exposes several ports, including 8080, there is also a publicly accessible route:

点击“创建”,创建后单击“资源”选项卡,您将看到一个pod和一个服务,该服务公开了多个端口,包括8080,还有一条可公开访问的路由:

Image for post
Image for post

There’s a nice ‘topology view’ you can toggle to by clicking this icon in top right hand side:

您可以通过单击右上角的此图标来切换到一个漂亮的“拓扑视图”:

Image for post

.. to see the topology:

..查看拓扑:

Image for post

So let’s test the application, grab the public route by clicking on this icon:

因此,让我们测试应用程序,通过单击以下图标来​​获取公共路由:

Image for post

… and test, e.g.:

…并进行测试,例如:

$ export ROUTE=http://mood-service-mood-board.apps.us-east-1.starter.openshift-online.com 
$ curl -X PUT -H "Content-Type: text/plain" -d "happy with OpenShift" ${ROUTE}/mood/user/stehrn
$ curl ${ROUTE}/mood/user/stehrn
{"user":"stehrn","mood":"happy with OpenShift"}

You’ve just hit your REST service on OpenShift, and stored a mood in redis, nice!

您刚刚在OpenShift上单击了REST服务,并在redis中存储了心情,太好了!

Now is the time to click around the OpenShift web console to see what features are available and read the (very good) OpenShift documentation.

现在是时候在OpenShift Web控制台附近单击以查看可用的功能,并阅读(非常好) OpenShift文档

翻译自: https://medium.com/swlh/deploying-to-redhat-openshift-95ee9e1a6ba7

redhat部署rz

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值