Advanced chapter: dockersurm of docker adjusts micro service and service configuration (29)

Keywords: Linux Docker Java Dubbo snapshot

>Original article, welcome to reprint. Reprint please indicate: reprint from IT people's story meeting Thank you!
>Original link address: Advanced chapter: dockersurm of docker adjusts micro service and service configuration (29)

Last time, the swarm cluster environment has been set up. There are three virtual machines, server01, server02 and server03. Each manager node is also a work node. First, we consider the discovery of services. From the perspective of microservices, we have services for other services, such as message service and user service. For swarm, some ports need to be exposed to For other services, some can be accessed directly through the name of the service. Change the mode, change the code, and then upload it to the image warehouse. Finally, configure a docker stack to write their relationship, and a command is completed. Source code: https://github.com/limingios/msA-docker swarm bifurcation

Modify the configuration of microservices

  • course-dubbo-service

sh

#!/usr/bin/env bash

source ~/.bash_profile
mvn package
docker build -f ./Dockerfile-hub -t zhugeaming/course-dubbo-service:latest .
docker push zhugeaming/course-dubbo-service:latest

>Dockerfile
``` bash
FROM java:openjdk-8
MAINTAINER liming www.idig8.com

COPY target/course-dubbo-service-1.0-SNAPSHOT.jar /course-dubbo-service.jar

ENTRYPOINT ["java","-jar","/course-dubbo-service.jar"]
  • course-edge-service

sh

#!/usr/bin/env bash

source ~/.bash_profile
mvn package
docker build -f ./Dockerfile-hub -t zhugeaming/course-edge-service:latest .
docker push zhugeaming/course-edge-service:latest

>Dockerfile
``` bash
FROM java:openjdk-8
MAINTAINER liming www.idig8.com

COPY target/course-edge-service-1.0-SNAPSHOT.jar /course-edge-service.jar

ENTRYPOINT ["java","-jar","/course-edge-service.jar"]
  • gataway-zuul

    sh

    #!/usr/bin/env bash

source ~/.bash_profile
mvn package
docker build -f ./Dockerfile-hub -t zhugeaming/gataway-zuul:latest .
docker push zhugeaming/gataway-zuul:latest

>Dockfile
``` bash
FROM java:openjdk-8
MAINTAINER liming www.idig8.com

COPY target/gataway-zuul-1.0-SNAPSHOT.jar /gataway-zuul.jar

ENTRYPOINT ["java","-jar","/gataway-zuul.jar"]
  • user-edge-service

    sh

    #!/usr/bin/env bash
    source ~/.bash_profile
    mvn package
    docker build -f ./Dockerfile-hub -t zhugeaming/user-edge-service:latest .
    docker push zhugeaming/user-edge-service:latest

Dockerfile

#!/usr/bin/env bash
source ~/.bash_profile
mvn package
docker build -f ./Dockerfile-hub -t zhugeaming/user-edge-service:latest .
docker push zhugeaming/user-edge-service:latest
  • user-thrift-service

    sh

    #!/usr/bin/env bash
    source ~/.bash_profile
    mvn package
    docker build -f ./Dockerfile-hub -t zhugeaming/user-thrift-service:latest .
    docker push zhugeaming/user-thrift-service:latest

    Dockerfile

    FROM java:openjdk-8
    MAINTAINER liming www.idig8.com

COPY target/user-thrift-service-1.0-SNAPSHOT.jar /user-thrift-service.jar

ENTRYPOINT ["java","-jar","/user-thrift-service.jar"]

* To write yml File usage docker stack Batch generation

``` yml
version: "3.4"
services:
  message-thrift-python-service:
    image: zhugeaming/message-thrift-python-service:latest
    deploy:
      endpoint_mode: dnsrr
      resources:
        limits:
          cpus: "0.2"
          memory: "128M"

  user-thrift-service:
    image: zhugeaming/user-thrift-service:latest
    deploy:
      endpoint_mode: dnsrr
      resources:
        limits:
          cpus: "0.2"
          memory: "512M"

  user-edge-service:
    image: zhugeaming/user-edge-service:latest
    deploy:
      endpoint_mode: vip
      resources:
        limits:
          cpus: "0.2"
          memory: "512M"
    ports:
    - "8082:8082"
    depends_on:
    - user-thrift-service
    - message-thrift-python-service

  course-dubbo-service:
    image: zhugeaming/user-edge-service:latest
    deploy:
      endpoint_mode: dnsrr
      resources:
        limits:
          cpus: "0.2"
          memory: "512M"
    depends_on:
    - user-thrift-service

  course-edge-service:
    image: zhugeaming/course-edge-service:latest
    deploy:
      endpoint_mode: vip
      resources:
        limits:
          cpus: "0.2"
          memory: "512M"
    ports:
    - "8081:8081"
    depends_on:
    - user-edge-service
  gateway-zuul:
    image: zhugeaming/gataway-zuul:latest
    deploy:
      endpoint_mode: vip
      resources:
        limits:
          cpus: "0.2"
          memory: "512M"
    ports:
    - "8080:8080"
    depends_on:
    - user-edge-service
    - course-edge-service

networks:
  default:
    external:
      name: idig8-overlay

docker stack is created. Because the machine memory is too small, I still use the Internet. Downloading the image is a little slow.

docker stack deploy -c ms-service.yml ms
docker stack services ms 

PS: the next step is to debug the microservice.

Posted by aclees86 on Sat, 07 Dec 2019 18:12:34 -0800