Docker &引用;连接:连接被拒绝”;把普罗米修斯和库伯内特斯联系起来的时候
我对普罗米修斯是新来的,对库伯尼特斯也是比较新的,所以请容忍我。我试图测试普罗米修斯,并尝试了两种不同的方法Docker &引用;连接:连接被拒绝”;把普罗米修斯和库伯内特斯联系起来的时候,docker,kubernetes,yaml,prometheus,Docker,Kubernetes,Yaml,Prometheus,我对普罗米修斯是新来的,对库伯尼特斯也是比较新的,所以请容忍我。我试图测试普罗米修斯,并尝试了两种不同的方法 将普罗米修斯作为码头工人的集装箱运到库伯内特斯城外。为此,我创建了此Dockerfile: FROM prom/prometheus ADD prometheus.yml /etc/prometheus/ 这个yaml文件: global: scrape_interval: 15s external_labels: monitor: 'codelab-monitor'
FROM prom/prometheus
ADD prometheus.yml /etc/prometheus/
这个yaml文件:
global:
scrape_interval: 15s
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'kubernetes-apiservers'
scheme: http
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: endpoints
api_server: localhost:443
当我运行此命令时,我得到:
Failed to list *v1.Pod: Get http://localhost:443/api/v1/pods?limit=500&resourceVersion=0: dial tcp 127.0.0.1:443: connect: connection refused"
Failed to list *v1.Service: Get http://localhost:443/api/v1/pods?limit=500&resourceVersion=0: dial tcp 127.0.0.1:443: connect: connection refused"
Failed to list *v1.Endpoints: Get http://localhost:443/api/v1/pods?limit=500&resourceVersion=0: dial tcp 127.0.0.1:443: connect: connection refused"
在循环中。普罗米修斯将在我转到localhost:9090时加载,但没有数据kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: prometheus-monitor
spec:
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
spec:
containers:
- name: prometheus-monitor
image: prom/prometheus
# args:
# - '-config.file=/etc/prometheus/prometheus.yaml'
imagePullPolicy: IfNotPresent
ports:
- name: webui
containerPort: 9090
部署成功,但是如果我转到localhost:9090,我会得到“ERR\u SOCKET\u NOT\u CONNECTED”。(我的端口已转发)此外,我的配置文件被禁止,因为它给出了一个错误,一旦我能够加载Prometheus,我将对此进行研究。部署容器时,Kubernetes不会映射其集群外的端口 您还必须创建一个服务(可以在同一个文件中)以使其从您的工作站可用(将其附加到您的prometheus yaml中): NodePort打开所有节点上的给定端口。你应该可以看到前端与 默认情况下,kubernetes允许节点端口类型()的端口30000到32767
请阅读一般文献以了解更多关于KubNeNETs服务的信息: < P> > 2个不同的问题。关于:
localhost:443
,它希望与Kubernetes API服务器通信。显然,本地主机443上没有任何内容在监听。您正在将端口转发到kube apiserver吗 kubectl expose deployment prmetheus-web --type=LoadBalancer # or
kubectl expose deployment prmetheus-web --type=NodePort
这取决于您要公开服务的方式。NodePort在服务中公开它,该服务映射到Kubernetes节点上的端口(IPAddress:port),LoadBalancer使用外部负载平衡器公开部署,该外部负载平衡器根据您使用的云(AWS、GCP、OpenStack、Azure等)而有所不同。有关公开部署、守护程序集或状态集的详细信息。更多关于服务的信息 kubectl expose deployment prmetheus-web --type=LoadBalancer # or
kubectl expose deployment prmetheus-web --type=NodePort