用kustomize部署kube-prometheus-stack not

发布于 2025-01-27 01:51:35 字数 1581 浏览 3 评论 0 原文

我正在尝试部署kube-prometheus-stack 。但是我从部署中得到:

unable to recognize ".": no matches for kind "Alertmanager" in version "monitoring.coreos.com/v1"
unable to recognize ".": no matches for kind "Prometheus" in version "monitoring.coreos.com/v1"
unable to recognize ".": no matches for kind "PrometheusRule" in version "monitoring.coreos.com/v1"
...(and so on)

完整输出下:

我试图在牧场主桌面上部署本地,但是在docker桌面上,我得到了相同的。

我做了什么: 该堆栈的文件也没有kustomize文件,因此我进行了清单

helm template prometheus-community/kube-prometheus-stack > prometheus.yaml

:没有工作后,我试图将直接放在我的kustomize

 helmCharts:
 - name: kube-prometheus-stack 
   repo: https://prometheus-community.github.io/helm-charts
   version: 35.0.3
   releaseName: prometheus

kubectl kustomize . --enable-helm | kubectl apply -f -

如果使用helm,则

helm install prometheus prometheus-community/kube-prometheus-stack

可以使用以下操作。

有趣的是,当我卸载它时:

helm uninstall prometheus

然后通过kustomize

kubectl apply -k .

的工作再次部署它,但这不是我需要的解决方案。那我做错了什么?

I am trying to deploy kube-prometheus-stack
https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack through kustomize. But I am getting from the deployment:

unable to recognize ".": no matches for kind "Alertmanager" in version "monitoring.coreos.com/v1"
unable to recognize ".": no matches for kind "Prometheus" in version "monitoring.coreos.com/v1"
unable to recognize ".": no matches for kind "PrometheusRule" in version "monitoring.coreos.com/v1"
...(and so on)

Full output under: https://app.warp.dev/block/JJwOYMJZng9CyBdVlBaIIF

I tried to deploy local on rancher desktop but on docker desktop I get the same.

What I did:
There are nor kustomize file for this stack so I take the manifest with:

helm template prometheus-community/kube-prometheus-stack > prometheus.yaml

after this didn't work I tried to take directly in my kustomize.yaml the helm with:

 helmCharts:
 - name: kube-prometheus-stack 
   repo: https://prometheus-community.github.io/helm-charts
   version: 35.0.3
   releaseName: prometheus

and started kustomize with:

kubectl kustomize . --enable-helm | kubectl apply -f -

both have the same problem.

If use helm with:

helm install prometheus prometheus-community/kube-prometheus-stack

its working.

What interesting is that when I uninstall it:

helm uninstall prometheus

and then deploy it again through kustomize

kubectl apply -k .

Its working, but it is not the solution which I need. So what am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浮云落日 2025-02-03 01:51:35

在尝试部署“使用”这些CRD的对象之前,您需要给Kubernetes一些时间来创建CRD。

下次只做一次申请,等待10秒,然后再次申请。甚至几次,直到错误消失。

You need to give kubernetes some time to create CRDs before trying to deploy objects that "use" those CRDs.

Next time just do the apply one time, wait 10 seconds and do the apply again. even several times until the errors disappear.

花间憩 2025-02-03 01:51:35

我在Helmfile也有类似的问题。当CRD与资源同时部署(在同一图表中甚至是Helmfile依赖性)时,Helmfile验证将失败:

Error: unable to build kubernetes objects from release manifest: [unable to recognize "": no matches for kind "Alertmanager" in version "monitoring.coreos.com/v1", unable to recognize "": no matches for kind "Prometheus" in version "monitoring.coreos.com/v1", unable to recognize "": no matches for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"]

但是,Kubernetes代理完全能够同时处理CRD/资源创建。使用Helmfile的解决方案是禁用第一次部署的验证:

helmfile.yaml

releases:
- name: prometheus
  disableValidation: true # Missing CRDs on first deploy
  installed: true
  values:
    - values.yaml

这是我到目前为止唯一发现的解决方法,
我对Kustomize不太熟悉,但是我想也必须有一种跳过验证的方法吗?

希望这对

I had a similar problem with Helmfile. When the CRDs are deployed at the same time (in the same chart or even as Helmfile dependency) as the resources, Helmfile validation will fail :

Error: unable to build kubernetes objects from release manifest: [unable to recognize "": no matches for kind "Alertmanager" in version "monitoring.coreos.com/v1", unable to recognize "": no matches for kind "Prometheus" in version "monitoring.coreos.com/v1", unable to recognize "": no matches for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"]

However, Kubernetes agent is perfectly capable of handling crd/resource creation at the same time. The solution with Helmfile was to disable validation on first deploy :

helmfile.yaml

releases:
- name: prometheus
  disableValidation: true # Missing CRDs on first deploy
  installed: true
  values:
    - values.yaml

It's the only workaround I have found so far,
I'm not very familiar with Kustomize, but I suppose there must be a way to skip validation as well ?

Hope this helps anyway

南城旧梦 2025-02-03 01:51:35

我通过设置 helmcharts.includecrds:true kustomization.yaml 中解决了这个问题。

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: monitoring

helmCharts:
  - name: kube-prometheus-stack
    repo: https://prometheus-community.github.io/helm-charts
    version: 45.28.1
    includeCRDs: true
    releaseName: kube-prometheus-stack
    namespace: monitoring
    valuesFile: values.yaml


I solved this by setting helmCharts.includeCRDs: true in kustomization.yaml.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: monitoring

helmCharts:
  - name: kube-prometheus-stack
    repo: https://prometheus-community.github.io/helm-charts
    version: 45.28.1
    includeCRDs: true
    releaseName: kube-prometheus-stack
    namespace: monitoring
    valuesFile: values.yaml


~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文