<p>Getting this error.</p>
<p><code>Error: failed to prepare subPath for volumeMount &quot;solr-collection-config&quot; of container &quot;upload-config-container&quot; </code></p>
<p>Using kubernetes <strong>1.10.11</strong></p>
<pre><code>      - name: upload-config-container
        image: solr:7.4.0-alpine
        imagePullPolicy: Always
        resources:
          requests:
            memory: &quot;128Mi&quot;
            cpu: &quot;100m&quot;
          limits:
            memory: &quot;256Mi&quot;
            cpu: &quot;200m&quot;
        volumeMounts:
        - name: solr-collection-config
          mountPath: /tell/carbon/conf
          subPath: conf
</code></pre>
<p><code>solr-collection-config</code> is a volume that represents a ConfigMap</p>
<pre><code>     volumes:
      - name: solr-collection-config
        configMap:
          name: solr-collection-resources
          items:
          - key: stopwords_en.txt
            path: &quot;conf/lang/stopwords_en.txt&quot;
          - key: _rest_managed.json
            path: &quot;conf/_rest_managed.json&quot;
          - key: currency.xml
            path: &quot;conf/currency.xml&quot;
          - key: protwords.txt
            path: &quot;conf/protwords.txt&quot;
          - key: schema.xml
            path: &quot;conf/schema.xml&quot;
          - key: solrconfig.xml
            path: &quot;conf/solrconfig.xml&quot;
          - key: stopwords.txt
            path: &quot;conf/stopwords.txt&quot;
          - key: synonyms.txt
            path: &quot;conf/synonyms.txt&quot;
      restartPolicy: Never
</code></pre>
<p>Help is kindly appreciated. Thank you</p>

smk
<p>What happens if you do not use <code>subPath</code>?</p>

<p>All keys from <strong>configMap</strong> will be mounted in directory <code>/tell/carbon/conf</code>. That means, every key will be a separate file under this directory.</p>

<p>Now, what this <code>subPath</code> does? From your example,</p>

<pre><code>volumeMounts:
  - name: solr-collection-config
    mountPath: /tell/carbon/conf
    subPath: conf
</code></pre>

<p>Means, key <code>conf</code> from <strong>configMap</strong> will be mounted as file <code>conf</code> under <code>/tell/carbon</code> directory.</p>

<p>But, you do not have this key. So getting this error.</p>

<blockquote>
  <p>Error: failed to prepare subPath for volumeMount "solr-collection-config" of container "upload-config-container"</p>
</blockquote>

<p>Now, you can do like this</p>

<pre><code>volumeMounts:
  - name: solr-collection-config
    mountPath: /tell/carbon/conf
    subPath: stopwords_en.txt
</code></pre>

<p>Which means, value of <code>stopwords_en.txt</code> from your <strong>configMap</strong> will be mounted as <code>conf</code> file under <code>/tell/carbon</code>.</p>

<p>Final words, this <code>subPath</code> is actually a path from volume, from where your data is coming. In your case, <code>subPath</code> should be one of the key from your <strong>configMap</strong></p>
