繁体   English   中英

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

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

我对Kube.netes很陌生,我一直在努力将我当前的docker-compose环境迁移到 Kube.netes ...

我使用kompose将我的docker-compose.yml转换为 Kube.netes 清单。

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

我的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

我的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;
}

我知道docker-compose使容器能够通过服务名称(在本例中为myappmynginx )相互通信。 有人能告诉我我需要做什么才能在 Kube.netes 中实现同样的目标吗?

Kompose 确实为我创建了服务。 原来我错过的是 docker-compose.overwrite 文件(显然 kompose 只是忽略了 overwrite.yml)。

暂无
暂无

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

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