Rewriting nginx.conf when converting docker-compose to Kubernetes using Kompose?

8/2/2020

I am quite new to Kubernetes and I have been struggling to migrate my current docker-compose environment to Kubernetes...

I converted my docker-compose.yml to Kubernetes manifests using kompose.

So far, I can access each pod individually but it seems like I have some issues to get those pods to communicate each other.. My Nginx pod can not access my app pod

My docker-compose.yml is something like below

version: '3.3'
services:

  myapp:
    image: my-app
    build: ./docker/
    restart: unless-stopped
    container_name: app
    stdin_open: true
    volumes:
      - mnt:/mnt
    env_file:
      - .env


  mynginx:
    image: nginx:latest
    build: ./docker/
    container_name: nginx
    ports:
      - 80:80
    stdin_open: true
    restart: unless-stopped
    user: root

My Nginx.conf is something like below

server{
    listen 80;
    index index.html index.htm;
    root   /mnt/volumes/statics/;


location /myapp {

  proxy_pass http://myapp/index;

  proxy_redirect     off;
  proxy_set_header   Host $host;
  proxy_set_header   X-Real-IP $remote_addr;
}

I understand that docker-compose enables containers to communicate each other through service names (myapp and mynginx in this case). Could somebody tell me what I need to do to achieve the same thing in Kubernetes?

-- rks
docker
docker-compose
kompose
kubernetes
nginx

1 Answer

8/6/2020

Kompose did create services for me. It turned out that what I missed was docker-compose.overwrite file (apparently kompose just ignores overwrite.yml).

-- rks
Source: StackOverflow