简体   繁体   English

如何将 prometheus 适配器移动到另一个命名空间?

[英]how to move prometheus adapter to another namespace?

For now I have prometheus and prometheus adapter in different namespaces:现在我在不同的命名空间中有 prometheus 和 prometheus 适配器:文本

I tried to configure adapter YML but I was not successful: apiVersion: apps/v1 kind: Deployment metadata:我尝试配置适配器 YML,但没有成功: apiVersion: apps/v1 kind: Deployment metadata:

  annotations:
    deployment.kubernetes.io/revision: "2"
  creationTimestamp: "2020-01-30T08:49:05Z"
  generation: 2
  labels:
    app: prometheus-adapter
    chart: prometheus-adapter-2.0.1
    heritage: Tiller
    release: prometheus-adapter
  name: prometheus-adapter
  namespace: my-custom-namespace
  resourceVersion: "18513075"
  selfLink: /apis/apps/v1/namespaces/my-custom-namespace/deployments/prometheus-adapter
  ...

But I see error:但我看到错误:

the namespace of the object (my-custom-namespace) does not match the namespace on the request (default)

How to fix it ?如何解决?

You can not edit an existing resource to change namespace.You need to delete the existing deployment first and then recreate the deployment in another namespace.您不能编辑现有资源来更改命名空间。您需要先删除现有部署,然后在另一个命名空间中重新创建部署。

Edit:编辑:

With Helm2 you need to delete the release first helm delete --purge release-name and then deploy it to different namespace as helm install stable/prometheus-adapter --namespace namespace-name使用 Helm2,您需要先删除发行版helm delete --purge release-name然后将其部署到不同的命名空间作为helm install stable/prometheus-adapter --namespace namespace-name

With helm 3 since there is no --namespace flag you need to delete the existing deployment and then redeploy it to a different namespace as below example to deploy metrics server.使用 helm 3,因为没有--namespace标志,您需要删除现有部署,然后将其重新部署到不同的命名空间,如下例所示以部署指标服务器。

$ helm install metricserver stable/metrics-server
Error: the namespace from the provided object "kube-system" does not          match the namespace "default". You must pass '--namespace=kube-system' to perform this operation.

$ helm install metricserver stable/metrics-server --namespace=kube-system
Error: the namespace from the provided object "kube-system" does not match the namespace "default". You must pass '--namespace=kube-system' to perform this operation.

$ kubectl config set-context kube-system --cluster=kubernetes --user=kubernetes-admin --namespace=kube-system
Context "kube-system" created.

$ kubectl config use-context kube-system
Switched to context "kube-system".

$ kubectl config get-contexts
CURRENT   NAME                          CLUSTER      AUTHINFO           NAMESPACE
*         kube-system                   kubernetes   kubernetes-admin   kube-system
          kubernetes-admin@kubernetes   kubernetes   kubernetes-admin
          metallb                       kubernetes   kubernetes-admin   metallb
          nfstorage                     kubernetes   kubernetes-admin   nfstorage

$ helm install metricserver stable/metrics-server
NAME: metricserver
LAST DEPLOYED: 2019-05-26 14:37:45.582245559 -0700 PDT m=+2.942929639
NAMESPACE: kube-system
STATUS: deployed

For helm 2 you can install the chart in any namespace you want by using:对于 helm 2,您可以使用以下命令将图表安装在您想要的任何命名空间中:

helm install stable/prometheus-adapter --name my-release --namespace foo

Keep in mind that you need to remove the previous one.请记住,您需要删除前一个。

This can be done using helm delete --purge my-release这可以使用helm delete --purge my-release来完成

Also there is a really nice article regarding changes in Helm3 Breaking Changes in Helm 3 (and How to Fix Them) .还有一篇非常好的文章关于 Helm3 Breaking Changes in Helm 3 (and How to Fix Them) 的变化

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ServiceMonitor Prometheus 不在另一个命名空间中工作 - ServiceMonitor Prometheus not working in another namespace Prometheus适配器和Prometheus操作器之间的区别 - Difference between Prometheus Adapter and Prometheus Operator kubernetes 指标的 Prometheus 适配器配置 - Prometheus Adapter configuration for kubernetes metrics 普罗米修斯适配器未正常运行 - prometheus-adapter is not running properly Prometheus适配器自定义指标HPA - Prometheus Adapter custom metrics HPA Prometheus 检查命名空间是否缺少配额 - Prometheus check if namespace missing quota 使用 Prometheus Adapter 的 Horizo​​ntal Pod Autoscaler (HPA) 自定义指标(如何定义单位?) - Horizontal Pod Autoscaler (HPA) custom metrics with Prometheus Adapter (How are units defined?) 如何使用 Prometheus 适配器根据响应时间(自定义指标)在 Kubernetes 中执行 HorizontalPodAutoscaling? - how to perform HorizontalPodAutoscaling in Kubernetes based on response time (custom metric) using Prometheus adapter? 如何将监控限制在普罗米修斯中的单个命名空间。 我无法获得任何命名空间选项来设置单个命名空间 - How monitoring can be limited to single namespace in prometheus. I am unable to get any namespaces options to set a single namespace 如何在稳定/ prometheus图表values.yaml中包含来自另一个yaml文件的prometheus规则? - How to include prometheus rules from another yaml file in stable/prometheus chart values.yaml?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM