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

时间:2020-10-23 05:46:37

标签: kubernetes alert monitoring

在天蓝色下运行kubernetes 1.15。

当我的一个或多个应用程序/容器在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界面并配置警报,因此基于:

https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack

https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack

我尝试过:

<div id="create"><a href="home.html">CREATE USER</a></div>

<div id="back"><b href="main.html">Go back to the homepage</b></div>

但这给出了:

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

这里有一些有关如何手动创建crds的指南:

https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#helm-fails-to-create-crds

但这仅在运行helm 2.x(不是我正在运行3.1.2)时才是必需的。

如果我尝试手动安装它们,我也会得到:

Error: failed to install CRD crds/crd-alertmanager.yaml: unable to recognize "": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1"

我也找到了这个 kube-prometheus堆栈兼容性矩阵:

https://github.com/prometheus-operator/kube-prometheus#compatibility

但是该母舰中的版本与我得到的版本不匹配:

$ 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"
...

所以看来这可能是安装Prometheus的第三种方法

任何输入表示赞赏。

更新:

随机选择以前的主要版本(9.4.10)似乎可行:

$ 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...

在较旧的k8s版本上安装内容时,可以通过试错法来尝试,但是对于兼容性矩阵来说可能很好。

1 个答案:

答案 0 :(得分:1)

基于kube-prometheus-stack回购,此头盔图表仅限于K8s 1.16.0或更高版本;

kubeVersion:“> = 1.16.0-0”

即使github自述文件将先决条件表示为String _mi_email=''; String _mi_nombre=''; String _mis_apellidos=''; String _mi_foto=''; String _mi_clinica=''; String _mi_id=''; class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { void getValues() async { SharedPreferences sharedPrefs = await SharedPreferences.getInstance(); _mi_email = sharedPrefs.getString('email'); _mi_clinica = sharedPrefs.getString('clinica') ?? "ninguna"; _mi_nombre = sharedPrefs.getString('nombre') ?? "ninguno"; _mis_apellidos = sharedPrefs.getString('apellidos') ?? "ningunos"; _mi_foto = sharedPrefs.getString('foto') ?? "ninguna"; _mi_id = sharedPrefs.getString('id') ?? "0"; } @override void initState() { getValues(); super.initState(); } @override Widget build(BuildContext context) { ... ,但在helm图表内部也会检查kube版本是否为1.16.0或更高版本。

所以我相信,您需要在升级的K8s集群上尝试。

如果无法升级群集,则可以尝试使用不建议使用的旧版本。

https://github.com/helm/charts/tree/master/stable/prometheus