<p>I added this in my values.yaml expecting the serviceAccount to be created when I do the helm install but that did not work, am I missing something ?</p>
<ul>
<li>helm version v3.9.0</li>
<li>kubernetes version v1.24.0</li>
</ul>
<pre><code>serviceAccount:
  # Specifies whether a service account should be created
  create: true
  # Annotations to add to the service account
  annotations: {}
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  name: my-service-account
</code></pre>
<p>I even tried adding the following (based on <a href="https://helm.sh/docs/chart_best_practices/rbac/#helm" rel="nofollow noreferrer">https://helm.sh/docs/chart_best_practices/rbac/#helm</a>), with no luck:</p>
<pre><code>rbac:
  # Specifies whether RBAC resources should be created
  create: true
</code></pre>
<p>Thanks</p>

<p>Thanks for the help, I ended up putting this file in the templates directory so it gets processed as you mentioned, I used helm lookup to check if the ServiceAccount is there or not so the first helm install does the installation (<a href="https://helm.sh/docs/chart_template_guide/functions_and_pipelines/#using-the-lookup-function" rel="nofollow noreferrer">https://helm.sh/docs/chart_template_guide/functions_and_pipelines/#using-the-lookup-function</a>)</p>
<pre><code>{{- if not (lookup &quot;v1&quot; &quot;ServiceAccount&quot; &quot;my-namespace&quot; &quot;my-service-account&quot;) }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: my-service-account
  namespace: {{ .Values.namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: my-cluster-role
rules:
- apiGroups: [&quot;&quot;]
  resources: [&quot;pods&quot;]
  verbs: [&quot;get&quot;, &quot;list&quot;]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: my-cluster-role-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: my-cluster-role
subjects:
- kind: ServiceAccount
  name: my-service-account
  namespace: {{ .Values.namespace }}    
{{- end }}
</code></pre>
