首页 > 解决方案 > prometheus-9.5.4 获取 helm status 失败

问题描述

我正在关注但无法理解和排除部署状态失败的原因。 https://linuxacademy.com/cp/courses/lesson/course/2205/lesson/2/module/218

curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > /tmp/get_helm.sh
chmod 700 /tmp/get_helm.sh
DESIRED_VERSION=v2.8.2 /tmp/get_helm.sh
helm init --wait
kubectl --namespace=kube-system create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default
helm ls
cd ~/
git clone https://github.com/kubernetes/charts
cd charts
git checkout efdcffe0b6973111ec6e5e83136ea74cdbe6527d
cd ../
vi prometheus-values.yml
prometheus-values.yml:

alertmanager:
    persistentVolume:
        enabled: false
server:
    persistentVolume:
        enabled: false
Then run:

helm install -f prometheus-values.yml charts/stable/prometheus --name prometheus --namespace prometheus
vi grafana-values.yml
grafana-values.yml:

adminPassword: password
Then run:

helm install -f grafana-values.yml charts/stable/grafana/ --name grafana --namespace grafana
vi grafana-ext.yml
grafana-ext.yml:

kind: Service
apiVersion: v1
metadata:
  namespace: grafana
  name: grafana-ext
spec:
  type: NodePort
  selector:
    app: grafana
  ports:
  - protocol: TCP
    port: 3000
    nodePort: 8080
Then run:

kubectl apply -f grafana-ext.yml
You can check on the status of the prometheus and grafana pods with these commands:

kubectl get pods -n prometheus
kubectl get pods -n grafana
When setting up your dastasource in grafana, use this url:

http://prometheus-server.prometheus.svc.cluster.local

在 2 个不同的环境中遇到相同的问题

  1. 在 aws 中运行的 k8s 集群状态为失败

    $ kubectl 描述部署普罗米修斯 -n 普罗米修斯

来自服务器的错误 (NotFound): deployments.extensions "prometheus" not found

$ helm ls --all

   NAME            REVISION        UPDATED                         STATUS          CHART                   NAMESPACE
grafana         1               Tue Dec 17 12:26:32 2019        DEPLOYED        grafana-1.8.0           grafana
prometheus      1               Wed Dec 18 10:24:58 2019        FAILED          prometheus-9.5.4        prometheus
  1. 在 hyper V 上运行的 k8s 集群

    admin1@POC-k8s-master:~/poc-cog$ helm init --wait

        $HELM_HOME has been configured at /home/admin1/.helm.
        Error: error installing: the server could not find the requested resource
    

admin1@POC-k8s-master:~/.helm$ kubectl 获取节点 -o 宽

NAME             STATUS   ROLES    AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION     CONTAINER-RUNTIME
poc-k8s-master   Ready    master   24d   v1.16.3   192.168.137.2   <none>        Ubuntu 16.04.6 LTS   4.4.0-62-generic   docker://19.3.5
poc-k8s-node1    Ready    <none>   24d   v1.16.3   192.168.137.3   <none>        Ubuntu 16.04.6 LTS   4.4.0-62-generic   docker://18.6.2

admin@ip-172-20-49-150:~/dev-migration/stage$ helm install stable/prometheus

