
云原生
Docker Swarm 中 Nginx 反代网关报 "No route to host" 的根因与解法
背景 集群使用 Docker Swarm 部署,Nginx 通过反向代理访问网关服务 wulaoer。按 Swarm 规则,Nginx 配置里写服务名加端口即可通信,例如: 但实际
后来查看了一些资料原来是 ServiceAccount 的授权问题,对应的 ClusterRoleBind 在修改之前是这样的:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: prometheus
rules:
- apiGroups: [""]
resources: ["nodes", "nodes/metrics", "services", "endpoints", "pods"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
问题就出现标红的那一行。由于 cadvisor 对应的 api 是,/api/v1/nodes/${1}/proxy/metrics/cadvisor (这里的 ${1} 会替换成具体的节点名称)。所属的 api 资源 nodes/proxy 没有被授权。如果加上授权:
resources: ["nodes", "nodes/proxy", "nodes/metrics", "services", "endpoints", "pods"]修改后自动重新加载,所有的DOWN就自动UP了
评论 0