在 OpenShift Origin Server 中公开服务 - 路由器不工作

Kam*_*łys 3 openshift-origin

Our team decided to try using OpenShift Origin server to deploy services. We have a separate VM with OpenShift Origin server installed and working fine. I was able to deploy our local docker images and those services are running fine as well - Pods are up and running, get their own IP and I can reach services endpoints from VM.

The issue is I can't get it working, so the services are exposed outside the machine. I read about the routers, which suppose to be the right way of exposing services, but it just won't work, now some details.

Lets say my VM is 10.48.1.1. The Pod with docker container with one of my services is running on IP 172.30.67.15:

~$ oc get svc
NAME                CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
my-svc              172.30.67.15     <none>        8182/TCP   4h
Run Code Online (Sandbox Code Playgroud)

The service is simple Spring Boot app with REST endpoint exposed at port 8182. Whe I call it from VM hosting it, it works just fine:

$ curl -H "Content-Type: application/json" http://172.30.67.15:8182/home
{"valid":true}
Run Code Online (Sandbox Code Playgroud)

Now I wanted to expose it outside, so I created a router: oc adm router my-svc --ports='8182'

I followed the steps from OpenShift dev doc both from CLI and Console UI. The router gets created fine, but then when I want to check its status, I get this:

$ oc status
In project sample on server https://10.48.3.161:8443
...
Errors:
  * route/my-svc is routing traffic to svc/my-svc, but either the administrator has not installed a router or the router is not selecting this route.
Run Code Online (Sandbox Code Playgroud)

I couldn't find anything about this error that could help me solve the issue - does anyone had similar issue? Is there any other (better/proper?) way of exposing service endpoint? I am new to OpenShift so any suggestions would be appirciated.

Kam*_*łys 5

如果有人感兴趣,我终于找到了“解决方案”。问题是没有创建“路由器”服务 - 我不知道它必须被创建。

一步一步地,为了创建这个服务,我按照OpenShift 文档页面的说明操作,这很简单,但我无法使用管理员帐户登录。我使用默认管理员帐户

$ oc login -u system:admin
Run Code Online (Sandbox Code Playgroud)

但是使用可用的证书,它一直要求我输入密码,但它不应该。哪里错了?我的环境变量被重置,我不得不再次设置它们

$ export KUBECONFIG="$(pwd)"/openshift.local.config/master/admin.kubeconfig
$ export CURL_CA_BUNDLE="$(pwd)"/openshift.local.config/master/ca.crt
$ sudo chmod +r "$(pwd)"/openshift.local.config/master/admin.kubeconfig
Run Code Online (Sandbox Code Playgroud)

这是 OpenShift 文档OpenShift 文档 中描述的第一步。之后,证书设置正确,登录按预期工作。作为管理员,我创建了路由器服务(第一个链接)并且路由开始工作 - 没有更多错误。所以最终它变得非常简单和虚拟,但鉴于我没有使用 OpenShift 的经验,我很难找出发生了什么。如果有人遇到同样的问题,希望它会有所帮助。