<p>I am trying to install the same chart two times in the same cluster in two different namespaces. However I am getting this error:</p>
<pre><code>Error: rendered manifests contain a resource that already exists. Unable to continue with install: ClusterRole &quot;nfs-provisioner&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;namespace2&quot;: current value is &quot;namespace1&quot;
</code></pre>
<p>As I understood cluster roles suposed to be independet from the namespace, so I found this contradictory. We are using helm3</p>

KilyenOrs
<p>I decided to provide a Community Wiki answer that may help other people facing a similar issue.<br />
I assume you want to install the same chart multiple times but get the following error:</p>
<pre><code>Error: rendered manifests contain a resource that already exists. Unable to continue with install: ClusterRole &quot;&lt;CLUSTERROLE_NAME&gt;&quot; in namespace &quot;&quot; exists and cannot be imported into the current release: ...
</code></pre>
<p><br>First, it's important to decide if we really need <code>ClusterRole</code> instead of <code>Role</code>.
As we can find in the <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-and-clusterrole" rel="noreferrer">Role and ClusterRole documentation</a>:</p>
<blockquote>
<p>If you want to define a role within a namespace, use a Role; if you want to define a role cluster-wide, use a ClusterRole.</p>
</blockquote>
<p>Second, we can use the variable name for <code>ClusterRole</code> instead of hard-coding the name in the template:</p>
<p>For example, instead of:</p>
<pre><code>apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: clusterrole-1
...
</code></pre>
<p>Try to use something like:</p>
<pre><code>apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ .Values.clusterrole.name }}
...
</code></pre>
<p>Third, we can use the <code>lookup</code> function and the <code>if</code> control structure to skip creating resources if they already exist.</p>
<p>Take a look at a simple example:</p>
<pre><code>$ cat clusterrole-demo/values.yaml
clusterrole:
  name: clusterrole-1

$ cat clusterrole-demo/templates/clusterrole.yaml
{{- if not (lookup &quot;rbac.authorization.k8s.io/v1&quot; &quot;ClusterRole&quot; &quot;&quot; .Values.clusterrole.name) }}

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ .Values.clusterrole.name }}
rules:
- apiGroups:
  - &quot;&quot;
  resources:
  - pods
  verbs:
  - get
  - list
  - watch
{{- end }}
</code></pre>
<p>In the example above, if <code>ClusterRole</code> <code>clusterrole-1</code> already exits, it won’t be created.</p>
