kompose: Error when targeting a different (than 8080) API port

I am useing k3s and by default the kubernetes API listens on port 6443. When trying to do kompose up in this situation I get Error while deploying application: Get http://localhost:8080/api: dial tcp [::1]:8080: connect: connection refused Is there a way to target a different (than 8080) port?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 23 (9 by maintainers)

Most upvoted comments

A simple solution is to start a proxy to the API that listens on 8080.

kubectl proxy --port=8080

If anyone lands here, this version of compose worked for me on mac:

curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v1.18.0/kompose-darwin-amd64 -o kompose
chmod +x kompose
sudo mv ./kompose /usr/local/bin/kompose

Any status here? We struggle with the same issue

Hello!

@cdrage I am not sure if this is the right place to ask this. I am incredibly new to both Kubernetes and Kompose

I have a docker-compose.yml file that does work locally without issue and I was under the impression I would be able to use kompose up on it to spin up my deployment on my minikube locally.

However when I run it I get this output

╭─lknecht@愛と支えボックス ~/Repositories/api_webserver/api_webserver ‹feature/create_minikube_deployment-dev*›
╰─$ kompose up --file continuous_integration/local_api_docker_compose.yml                                                                                                                                                               1 ↵
INFO Build key detected. Attempting to build and push image 'lab/api'
INFO Building image 'lab/api' from directory 'api_webserver'
INFO Image 'lab/api' from directory 'api_webserver' built successfully
INFO Pushing image 'lab/api:latest' to registry 'docker.io'
INFO Attempting authentication credentials 'https://index.docker.io/v1/
INFO Successfully pushed image 'lab/api:latest' to registry 'docker.io'
INFO Build key detected. Attempting to build and push image 'lab/api'
INFO Building image 'lab/api' from directory 'api_webserver'
INFO Image 'lab/api' from directory 'api_webserver' built successfully
INFO Pushing image 'lab/api:latest' to registry 'docker.io'
INFO Attempting authentication credentials 'https://index.docker.io/v1/
INFO Successfully pushed image 'lab/api:latest' to registry 'docker.io'
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.

FATA Error while deploying application: Get http://localhost:8080/api: dial tcp [::1]:8080: connect: connection refused

This is my docker-compose.yml file’s contents

version: "3.7"

services:
    api:
        build:
            context: ../.
            dockerfile: ./continuous_integration/api_webserver.dockerfile
        image: lab/api
        command: ["sh", "-c", "python manage.py makemigrations api &&
                               python manage.py migrate &&
                               gunicorn --bind 0.0.0.0:$$CI_API_PORT api_webserver.wsgi"]
        depends_on:
            - rabbitmq
            - redis
            - postgres
        env_file:
            - ./local_api_docker_compose.env
        networks:
            - backend
        ports:
            - "8000:8000"
        volumes:
            - "api_media:/opt/api_webserver/media"
    worker:
        build:
            context: ../.
            dockerfile: ./continuous_integration/api_webserver.dockerfile
        image: lab/api
        command: ["sh", "-c", "celery worker --app=api_webserver --loglevel=INFO"]
        depends_on:
            - api
            - rabbitmq
            - redis
            - postgres
        env_file:
            - ./local_api_docker_compose.env
        networks:
            - backend
        volumes:
            - "api_media:/opt/api_webserver/media"
    postgres:
        image: postgres:12-alpine
        env_file:
            - ./local_api_docker_compose.env
        networks:
            - backend
        ports:
            - "5432:5432"
    rabbitmq:
        image: "rabbitmq:3.7-alpine"
        hostname: "rabbitmq"
        depends_on:
            - redis
        env_file:
            - ./local_api_docker_compose.env
        networks:
            - backend
        ports:
            - "5672:5672"   # Broker port
            - "15672:15672" # Management port
    redis:
        image: "redis:5.0-alpine"
        hostname: "redis"
        networks:
            - backend
        ports:
            - "6379:6379"

networks:
    backend:

volumes:
    api_media:

I have tried the work around of running kubectl proxy --port=8080 in a separate terminal window for proxying, but then the output changes to this

╭─lknecht@愛と支えボックス ~/Repositories/api_webserver/api_webserver ‹feature/create_minikube_deployment-dev*›
╰─$ kompose --file continuous_integration/local_api_docker_compose.yml up
INFO Build key detected. Attempting to build and push image 'lab/api'
INFO Building image 'lab/api' from directory 'api_webserver'
INFO Image 'lab/api' from directory 'api_webserver' built successfully
INFO Pushing image 'lab/api:latest' to registry 'docker.io'
INFO Attempting authentication credentials 'https://index.docker.io/v1/
INFO Successfully pushed image 'lab/api:latest' to registry 'docker.io'
INFO Build key detected. Attempting to build and push image 'lab/api'
INFO Building image 'lab/api' from directory 'api_webserver'
INFO Image 'lab/api' from directory 'api_webserver' built successfully
INFO Pushing image 'lab/api:latest' to registry 'docker.io'
INFO Attempting authentication credentials 'https://index.docker.io/v1/
INFO Successfully pushed image 'lab/api:latest' to registry 'docker.io'
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.

INFO Deploying application in "default" namespace
INFO Successfully created Service: api
INFO Successfully created Service: postgres
INFO Successfully created Service: rabbitmq
INFO Successfully created Service: redis
FATA Error while deploying application: the server could not find the requested resource

Apologies if I’m creating a bunch of unrelated noise, I’m just not sure if I’m doing something wrong, or the tool is working incorrectly.

Any guidance is appreciated.

Yeah, this is critical and needs to be fixed. Thank you @greyarch

A lot of clusters use 6443 by default now… you’re totally correct.

Tempory solution:

export KUBERNETES_MASTER=https://127.0.0.1:6443
kompose....

Finale solution: update code (the library we use is serious out of date, it’s a bit of messy)