Problems with kompose and kubernetes

5/10/2019

I am trying to deploy my docker-compose.yaml to kubernetes by using Kompose (kompose.io). I have tried to run it locally by using docker-compose up -d nginx mariadb and everything works perfectly fine. My project uses Laradock as development baes (laradock.io). When I try to deploy it by using pipelines (from BitBucket) then everything works fine, it deploys, there is only one problem: when I go to the host I still see: welcome to nginx. I am using docker-compose.

My docker-compose.yaml looks like this:

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

My nginx configuration (located in the /nginx/sites/default.conf) looks like this:

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

If you go to, organize.eduskoel.net: you'll see: Welcome to nginx.

So, what I thought; mapping the FQDN (organize.eduskoel.net) with the located files does not succeed; it is not able to find the root files (v-host files). Note that laravel's public folder is the document root of the application.

Does someone have a clue?

-- Kevin van Leeuwen
continuous-deployment
docker
docker-compose
kubernetes
nginx

0 Answers