Error: release loping-owl failed: clusterroles.rbac.authorization.k8s.io "loping-owl-prometheus-kube-state-metrics" is forbidden: attempt to grant extra privileges: [PolicyRule{Resources:["namespaces"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["namespaces"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["nodes"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["nodes"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["persistentvolumeclaims"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["persistentvolumeclaims"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["pods"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["pods"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["services"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["services"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["resourcequotas"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["resourcequotas"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["replicationcontrollers"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["replicationcontrollers"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["limitranges"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["limitranges"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["persistentvolumeclaims"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["persistentvolumeclaims"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["persistentvolumes"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["persistentvolumes"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["endpoints"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["endpoints"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["secrets"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["secrets"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["configmaps"], APIGroups:[""], Verbs:["list"]} PolicyRule{Resources:["configmaps"], APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["daemonsets"], APIGroups:["extensions"], Verbs:["list"]} PolicyRule{Resources:["daemonsets"], APIGroups:["extensions"], Verbs:["watch"]} PolicyRule{Resources:["deployments"], APIGroups:["extensions"], Verbs:["list"]} PolicyRule{Resources:["deployments"], APIGroups:["extensions"], Verbs:["watch"]} PolicyRule{Resources:["ingresses"], APIGroups:["extensions"], Verbs:["list"]} PolicyRule{Resources:["ingresses"], APIGroups:["extensions"], Verbs:["watch"]} PolicyRule{Resources:["replicasets"], APIGroups:["extensions"], Verbs:["list"]} PolicyRule{Resources:["replicasets"], APIGroups:["extensions"], Verbs:["watch"]} PolicyRule{Resources:["daemonsets"], APIGroups:["apps"], Verbs:["get"]} PolicyRule{Resources:["daemonsets"], APIGroups:["apps"], Verbs:["list"]} PolicyRule{Resources:["daemonsets"], APIGroups:["apps"], Verbs:["watch"]} PolicyRule{Resources:["deployments"], APIGroups:["apps"], Verbs:["get"]} PolicyRule{Resources:["deployments"], APIGroups:["apps"], Verbs:["list"]} PolicyRule{Resources:["deployments"], APIGroups:["apps"], Verbs:["watch"]} PolicyRule{Resources:["statefulsets"], APIGroups:["apps"], Verbs:["get"]} PolicyRule{Resources:["statefulsets"], APIGroups:["apps"], Verbs:["list"]} PolicyRule{Resources:["statefulsets"], APIGroups:["apps"], Verbs:["watch"]} PolicyRule{Resources:["cronjobs"], APIGroups:["batch"], Verbs:["list"]} PolicyRule{Resources:["cronjobs"], APIGroups:["batch"], Verbs:["watch"]} PolicyRule{Resources:["jobs"], APIGroups:["batch"], Verbs:["list"]} PolicyRule{Resources:["jobs"], APIGroups:["batch"], Verbs:["watch"]} PolicyRule{Resources:["horizontalpodautoscalers"], APIGroups:["autoscaling"], Verbs:["list"]} PolicyRule{Resources:["horizontalpodautoscalers"], APIGroups:["autoscaling"], Verbs:["watch"]} PolicyRule{Resources:["poddisruptionbudgets"], APIGroups:["policy"], Verbs:["list"]} PolicyRule{Resources:["poddisruptionbudgets"], APIGroups:["policy"], Verbs:["watch"]} PolicyRule{Resources:["certificatesigningrequests"], APIGroups:["certificates.k8s.io"], Verbs:["list"]} PolicyRule{Resources:["certificatesigningrequests"], APIGroups:["certificates.k8s.io"], Verbs:["watch"]}] user=&{system:serviceaccount:kube-system:tiller b474eab9-b753-11e9-83a0-06e8a114eea2 [system:serviceaccounts system:serviceaccounts:kube-system system:authenticated] map[]} ownerrules=[] ruleResolutionErrors=[[clusterroles.rbac.authorization.k8s.io "cluster-admin" not found, clusterroles.rbac.authorization.k8s.io "cluster-admin" not found]]

admin@ip-172-20-49-150:~/dev-migration/stage$ kubectl --namespace=kube-system create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-系统:默认

   Error from server (AlreadyExists): clusterrolebindings.rbac.authorization.k8s.io "add-on-cluster-admin" already exists

admin@ip-172-20-49-150:~/dev-migration/stage$ helm inspect prometheus

Error: failed to download "prometheus"

标签: amazon-web-serviceskubernetesprometheuskubernetes-helmhyper-v

解决方案


推荐阅读