<p>I have upload.yaml file which is uploads a script to mongo, I package with helm.</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  generateName: upload-strategy-to-mongo-v2
spec:
  parallelism: 1
  completions: 1
  template:
    metadata:
      name: upload-strategy-to-mongo
    spec:
      volumes:
      - name: upload-strategy-to-mongo-scripts-volume
        configMap:
          name: upload-strategy-to-mongo-scripts-v3
      containers:
      - name: upload-strategy-to-mongo
        image: mongo
        env:
        - name: MONGODB_URI
          value: @@@@
        - name: MONGODB_USERNAME
          valueFrom:
            secretKeyRef:
              name: mongodb-user
              key: @@@@
        - name: MONGODB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mongodb-user
              key: @@@@@
        volumeMounts:
          - mountPath: /scripts
            name: upload-strategy-to-mongo-scripts-volume
        command: [&quot;mongo&quot;]
        args:
          - $(MONGODB_URI)/ravnml
          - --username
          - $(MONGODB_USERNAME)
          - --password
          - $(MONGODB_PASSWORD)
          - --authenticationDatabase
          - admin
          - /scripts/upload.js
      restartPolicy: Never
---
apiVersion: v1
kind: ConfigMap
metadata:
  creationTimestamp: null
  name:  upload-strategy-to-mongo-scripts-v3
data:
  upload.js: |
    // Read the object from file and parse it
    var data = cat('/scripts/strategy.json');
    var obj = JSON.parse(data);

    // Upsert strategy
    print(db.strategy.find());
    db.strategy.replaceOne(
        { name : obj.name },
          obj,
        { upsert: true }
    )
    print(db.strategy.find());
  strategy.json: {{ .Files.Get &quot;strategy.json&quot; | quote }}
</code></pre>
<p>now I am using generateName to generate a custom name every time I install it. I require to have multiple packages been installed and I require the name to be dynamic.</p>
<p>Error
When I install this script with <code>helm install &lt;name&gt; &lt;tar.gz file&gt; -n &lt;namespace&gt;</code> I get the following error</p>
<pre><code>Error: rendered manifests contain a resource that already exists. Unable to continue with install: could not get information about the resource: resource name may not be empty
</code></pre>
<p>but I am able to install if I don't use generateName. Any ideas?</p>
<p>I looked at various resources but they don't seem to answer how to install via helm.
references looked:
<a href="https://stackoverflow.com/questions/48023475/add-random-string-on-kubernetes-pod-deployment-name;">Add random string on Kubernetes pod deployment name</a> <a href="https://github.com/kubernetes/kubernetes/issues/44501" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/44501</a> ;
<a href="https://zknill.io/posts/kubernetes-generated-names/" rel="nofollow noreferrer">https://zknill.io/posts/kubernetes-generated-names/</a></p>

<p>This seems to be a known issue. Helm doesn't work with <code>generateName</code>. For unique names, you can use the <a href="https://helm.sh/docs/chart_template_guide/builtin_objects/" rel="nofollow noreferrer">Helm's build in properties</a> like <code>Revision</code> or <code>Name</code>. See the following link for reference:</p>
<ul>
<li><a href="https://github.com/helm/helm/issues/3348#issuecomment-482369133" rel="nofollow noreferrer">https://github.com/helm/helm/issues/3348#issuecomment-482369133</a></li>
</ul>
