访问 kubernetes pod 中的 spring 引导控制器端点
Accessing spring boot controller endpoint in kubernetes pod
我在 kubernetes pod 中部署了一个 spring 引导应用程序。但通常我以这种代理端口转发的方式访问任何应用程序 -
http://192.64.125.29:8001/api/v1/namespaces/kube-system/services/https:hello-app:/proxy/
但是我的 spring 启动应用程序是 运行 在下面 url -
http://192.64.125.29:8001/api/v1/namespaces/kube-system/services/https:myspringbootapp:/proxy/
但我不知道如何调用我的控制器端点 /visitid
如果您只是想快速检查一下,那么您可以 port-forward to the pod - 执行 kubectl get pods
查找 pod 名称,然后 kubectl port-forward <pod-name> 8080:8080
或您使用的任何端口(如果不是 8080) . 然后你可以在你的浏览器中访问你的端点或者在本地主机上使用 curl。例如,如果您有 spring 引导执行器 运行,您可以转到 http://localhost:8080/actuator/health
.
如果您尝试通过服务访问 Pod,那么您可以 port-forward to the Service but you may want to expose the Service externally. You'll want to pick how to expose it externally 并进行设置。然后你将有一个外部 URL 你可以使用并且不需要通过 kube 内部 API。
也可以to construct a URL to hit the Service when proxying with kubectl proxy
。例如,您可以使用带有 api/v1/namespaces/<namespace>/services/<http:><service_name>:<port_name>/proxy/actuator/health
的 http(而非 https)在 spring 启动应用程序上点击执行器。 <port_name>
将在服务规范中,您会在 kubectl describe service
.
的输出中找到它
我在 kubernetes pod 中部署了一个 spring 引导应用程序。但通常我以这种代理端口转发的方式访问任何应用程序 -
http://192.64.125.29:8001/api/v1/namespaces/kube-system/services/https:hello-app:/proxy/
但是我的 spring 启动应用程序是 运行 在下面 url -
http://192.64.125.29:8001/api/v1/namespaces/kube-system/services/https:myspringbootapp:/proxy/
但我不知道如何调用我的控制器端点 /visitid
如果您只是想快速检查一下,那么您可以 port-forward to the pod - 执行 kubectl get pods
查找 pod 名称,然后 kubectl port-forward <pod-name> 8080:8080
或您使用的任何端口(如果不是 8080) . 然后你可以在你的浏览器中访问你的端点或者在本地主机上使用 curl。例如,如果您有 spring 引导执行器 运行,您可以转到 http://localhost:8080/actuator/health
.
如果您尝试通过服务访问 Pod,那么您可以 port-forward to the Service but you may want to expose the Service externally. You'll want to pick how to expose it externally 并进行设置。然后你将有一个外部 URL 你可以使用并且不需要通过 kube 内部 API。
也可以to construct a URL to hit the Service when proxying with kubectl proxy
。例如,您可以使用带有 api/v1/namespaces/<namespace>/services/<http:><service_name>:<port_name>/proxy/actuator/health
的 http(而非 https)在 spring 启动应用程序上点击执行器。 <port_name>
将在服务规范中,您会在 kubectl describe service
.