问题
I'm currently deploying a project on a kubernetes cluster by using Kompose (http://www.kompose.io) to convert the docker-compose configuration to kubernetes configuration files.
This is a project for a master class at my university and they took care of the kubernetes cluster, so I'm almost certain that the configuration for it is done properly. FYI, this is the version of that kubernetes cluster;
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-13T11:23:11Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-13T11:13:49Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
This is the version of Kompose;
$ kompose version
1.20.0 (f3d54d784)
The problem that I have is as follows. I use the command kompose convert and this works without any problem, but when I try deploying it by using the command kompose up, it fails with the following error message.
FATA Error while deploying application: Get http://localhost:8080/api: dial tcp [::1]:8080: connect: connection refused
This is my first time using kubernetes and kompose. I've looked for others who also have this problem but nothing really helped for what I've found.
This is my docker-compose file at the moment: (I'm aware I shouldn't put passwords in my docker-compose file but it's not part of the problem)
version: "3"
services:
zookeeper-container:
image: confluentinc/cp-zookeeper
environment:
- ZOOKEEPER_CLIENT_PORT=2181
kafka-container:
image: confluentinc/cp-kafka
depends_on:
- zookeeper-container
environment:
- KAFKA_BROKER_ID=1
- KAFKA_ZOOKEEPER_CONNECT=zookeeper-container:2181
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka-container:9092
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
route-db:
image: neo4j:3.5.6
environment:
- NEO4J_AUTH=neo4j/route
ports:
- 7687:7687
delay-request-db:
image: redis
staff-db:
image: mongo
train-db:
image: mongo
maintenance-db:
image: mysql:5.7
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=maintenancedatabase
- MYSQL_DATABASE=Maintenance
station-db:
image: mysql:5.7
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=stationdatabase
- MYSQL_DATABASE=Station
ticket-sale-db:
image: mysql:5.7
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=ticketsaledatabase
- MYSQL_DATABASE=TicketSale
ticket-validation-db:
image: mysql:5.7
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=ticketvalidationdatabase
- MYSQL_DATABASE=TicketValidation
timetable-db:
image: mysql:5.7
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=timetabledatabase
- MYSQL_DATABASE=Timetable
delay-service:
build: ./railway-app-delay
image: gilliswerrebrouck/railway-app-delay-service
volumes:
- ./railway-app-delay/target:/app
links:
- kafka-container
- zookeeper-container
depends_on:
- kafka-container
- zookeeper-container
maintenance-service:
build: ./railway-app-maintenance
image: gilliswerrebrouck/railway-app-maintenance-service
volumes:
- ./railway-app-maintenance/target:/app
links:
- kafka-container
- zookeeper-container
- maintenance-db
depends_on:
- kafka-container
- zookeeper-container
- maintenance-db
route-service:
build: ./railway-app-route-management
image: gilliswerrebrouck/railway-app-route-management-service
volumes:
- ./railway-app-route-management/target:/app
links:
- kafka-container
- zookeeper-container
- route-db
depends_on:
- kafka-container
- zookeeper-container
- route-db
staff-service:
build: ./railway-app-staff
image: gilliswerrebrouck/railway-app-staff-service
volumes:
- ./railway-app-staff/target:/app
links:
- kafka-container
- zookeeper-container
- staff-db
depends_on:
- kafka-container
- zookeeper-container
- staff-db
station-service:
build: ./railway-app-station
image: gilliswerrebrouck/railway-app-station-service
volumes:
- ./railway-app-station/target:/app
links:
- kafka-container
- zookeeper-container
- station-db
- delay-request-db
depends_on:
- kafka-container
- zookeeper-container
- station-db
- delay-request-db
ticket-sale-service:
build: ./railway-app-ticket-sale
image: gilliswerrebrouck/railway-app-ticket-sale-service
volumes:
- ./railway-app-ticket-sale/target:/app
links:
- kafka-container
- zookeeper-container
- ticket-sale-db
depends_on:
- kafka-container
- zookeeper-container
- ticket-sale-db
ticket-validation-service:
build: ./railway-app-ticket-validation
image: gilliswerrebrouck/railway-app-ticket-validation-service
volumes:
- ./railway-app-ticket-validation/target:/app
links:
- kafka-container
- zookeeper-container
- ticket-validation-db
depends_on:
- kafka-container
- zookeeper-container
- ticket-validation-db
timetable-service:
build: ./railway-app-timetable
image: gilliswerrebrouck/railway-app-timetable-service
volumes:
- ./railway-app-timetable/target:/app
links:
- kafka-container
- zookeeper-container
- timetable-db
- route-service
- station-service
- train-service
depends_on:
- kafka-container
- zookeeper-container
- timetable-db
- route-service
- station-service
- train-service
train-service:
build: ./railway-app-train
image: gilliswerrebrouck/railway-app-train-service
volumes:
- ./railway-app-train/target:/app
links:
- kafka-container
- zookeeper-container
- train-db
depends_on:
- kafka-container
- zookeeper-container
- train-db
apigateway:
build: ./railway-app-api-gateway
image: gilliswerrebrouck/railway-app-api-gateway-service
volumes:
- ./railway-app-api-gateway/target:/app
links:
- kafka-container
- zookeeper-container
- delay-service
- maintenance-service
- route-service
- staff-service
- station-service
- ticket-sale-service
- ticket-validation-service
- timetable-service
- train-service
depends_on:
- kafka-container
- zookeeper-container
- delay-service
- maintenance-service
- route-service
- staff-service
- station-service
- ticket-sale-service
- ticket-validation-service
- timetable-service
- train-service
ports:
- 8080:8080
frontend:
build: ./railway-app-frontend
image: gilliswerrebrouck/railway-app-frontend
volumes:
- ./railway-app-frontend/target:/app
links:
- apigateway
- route-db
depends_on:
- apigateway
- route-db
ports:
- 80:80
Anyone has any tips on how to troubleshoot this issue or how to fix it?
UPDATE:
These are the files generated by the kompose convert
command
回答1:
I've solved it by replacing all apiversions in the deployment files from v1beta2 to apps/v1 and by adding a selector to each deployment.
selector:
matchLabels:
app: ...
I then didn't use the command Kompose up
to deploy since this gives me an error, but I used the command kubectl create -f <file(s)>
to deploy and this succeeded without the connection error. There are still some pods crashing but I don't think it has anything to do with this original problem.
来源:https://stackoverflow.com/questions/59690266/not-able-to-deploy-to-kubernetes-cluster-using-kompose