This example describes how to deploy multiple Lightwave instances in Docker containers using the experimental networking features of Docker 1.8.0-dev. The multi-host networking allows lightwave directory instances to communicate between containers, even if they are on different Photon host machines.
Here is the Docker documentation on how to use the multi-host overlay driver to provision two hosts:
Note that the multi-host networking feature is an experimental Docker feature which is not yet released in Docker 1.7.0 that is installed in Photon TP1.
The Lightwave setup shown here provisions two Photon TP1 Docker hosts with the multi-host overlay driver and the Consul key-value store. Then a Lightwave server is deployed in a container on each of the Photon hosts.
Many of the steps shown below must be done on each of two Photon host machines. If PHOTON-HOST-1 or PHOTON-HOST-2 is specified, then the step should be performed only on that host.
bash-4.3# wget https://dl.bintray.com/mitchellh/consul/0.5.2_linux_amd64.zip
bash-4.3# unzip 0.5.2_linux_amd64.zip
bash-4.3# mv consul /bin
bash-4.3# consul --version
Consul v0.5.2
Consul Protocol: 2 (Understands back to: 1)
- PHOTON-HOST-1
bash-4.3# cat >/lib/systemd/system/consul.service
[Unit]
Description=Consul Service
After=syslog.target network.target
[Service]
ExecStart=/bin/consul agent -server -bootstrap -data-dir /tmp/consul -bind=IPADDR2
[Install]
WantedBy=multi-user.target
Make sure that IPADDR2 is set to the address of the PHOTON-HOST-2 machine.
- PHOTON-HOST-2
For the second photon host, use the following consul command arguments instead
ExecStart=/bin/consul agent -server -data-dir /tmp/consul -bind=IPADDR1
Make sure that IPADDR1 is set to the address of the PHOTON-HOST-1 machine.
bash-4.3# systemctl enable consul
Created symlink from /etc/systemd/system/multi-user.target.wants/consul.service to /usr/lib/systemd/system/consul.service.
bash-4.3# systemctl daemon-reload
bash-4.3# systemctl start consul
bash-4.3# systemctl | grep consul
consul.service loaded active running Consul Service
- PHOTON-HOST-2:
bash-4.3# consul join IPADDR1
Make sure that IPADDR1 is the address of the PHOTON-HOST-2 machine.
Photon TP1 has docker-1.7.0 installed. Install docker.1.8.0-dev instead.
bash-4.3# wget https://experimental.docker.com/builds/Linux/x86_64/docker-1.8.0-dev.tgz
bash-4.3# tar xfvz docker-1.8.0-dev.tgz
This will extract the file 'usr/local/bin/docker'.
On Photon, /bin/docker is a symbolic link to docker-1.7.0. To install docker-1.8.0-dev, copy it to /bin and change the symbolic link to point to it.
bash-4.3# mv usr/local/bin/docker /bin/docker-1.8.0-dev
bash-4.3# rm /bin/docker
bash-4.3# ln -s docker-1.8.0-dev /bin/docker
bash-4.3# docker --version
Docker version 1.8.0-dev, build 5fdc102, experimental
- PHOTON HOST
Modify the systemd configuration for docker.service with the following docker command line:
ExecStart=/bin/docker -d --kv-store=consul:localhost:8500 --label=com.docker.network.driver.overlay.bind_interface=ens32
The example above shows the network interface name 'ens32'. Make sure to configure the correct interface name for your photon host.
- PHOTON HOST 2
Modify the systemd configuration for docker.service with the following docker command line:
ExecStart=/bin/docker -d --kv-store=consul:localhost:8500 --label=com.docker.network.driver.overlay.bind_interface=ens32
bash-4.3# systemctl daemon-reload
bash-4.3# systemctl start docker
bash-4.3# systemctl | grep docker
docker.service loaded active running Docker Daemon
- PHOTON HOST 1
bash-4.3# docker network create -d overlay prod
- PHOTON HOST 1
bash-4.3# docker service publish lightwave1.prod
- PHOTON HOST 2
bash-4.3# docker service publish lightwave2.prod
bash-4.3# docker import vmware-lightwave-sts.tar vmware/lightwave-sts:latest
- PHOTON-HOST-1
bash-4.3# docker run --privileged --name lw_01 vmware/lightwave-sts
bash-4.3# docker service attach lw_01 lightwave1.prod
- PHOTON-HOST-2
bash-4.3# docker run --privileged --name lw_02 vmware/lightwave-sts
bash-4.3# docker service attach lw_02 lightwave2.prod
bash-4.3# docker exec -it lw_01 sh
sh-4.3#
The inetutils package is needed for the ifconfig command to determine the IP address of the container. The iana-etc package is required for ping to work.
sh-4.3# tdnf install -y inetutils
sh-4.3# tdnf install -y iana-etc
sh-4.3# ifconfig eth1
In this example, PHOTON-HOST-1 now has IP address 172.21.0.1 and PHOTON-HOST-2 now has IP address 172.21.0.2.
- PHOTON-HOST-1
sh-4.3# ping 172.17.42.2
PING 172.17.42.2
(172.17.42.2): 56 data bytes 64 bytes from 172.17.42.2: icmp_seq=0 ttl=64 time=0.051 ms
- PHOTON-HOST-1
sh-4.3# hostname lw_01_prod
- PHOTON-HOST-2
sh-4.3# hostname lw_02_prod
sh-4.3# cat >>/etc/hosts
172.21.0.1 lw_01_prod
172.21.0.2 lw_02_prod
- PHOTON-HOST-1
sh-4.3# /opt/vmware/bin/configure-lightwave-server \
--password ADMIN-PASSWORD \
--domain vsphere.local \
--hostname 172.21.0.1
This command deploys the first lightwave server in standalone mode.
Set ADMIN-PASSWORD to the desired Administrator password for the domain.
- PHOTON-HOST-2
sh-4.3# /opt/vmware/bin/configure-lightwave-server \
--server 172.21.0.1 \
--hostname 172.21.0.2 \
--password ADMIN-PASSWORD
This command deploys the second lightwave server in replication partner mode with the first lightwave server.
By following these steps additional lightwave servers may be deployed in containers with whatever replication topology is desired. Each container will be able to communicate with all other containers no matter which Photon host the container is deployed on.