<p>I am trying to use nginx reverse-proxy and use simple default.conf. Here is my docker-compose file:</p>

<pre><code>version: '3'
services:
  authorizationmicroservice:
    image: gcr.io/root-booking-245613/authorizationmicroservice:v1
    container_name: authorizationmicroservice
    restart: always
    labels:
      - "kompose.service.type=LoadBalancer"
    ports:
      - "3002:${PORT:-3002}"
    networks:
      - backend
  musicmicroservice:
    image: gcr.io/root-booking-245613/musicmicroservice:v1
    container_name: musicmicroservice
    restart: always
    ports:
      - "3001:${PORT:-3001}"
    networks:
      - backend
    labels:
      - "kompose.service.type=LoadBalancer"
  nginx:
    image: nginx:latest
    networks:
      - backend
    ports:
      - "8080:${PORT:-8080}"
    volumes:
      - ./nginxProxy:/etc/nginx/conf.d
    depends_on:
      - authorizationmicroservice
      - musicmicroservice
    labels:
      - "kompose.service.type=LoadBalancer"
networks:
    backend:
</code></pre>

<p>Everything works fine if I do docker-compose up, but when I try to deploy it with kubernetes, I' ve got the following error log in nginx pod:</p>

<pre><code>Warning  Failed     
34m
                   kubelet, gke-hello-cluster-default-pool-8c57f061-7hd8 

Error: failed to start container "nginx": Error response from daemon:
 OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/home/artemda4/kubernetes-engine-samples/muniverse/home/artemda4/kubernetes-engine-samples/muniverse/nginxProxy/default.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/751acda10027acdcca21d16df3be48197170c04dd3520cd7fa8aeb083b5b6bc1/merged\\\" at \\\"/var/lib/docker/overlay2/751acda10027acdcca21d16df3be48197170c04dd3520cd7fa8aeb083b5b6bc1/merged/etc/nginx/conf.d/default.conf\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
</code></pre>

<p>How should i mount volumes in Kubernetes? 
This is my nginx config,it is placed in nginxProxy</p>

<pre><code>server {
  listen 8080;
  client_max_body_size 50m;
  fastcgi_send_timeout 600;
  fastcgi_read_timeout 600;
  proxy_connect_timeout 600;
  proxy_send_timeout 600;
  proxy_read_timeout 600;
  send_timeout 600;
  root /srv/www/static;
  location /api/authorization {
    proxy_pass http://authorizationmicroservice:3002;
  }
  location /api/music {
    proxy_pass http://musicmicroservice:3001;
  }
  location /api/playlist {
    proxy_pass http://musicmicroservice:3001;
  }
  #this where socket io will be handling the request
  location /socket.io {
    proxy_pass http://musicmicroservice:3001/socket.io/;
  }
}
</code></pre>

Артем Дачевский
<p>In Kubernetes, typically you store configuration data like this in a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">ConfigMap</a>.  It looks like <a href="https://github.com/kubernetes/kompose/issues/1060" rel="nofollow noreferrer">Kompose won't automatically create a ConfigMap for you</a> so you need to create it by hand.</p>

<p>I'd suggest <a href="http://kompose.io/user-guide/#kubernetes" rel="nofollow noreferrer">converting the Docker Compose YAML file to Kubernetes YAML files</a></p>

<pre><code>kompose convert
</code></pre>

<p>The easiest thing to do here is to create a ConfigMap from your existing config file.  (For longer-term use, I'd package it into a YAML file next to the other files Kompose created.)</p>

<pre><code>kubectl create configmap nginx --from-file=./nginxProxy/
</code></pre>

<p>In the generated <code>nginx-deployment.yaml</code> file you are looking for two things, one to make the ConfigMap available in the pod and one to mount the resulting storage into the container.</p>

<pre class="lang-yaml prettyprint-override"><code># Inside the deployment template
spec:
  volumes:
    - name: nginx-config
      configMap:
        name: nginx # matches `kubectl create` command
  containers:
    - name: nginx
      # other standard container settings
      volumeMounts:
        - name: nginx-config # matches `volumes:` above
          mountPath: /etc/nginx/conf.d
</code></pre>

<p>Then when you run <code>kubectl apply -f .</code> to install these objects into the cluster, it will read the configuration from the in-cluster ConfigMap, and not depend on any host-specific paths (which Kompose isn't generating anyways).</p>
