<ul>
<li>I have a deployment and related K8s resources implemented in a K8s environment under the namespace &quot;A&quot;</li>
<li>These resources are deployed via an Azure-DevOps release pipeline</li>
<li>Now I have a requirement to deploy the same set of resources under the namespace &quot;B&quot;</li>
<li>When I tried by editing the deployment.yaml code and pipeline parameter it's failing and giving the below error</li>
</ul>
<hr />
<pre><code>Error from server (Forbidden): error when retrieving current configuration of:
Resource: &quot;/v1, Resource=configmaps&quot;, GroupVersionKind: &quot;/v1, Kind=ConfigMap&quot;
Name: &quot;XXXX-XXXX-XXX&quot;, Namespace: &quot;B&quot;
</code></pre>
<hr />
<h2><strong>My deployment.yaml file</strong></h2>
<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: XXXX
  namespace: B
data:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: XXXX
  namespace: B
spec:

apiVersion: v1
kind: Service
metadata:
  name: XXXX
  namespace: B
spec:
</code></pre>
<hr />
<p>Azure-DevOps pipeline configs
<a href="https://i.stack.imgur.com/QxzB3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QxzB3.png" alt="enter image description here" /></a></p>

JeewanaSL
<h2><strong>PROBLEM SOLVED</strong></h2>
<p>There were two things to fix in my implementation</p>
<ol>
<li>[OPTIONAL-not a must to perform]Remove the namespace definition in deployment.yaml</li>
</ol>
<hr />
<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: XXXX
  namespace: B
data:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: XXXX
  namespace: B
spec:

apiVersion: v1
kind: Service
metadata:
  name: XXXX
  namespace: B
spec:
</code></pre>
<hr />
<ol start="2">
<li>Create a new service connection and load it in the CD pipeline
<a href="https://i.stack.imgur.com/qad42.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qad42.png" alt="enter image description here" /></a></li>
<li>Be careful to mention the exact namespace and then the new service connection will be dedicated to the mentioned namespace</li>
</ol>
<p><a href="https://i.stack.imgur.com/UBcQd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UBcQd.png" alt="enter image description here" /></a></p>
<ol start="4">
<li>Deployment was successful</li>
</ol>
<p><a href="https://i.stack.imgur.com/7aqSc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7aqSc.png" alt="enter image description here" /></a></p>
