简体   繁体   English

使用 Kompose 将 docker-compose 转换为 Kube.netes 时重写 nginx.conf?

[英]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...我对Kube.netes很陌生,我一直在努力将我当前的docker-compose环境迁移到 Kube.netes ...

I converted my docker-compose.yml to Kube.netes manifests using kompose .我使用kompose将我的docker-compose.yml转换为 Kube.netes 清单。

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到目前为止,我可以单独访问每个 pod,但似乎我在让这些 pod 相互通信时遇到了一些问题。我的 Nginx pod 无法访问我的应用程序 pod

My docker-compose.yml is something like below我的docker-compose.yml如下所示

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我的Nginx.conf如下所示

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).我知道docker-compose使容器能够通过服务名称(在本例中为myappmynginx )相互通信。 Could somebody tell me what I need to do to achieve the same thing in Kube.netes?有人能告诉我我需要做什么才能在 Kube.netes 中实现同样的目标吗?

Kompose did create services for me. Kompose 确实为我创建了服务。 It turned out that what I missed was docker-compose.overwrite file (apparently kompose just ignores overwrite.yml).原来我错过的是 docker-compose.overwrite 文件(显然 kompose 只是忽略了 overwrite.yml)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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