首页 > 解决方案 > kompose 和 kubernetes 的问题

问题描述

我正在尝试使用 Kompose (kompose.io) 将我的 docker-compose.yaml 部署到 kubernetes。我尝试使用 docker-compose up -d nginx mariadb 在本地运行它,一切正常。我的项目使用 Laradock 作为开发基础(laradock.io)。当我尝试使用管道(来自 BitBucket)部署它时,一切正常,它部署,只有一个问题:当我转到主机时,我仍然看到:欢迎使用 nginx。我正在使用 docker-compose。

我的 docker-compose.yaml 看起来像这样:

version: '3'

networks:
  frontend:
    driver: bridge
  backend:
    driver: bridge

volumes:
  mariadb:
    driver: local

services:

### PHP-FPM ##############################################
    php-fpm:
      build:
        context: ./php-fpm
        args:
          - LARADOCK_PHP_VERSION=7.2
          - INSTALL_XDEBUG=true
          - INSTALL_PHPDBG=true
          - INSTALL_SOAP=true
          - INSTALL_XSL=true
          - INSTALL_OPCACHE=true
          - INSTALL_MYSQLI=true
          - INSTALL_CALENDAR=true
          - INSTALL_YAML=true
          - INSTALL_ADDITIONAL_LOCALES=true
          - INSTALL_MYSQL_CLIENT=true
          - ADDITIONAL_LOCALES=nl_NL.UTF-8
      volumes:
        - ./php-fpm/php7.2.ini:/usr/local/etc/php/php.ini
        - ../:/var/www:cached
      expose:
        - "9000"
      networks:
        - backend

### NGINX Server #########################################
    nginx:


     build:
        context: ./nginx
        args:
          - PHP_UPSTREAM_CONTAINER=php-fpm
          - PHP_UPSTREAM_PORT=9000
      volumes:
        - ../:/var/www:cached
        - ./nginx/sites/:/etc/nginx/sites-available
        - ./logs/nginx/:/var/log/nginx
        - ./nginx/ssl/:/etc/nginx/ssl
      ports:
        - "80:80"
        - "443:443"
      depends_on:
        - php-fpm
      networks:
        - frontend
        - backend
      labels:
        - "kompose.service.type=LoadBalancer"
        - "kompose.service.expose=organize.eduskoel.net"

### MariaDB ##############################################
    mariadb:
      build: ./mariadb
      volumes:
        - ~/.laradock/data/mariadb:/var/lib/mysql
        - ./mariadb/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
      ports:
        - "3306:3306"
      environment:
        - MYSQL_DATABASE=
        - MYSQL_USER=
        - MYSQL_PASSWORD=
        - MYSQL_ROOT_PASSWORD=
      networks:
        - backend

### Certbot #########################################
    certbot:
      build:
        context: ./certbot
      volumes:
        - ./data/certbot/certs/:/var/certs
        - ./certbot/letsencrypt/:/var/www/letsencrypt
      environment:
        - CN="organize.eduskoel.net"
        - EMAIL=""
      networks:
        - frontend

### HAProxy ####################################
    haproxy:
      build: ./haproxy
      ports:
        - "8085:8085"
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
      links:
        - proxy
        - proxy2

我的 nginx 配置(位于 /nginx/sites/default.conf 中)如下所示:

server {

    listen 80;
    listen [::]:80;

    # For https
    # listen 443 ssl;
    # listen [::]:443 ssl ipv6only=on;
    # ssl_certificate /etc/nginx/ssl/default.crt;
    # ssl_certificate_key /etc/nginx/ssl/default.key;

    server_name organize.eduskoel.net;
    root /var/www/public;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }

    error_log /var/log/nginx/laravel_error.log;
    access_log /var/log/nginx/laravel_access.log;
}

如果你去,organize.eduskoel.net:你会看到:Welcome to nginx。

所以,我的想法;将 FQDN (organize.eduskoel.net) 与定位的文件映射不成功;它无法找到根文件(v-host 文件)。请注意,laravel 的公用文件夹是应用程序的文档根目录。

有人有线索吗?

标签: dockernginxkubernetesdocker-composecontinuous-deployment

解决方案


推荐阅读