繁体   English   中英

无法在 K8S 集群中创建 Prometheus

[英]Not able to create Prometheus in K8S cluster

我正在尝试在我的 K8S 集群上安装 Prometheus

当我运行命令时

kubectl get namespaces

我得到了以下命名空间:

default       Active   26h
kube-public   Active   26h
kube-system   Active   26h
monitoring    Active   153m
prod          Active   5h49m

现在我想通过创建普罗米修斯

helm install stable/prometheus --name prom -f k8s-values.yml

我得到了错误:

错误:发布 prom-demo 失败:命名空间“default”被禁止:用户“system:serviceaccount:kube-system:default”无法在命名空间“default”中的 API 组“”中获取资源“namespaces”

即使我切换到monitoring ns 我也遇到了同样的错误,

k8s-values.yml 如下所示

rbac:
  create: false
server:
  name: server

  service:
    nodePort: 30002
    type: NodePort

知道这里可能缺少什么吗?

您收到此错误是因为您在使用 RBAC 的情况下没有授予正确的权限。

授予分蘖权限:
取自https://github.com/helm/helm/blob/master/docs/rbac.md

示例:具有 cluster-admin 角色的服务帐户在 rbac-config.yaml 中:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tiller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: tiller
    namespace: kube-system

注意:cluster-admin 角色是在 Kubernetes 集群中默认创建的,因此您不必明确定义它。

$ kubectl create -f rbac-config.yaml
serviceaccount "tiller" created
clusterrolebinding "tiller" created
$ helm init --service-account tiller

为 prometheus 创建一个服务账户:
rbac.create的值更改为true

rbac:
  create: true
server:
  name: server

  service:
    nodePort: 30002
    type: NodePort

查看 prometheus operator 以启动 prometheus 堆栈中的所有监控服务。 以下链接很有帮助https://github.com/coreos/prometheus-operator/tree/master/contrib/kube-prometheus/manifests

所有清单都列在那里。 浏览这些文件并在 k8s 集群中部署您需要监控的任何内容

暂无
暂无

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

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