简体   繁体   中英

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

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

I converted my docker-compose.yml to Kube.netes 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 Kube.netes?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM