Menu Close
1.6. 创建前端服务
frontend 服务是一个简单的 Python 应用,显示来自 backend 应用的消息。
流程
执行 west 终端会话中的所有任务:
部署 frontend 服务:
$ oc create deployment hello-world-frontend --image quay.io/skupper/hello-world-frontend
将 frontend 部署公开为集群服务:
$ oc expose deployment hello-world-frontend --port 8080 --type LoadBalancer
为 frontend 创建路由:
$ oc expose svc/hello-world-frontend
检查 frontend 路由:
获取路由详情:
$ oc get routes
输出结果应类似如下:
NAME HOST/PORT hello-world-frontend <frontend-url>
进入浏览器中的
<frontend-url>
值,您会看到类似以下内容的消息,因为 frontend 还无法与后端通信:Trouble! HTTPConnectionPool(host='hello-world-backend', port=8080): Max retries exceeded with url: /api/hello (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fbfcdf0d1d0>: Failed to establish a new connection: [Errno -2] Name or service not known'))
要解决这种情况,您必须创建后端服务并在服务网络中可用。