提问人:Seppe 提问时间:11/15/2023 更新时间:11/15/2023 访问量:19
Okteto 服务重新启动并失败
Okteto service restarts and fails
问:
我正在使用 Okteto 进行一个项目来部署我的服务。我不知道为什么,但我的一个服务不断重新启动,然后失败了。在此处输入图像描述
它以前工作过,但是自从我添加了一个api网关后,它就停止了。
我的main-flow.yaml
name: Build and deliver containers
on: push
jobs:
customerservice:
runs-on: ubuntu-latest
name: Java 17 build, test, deliver customer-service container
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
cache: maven
distribution: adopt
- name: Build, test and package project
working-directory: customer-service
run: mvn package -DskipTests
- name: Docker login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Build
run: docker build -t ${{ secrets.DOCKER_USER }}/customer-service:latest ./customer-service
- name: Upload container to Docker Hub with Push
run: docker push ${{ secrets.DOCKER_USER }}/customer-service:latest
taxiservice:
runs-on: ubuntu-latest
name: Java 17 build, test, deliver taxi-service container
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
cache: maven
distribution: adopt
- name: Build, test and package project
working-directory: taxi-service
run: mvn package -DskipTests
- name: Docker login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Build
run: docker build -t ${{ secrets.DOCKER_USER }}/taxi-service:latest ./taxi-service
- name: Upload container to Docker Hub with Push
run: docker push ${{ secrets.DOCKER_USER }}/taxi-service:latest
tripservice:
runs-on: ubuntu-latest
name: Java 17 build, test, deliver trip-service container
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
cache: maven
distribution: adopt
- name: Build, test and package project
working-directory: trip-service
run: mvn package -DskipTests
- name: Docker login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Build
run: docker build -t ${{ secrets.DOCKER_USER }}/trip-service:latest ./trip-service
- name: Upload container to Docker Hub with Push
run: docker push ${{ secrets.DOCKER_USER }}/trip-service:latest
apigateway:
runs-on: ubuntu-latest
name: Java 17 build, test, deliver ede-api-gateway container
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
cache: maven
distribution: adopt
- name: Build, test and package project
working-directory: ./api-gateway
run: mvn package -DskipTests
- name: Docker login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Build
run: docker build -t ${{ secrets.DOCKER_USER }}/ede-project-api-gateway:latest ./api-gateway
- name: Upload container to Docker Hub with Push
run: docker push ${{ secrets.DOCKER_USER }}/ede-project-api-gateway:latest
还有我的docker-compose
services:
mongo-customers:
image: mongo:latest
ports:
- 27017:27017
volumes:
- mongodb_customer_data:/data/db
mysql-trip:
image: mysql:latest
ports:
- 3306:3306
volumes:
- mysql_trip_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: trippassword
mysql-taxi:
image: mysql:latest
ports:
- 3307:3306
volumes:
- mysql_taxi_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: taxipassword
customer-service:
depends_on:
- mongo-customers
image: compacte/customer-service
ports:
- 8081:8081
links:
- mongo-customers
environment:
MONGODB_PORT: 27017
MONGODB_HOST: mongo-customers
taxi-service:
depends_on:
- mysql-taxi
image: compacte/taxi-service
ports:
- 8082:8082
links:
- mysql-taxi
environment:
MYSQL_DB_USERNAME: root
MYSQL_DB_PASSWORD: taxipassword
MYSQL_DB_HOST: mysql-taxi
MYSQL_DB_PORT: 3307
trip-service:
depends_on:
- taxi-service
- customer-service
image: compacte/trip-service
ports:
- 8083:8083
links:
- taxi-service
- customer-service
environment:
CUSTOMER_SERVICE_BASEURL: customer-service:8081
TAXI_INFO_SERVICE_BASEURL: taxi-service:8082
MYSQL_DB_USERNAME: root
MYSQL_DB_PASSWORD: trippassword
MYSQL_DB_HOST: mysql-trip
MYSQL_DB_PORT: 3306
api-gateway:
depends_on:
- taxi-service
- trip-service
image: compacte/ede-project-api-gateway
ports:
- 8084:8084
links:
- taxi-service
- trip-service
environment:
TAXI_SERVICE_BASEURL: taxi-service:8082
TRIP_SERVICE_BASEURL: trip-service:8083
volumes:
mongodb_customer_data:
mysql_taxi_data:
mysql_trip_data:
如果有什么不清楚的地方,请询问
我已经检查了所有缩进,因为 yaml 对安静敏感,但它们应该没问题。
答:
0赞
Arsh Sharma
11/15/2023
#1
我认为问题可能是因为您已硬编码为:https://github.com/SeppeVE/EDE/blob/main/taxi-service/src/main/resources/application.properties#L1datasource
localhost
您需要从您在 docker compose 中定义的环境变量中获取它:
MYSQL_DB_HOST: mysql-taxi
MYSQL_DB_PORT: 3307
类似于您为这里所做的:https://github.com/SeppeVE/EDE/blob/main/trip-service/src/main/resources/application.properties#L1trip-service
如果它仍然不起作用,请告诉我。还建议联系 Okteto 社区论坛以获得更快的支持:)https://community.okteto.com/
评论
0赞
Seppe
11/15/2023
哦,我完全错过了,谢谢!不幸的是,它没有解决问题。
0赞
Arsh Sharma
11/16/2023
啊!那你能在社区论坛上发帖吗?这是获得帮助的最佳方式!
评论