<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Navneet Nandan Jha on Medium]]></title>
        <description><![CDATA[Stories by Navneet Nandan Jha on Medium]]></description>
        <link>https://medium.com/@navneetnandanjha?source=rss-d0bfc67ca8cc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RT-7-JUKDyP8biE6.</url>
            <title>Stories by Navneet Nandan Jha on Medium</title>
            <link>https://medium.com/@navneetnandanjha?source=rss-d0bfc67ca8cc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 07:02:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@navneetnandanjha/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Avoid Single Point of Failure Using Keepalived]]></title>
            <link>https://medium.com/@navneetnandanjha/avoid-single-point-of-failure-using-keepalived-d32954d006b4?source=rss-d0bfc67ca8cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d32954d006b4</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[vrrp]]></category>
            <category><![CDATA[keepalived]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[apache]]></category>
            <dc:creator><![CDATA[Navneet Nandan Jha]]></dc:creator>
            <pubDate>Mon, 05 Aug 2019 19:28:20 GMT</pubDate>
            <atom:updated>2019-08-06T15:20:24.644Z</atom:updated>
            <content:encoded><![CDATA[<p>(Ansible Script is below of the page for deploying the Same with one click)</p><p>The <strong><em>keepalived</em></strong> daemon runs on both the active and passive LVS routers. All routers running <em>keepalived</em> use the Virtual Redundancy Routing Protocol (VRRP). The active LVS router serves two roles:</p><ul><li>To balance the load across the real servers.</li><li>To check the integrity of the services on each real server.</li></ul><p>The active (master) router informs the backup routers of its active status using the <em>Virtual Router Redundancy Protocol</em> (VRRP), which requires the master router to send out advertisements at regular intervals. If the active router stops sending advertisements, a new master is elected. Same is explained in the below diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*weFv1rVdWhiHh96HpftboQ.jpeg" /></figure><p>My Environment is below:<br><strong>keepalived server1</strong>: 192.168.43.90 Centos 7<br><strong>keepalived server2</strong>: 192.168.43.211 Centos 7<br><strong>Virtual IP:</strong> 192.168.43.149<br><strong>Disabled</strong>: SELinux and firewalld in both the servers<br>I installed <strong><em>httpd</em></strong> on both the servers and it is accessible using their respective IPs.</p><p><strong>Use Case:</strong><br>When my one router is down, It should route through the backup router so that there will not be any downtime and vice versa.</p><p>Keepalived takes configuration from /etc/keepalived/keepalived.conf file. This file mainly has two parts</p><p><strong>1. vrrp_script:</strong> The script will be executed periodically, every &lt;interval&gt; second. Its exit code will be recorded for all VRRP instances which monitor it. Note that the script will only be executed if at least one VRRP instance monitors it. The default weight equals 0, which means that any VRRP instance monitoring the script will transition to the fault state after &lt;fall&gt;consecutive failures of the script. After that, &lt;rise&gt; consecutive successes will cause VRRP instances to leave the fault state unless they are also in the fault state due to other scripts or interfaces that they are tracking.<br>A positive weight means that &lt;rise&gt; successes will add&lt;weight&gt; to the priority of all VRRP instances which monitor it. On the opposite, a negative weight will be subtracted from the initial priority in case of &lt;fall&gt; failures.</p><p><strong>2. vrrp_instance:</strong> A VRRP Instance is the VRRP protocol key feature. It defines and configures VRRP behavior to run on a specific interface. Each VRRP Instances are related to a unique interface.</p><p>reference is taken from <a href="https://www.keepalived.org/manpage.html">https://www.keepalived.org/manpage.html</a></p><p>keepalived configuration at server1 is below at /etc/keepalived/keepalived.conf</p><pre>#keepalived configuration</pre><pre>! Configuration File for keepalived<br>vrrp_script chk_apache2 {<br>    script &quot;killall -0 httpd&quot;<br>    interval 1<br>    rise 60<br>    fall 1<br>}</pre><pre>global_defs {<br>   notification_email {<br>     <a href="/service/mailto:nandanjha.navneet@gmail.com">nandanjha.navneet@gmail.com</a><br>   }<br>   notification_email_from <a href="/service/mailto:hello@blabla.com">hello@blabla.com</a><br>   smtp_server xxx.xxx.xxx.xxx<br>   smtp_connect_timeout 30<br>}</pre><pre>vrrp_instance VI_apache2_dcos_test {<br>    state MASTER<br>    interface enp0s3<br>    virtual_router_id 1<br>    smtp_alert<br>    priority 200<br>    advert_int 1<br>    unicast_src_ip 192.168.43.90<br>    unicast_peer {<br>        192.168.43.211<br>    }<br>    virtual_ipaddress {<br>        192.168.43.149<br>    }<br>    track_script {<br>        chk_apache2<br>    }</pre><p>keepalived configuration at server2 is below at <br>/etc/keepalived/keepalived.conf</p><pre>! Configuration File for keepalived<br>vrrp_script chk_apache2 {<br>    script &quot;killall -0 httpd&quot;<br>    interval 1<br>    rise 60<br>    fall 1<br>}</pre><pre>global_defs {<br>   notification_email {<br>     <a href="/service/mailto:nandanjha.navneet@gmail.com">nandanjha.navneet@gmail.com</a><br>   }<br>   notification_email_from <a href="/service/mailto:hello@blabla.com">hello@blabla.com</a><br>   smtp_server xxx.xxx.xxx.xxx<br>   smtp_connect_timeout 30<br>}</pre><pre>vrrp_instance VI_apache2_dcos_test {<br>    state MASTER<br>    interface enp0s3<br>    virtual_router_id 1<br>    smtp_alert<br>    priority 100<br>    advert_int 1<br>    unicast_src_ip 192.168.43.211<br>    unicast_peer {<br>        192.168.43.90<br>    }<br>    virtual_ipaddress {<br>        192.168.43.149<br>    }<br>    track_script {<br>        chk_apache2<br>    }</pre><p>Now start the keepalived in both the servers.</p><pre>systemctl start keepalived.service</pre><p>now if you do <strong><em>ip addr show, </em></strong>you will get that Virtual IP is enabled and you should be able to access the application using virtual IP.</p><p>Now if you down your Router1, Still Virtual IP will be enabled and traffic will go through the Backup Router. Explained in the below image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*s9zifYT8IRkDgjyONCxy9Q.jpeg" /></figure><p>Above example is a very basic implementation of Keepalived. There are other use cases where you want to use the same logic for Cluster Orchestrators, Load Balancers, etc.</p><h3>Bonus:</h3><p><a href="https://github.com/navneet066/keepalived">https://github.com/navneet066/keepalived</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d32954d006b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DC/OS Cheat Sheet]]></title>
            <link>https://medium.com/@navneetnandanjha/dc-os-cheat-sheet-e60afbd9e4c8?source=rss-d0bfc67ca8cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/e60afbd9e4c8</guid>
            <category><![CDATA[mesos]]></category>
            <category><![CDATA[marathon]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[dcos]]></category>
            <category><![CDATA[container-orchestration]]></category>
            <dc:creator><![CDATA[Navneet Nandan Jha]]></dc:creator>
            <pubDate>Fri, 12 Jul 2019 12:50:11 GMT</pubDate>
            <atom:updated>2019-07-12T12:50:11.362Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VYuxPkDzv70dRI5pAB-sRQ.png" /></figure><h4>1. The command for getting the configured Cluster from CLI</h4><pre>dcos cluster list</pre><h4>2. Verify Login Credentials</h4><pre>dcos auth login</pre><h4>3. Verify services running on the cluster</h4><pre>dcos service</pre><h4>4. Checking status of the connected nodes</h4><pre>dcos node list</pre><h4>5. Retrieve detailed information about the current master node leader</h4><pre>dcos node log --leader</pre><h4>6. Retrieve detailed information about a specific node</h4><pre>dcos node log --mesos-id &lt;nodeID&gt;</pre><h4>7. Search for the package from the DCOS catalog</h4><pre>dcos package search redis</pre><h4>8. Install the package using the below commnd</h4><pre>dcos package install &lt;PackageName&gt; --yes</pre><h4>9. Check the Status of a task from below command</h4><pre>dcos task</pre><h4>10. Review information for all deployed Marathon apps by running the following command</h4><pre>dcos marathon app list</pre><h4>11. Check the logs of a task</h4><pre>dcos task log &lt;taskName&gt;</pre><h4>12. You can also use dcos task to look up the Mesos ID for the any service, then open a secure shell using a command similar to the following:</h4><pre>dcos node ssh --master-proxy --mesos-id=dedbb786-feb7-47f2-ae69-27bf86ba53fb-S0</pre><pre>dcos node ssh --master-proxy --leader</pre><h4>13. Deploy the sample app</h4><pre>dcos marathon app add <a href="https://raw.githubusercontent.com/joerg84/dcos-101/master/app1/app1.json">https://raw.githubusercontent.com/joerg84/dcos-101/master/app1/app1.json</a></pre><h4>14. Create a single command service</h4><p>single-cmd-app-cli.json</p><pre>{<br>  &quot;id&quot;: &quot;/single-cmd-app-cli&quot;,<br>  &quot;cmd&quot;: &quot;sleep 10&quot;,<br>  &quot;instances&quot;: 1,<br>  &quot;cpus&quot;: 1,<br>  &quot;mem&quot;: 128,<br>  &quot;portDefinitions&quot;: [<br>    {<br>      &quot;protocol&quot;: &quot;tcp&quot;,<br>      &quot;port&quot;: 10000<br>    }<br>  ],<br>  &quot;requirePorts&quot;: false<br>}</pre><p>after creating the json, Run the below command to create app:</p><pre>dcos marathon app add single-cmd-app-cli.json</pre><h4>15. Create a simple containerized service</h4><p>Create a json container-app-cli.json</p><pre>{<br>  &quot;id&quot;: &quot;/container-hello-dcos-cli&quot;,<br>  &quot;instances&quot;: 1,<br>  &quot;cpus&quot;: 1,<br>  &quot;mem&quot;: 128,<br>  &quot;container&quot;: {<br>    &quot;type&quot;: &quot;DOCKER&quot;,<br>    &quot;docker&quot;: {<br>      &quot;image&quot;: &quot;mesosphere/hello-dcos:&lt;image-tag&gt;&quot;,<br>      &quot;forcePullImage&quot;: false,<br>      &quot;privileged&quot;: false<br>    }<br>  },<br>  &quot;acceptedResourceRoles&quot;: [&quot;slave_public&quot;],<br>  &quot;portDefinitions&quot;: [<br>    {<br>      &quot;protocol&quot;: &quot;tcp&quot;,<br>      &quot;port&quot;: 10001<br>    }<br>  ],<br>  &quot;requirePorts&quot;: false<br>}</pre><p>Start the service by running the following command:</p><pre>dcos marathon app add container-app-cli.json</pre><h3>DCOS Service Discovery</h3><p>When you create a service in DCOS, You can discover by two ways:</p><h4>1. Using Mesos-DNS</h4><p>Finding the host address</p><pre>dig @&lt;dcos-web-URL&gt; hello-world.marathon.mesos</pre><p>where hello-world is the app name. output of the above command will be similar to below:</p><pre>; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; @&lt;dcos-web-url&gt; hello-world.marathon.mesos<br>; (1 server found)<br>;; global options: +cmd<br>;; Got answer:<br>;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 35161<br>;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0</pre><pre>;; QUESTION SECTION:<br>;hello-world.marathon.mesos.	IN	A</pre><pre>;; ANSWER SECTION:<br>hello-world.marathon.mesos. 60	IN	A	172.31.2.2<br>hello-world.marathon.mesos. 60	IN	A	172.31.2.13</pre><pre>;; Query time: 147 msec<br>;; SERVER: 172.30.2.2#53(172.30.2.2)<br>;; WHEN: Fri Jul 12 16:10:00 IST 2019<br>;; MSG SIZE  rcvd: 76</pre><p>Finding the host service port (SRV) record</p><pre>dig @&lt;dcos-web-url&gt; _hello-world._tcp.marathon.mesos SRV</pre><p>output of the above command will be similar to below:</p><pre>; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; @&lt;dcos-web-url&gt; _hello-world._tcp.marathon.mesos SRV<br>; (1 server found)<br>;; global options: +cmd<br>;; Got answer:<br>;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 25034<br>;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2</pre><pre>;; QUESTION SECTION:<br>;_hello-world._tcp.marathon.mesos. IN	SRV</pre><pre>;; ANSWER SECTION:<br>_hello-world._tcp.marathon.mesos. 60 IN	SRV	0 1 7819 hello-world-4jei4-s12.marathon.mesos.<br>_hello-world._tcp.marathon.mesos. 60 IN	SRV	0 1 16794 hello-world-3x1xd-s0.marathon.mesos.</pre><pre>;; ADDITIONAL SECTION:<br>hello-world-3x1xd-s0.marathon.mesos. 60	IN A	172.31.2.13<br>hello-world-4jei4-s12.marathon.mesos. 60 IN A	172.31.2.2</pre><pre>;; Query time: 163 msec<br>;; SERVER: 172.30.2.2#53(172.30.2.2)<br>;; WHEN: Fri Jul 12 17:30:21 IST 2019<br>;; MSG SIZE  rcvd: 193</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e60afbd9e4c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>