<p>I have a problem with helm chart that I would like to use to deploy multiple instances of my app in many namespaces. Let's say it would be ns1, ns2 and ns3.</p>
<p>I run helm upgrade with --install option and it goes well for ns1 but when I want to run it second time for ns2 I get an error:</p>
<pre><code>Error: rendered manifests contain a resource that already exists. Unable to continue with install: PodSecurityPolicy &quot;my-psp&quot; in namespace &quot;&quot; exists and cannot be imported into the current release: invalid ownership metadata; annotation validation error: key &quot;meta.helm.sh/release-namespace&quot; must equal &quot;ns2&quot;: current value is &quot;ns1&quot;
</code></pre>
<p>I found many topics about this problem but everytime the only answer is to delete the old object and install it again with helm. I don't want to do that - I would like to get two or more instances of my app that uses k8s objects that are common for many namespaces.</p>
<p>What can I do in this situation? I know I could change names of those objects with every deployment but that would be really messy. Second idea is to move those object to another chart and deploy it just once but sadly there's like a ton of work to do that so I would like to avoid it. Is it possible to ignore this error somehow and still make this work?</p>

<p>Found out the solution. The easiest way is to add lookup block into your templates:</p>
<pre><code>{{- if not (lookup &quot;policy/v1beta1&quot; &quot;PodSecurityPolicy&quot; &quot;&quot; &quot;my-psp&quot;) }}
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
  name: my-psp
...
{{- end }}
</code></pre>
<p>With this config the object will be created only if case that the object with the same name does not exist.</p>
<p>It may not be perfect solution but if you know what you do you can save a lot of time.</p>
