我的問題是在K8s集群安裝 prometheus-operator 報這個錯
問題的原因
我的集群版本太高了,1.22的版本,而且 prometheus-operator 之后的版本改變了名字,舊的版本不兼容,
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm search repo prometheus-operator NAME CHART VERSION APP VERSION DESCRIPTION ali/prometheus-operator 8.7.0 0.35.0 Provides easy monitoring definitions for Kubern... azure/prometheus-operator 9.3.2 0.38.1 DEPRECATED Provides easy monitoring definitions... ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm install liruilong ali/prometheus-operator Error: failed to install CRD crds/crd-alertmanager.yaml: unable to recognize "": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1" ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create]
解決辦法
用新版的chart ,Github地址為:
https://github.com/prometheus-community/helm-charts/releases/download/kube-prometheus-stack-30.0.1/kube-prometheus-stack-30.0.1.tgz
這里如果小伙伴有爬牆的話,沒啥問題,下載好直接安裝就可以了。
沒有的話,就有些麻煩,安裝過程拉取不下來的鏡像需要到docker倉庫上找相關的鏡像替換一下。
直接修改資源文件就可以了,下面是我的替換
image: k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 替換為 : docker.io/liangjw/kube-webhook-certgen:v1.1.1
k8s.gcr.io/kube-state-metrics/kube-state-metrics 替換為: docker.io/dyrnq/kube-state-metrics:v2.3.0

然后所有節點沒問題之后,改一下SVC類型就可以在宿主機訪問了