[英]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.