{"id":1339,"date":"2019-02-17T06:44:17","date_gmt":"2019-02-17T06:44:17","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw93\/?p=1339"},"modified":"2019-03-07T17:23:20","modified_gmt":"2019-03-07T17:23:20","slug":"glusterfs-docker-building-an-html5-game","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw93\/index.php\/2019\/02\/17\/glusterfs-docker-building-an-html5-game\/","title":{"rendered":"GlusterFS Docker | Building an HTML5 Game"},"content":{"rendered":"<p><a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/05\/08145326\/gluster-logo.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/05\/08145326\/gluster-logo-150x112.png\" alt=\"gluster logo\" \/><\/a>GlusterFS<br \/>\nis a scalable, highly available, and distributed network file system<br \/>\nwidely used for applications that need shared storage including cloud<br \/>\ncomputing, media streaming, content delivery networks, and web cluster<br \/>\nsolutions. High availability is ensured by the fact that storage data is<br \/>\nredundant, so in case one node fails another will cover it without<br \/>\nservice interruption. In this post I\u2019ll show you how to create a<br \/>\nGlusterFS cluster for Docker that you can use to store your containers<br \/>\ndata. The storage volume where data resides is replicated twice, so data<br \/>\nwill be accessible if at least one Gluster container is working. We\u2019ll<br \/>\nuse Rancher for Docker management and orchestration. In order to test<br \/>\nstorage availability and reliability I\u2019ll be deploying an Asteroids<br \/>\ngame.<br \/>\n<a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/GlusterFS-Asteroids-Architecture.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/GlusterFS-Asteroids-Architecture.png\" alt=\"GlusterFS-Asteroids-Architecture\" \/><\/a><\/p>\n<h2>Prerequisites<\/h2>\n<p>Preparing AWS environment Before deploying the GlusterFS cluster you<br \/>\nneed to satisfy the following requirements in AWS:<\/p>\n<ul>\n<li>Create an Access Key to use Rancher AWS provisioning feature.<br \/>\nYou can get an Access Ke<\/li>\n<li>\n<ul>\n<li>Allow 22\/tcp, 2376\/tcp and 8080\/tcp ports from any source,<br \/>\nneeded for Docker machine to provision hosts<\/li>\n<\/ul>\n<ul>\n<li>Allow 500\/udp and 4500\/udp ports from any source, needed for<br \/>\nRancher network<\/li>\n<li>Allow 9345\/tcp and 9346\/tcp ports from any source, needed for UI<br \/>\nfeatures like graphs, view logs, and execute shell<\/li>\n<li>Allow 80\/tcp and 443\/tcp ports from any source, needed to<br \/>\npublish the Asteroids game<\/li>\n<\/ul>\n<\/li>\n<li>Create a RancherOS instance (look for RancherOS AMI in<br \/>\n<em>Community AMIs<\/em>). Configure it to run Rancher Server by<br \/>\ndefining the following user data and associate it to the Gluster<br \/>\nSecurity Group. Once the instance is running you can browse to<br \/>\nRancher UI: <a href=\"http:\/\/RANCHER_INSTANCE_PUBLIC_IP:8080\/\">http:\/\/RANCHER_INSTANCE_PUBLIC_IP:8080\/<\/a><\/li>\n<\/ul>\n<p>#!\/bin\/bash<br \/>\ndocker run -d -p 8080:8080 rancher\/server:v0.17.1<\/p>\n<h2>Preparing Docker images<\/h2>\n<p>I have prepared two Docker images that we are using later. This is how I<br \/>\nbuilt them. The GlusterFS server image This is the Dockerfile:<\/p>\n<p>FROM ubuntu:14.04<\/p>\n<p>MAINTAINER Manel Martinez &lt;manel@nixelsolutions.com&gt;<\/p>\n<p>RUN apt-get update &amp;&amp;<br \/>\napt-get install -y python-software-properties software-properties-common<br \/>\nRUN add-apt-repository -y ppa:gluster\/glusterfs-3.5 &amp;&amp;<br \/>\napt-get update &amp;&amp;<br \/>\napt-get install -y glusterfs-server supervisor<\/p>\n<p>RUN mkdir -p \/var\/log\/supervisor<\/p>\n<p>ENV GLUSTER_VOL ranchervol<br \/>\nENV GLUSTER_REPLICA 2<br \/>\nENV GLUSTER_BRICK_PATH \/gluster_volume<br \/>\nENV GLUSTER_PEER **ChangeMe**<br \/>\nENV DEBUG 0<\/p>\n<p>VOLUME [&#8220;\/gluster_volume&#8221;]<\/p>\n<p>RUN mkdir -p \/usr\/local\/bin<br \/>\nADD .\/bin \/usr\/local\/bin<br \/>\nRUN chmod +x \/usr\/local\/bin\/*.sh<br \/>\nADD .\/etc\/supervisord.conf \/etc\/supervisor\/conf.d\/supervisord.conf<\/p>\n<p>CMD [&#8220;\/usr\/local\/bin\/run.sh&#8221;]<\/p>\n<p>As you can see, we are using 2 replicas for distributing the Gluster<br \/>\nvolume ranchervol. All its data will be persisted in Docker volume<br \/>\n\/gluster_volume. Note that we are not exposing any port because<br \/>\nGlusterFS containers are connecting through Rancher network. The<br \/>\nrun.sh script is as follows:<\/p>\n<p>#!\/bin\/bash<\/p>\n<p>[ &#8220;$DEBUG&#8221; == &#8220;1&#8221; ] &amp;&amp; set -x<\/p>\n<p>prepare-gluster.sh &amp;<br \/>\n\/usr\/bin\/supervisord<\/p>\n<p>It will invoke another script to prepare GlusterFS cluster in<br \/>\nbackground. This is required because Gluster commands need to be<br \/>\nexecuted when its daemon is running. This is the content for<br \/>\nprepare-gluster.sh script:<\/p>\n<p>#!\/bin\/bash<\/p>\n<p>set -e<\/p>\n<p>[ &#8220;$DEBUG&#8221; == &#8220;1&#8221; ] &amp;&amp; set -x<\/p>\n<p>if [ &#8220;$&#8221; == &#8220;**ChangeMe**&#8221; ]; then<br \/>\n# This node is not connecting to the cluster yet<br \/>\nexit 0<br \/>\nfi<\/p>\n<p>echo &#8220;=&gt; Waiting for glusterd to start&#8230;&#8221;<br \/>\nsleep 10<\/p>\n<p>if gluster peer status | grep $ &gt;\/dev\/null; then<br \/>\necho &#8220;=&gt; This peer is already part of Gluster Cluster, nothing to do&#8230;&#8221;<br \/>\nexit 0<br \/>\nfi<\/p>\n<p>echo &#8220;=&gt; Probing peer $&#8230;&#8221;<br \/>\ngluster peer probe $<\/p>\n<p>echo &#8220;=&gt; Creating GlusterFS volume $&#8230;&#8221;<br \/>\nmy_rancher_ip=`echo $ | awk -F\/ &#8221;`<br \/>\ngluster volume create $ replica $ $:$ $:$ force<\/p>\n<p>echo &#8220;=&gt; Starting GlusterFS volume $&#8230;&#8221;<br \/>\ngluster volume start $<\/p>\n<p>As we can see, if we don\u2019t provide GLUSTER_PEER environment variable<br \/>\nthe container will only start GlusterFS daemon and wait for a second<br \/>\npeer container to join the cluster. The second container needs to know<br \/>\nabout GLUSTER_PEER address in order to contact it (peer probe) and<br \/>\ncreate the shared storage volume. This is the supervisor configuration<br \/>\nfile, needed to start GlusterFS daemon:<\/p>\n<p>[supervisord]<br \/>\nnodaemon=true<\/p>\n<p>[program:glusterd]<br \/>\ncommand=\/usr\/sbin\/glusterd -p \/var\/run\/glusterd.pid<\/p>\n<p>The following commands are required to publish the Docker image:<\/p>\n<p>docker build -t nixel\/rancher-glusterfs-server .<br \/>\ndocker push nixel\/rancher-glusterfs-server .<\/p>\n<p>The Asteroids game image This is the image we are using to publish<br \/>\nthe Asteroids HTML5 game for testing Gluster HA capabilities. This<br \/>\ncontainer acts as a GlusterFS client that will mount the shared volume<br \/>\nwhere the following game content is being stored:<\/p>\n<ul>\n<li>static files (HTML, JS, CSS) needed to open the client-side game in<br \/>\nyour browser. A Nginx server will publish this to the Internet.<\/li>\n<li>A WebSocket server application used to handle user connections and<br \/>\ncontrol game logics. A Node.js service will publish this application<br \/>\nto the Internet.<\/li>\n<\/ul>\n<p>This is the Dockerfile which defines the image:<\/p>\n<p>FROM ubuntu:14.04<\/p>\n<p>MAINTAINER Manel Martinez &lt;manel@nixelsolutions.com&gt;<\/p>\n<p>RUN apt-get update &amp;&amp;<br \/>\napt-get install -y python-software-properties software-properties-common<br \/>\nRUN add-apt-repository -y ppa:gluster\/glusterfs-3.5 &amp;&amp;<br \/>\napt-get update &amp;&amp;<br \/>\napt-get install -y git nodejs nginx supervisor glusterfs-client dnsutils<\/p>\n<p>ENV GLUSTER_VOL ranchervol<br \/>\nENV GLUSTER_VOL_PATH \/mnt\/$<br \/>\nENV GLUSTER_PEER **ChangeMe**<br \/>\nENV DEBUG 0<\/p>\n<p>ENV HTTP_CLIENT_PORT 80<br \/>\nENV GAME_SERVER_PORT 443<br \/>\nENV HTTP_DOCUMENTROOT $\/asteroids\/documentroot<\/p>\n<p>EXPOSE $<br \/>\nEXPOSE $<\/p>\n<p>RUN mkdir -p \/var\/log\/supervisor $<br \/>\nWORKDIR $<\/p>\n<p>RUN mkdir -p \/usr\/local\/bin<br \/>\nADD .\/bin \/usr\/local\/bin<br \/>\nRUN chmod +x \/usr\/local\/bin\/*.sh<br \/>\nADD .\/etc\/supervisord.conf \/etc\/supervisor\/conf.d\/supervisord.conf<br \/>\nADD .\/etc\/nginx\/sites-available\/asteroids \/etc\/nginx\/sites-available\/asteroids<\/p>\n<p>RUN echo &#8220;daemon off;&#8221; &gt;&gt; \/etc\/nginx\/nginx.conf<br \/>\nRUN rm -f \/etc\/nginx\/sites-enabled\/default<br \/>\nRUN ln -fs \/etc\/nginx\/sites-available\/asteroids \/etc\/nginx\/sites-enabled\/asteroids<br \/>\nRUN perl -p -i -e &#8220;s\/HTTP_CLIENT_PORT\/$\/g&#8221; \/etc\/nginx\/sites-enabled\/asteroids<br \/>\nRUN HTTP_ESCAPED_DOCROOT=`echo $ | sed &#8220;s\/\/\/\\\\\\\\\/\/g&#8221;` &amp;&amp; perl -p -i -e &#8220;s\/HTTP_DOCUMENTROOT\/$\/g&#8221; \/etc\/nginx\/sites-enabled\/asteroids<\/p>\n<p>RUN perl -p -i -e &#8220;s\/GAME_SERVER_PORT\/$\/g&#8221; \/etc\/supervisor\/conf.d\/supervisord.conf<br \/>\nRUN HTTP_ESCAPED_DOCROOT=`echo $ | sed &#8220;s\/\/\/\\\\\\\\\/\/g&#8221;` &amp;&amp; perl -p -i -e &#8220;s\/HTTP_DOCUMENTROOT\/$\/g&#8221; \/etc\/supervisor\/conf.d\/supervisord.conf<\/p>\n<p>CMD [&#8220;\/usr\/local\/bin\/run.sh&#8221;]<\/p>\n<p>And this is the run.sh script:<\/p>\n<p>#!\/bin\/bash<\/p>\n<p>set -e<\/p>\n<p>[ &#8220;$DEBUG&#8221; == &#8220;1&#8221; ] &amp;&amp; set -x &amp;&amp; set +e<\/p>\n<p>if [ &#8220;$&#8221; == &#8220;**ChangeMe**&#8221; ]; then<br \/>\necho &#8220;ERROR: You did not specify &#8220;GLUSTER_PEER&#8221; environment variable &#8211; Exiting&#8230;&#8221;<br \/>\nexit 0<br \/>\nfi<\/p>\n<p>ALIVE=0<br \/>\nfor PEER in `echo &#8220;$&#8221; | sed &#8220;s\/,\/ \/g&#8221;`; do<br \/>\necho &#8220;=&gt; Checking if I can reach GlusterFS node $ &#8230;&#8221;<br \/>\nif ping -c 10 $ &gt;\/dev\/null 2&gt;&amp;1; then<br \/>\necho &#8220;=&gt; GlusterFS node $ is alive&#8221;<br \/>\nALIVE=1<br \/>\nbreak<br \/>\nelse<br \/>\necho &#8220;*** Could not reach server $ &#8230;&#8221;<br \/>\nfi<br \/>\ndone<\/p>\n<p>if [ &#8220;$ALIVE&#8221; == 0 ]; then<br \/>\necho &#8220;ERROR: could not contact any GlusterFS node from this list: $ &#8211; Exiting&#8230;&#8221;<br \/>\nexit 1<br \/>\nfi<\/p>\n<p>echo &#8220;=&gt; Mounting GlusterFS volume $ from GlusterFS node $ &#8230;&#8221;<br \/>\nmount -t glusterfs $:\/$ $<\/p>\n<p>echo &#8220;=&gt; Setting up asteroids game&#8230;&#8221;<br \/>\nif [ ! -d $ ]; then<br \/>\ngit clone https:\/\/github.com\/BonsaiDen\/NodeGame-Shooter.git $<br \/>\nfi<\/p>\n<p>my_public_ip=`dig -4 @ns1.google.com -t txt o-o.myaddr.l.google.com +short | sed &#8220;s\/&#8221;\/\/g&#8221;`<br \/>\nperl -p -i -e &#8220;s\/HOST = &#8216;.*&#8217;\/HOST = &#8216;$&#8217;\/g&#8221; $\/client\/config.js<br \/>\nperl -p -i -e &#8220;s\/PORT = .*;\/PORT = $;\/g&#8221; $\/client\/config.js<\/p>\n<p>\/usr\/bin\/supervisord<\/p>\n<p>As you can see we need to inform about GlusterFS containers where<br \/>\nranchervol storage is being served using GLUSTER_PEER environment<br \/>\nvariable. Although GlusterFS client does not need to know about all<br \/>\ncluster nodes, this is useful for Asteroids container to be able to<br \/>\nmount the volume if at least one GlusterFS container is alive. We are<br \/>\nproving this HA feature later. In this case we are exposing 80 (Nginx)<br \/>\nand 443 (Node.js Websocket server) ports so we can open the game in our<br \/>\nbrowser. This is the Nginx configuration file:<\/p>\n<p>server {<br \/>\nlisten HTTP_CLIENT_PORT;<br \/>\nlocation \/ {<br \/>\nroot HTTP_DOCUMENTROOT\/client\/;<br \/>\n}<br \/>\n}<\/p>\n<p>And the following supervisord configuration is required to run Nginx and<br \/>\nNode.js:<\/p>\n<p>[supervisord]<br \/>\nnodaemon=true<\/p>\n<p>[program:nginx]<br \/>\ncommand=\/usr\/sbin\/nginx<\/p>\n<p>[program:nodejs]<br \/>\ncommand=\/usr\/bin\/nodejs HTTP_DOCUMENTROOT\/server\/server.js GAME_SERVER_PORT<\/p>\n<p>Finally, the run.sh script will download the Asteroids source code and<br \/>\nsave it on GlusterFS shared volume. The last step is to replace the<br \/>\nrequired parameters on configuration files to run Nginx and Node.js<br \/>\nserver application. The following commands are needed to publish the<br \/>\nDocker image:<\/p>\n<p>docker build -t nixel\/rancher-glusterfs-client .<br \/>\ndocker push nixel\/rancher-glusterfs-client .<\/p>\n<h2>Creating Docker hosts<\/h2>\n<p>Now we need to create three Docker hosts, two of them used to run<br \/>\nGlusterFS server containers, and the third to publish the Asteroids<br \/>\ngame.<br \/>\n<a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Create_Amazon_Instance.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Create_Amazon_Instance.png\" alt=\"Create_Amazon_Instance\" \/><\/a><br \/>\nIn Rancher UI, click <em>+ Add Host<\/em> button and choose <em>Amazon EC2<br \/>\nprovider<\/em>. You need to specify, at least, the following information:<\/p>\n<ul>\n<li>Container names<\/li>\n<li>Amazon <em>Access Key<\/em> and <em>Secret Key<\/em> that you got before.<\/li>\n<li>EC2 <em>Region<\/em>, <em>Zone<\/em> and <em>VPC\/Subnet ID<\/em>. Be sure to choose the same<br \/>\nregion, zone and VPC\/subnet ID where Rancher Server is deployed.<\/li>\n<li>Type the <em>Security Group<\/em> name that we created before: Gluster.<\/li>\n<\/ul>\n<p>Repeat this step three times to create gluster01, gluster02, and<br \/>\nasteroids hosts. <a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Gluster-hosts.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Gluster-hosts.png\" alt=\"Gluster hosts\" \/><\/a><\/p>\n<h2>Adding GlusterFS server containers<\/h2>\n<p>Now you are ready to deploy your GlusterFS cluster. First, click <em>+<br \/>\nAdd Container<\/em> button on gluster01 host and enter the following<br \/>\ninformation:<\/p>\n<ul>\n<li>Name: gluster01<\/li>\n<li>Image: nixel\/rancher-glusterfs-server:latest<\/li>\n<\/ul>\n<p>Expand <em>Advanced Options<\/em> and follow these steps:<\/p>\n<ul>\n<li><em>Volumes section<\/em> &#8211; Add this volume:<br \/>\n\/gluster_volume:\/gluster_volume<\/li>\n<li><em>Networking section<\/em> &#8211; Choose <em>Managed Network on Docker0<\/em><\/li>\n<li><em>Security\/Host section<\/em> &#8211; Enable <em>Give the container full access to<br \/>\nthe host<\/em> checkbox<\/li>\n<\/ul>\n<p><a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Create_gluster_server_container_1.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Create_gluster_server_container_1.png\" alt=\"Create_gluster_server_container_1\" \/><\/a><br \/>\nNow wait for gluster01 container to be created and copy its Rancher<br \/>\nIP address, you are needing it now. Then click <em>+ Add Container<\/em> button<br \/>\non gluster02 host to create the second GlusterFS server container<br \/>\nwith the following configuration:<\/p>\n<ul>\n<li>Name: gluster02<\/li>\n<li>Image: nixel\/rancher-glusterfs-server:latest<\/li>\n<\/ul>\n<p>Expand <em>Advanced Options<\/em> and follow these steps:<\/p>\n<ul>\n<li><em>Command section<\/em> &#8211; Add an Environment Variable named GLUSTER_PEER<br \/>\nwhich value is the gluster01 container IP. In my case it is<br \/>\n10.42.46.31<\/li>\n<li><em>Volumes section<\/em> &#8211; Add this volume:<br \/>\n\/gluster_volume:\/gluster_volume<\/li>\n<li><em>Networking section<\/em> &#8211; Choose <em>Managed Network on Docker0<\/em><\/li>\n<li><em>Security\/Host section<\/em> &#8211; Enable <em>Give the container full access to<br \/>\nthe host<\/em> checkbox<\/li>\n<\/ul>\n<p><a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Gluster02_container_env_vars.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Gluster02_container_env_vars.png\" alt=\"Gluster02_container_env_vars\" \/><\/a><br \/>\nNow wait for gluster02 container to be created and open its menu,<br \/>\nthen click View Logs option.<br \/>\n<a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Gluster02_container_logs_menu.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Gluster02_container_logs_menu.png\" alt=\"Gluster02_container_logs_menu\" \/><\/a><br \/>\nYou will see the following messages at the bottom of log screen<br \/>\nconfirming that shared volume was successfully created.<br \/>\n<a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Gluster02_container_logs.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Gluster02_container_logs.png\" alt=\"Gluster02_container_logs\" \/><\/a><\/p>\n<h2>Adding Asteroids container<\/h2>\n<p>Now it is time to create our GlusterFS client container, which is<br \/>\npublishing an Asteroids game to the Internet. Click <em>+ Add Container<\/em> on<br \/>\nasteroids host and enter the following container information:<\/p>\n<ul>\n<li>Name: asteroids<\/li>\n<li>Image: nixel\/rancher-glusterfs-client:latest<\/li>\n<li>Port Map: map 80 (public) port to 80 (container) TCP<br \/>\nport<\/li>\n<li>Port Map: map 443 (public) port to 443 (container) TCP<br \/>\nport<\/li>\n<\/ul>\n<p>Expand <em>Advanced Options<\/em> and follow these steps:<\/p>\n<ul>\n<li><em>Command section<\/em> &#8211; Add an <em>Environment Variable<\/em> named<br \/>\nGLUSTER_PEER which value is a comma separated list of gluster01<br \/>\nand gluster02 containers IPs. In my case I\u2019m typing this:<br \/>\n10.42.46.31,10.42.235.105<\/li>\n<li><em>Networking section<\/em> &#8211; Choose <em>Managed Network on Docker0<\/em><\/li>\n<li><em>Security\/Host section<\/em> &#8211; Enable <em>Give the container full access to<br \/>\nthe host<\/em> checkbox<\/li>\n<\/ul>\n<p>Note that we are not configuring any container volume, because all data<br \/>\nis stored in GlusterFS cluster.<br \/>\n<a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/asteroids_container_port_mapping.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/asteroids_container_port_mapping.png\" alt=\"asteroids_container_port_mapping\" \/><\/a><br \/>\nWait for asteroids container to be created and show its logs. You will<br \/>\nfind something like this at the top:<br \/>\n<a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/asteroids_container_top_logs.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/asteroids_container_top_logs.png\" alt=\"asteroids_container_top_logs\" \/><\/a><br \/>\nYou will also see how Nginx server and Node.js application are started<br \/>\nat the bottom:<br \/>\n<a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/asteroids_container_bottom_logs.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/asteroids_container_bottom_logs.png\" alt=\"asteroids_container_bottom_logs\" \/><\/a><br \/>\nAt this point your Rancher environment is up and running.<br \/>\n<a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/all_containers_gluster.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/all_containers_gluster.png\" alt=\"all_containers_gluster\" \/><\/a><\/p>\n<h2>Testing GlusterFS HA capabilities<\/h2>\n<p><a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Asteroids_game.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2015\/04\/08145326\/Asteroids_game.png\" alt=\"Asteroids_game\" \/><\/a><br \/>\nIt is time to play and test GLusterFS HA capabilities. What you are<br \/>\ndoing now is to stop one GlusterFS container and check that game will<br \/>\nnot suffer downtimes. Browse to <a href=\"http:\/\/ASTEROIDS_HOST_PUBLIC_IP\">http:\/\/ASTEROIDS_HOST_PUBLIC_IP<\/a> and<br \/>\nyou will access Asteroids game, enter your name and try to explode some<br \/>\nasteroids. Go to Rancher UI and stop gluster02 container, then open<br \/>\na new browser tab and navigate to the game again. The game is<br \/>\naccessible. You can start gluster02 container, then stop<br \/>\ngluster01 container, and try again. You are still able to play.<br \/>\nFinally, keep gluster01 container stopped, restart asteroids<br \/>\ncontainer and wait for it to start. As you can see, if at least one<br \/>\nGlusterFS server container is running you are able to play. Finally you<br \/>\nmay want to stop gluster01 and gluster02 containers to check how<br \/>\ngame becomes unavailable because its public content is not reachable<br \/>\nnow. To recover the service start gluster01 and\/or gluster02<br \/>\ncontainers again.<\/p>\n<h2>Conclusion<\/h2>\n<p>Shared storage is a required feature when you have to deploy software<br \/>\nthat needs to share information across all nodes. In this post you have<br \/>\nseen how to easily deploy a Highly Available shared storage solution for<br \/>\nRancher based on GlusterFS Docker images. By using an Asteroids game you<br \/>\nhave checked that storage is available when, at least, one GlusterFS<br \/>\ncontainer is running. In future posts we are combining the shared<br \/>\nstorage solution with Rancher Load Balancing feature, added in 0.16<br \/>\nversion, so you will see how to build scalable, distributable, and<br \/>\nHighly Available Web server solutions ready for production use. To learn<br \/>\nmore about Rancher, please join us for our next online meetup, where<br \/>\nwe\u2019ll be demonstrating some of these features and answering your<br \/>\nquestions. <em>Manel Martinez is a Linux systems<br \/>\nengineer with experience in the design and management of scalable,<br \/>\ndistributable and highly available open source web infrastructures based<br \/>\non products like KVM, Docker, Apache, Nginx, Tomcat, Jboss, RabbitMQ,<br \/>\nHAProxy, MySQL and XtraDB. He lives in spain, and you can find him on<br \/>\nTwitter <a href=\"http:\/\/twitter.com\/manel_martinezg\">@manel_martinezg<\/a>.<\/em><\/p>\n<p><a href=\"https:\/\/rancher.com\/creating-a-glusterfs-cluster-for-docker-on-aws\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>GlusterFS is a scalable, highly available, and distributed network file system widely used for applications that need shared storage including cloud computing, media streaming, content delivery networks, and web cluster solutions. High availability is ensured by the fact that storage data is redundant, so in case one node fails another will cover it without service &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw93\/index.php\/2019\/02\/17\/glusterfs-docker-building-an-html5-game\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;GlusterFS Docker | Building an HTML5 Game&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1339","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/1339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/comments?post=1339"}],"version-history":[{"count":2,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/1339\/revisions"}],"predecessor-version":[{"id":1413,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/1339\/revisions\/1413"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/media?parent=1339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/categories?post=1339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/tags?post=1339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}