I need information about docker-compose.yml - how to configure/export to kubernetes ingress

1/7/2019

I'm building an application written in PHP/Symfony4. I have prepared an API service and some services written in NodeJS/Express. I'm configuring server structure with Google Cloud Platform. The best idea, for now, is to have multizone multi-clusters configuration with the load balancer.

I was using this link https://github.com/GoogleCloudPlatform/k8s-multicluster-ingress/tree/master/examples/zone-printer as a source for my configuration. But now I don't know how to upload/build docker-compose.yml do GCR which can be used in Google Kubernetes.

version: '3'
services:
php:
    image: gcr.io/XXX/php
    build: build/php
    expose:
        - '9000'
    volumes:
        - ./symfony:/var/www/html/symfony:cached
        - ./logs:/var/log
 web:
    image: gcr.io/XXX/nginx
    build: build/nginx
    restart: always
    ports:
        - "81:80"
    depends_on:
        - php
    volumes:
        - ./symfony:/var/www/html/symfony:cached
        - ./logs:/var/log/nginx

I need to have a single container GCR.io/XXX/XXX/XXX for kubernetes-ingress configuration. Should I use docker-compose.yml or find something else? Which solution will be best?

-- tomasz n. 'entom'
docker
docker-compose
dockerfile
google-cloud-platform
kubernetes

1 Answer

1/7/2019

docker-compose and Kubernetes declarations are not compatible with each other. If you want to use Kubernetes you can use a Pod with 2 containers (according to your example). If you want to take it a step further, you can use a Kubernetes Deployment that can manage your pod replicas, in case you are using multiple replicas.

Something like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
  labels:
    app: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: php
        image: gcr.io/XXX/php
        ports:
        - containerPort: 9000
        volumeMounts:
        - mountPath: /var/www/html/symfony
          name: symphony
        - mountPath: /var/log
          name: logs
      - name: web
        image: gcr.io/XXX/nginx
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: /var/www/html/symfony
          name: symphony
        - mountPath: /var/log
          name: logs
      volumes:
      - name: symphony
        hostPath:
          path: /home/symphony
      - name: logs
        hostPath:
          path: /home/logs

Even further, you can remove your web container and use nginx ingress controller. More about Kubernetes Ingresses here

-- Rico
Source: StackOverflow