<p>How can I pass the <code>nginx.conf</code> configuration file to an nginx instance running inside a Kubernetes cluster?</p>

<p>You can create a ConfigMap object and then mount the values as files where you need them:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
data:
  nginx.conf: |
    your config
    comes here
    like this
  other.conf: |
    second file
    contents
</code></pre>
<p>And in you pod spec:</p>
<pre><code>spec:
  containers:
    - name: nginx
      image: nginx
      volumeMounts:
        - name: nginx-config
          mountPath: /etc/nginx/nginx.conf
          subPath: nginx.conf
        - name: other.conf
          mountPath: /etc/nginx/other.conf
          subPath: other.conf
  volumes:
    - name: nginx-config
      configMap:
        name: nginx-config
</code></pre>
<p>(Take note of the duplication of the filename in mountPath and using the exact same subPath; same as bind mounting files.)</p>
<p>For more information about ConfigMap see:
<a href="https://kubernetes.io/docs/user-guide/configmap/" rel="noreferrer">https://kubernetes.io/docs/user-guide/configmap/</a></p>
<blockquote>
<p>Note: A container using a ConfigMap as a subPath volume will not receive ConfigMap updates.</p>
</blockquote>
