kubernetes / kompose

Convert Compose to Kubernetes
http://kompose.io
Apache License 2.0
9.61k stars 760 forks source link

Error when targeting a different (than 8080) API port #1131

Closed greyarch closed 4 years ago

greyarch commented 5 years ago

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?

greyarch commented 5 years ago

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

kubectl proxy --port=8080
fejta-bot commented 5 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot commented 5 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

cdrage commented 5 years ago

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.

cdrage commented 5 years ago

/remove-lifecycle rotten

loganknecht commented 4 years ago

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.

hangyan commented 4 years ago

The 8080 port issue seems comes from a dependency of kompose, and it's hard to change that.

aaneto18 commented 4 years ago

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.

Hi Guys,

I have exactly the same problem. Does anyone know how to fix it?

Thanks

pgordon9 commented 4 years ago

This is a big deal. Kompose is essentially just yaml converter now. I'm getting this on all up's/down's actions.

FATA Error while deploying application: Get http://localhost:8080/api: dial tcp [::1]:8080: connect: connection refused
thomas-thaulow commented 4 years ago

Any status here? We struggle with the same issue

hangyan commented 4 years ago

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)

hangyan commented 4 years ago

@CiaraCode I just merge a PR for this issue, if you can try the master build..

thomas-thaulow commented 4 years ago

@hangyan your solution did not work for us... In OpenStack Rancher, I have tried installing a software named Waldur throgh Komposer. We have successfully:

When this is done with your solution, we get asked for username and password (not happened before) and then it shows connection refused.

Then we tried master build without doing the export KUBERNETES_MASTER=https://127.0.0.1:6443 and we still keep getting the same "...could not find requested resource" error.

We get "...could not find requested resource" error."

hangyan commented 4 years ago

what's in your lube config file?


From: CiaraCode notifications@github.com Sent: Wednesday, December 25, 2019 5:17:50 AM To: kubernetes/kompose kompose@noreply.github.com Cc: Hang Yan hang.yan@hotmail.com; Mention mention@noreply.github.com Subject: Re: [kubernetes/kompose] Error when targeting a different (than 8080) API port (#1131)

@hangyanhttps://github.com/hangyan your solution did not work for us... In OpenStack Rancher, I have tried installing a software named Waldur throgh Komposer. We have successfully:

When this is done with your solution, we get asked for username and password (not happened before) and then it shows connection refused.

Then we tried master build without doing the export KUBERNETES_MASTER=https://127.0.0.1:6443 and we still keep getting the same "...could not find requested resource" error.

We get "...could not find requested resource" error."

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/kubernetes/kompose/issues/1131?email_source=notifications&email_token=AA6BVR3QKYBVTWG2IYGMJXLQ2J375A5CNFSM4HOIBLA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHTT6PY#issuecomment-568803135, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA6BVRZFVMEG62LS7C6DILLQ2J375ANCNFSM4HOIBLAQ.

hangyan commented 4 years ago

kompse use you kubeconifg to access the cluster. Since it now is the 6443 port, it certainly need some auth. usually it is in the kubeconifg file


From: Hang Yan hang.yan@hotmail.com Sent: Wednesday, December 25, 2019 8:26:19 AM To: kubernetes/kompose reply@reply.github.com; kubernetes/kompose kompose@noreply.github.com Cc: Mention mention@noreply.github.com Subject: Re: [kubernetes/kompose] Error when targeting a different (than 8080) API port (#1131)

what's in your lube config file?


From: CiaraCode notifications@github.com Sent: Wednesday, December 25, 2019 5:17:50 AM To: kubernetes/kompose kompose@noreply.github.com Cc: Hang Yan hang.yan@hotmail.com; Mention mention@noreply.github.com Subject: Re: [kubernetes/kompose] Error when targeting a different (than 8080) API port (#1131)

@hangyanhttps://github.com/hangyan your solution did not work for us... In OpenStack Rancher, I have tried installing a software named Waldur throgh Komposer. We have successfully:

When this is done with your solution, we get asked for username and password (not happened before) and then it shows connection refused.

Then we tried master build without doing the export KUBERNETES_MASTER=https://127.0.0.1:6443 and we still keep getting the same "...could not find requested resource" error.

We get "...could not find requested resource" error."

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/kubernetes/kompose/issues/1131?email_source=notifications&email_token=AA6BVR3QKYBVTWG2IYGMJXLQ2J375A5CNFSM4HOIBLA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHTT6PY#issuecomment-568803135, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA6BVRZFVMEG62LS7C6DILLQ2J375ANCNFSM4HOIBLAQ.

acelinkio commented 4 years ago

@hangyan

Still getting this same error. I have tried with 1.20 and building from master, 1.20.0 (dd3f6a28)

kompose version
1.20.0 (dd3f6a28)
kompose up
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 https://127.0.0.1:6443/api: dial tcp 127.0.0.1:6443: connect: connection refused

I verified that my .kube/config is properly configred and am able to run kubectl deployments from it. I also attempted to use export KUBERNETES_MASTER=https://127.0.0.1:8443 without any success. kompose still points to 6443.

hangyan commented 4 years ago

I'm sorry for that. The current solution is not good enough, it use a very old client-go version and my fixed only add support for port 6443. I will figure out some to allow user customized pod

hangyan commented 4 years ago

@AcelinkIT Sorry for your inconvenient , would you mind to try the master build again?

jouellnyc commented 4 years ago

export KUBERNETES_MASTER=https://127.0.0.1:6443 works

getting prompted for un/pw... seems a separate problem...

jsmedmar commented 4 years ago

I'm getting this error:

FATA Error while deleting application: Get "https://127.0.0.1:6443/api": x509: certificate signed by unknown authority

When I visit https://127.0.0.1:6443/api, I see this:

{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {

  },
  "status": "Failure",
  "message": "forbidden: User \"system:anonymous\" cannot get path \"/api\"",
  "reason": "Forbidden",
  "details": {

  },
  "code": 403
}

Any clues how to address this situation?

jsmedmar commented 4 years ago

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
ghost commented 4 years ago

I also have similar issue on the latest kompose . My error is: FATA Error while deploying application: Get "https://127.0.0.1:6443/api": dial tcp 127.0.0.1:6443: connect: connection refused

@hangyan , I am still facing the issue. I even tried running minikube using minikube start --apiserver-port=6443 but still facing the issue. I checked you PR #1204 , is it merged and published yet ?

ernievd commented 4 years ago

Same issue here. I just installed kompose fresh and get the following :

kompose up

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 127.0.0.1:8080: connect: connection refused

Here is the docker-compose.yml file I am using:

version: '3'
services:

  #Nginx Service
  webserver:
    image: nginx:alpine
    container_name: webserver
    restart: always
    tty: true
    ports:
      - "80:80"
      - "443:443"
    networks:
      - app-network

#Docker Networks
networks:
  app-network:
    driver: bridge
#Volumes
volumes:
  dbdata:
    driver: local

Anyone? Please!!!