使用带有外部IP地址的Prometheus [英] use prometheus with external ip address
问题描述
我们有k8s集群,并且我有正在其中运行的应用程序. 现在,我尝试添加 https://prometheus.io/ 我使用命令
we have k8s cluster and I’ve application which is running there. Now I try to add https://prometheus.io/ and I use the command
helm install stable/prometheus --version 6.7.4 --name my-prometheus
此命令有效,我知道了
NAME: my-prometheus
LAST DEPLOYED: Tue Feb 5 15:21:46 2019
NAMESPACE: default
STATUS: DEPLOYED
...
当我运行命令
NAME: my-prometheus
LAST DEPLOYED: Tue Feb 5 15:21:46 2019
NAMESPACE: default
STATUS: DEPLOYED
...
when I run command
kubectl get services
我知道了
kubernetes ClusterIP 100.64.0.1 <none> 443/TCP 2d4h
my-prometheus-alertmanager ClusterIP 100.75.244.55 <none> 80/TCP 8m44s
my-prometheus-kube-state-metrics ClusterIP None <none> 80/TCP 8m43s
my-prometheus-node-exporter ClusterIP None <none> 9100/TCP 8m43s
my-prometheus-pushgateway ClusterIP 100.75.24.67 <none> 9091/TCP 8m43s
my-prometheus-server ClusterIP 100.33.26.206 <none> 80/TCP 8m43s
我没有任何外部IP
有人知道如何添加吗?通过服务?任何例子
Does someone knows how to add it ? via service? any example for this
更新
我添加了以下yml
apiVersion: v1
kind: Service
metadata:
name: prometheus-service
spec:
selector:
app: prometheus-server
type: LoadBalancer
ports:
- port: 8080
targetPort: 9090
nodePort: 30001
创建成功
现在我看到运行kubectl get services时的外部IP
now I see the external ip like when running kubectl get services
my-prometheus-server LoadBalancer 100.33.26.206 8080:30001/TCP 80/TCP 8m43s
我在浏览器中使用100.33.26.206:30001,什么都没有发生,有什么主意吗?
And I use in the browser 100.33.26.206:30001 and nothing happen, any idea?
推荐答案
我认为您要尝试创建的类型为LoadBalancer的服务,这些服务具有内部和外部IP.
I think what you are trying to do is to create a service with a type LoadBalancer, those have an internal and external IP.
您可以像创建其他任何服务一样创建一个服务,但是您应该精确调整这两个字段:
You can create one like any other service but you should precise those two fields:
externalTrafficPolicy: Local
type: LoadBalancer
已更新:
似乎有些混乱,您不需要外部ip来监视您的应用程序,它将仅用于访问prometheus UI.
There seems to be some confusion, you don't need an external ip to monitor your apps, it will only be used to access prometheus UI.
可以在端口9090上访问UI,但是出口商从不访问普罗米修斯,因为普罗米修斯将废弃出口商.
The UI is accessible on port 9090 but prometheus is never accessed by the exporter as it will be prometheus wich will be scrapping the exporters.
现在要从Internet访问服务,您应该有一个google ip,但是看来您拥有的仍然是内部IP,它与另一个clusterIP位于同一子网中,应该没有.现在,代替外部ip,这表明端口重定向非常错误,因为prometheus UI位于端口9090上(如果您未修改配置,它应该仍然是).您应该尝试删除"nodePort"并将端口重定向到kubernetes.
Now to access a service from the internet you should have a google ip, but it seems that what you have is still an internal IP, it's in the same subnet as the other clusterIP, and it should not. For now in place of an external ip it's showing a port redirect wich is also wrong as the prometheus UI is on port 9090 (if you didn't modify your configuration it should still be). You should try to remove the "nodePort" and leave the port redirect to kubernetes.
这篇关于使用带有外部IP地址的Prometheus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!