<p>I have project written in Django Restframework, Celery for executing long running task, Redis as a broker and Flower for monitoring Celery task. I have written a <code>Dockerfile</code> &amp; <code>docker-compose.yaml</code> to create a network and run this services inside containers.</p>
<p><em><strong>Dockerfile</strong></em></p>
<pre><code>FROM python:3.7-slim

ENV PYTHONUNBUFFERED 1

RUN apt-get update &amp;&amp;\
    apt-get install python3-dev default-libmysqlclient-dev gcc  -y &amp;&amp;\
    apt-get install -y libssl-dev libffi-dev &amp;&amp;\
    python -m pip install --upgrade pip &amp;&amp;\
    mkdir /ibdax

WORKDIR /ibdax

COPY ./requirements.txt /requirements.txt

COPY . /ibdax

EXPOSE 80

EXPOSE 5555

ENV ENVIRONMENT=LOCAL

#install dependencies
RUN pip install -r /requirements.txt

RUN pip install django-phonenumber-field[phonenumbers]
RUN pip install drf-yasg[validation]
</code></pre>
<p><em><strong>docker-compose.yaml</strong></em></p>
<pre><code>version: &quot;3&quot;

services:
  redis:
    container_name: redis-service
    image: &quot;redis:latest&quot;
    ports:
      - &quot;6379:6379&quot;
    restart: always
    command: &quot;redis-server&quot;

  ibdax-backend:
    container_name: ibdax
    build:
      context: .
      dockerfile: Dockerfile
    image: &quot;ibdax-django-service&quot;
    volumes:
      - .:/ibdax
    ports:
      - &quot;80:80&quot;
    expose:
      - &quot;80&quot;
    restart: always
    env_file:
      - .env.staging
    command: &gt;
      sh -c &quot;daphne -b 0.0.0.0 -p 80 ibdax.asgi:application&quot;
    links:
      - redis

  celery:
    container_name: celery-container
    image: &quot;ibdax-django-service&quot;
    command: &quot;watchmedo auto-restart -d . -p '*.py' -- celery  -A ibdax worker -l INFO&quot;
    volumes:
      - .:/ibdax
    restart: always
    env_file:
      - .env.staging
    links:
      - redis
    depends_on:
      - ibdax-backend

  flower:
    container_name: flower
    image: &quot;ibdax-django-service&quot;
    command: &quot;flower -A ibdax --port=5555 --basic_auth=${FLOWER_USERNAME}:${FLOWER_PASSWORD}&quot;
    volumes:
      - .:/ibdax
    ports:
      - &quot;5555:5555&quot;
    expose:
      - &quot;5555&quot;
    restart: always
    env_file:
      - .env
      - .env.staging
    links:
      - redis
    depends_on:
      - ibdax-backend
</code></pre>
<p>This <code>Dockerfile</code> &amp; <code>docker-compose</code> is working just fine and now I want to deploy this application to GKE. I came across <em><strong>Kompose</strong></em> which translate the <code>docker-compose</code> to <em><strong>kubernetes</strong></em> resources. I read the documentation and started following the steps and the first step was to run <code>kompose convert</code>. This returned few warnings and created few files as show below -</p>
<pre><code>WARN Service &quot;celery&quot; won't be created because 'ports' is not specified 
WARN Volume mount on the host &quot;/Users/jeetpatel/Desktop/projects/ibdax&quot; isn't supported - ignoring path on the host 
WARN Volume mount on the host &quot;/Users/jeetpatel/Desktop/projects/ibdax&quot; isn't supported - ignoring path on the host 
WARN Volume mount on the host &quot;/Users/jeetpatel/Desktop/projects/ibdax&quot; isn't supported - ignoring path on the host 
INFO Kubernetes file &quot;flower-service.yaml&quot; created 
INFO Kubernetes file &quot;ibdax-backend-service.yaml&quot; created 
INFO Kubernetes file &quot;redis-service.yaml&quot; created 
INFO Kubernetes file &quot;celery-deployment.yaml&quot; created 
INFO Kubernetes file &quot;env-dev-configmap.yaml&quot; created 
INFO Kubernetes file &quot;celery-claim0-persistentvolumeclaim.yaml&quot; created 
INFO Kubernetes file &quot;flower-deployment.yaml&quot; created 
INFO Kubernetes file &quot;flower-claim0-persistentvolumeclaim.yaml&quot; created 
INFO Kubernetes file &quot;ibdax-backend-deployment.yaml&quot; created 
INFO Kubernetes file &quot;ibdax-backend-claim0-persistentvolumeclaim.yaml&quot; created 
INFO Kubernetes file &quot;redis-deployment.yaml&quot; created 
</code></pre>
<p>I ignored the warnings and moved to the next step i.e running command</p>
<pre><code>kubectl apply -f flower-service.yaml, ibdax-backend-service.yaml, redis-service.yaml, celery-deployment.yaml
</code></pre>
<p>but I get this error -</p>
<pre><code>error: Unexpected args: [ibdax-backend-service.yaml, redis-service.yaml, celery-deployment.yaml]
</code></pre>
<p>Hence I planned to apply one by one like this -</p>
<pre><code>kubectl apply -f flower-service.yaml
</code></pre>
<p>but I get this error -</p>
<pre><code>The Service &quot;flower&quot; is invalid: spec.ports[1]: Duplicate value: core.ServicePort{Name:&quot;&quot;, Protocol:&quot;TCP&quot;, AppProtocol:(*string)(nil), Port:5555, TargetPort:intstr.IntOrString{Type:0, IntVal:0, StrVal:&quot;&quot;}, NodePort:0}
</code></pre>
<p>Not sure where am I going wrong.</p>
<p>Also the prerequisites of <em><strong>Kompose</strong></em> is to have a <em><strong>Kubernetes</strong></em> cluster so I created an Autopilot cluster with public network. Now I am not sure how this apply command will identify the cluster I created and deploy my application on it.</p>

<p>After <code>kompose convert</code> your <em>flower-service.yaml</em> file have duplicate ports - that's what the error is saying.</p>
<pre class="lang-yaml prettyprint-override"><code>...
  ports:
    - name: &quot;5555&quot;
      port: 5555
      targetPort: 5555
    - name: 5555-tcp
      port: 5555
      targetPort: 5555
...
</code></pre>
<p>You can either delete port <code>name: &quot;5555&quot;</code> or <code>name: 5555-tcp</code>.<br />
For example, replace ports block with</p>
<pre class="lang-yaml prettyprint-override"><code>  ports:
    - name: 5555-tcp
      port: 5555
      targetPort: 5555
</code></pre>
<p>and deploy the service again.<br />
I would also recommend changing port name to something more descriptive.</p>
<hr />
<p>Same thing happens with <em>ibdax-backend-service.yaml</em> file.</p>
<pre class="lang-yaml prettyprint-override"><code>...
  ports:
    - name: &quot;80&quot;
      port: 80
      targetPort: 80
    - name: 80-tcp
      port: 80
      targetPort: 80
...
</code></pre>
<p>You can delete one of the definitions, and redeploy the service (changing port name to something more descriptive is also recommended).</p>
<hr />
<p><code>kompose</code> is not a perfect tool, that will always give you a perfect result. You should check the generated files for any possible conflicts and/or missing fields.</p>
