<p>For now I have prometheus and prometheus adapter in different namespaces:
<img src="https://i.stack.imgur.com/9Bm2h.jpg" alt="Text"></p>

<p>I tried to configure adapter YML but I was not successful:
apiVersion: apps/v1
kind: Deployment
metadata:</p>

<pre><code>  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
  ...
</code></pre>

<p>But I see error:</p>

<pre><code>the namespace of the object (my-custom-namespace) does not match the namespace on the request (default)
</code></pre>

<p>How to fix it ?</p>

<p>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.</p>

<p><strong>Edit:</strong> </p>

<p>With Helm2 you need to delete the release first <code>helm delete --purge release-name</code>  and then deploy it to different namespace as <code>helm install stable/prometheus-adapter --namespace namespace-name</code></p>

<p>With helm 3 since there is no <code>--namespace</code> flag you need to delete the existing deployment and then redeploy it to a different namespace as below example to deploy metrics server.</p>

<pre><code>$ 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
</code></pre>
