简体   繁体   English

如何在Kubernetes上以Flink应用模式让pod暴露prometheus监控端口?

[英]How do I get the pod to expose the prometheus monitoring port in Flink application mode on Kubernetes?

I'm running flink run-application targetting Kubernetes, using these options:我正在运行以flink run-application目标的flink run-application ,使用以下选项:

-Dmetrics.reporter.prom.class=org.apache.flink.metrics.prometheus.PrometheusReporter
-Dmetrics.reporter.prom.port=9249

I specify a container image which has the Prometheus plugin copied into /opt/flink/plugins .我指定了一个容器映像,其中将 Prometheus 插件复制到/opt/flink/plugins From within the job manager container I can download Prometheus metrics on port 9249. However, kubectl describe on the flink pod does not show that the Prometheus port is exposed.从作业管理器容器内,我可以在端口9249.下载普罗米修斯指标然而, kubectl describe在弗林克荚不表明普罗米修斯端口暴露。 The ports line in the kubectl output is: kubectl 输出中的端口行是:

Ports: 8081/TCP, 6123/TCP, 6124/TCP

Therefore, I expect that nothing outside the container will be able to read the Prometheus metrics.因此,我希望容器之外的任何东西都无法读取 Prometheus 指标。

You are misunderstanding the concept of exposed ports .您误解了暴露端口的概念。
When you expose a port in kubernetes with the ports option (the same apply with Docker and the EXPOSE tag), nothing is open on this port from the outside world.当您在 kubernetes 中使用ports选项公开一个端口时(同样适用于 Docker 和EXPOSE标签),这个端口上的任何东西都不会从外界打开。

It's basically just a hint for users of that image to tell them "Hey, you want to use this image ? Ok, you may want to have a look at this port on this container."这基本上只是一个提示,让该图像的用户告诉他们“嘿,你想使用这个图像吗?好吧,你可能想看看这个容器上的这个端口。”

So if your port does not appear when you do kubectl describe , then it does not mean that you can't reach that port.因此,如果您在执行kubectl describe时没有出现您的端口,那么这并不意味着您无法访问该端口。 You can still map it with a service targetting this port.您仍然可以将其映射到针对此端口的服务。

Furthermore, if you really want to make it appear with kubectl describe , then you just have to add it to your kubernetes descriptor file :此外,如果你真的想用kubectl describe让它出现,那么你只需要将它添加到你的 kubernetes 描述符文件中:

...
  containers:
  - ports:
      - name: prom-http
        containerPort: 9249

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM