gpt4 book ai didi

kubernetes - 无法在 k8s 1.15 中安装 kube-prometheus-stack

转载 作者:行者123 更新时间:2023-12-03 19:01:59 26 4
gpt4 key购买 nike

在 azure 中运行 kubernetes 1.15。
当我的一个或多个应用程序/pod 在 kubernetes 中出现故障时,我需要一个基本警报(电子邮件/松弛通知)。
例如,我有 https://cert-manager.io/docs/在多个集群中运行(托管在 azure 中),如果它停止运行,我想收到警报(电子邮件/松弛通知)。
基于这篇文章:
How do I set up a hook to send an email on Kubernetes pod restart?
似乎收到电子邮件警报我需要安装 Prometheus + Grafana 访问 web-ui 并根据以下内容配置警报:
https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack
https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
我试过了:

helm version
version.BuildInfo{Version:"v3.1.2", GitCommit:"d878d4d45863e42fd5cff6743294a11d28a9abce", GitTreeState:"clean", GoVersion:"go1.13.8"}


helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add stable https://kubernetes-charts.storage.googleapis.com/
helm repo update

helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack --namespace monitoring
但这给出了:
Error: failed to install CRD crds/crd-alertmanager.yaml: unable to recognize "": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1"
这里有一些关于如何手动创建 crd 的指南:
https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#helm-fails-to-create-crds
但这只有在运行 helm 2.x 时才必要,我不是我正在运行 3.1.2。
此外,如果我尝试手动安装它们,我会得到:
$ kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.42/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml
error: unable to recognize "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.42/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1"
$ kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.42/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
error: unable to recognize "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.42/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1"
$ kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.42/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml
error: unable to recognize "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.42/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1"
...
我也发现了这个 kube-prometheus 堆栈 兼容性矩阵:
https://github.com/prometheus-operator/kube-prometheus#compatibility
但该矩阵中的版本与我得到的版本不匹配:
$ helm search repo prometheus-community/kube-prometheus-stack --versions
NAME CHART VERSION APP VERSION DESCRIPTION
prometheus-community/kube-prometheus-stack 10.1.2 0.42.1 kube-prometheus-stack collects Kubernetes manif...
prometheus-community/kube-prometheus-stack 10.1.1 0.42.1 kube-prometheus-stack collects Kubernetes manif...
prometheus-community/kube-prometheus-stack 10.1.0 0.42.1 kube-prometheus-stack collects Kubernetes manif...
prometheus-community/kube-prometheus-stack 10.0.2 0.42.1 kube-prometheus-stack collects Kubernetes manif...
prometheus-community/kube-prometheus-stack 10.0.1 0.42.1 kube-prometheus-stack collects Kubernetes manif...
所以似乎这可能是安装 Prometheus 的第三种方式
任何输入表示赞赏。
更新:
随机选择以前的主要版本(9.4.10)似乎有效:
$ helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack --namespace monitoring --version 9.4.10
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
NAME: kube-prometheus-stack
LAST DEPLOYED: Fri Oct 23 15:15:03 2020
NAMESPACE: monitoring
STATUS: deployed
REVISION: 1
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
kubectl --namespace monitoring get pods -l "release=kube-prometheus-stack"

Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.
在较旧的 k8s 版本上安装东西时,猜测试错是要走的路,不过对于兼容性矩阵可能很好。

最佳答案

基于 kube-prometheus-stack repo,此 helm chart 受限于 K8s 1.16.0 及以上版本;

kubeVersion: ">=1.16.0-0"


即使 github README 说先决条件为 Kubernetes 1.10+ with Beta APIs , helm chart 在内部检查 kube 版本是否为 1.16.0 或更高版本。
所以我相信,你需要在升级的 K8s 集群上尝试这个。
如果升级集群不是一种选择,也许您可​​以尝试使用已弃用的旧版本。
https://github.com/helm/charts/tree/master/stable/prometheus

关于kubernetes - 无法在 k8s 1.15 中安装 kube-prometheus-stack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64494540/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com