👋 欢迎来到吴老二技术博客,专注运维 / 数据库 / 云原生
首页/云原生/正文

在prometheus中target显示server retumed HTTP status 403 Forbidden

吴
吴老二
2022-02-15云原生2709 次浏览0 条评论
部署的prometheus在target中显示server retumed HTTP status 403 Forbidden,插件什么的都已经安装好了,正常不应该有这个错误,同一个安装方式,只是环境不同而已,报错显示的状态是没有权限,日志也没有,无从下手了,报错内容如下: 后来查看了一些资料原来是 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

评论需 登录 后发表(注册并验证邮箱)。
还没有评论,来抢沙发~