dockersamples / example-voting-app

Example distributed app composed of multiple containers for Docker, Compose, Swarm, and Kubernetes
Apache License 2.0
4.75k stars 10.99k forks source link

votingapp_result not showing the result #326

Closed PraveenMDevOps closed 11 months ago

PraveenMDevOps commented 11 months ago

Description

Docker Swarm | As mentioned in the docker-stack.yml, created all the services in docker swarm. Verified that all the configurations are done without error, but the votingapp_result is not showing the updated result. Refreshed the webpage again and again, but it shows 50% | 50%

Steps to reproduce the issue, if relevant:

docker info
Client: Docker Engine - Community
Version:    24.0.7
Context:    default
Swarm: active

Commands I have used
--------------------------------
docker network create -d overlay front_end_ntw
docker network create -d overlay back_end_ntw

docker create --name voting_app --replicas 5 --network front_end_ntw -p 5000:80 dockersamples/examplevotingapp_vote

docker service create --name voting_app --replicas 5 --network front_end_ntw -p 5000:80 dockersamples/examplevotingapp_vote

docker service create --name redis --replicas 5 --network front_end_ntw redis:alpine

docker service create --name worker --network front_end_ntw --network back_end_ntw dockersamples/examplevotingapp_worker

docker service create --name postgres --network back_end_ntw --mount type=volume,source=db-date,target=/var/lib/postgresql/data -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres:15-alpine

docker service create --name result_app --network back_end_ntw -p 5001:80 dockersamples/examplevotingapp_result

Describe the results you received:

votingapp_result not showing the updated result.

Describe the results you expected:

votingapp_result should have showed the updated result.

Output of docker version:

Version:    24.0.7

Output of docker info:

Client: Docker Engine - Community
 Version:    24.0.7
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.21.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 4
  Running: 4
  Paused: 0
  Stopped: 0
 Images: 3
 Server Version: 24.0.7
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: active
  NodeID: w99wi941uw1vxwrn6kbynt0gp
  Is Manager: true
  ClusterID: cj7zqi5bqwwr3d4dbvt0l62q1
  Managers: 3
  Nodes: 3
  Default Address Pool: 10.0.0.0/8  
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: 172.31.19.121
  Manager Addresses:
   172.31.19.121:2377
   172.31.20.103:2377
   172.31.24.224:2377
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dd1e886e55dd695541fdcd67420c2888645a495
 runc version: v1.1.10-0-g18a0cb0
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.14.0-362.8.1.el9_3.aarch64
 Operating System: Red Hat Enterprise Linux 9.3 (Plow)
 OSType: linux
 Architecture: aarch64
 CPUs: 2
 Total Memory: 1.552GiB
 Name: ip-172-31-19-121.ap-south-1.compute.internal
 ID: d1cc3c3e-73ec-49fb-b481-1cf6a86e67df
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS, Docker for Mac, Docker for Windows, VirtualBox, physical, etc.):

AWS EC2: Red Hat Enterprise Linux release 9.3 (Plow)
PraveenMDevOps commented 11 months ago

It was the version compatibility issue with the applications.

Used the below docker-stack.yml file and the application is working fine

version: "3"
services:

  redis:
    image: redis:latest
    networks:
      - frontend
    deploy:
      placement:
# Hostname mentioned here is ARM 64bit machine from aws, so the redis service will be deployed in the particular machine
        constraints: [node.hostname == ip-172-31-19-141.ap-south-1.compute.internal]
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure

  db:
    image: postgres:alpine3.19
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: "postgres"
      POSTGRES_PASSWORD: "postgres"
    networks:
      - backend
    deploy:
      placement:
        constraints: [node.role == manager]

  vote:
    image: dockersamples/examplevotingapp_vote
    ports:
      - 5000:80
    networks:
      - frontend
    depends_on:
      - redis
    deploy:
      replicas: 2
      update_config:
        parallelism: 2
      restart_policy:
        condition: on-failure

  result:
    image: dockersamples/examplevotingapp_result
    ports:
      - 5001:80
    networks:
      - backend
    depends_on:
      - db
    deploy:
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure

  worker:
    image: dockersamples/examplevotingapp_worker
    networks:
      - frontend
      - backend
    depends_on:
      - db
    deploy:
      mode: replicated
      replicas: 1
      labels: [APP=VOTING]
      restart_policy:
        condition: on-failure
        delay: 10s
        max_attempts: 3
        window: 120s
      placement:
        constraints: [node.role == manager]

  visualizer:
    image: dockersamples/visualizer:stable
    ports:
      - "8080:8080"
    stop_grace_period: 1m30s
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    deploy:
      placement:
# Hostname mentioned here is x86 64bit machine from aws, dockersamples/visualizer:stable will work only in the x86 architeture
        constraints: [node.hostname == ip-172-31-7-98.ap-south-1.compute.internal]

networks:
  frontend:
  backend:

volumes:
  db-data: