<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohammed Ashour</title>
    <description>The latest articles on DEV Community by Mohammed Ashour (@mohammedashour).</description>
    <link>https://dev.to/mohammedashour</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F105613%2Fcc0e8d90-e6a9-42f6-ab2c-3c260c5734f9.jpg</url>
      <title>DEV Community: Mohammed Ashour</title>
      <link>https://dev.to/mohammedashour</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohammedashour"/>
    <language>en</language>
    <item>
      <title>Setting up a shared volume for your docker swarm using GlusterFs</title>
      <dc:creator>Mohammed Ashour</dc:creator>
      <pubDate>Sat, 10 Apr 2021 13:57:42 +0000</pubDate>
      <link>https://dev.to/mohammedashour/setting-up-a-shared-volume-for-your-docker-swarm-using-glusterfs-3a16</link>
      <guid>https://dev.to/mohammedashour/setting-up-a-shared-volume-for-your-docker-swarm-using-glusterfs-3a16</guid>
      <description>&lt;p&gt;Working on a distributed software product before containers is certainly different than how it's now after the sweet introduction of the world of containerization. &lt;/p&gt;

&lt;p&gt;And without saying, for most of the community out there, when is containerization is mentioned, Docker is one of the first things that pop in their heads if it wasn't the first!&lt;br&gt;
I'm not here to argue that others started the idea of containerization before docker, that may be the topic of another blog.&lt;/p&gt;

&lt;p&gt;I'm here to talk about a problem I faced -and I'm sure others did- while dealing with Docker Swarm and needing some sort of data sharing between the nodes of the swarm. Unfortunately, this is not natively supported in Docker, you need to rely on a third-party storage service that provides you a good API that your nodes deal with and it will cost you a good deal of money for it, or you can go die-hard and make your own shared storage yourself. and here, I'm sharing the die-hard way that I chose to do it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;
&lt;h3&gt;
  
  
  What is GlusterFS?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3z6uty0jww5zldh5m44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3z6uty0jww5zldh5m44.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Gluster is a scalable, distributed file system that aggregates disk storage resources from multiple servers into a single global namespace.&lt;br&gt;
Gluster is Open source, Provides replication, quotas, geo-replication, snapshots, and others.&lt;/p&gt;

&lt;p&gt;Gluster gives you the ability of aggregating multiple nodes into one namespace, and from here you got multiple options.&lt;br&gt;
You can simply&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Have a replicated volume that offers the availability for your data without having to worry about your data loss&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have a distributed volume that can aggregate space for data by dividing your data across multiple machines, you here lose the availability but you gain more storage with the same resources&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can learn about the various setups of Gluster from here &lt;br&gt;
&lt;a href="https://docs.gluster.org/en/latest/Quick-Start-Guide/Architecture/" rel="noopener noreferrer"&gt;https://docs.gluster.org/en/latest/Quick-Start-Guide/Architecture/&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Let's start with our setup
&lt;/h3&gt;

&lt;p&gt;First, let's imagine that we have a swarm setup of 3 manager nodes and 3 worker nodes, and we need the containers on worker nodes to see the same data wherever they are, also, we need consistency for our data, the availability for our data matters the most. So, we need to make a replicated GlusterFs volume, that replicates all the data in multiple replication nodes, and since we don't have many resources to get extra machines that can act as storage pools, we will use our swarm machines to act also as storage pool nodes.&lt;/p&gt;
&lt;h4&gt;
  
  
  So, our architecture will be something like this
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fupfdd9ssl1pox0vmfpnb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fupfdd9ssl1pox0vmfpnb.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;3 Swarm Managers&lt;/li&gt;
&lt;li&gt;3 Swarm Workers&lt;/li&gt;
&lt;li&gt;GlusterFs Volume connected to the 3 servers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Yes, I know you are wondering now, this design makes our workers act as storage pool and clients at the same time, so they act as a replication for the data collected, and also works as servers that mount this volume and read from it, this may seem weird at first, but if you think about it, this can be a very good setup for a lot of use cases that your application may need. and it doesn't cost you any extra!&lt;/p&gt;
&lt;h4&gt;
  
  
  let's start the dirty work
&lt;/h4&gt;

&lt;p&gt;let's assume we are working with a Debian based distro, like ubuntu&lt;/p&gt;

&lt;p&gt;first, you will need to install glusterfs on all three worker machines&lt;br&gt;
you can do this by&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:gluster/glusterfs-7
sudo apt update
sudo apt install glusterfs-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then, you will need to start and enable the glusterfs daemon service on all the worker machines&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start glusterd
sudo systemctl enable glusterd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then, make sure you generate an ssh-key on each machine&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen -t rsa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;after that, to be able to deal with all machines with their hostnames, you will need to edit the &lt;code&gt;/etc/hosts&lt;/code&gt; for each of these machines and add the hostnames for the other nodes assigned to their IPs, like this format&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;IP1&amp;gt; &amp;lt;HOSTNAME1&amp;gt;
&amp;lt;IP2&amp;gt; &amp;lt;HOSTNAME2&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's create our storage cluster, start from one of the machines and add the others using this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo gluster peer probe &amp;lt;Hostname&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;after you add the 2 nodes, run this command to make sure that all of the nodes joined the storage cluster&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo gluster pool list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now, we will need to make a directory in all of the 3 workers to act like a brick for our volume&lt;br&gt;
But wait, what is a brick??&lt;br&gt;
a brick is basically a directory that acts as a volume unit, GlusterFs uses it in all of its storage pool nodes to know where is the data to store/deal with&lt;/p&gt;

&lt;p&gt;so basically you will need to create this directory on each worker node, let's name it &lt;code&gt;brick1&lt;/code&gt; and put it under &lt;code&gt;/gluster-volumes&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mkdir -p /gluster-volumes/brick1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we are ready to create our replicated volume (let's call it &lt;code&gt;demo-v&lt;/code&gt; )&lt;br&gt;
[run this command only on the main machine]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo gluster volume create demo-v replica 3 &amp;lt;HOSTNAME1&amp;gt;:&amp;lt;BRICK_DIRECTORY&amp;gt; &amp;lt;HOSTNAME2&amp;gt;:&amp;lt;BRICK_DIRECTORY&amp;gt; &amp;lt;HOSTNAME3&amp;gt;:&amp;lt;BRICK_DIRECTORY&amp;gt; force
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then start the volume&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo gluster volume start demo-v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and Congrats, you have a replicated volume now that ready to be mounted and used in any machine&lt;br&gt;
Now, let's mount this volume on our 3 workers&lt;br&gt;
let's say that we will mount our volume under &lt;code&gt;/our-application/logs&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mount.glusterfs localhost:/demo-v /our-application/logs/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then, to make it permanent, we will need to add it to our &lt;code&gt;fstab&lt;/code&gt; file&lt;br&gt;
so open &lt;code&gt;/etc/fstab&lt;/code&gt; and add this line&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
localhost:/demo-v /our-application/logs/ glusterfs defaults,_netdev,acl, backupvolfile-server=&amp;lt;HOSTNAME&amp;gt; 0 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;instead of the &lt;code&gt;&amp;lt;HOSTNAME&amp;gt;&lt;/code&gt; add a hostname of one of the worker machines you have, so if you needed to get it out of the storage pool, you can still mount the volume using the other machine.&lt;/p&gt;

&lt;p&gt;Now you can try this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch /our-application/logs/test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and check out the other workers, find the file? Congrats! you have a working replicated volume that is mounted across all of your workers.&lt;br&gt;
Any questions? leave a comment!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>glusterfs</category>
      <category>programming</category>
      <category>storage</category>
    </item>
    <item>
      <title>The Talkative creatures inside the silent beings' head (The SW Engineer mental health problems)</title>
      <dc:creator>Mohammed Ashour</dc:creator>
      <pubDate>Sat, 16 Jan 2021 15:11:13 +0000</pubDate>
      <link>https://dev.to/mohammedashour/the-talkative-creatures-in-the-silent-beings-head-the-sw-engineer-mental-health-problems-50h6</link>
      <guid>https://dev.to/mohammedashour/the-talkative-creatures-in-the-silent-beings-head-the-sw-engineer-mental-health-problems-50h6</guid>
      <description>&lt;p&gt;You wake up every day, checking your backlog, your tasks, your issues that are waiting for you to solve, it's exciting somedays, boring others, painful others, but most of the time you kinda like it, it's telling the story of you, your effect in the world. The solutions that you thought of, are making an impact somewhere for someone. This is exciting, yeah it is.&lt;/p&gt;

&lt;p&gt;Let me introduce myself, I'm a software engineer writing solutions in the Data and ML space, I'm also a researcher who tries so hard to find a problem so I can propose some solution to it, exciting life, isn't it?&lt;/p&gt;

&lt;p&gt;Beyond my tech intro, I kinda suck! who else am I? Is there another intro that I can tell others about myself besides my magical solution that I wrote to solve the problem we faced in the production? or that solution that made our product faster? or that open source project that I contributed to? What are my hobbies? What are hobbies? are they some sort of problems we can fix? If they aren't, how I deal with them? something is missing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dealing with silent creatures too much makes another one
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BUMLoH0S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fcqhuz7sqlznclkgco0r.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BUMLoH0S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fcqhuz7sqlznclkgco0r.jpg" alt="Alt Photo by Christina on Unsplash"&gt;&lt;/a&gt;&lt;br&gt;
Every day, I open my eyes, get my dose of caffeine, and start my journey this day with my everyday pal, my laptop, we are used to be silent, actually, we excel at it. &lt;br&gt;
TBH, it taught me how to be good at it. Dealing with a silent machine made me a one, and made me prefer their existence, my laptop, my phone, my books, I like spending my time with them, and they never complain.&lt;br&gt;
This isn't a problem? not for me at least, but for the ones inside my head, I don't think they like it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dealing with silent creatures too much created talkative ones trapped in my head
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oAsp4zVy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vx77km84w6qxwmhimq2b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oAsp4zVy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vx77km84w6qxwmhimq2b.jpg" alt="Alt Photo by Nicholas Kusuma on Unsplash"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I think this created some conflicts in my own being, being that social creature that prefers to be silent most of the time is kinda contradicting.&lt;br&gt;
Don't get me wrong, I don't mean that being silent is the problem, Personally, I think it's great not to be that annoying talkative person, but the thing I pointing to is being not able to express yourself, not able to talk out loud outside your inner zone, outside your inner world, with people that are outside your head.&lt;br&gt;
Yeah, I know you have these people that you are talking to them in your head right now, I know that because I have similar people of my own, we discuss everything that I can't discuss out loud, and these things are a lot.&lt;/p&gt;

&lt;h2&gt;
  
  
  The life problem of being trapped
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gp_UNYtj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ts1wdx0hbjc0dnbk76kd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gp_UNYtj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ts1wdx0hbjc0dnbk76kd.jpg" alt="Alt Photo by Sasha Freemind on Unsplash"&gt;&lt;/a&gt;&lt;br&gt;
Can you stop a moment and try to think of a good hobby you enjoy and practice?&lt;br&gt;
if you found one, good for you! if you haven't, what do you feel?&lt;br&gt;
you can ask your inner creatures now about how do they think about it? let me share with you what they are discussing now inside my head.&lt;br&gt;
One of them thinks that there is no problem here, asks the question of what are hobbies anyway? are they that important? what does it affect our life?&lt;br&gt;
another one replies that he thinks the main issue that we struggle to define ourselves outside being an SW Engineer, he thinks that there would be a problem if we quit this, a life problem of what are we now, and what do we do?&lt;br&gt;
another one thinks that may be the answer to all of this is to not think about it, maybe we should just keep ourselves busy with what we have, and then we won't have much time or energy to discuss this.&lt;br&gt;
There are other ones, but their ideas can't be shared without being concerned about how badly they can affect you as a reader, so let's skip them&lt;/p&gt;

&lt;h2&gt;
  
  
  So, What are you outside your commits?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BF1TS64r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vob7rartnh5ptrfex2ty.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BF1TS64r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vob7rartnh5ptrfex2ty.jpg" alt="Alt Photo by Matt Popovich on Unsplash"&gt;&lt;/a&gt;&lt;br&gt;
For me, I don't have an answer yet, maybe that is the middle age crisis that everybody is talking about, don't get me wrong I'm not the old, but maybe my folks inside my head are having one now.&lt;br&gt;
But what about you? Is there anything going on in your life outside your commits? so If I have gone through all your commits will I know the most about you and your life? or won't I?&lt;/p&gt;

&lt;h2&gt;
  
  
  Why?
&lt;/h2&gt;

&lt;p&gt;I don't know, I don't know why we should talk about it, and I don't know why I wrote this, maybe there is a different being in my head, one who is old enough to know much about who I was and wondering now about who am I. I couldn't answer, so I tried to solve it, I searched StackOverflow, found nothing! So I thought maybe should be writing about it.&lt;/p&gt;

</description>
      <category>mentalhealth</category>
      <category>swengineers</category>
      <category>life</category>
      <category>problemsolving</category>
    </item>
  </channel>
</rss>
