无法使用Kompose部署到Kubernetes集群 [英] Not able to deploy to Kubernetes cluster using Kompose

查看:77
本文介绍了无法使用Kompose部署到Kubernetes集群的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在通过使用Kompose在 http://www.kompose.io )将docker-compose配置转换为kubernetes配置文件.

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.

这是我大学的一个硕士班项目,他们负责kubernetes集群,因此我几乎可以肯定它的配置正确.仅供参考,这是该kubernetes集群的版本;

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"}

这是Kompose的版本;

This is the version of Kompose;

$ kompose version
1.20.0 (f3d54d784)

我遇到的问题如下.我使用命令kompose convert可以正常工作,但是当我尝试使用命令kompose up部署它时,它失败并显示以下错误消息.

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

这是我第一次使用kubernetes和kompose.我一直在寻找也有此问题的其他人,但对我发现的内容并没有真正帮助.

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.

这是我目前的docker-compose文件: (我知道我不应该将密码放入我的docker-compose文件中,但这不是问题的一部分)

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?

更新:

这些是kompose convert命令生成的文件

推荐答案

我已经解决了此问题,方法是将部署文件中的所有apiversion从v1beta2替换为apps/v1,并为每个部署添加选择器.

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: ...

然后我没有使用命令Kompose up进行部署,因为这给了我一个错误,但是我使用了命令kubectl create -f <file(s)>进行了部署,并且成功完成了而没有连接错误.仍然有一些豆荚崩溃,但我认为这与原始问题无关.

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.

这篇关于无法使用Kompose部署到Kubernetes集群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