<p>Recently I started to study Kubernetes and right now I can deploy nginx with default options.
But how I can deploy my nginx.conf in Kubernetes ?
Maybe somebody have a simple example ?</p>

noute
<p>Create yaml for nginx deployment:</p>
<pre class="lang-bash prettyprint-override"><code>kubectl run --image=nginx nginx -o yaml --dry-run
</code></pre>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      run: nginx
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        resources: {}
status: {}
</code></pre>
<p>Create config <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">ConfigMap</a> with nginx configuration</p>
<pre class="lang-bash prettyprint-override"><code>kubectl create configmap nginx-conf --from-file=./nginx.conf
</code></pre>
<p>Mount file:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      run: nginx
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        resources: {}
        volumeMounts:
        - mountPath: /etc/nginx/nginx.conf
          name: nginx-conf
          subPath: nginx.conf
      volumes:
      - configMap:
          name: nginx-conf
        name: nginx-conf
</code></pre>
