Could not make the load balancer work

I followed the guideline http://rancher.com/building-microservices-with-docker-on-the-new-rancher-beta/
I got stuck at the step configuring my load balancers and web servers. From whatever i did, i still could not access the site. I tried the local DNS mapping to the host ip and the the host ip, but that does not help

The log from load balancer and web server hosting wordpress look still good

Here is my configuration for load balancer:

Thanks,
Minh

Here are other configuration and host information:

And here are my droplets, services and graph from the example

Can you share your docker-compose.yml and rancher-compose.yml for the stack?

1 Like

Here is the docker-compose.yml:

pxc:
  restart: always
  environment:
    PXC_SST_PASSWORD: ye8kfGxP
  labels:
    io.rancher.scheduler.global: 'true'
    io.rancher.scheduler.affinity:host_label: target.service=database
  tty: true
  image: nixel/rancher-percona-xtradb-cluster:v1.1
  privileged: true
  stdin_open: true
  volume_driver: /var/lib/mysql:/var/lib/mysql
wordpress-lb:
  ports:
  - 80:80
  restart: always
  labels:
    io.rancher.loadbalancer.target.wordpress: 80/=80
  tty: true
  image: rancher/load-balancer-service
  links:
  - wordpress:wordpress
  stdin_open: true
wordpress:
  restart: always
  environment:
    DB_PASSWORD: ye8kfGxP
  labels:
    io.rancher.scheduler.affinity:host_label: target.service=web
  tty: true
  image: nixel/rancher-wordpress-ha:v1.1
  links:
  - gluster:storage
  - pxc:db
  privileged: true
  stdin_open: true
gluster:
  restart: always
  environment:
    ROOT_PASSWORD: LazNdFaj
  labels:
    io.rancher.scheduler.global: 'true'
    io.rancher.scheduler.affinity:host_label: target.service=storage
  tty: true
  image: nixel/rancher-glusterfs-server:v2.3
  privileged: true
  volumes:
  - /gluster_volume:/gluster_volume
  stdin_open: true

And here is the rancher-compose.yml:

pxc:
  scale: 3
wordpress-lb:
  scale: 3
  load_balancer_config:
    name: wordpress-lb config
wordpress:
  scale: 6
gluster:
  scale: 2

Did you copy this directly from your setup? Copy from the paper icon of the stack? Or did you type it up? There are some discrepancies between the image that you showed about the load balancer and the docker-compose.yml.

In the pxc service, you are missing the PXC_ROOT_PASSWORD environment variable. Was this just a typo?
In the wordpress-lb service, you do not need this label. By having the ports 80:80, all traffic at port 80 will be redirected to container port 80.

 labels:
    io.rancher.loadbalancer.target.wordpress: 80/=80

The blog post was written in a much older version so some things have changed (like how health checks move to the services instead of the load balancers). I made some tweaks to the docker-compose.yml that you shared, but I am having issues with the service (outside of the load balancer).

When you can’t access the site, is it a blank page or a 503 Service Unavailable?

In my debugging of the stack, I tested without the LB to see if the wordpress setup side worked, I can access the container and port of the Wordpress service, but unable to see the wordpress login. It just shows me a blank page with no issues.

Wordpress Test without LB docker-compose.yml

wordpress1:
  restart: always
  ports:
  - 8090:80/tcp
  environment:
    DB_PASSWORD: ye8kfGxP
  labels:
    io.rancher.scheduler.affinity:host_label: target.service=web
  tty: true
  image: nixel/rancher-wordpress-ha:v1.1
  links:
  - gluster:storage
  - pxc:db
  privileged: true
  stdin_open: true
pxc:
  restart: always
  environment:
    PXC_ROOT_PASSWORD: test
    PXC_SST_PASSWORD: ye8kfGxP
  labels:
    io.rancher.scheduler.global: 'true'
    io.rancher.scheduler.affinity:host_label: target.service=database
  tty: true
  image: nixel/rancher-percona-xtradb-cluster:v1.1
  privileged: true
  stdin_open: true
  volume_driver: /var/lib/mysql:/var/lib/mysql
gluster:
  restart: always
  environment:
    ROOT_PASSWORD: LazNdFaj
  labels:
    io.rancher.scheduler.global: 'true'
    io.rancher.scheduler.affinity:host_label: target.service=storage
  tty: true
  image: nixel/rancher-glusterfs-server:v2.3
  privileged: true
  volumes:
  - /gluster_volume:/gluster_volume
  stdin_open: true

Rancher-compose.yml

wordpress1:
  scale: 2
pxc:
  scale: 3
gluster:
  scale: 2

With the LB, there are no error pages (503 Service Unavailable), so I know that the load balancers is accessing the Wordpress service, but like the above, it’s just a blank screen.

Docker-compose.yml with the load balancer

pxc:
  restart: always
  environment:
    PXC_ROOT_PASSWORD: test
    PXC_SST_PASSWORD: ye8kfGxP
  labels:
    io.rancher.scheduler.global: 'true'
    io.rancher.scheduler.affinity:host_label: target.service=database
  tty: true
  image: nixel/rancher-percona-xtradb-cluster:v1.1
  privileged: true
  stdin_open: true
  volume_driver: /var/lib/mysql:/var/lib/mysql
wordpress-lb:
  restart: always
  ports:
  - 80:80
  labels:
    io.rancher.loadbalancer.target.wordpress: 80/=80
  tty: true
  image: rancher/load-balancer-service
  links:
  - wordpress:wordpress
  stdin_open: true
wordpress:
  restart: always
  environment:
    DB_PASSWORD: ye8kfGxP
  labels:
    io.rancher.scheduler.affinity:host_label: target.service=web
  tty: true
  image: nixel/rancher-wordpress-ha:v1.1
  links:
  - gluster:storage
  - pxc:db
  privileged: true
  stdin_open: true
gluster:
  restart: always
  environment:
    ROOT_PASSWORD: LazNdFaj
  labels:
    io.rancher.scheduler.global: 'true'
    io.rancher.scheduler.affinity:host_label: target.service=storage
  tty: true
  image: nixel/rancher-glusterfs-server:v2.3
  privileged: true
  volumes:
  - /gluster_volume:/gluster_volume
  stdin_open: true

Rancher-compose.yml

pxc:
  scale: 3
wordpress-lb:
  scale: 3
  load_balancer_config:
    name: wordpress-lb config
wordpress:
  scale: 6
gluster:
  scale: 2

If you are looking to see the load balancer work, you can try the wordpress example in our docs that just link to a mysql DB. http://docs.rancher.com/rancher/quick-start-guide/#create-a-multi-container-application