<?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 Habibullah     on Medium]]></title>
        <description><![CDATA[Stories by Habibullah     on Medium]]></description>
        <link>https://medium.com/@habibullah.127.0.0.1?source=rss-efba4c9b0f00------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dsbMg45gp0bAw4-kIa8toA.png</url>
            <title>Stories by Habibullah     on Medium</title>
            <link>https://medium.com/@habibullah.127.0.0.1?source=rss-efba4c9b0f00------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 19:54:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@habibullah.127.0.0.1/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[Cloud and System Security | Haveged Feeding Entropy to Security Services]]></title>
            <link>https://medium.com/@habibullah.127.0.0.1/cloud-and-system-security-haveged-feeding-entropy-to-security-services-f749b36b4f65?source=rss-efba4c9b0f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/f749b36b4f65</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[entropy]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[Habibullah    ]]></dc:creator>
            <pubDate>Sat, 31 Jan 2026 18:55:01 GMT</pubDate>
            <atom:updated>2026-01-31T18:55:01.019Z</atom:updated>
            <content:encoded><![CDATA[<p>In modern cloud environments, cryptographic operations — like SSH, TLS, AES encryption, and Kerberos authentication — depend heavily on high-quality random numbers. Without sufficient entropy, key generation becomes predictable, leaving systems vulnerable to attacks. This is where Haveged comes in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*VkDtj9vIF5pcZAtXJTbylw.png" /><figcaption>Haveged Feeding Entropy to Security Services</figcaption></figure><p><strong>What is Haveged?</strong></p><p>Haveged (Hardware Volatile Entropy Gathering and Expansion Daemon) is a lightweight daemon that feeds the Linux kernel’s entropy pool using CPU timing jitter. Unlike traditional methods that rely on hardware events (disk, mouse, keyboard), Haveged ensures a constant supply of randomness, especially in virtualized or headless environments where entropy can be low.</p><p><strong>Why it matters:</strong></p><ul><li>SSH key generation requires randomness for secure private keys.</li><li>TLS/SSL sessions depend on unpredictable session keys.</li><li>AES encryption keys are only as strong as the entropy used to create them.</li></ul><p><strong>Where Haveged is most useful:</strong></p><p>Haveged shines in virtual machines, containers, and cloud environments, where traditional sources of randomness (keyboard, mouse, disk I/O) are minimal or absent. In these low-entropy systems, cryptographic operations can stall or generate weak keys. Haveged ensures a steady supply of randomness, making SSH connections faster, TLS sessions stronger, and encryption keys more secure, without adding significant overhead.</p><p><strong>Haveged and SSH Security</strong></p><p>SSH sessions rely on public-private key pairs, which need high-entropy random numbers to remain secure. Without enough entropy, weak keys can be generated, making it easier for attackers to brute-force or predict key values.</p><p><strong>Benefits of Haveged for SSH:</strong></p><ul><li>Faster key generation during server setup.</li><li>Reduced risk of predictable keys in VMs or containers.</li><li>Continuous replenishment of /dev/random entropy pool.</li></ul><p>You can check the available entropy on your VM. Before Haveged, this may be low; after starting Haveged, it rises significantly.</p><pre>cat /proc/sys/kernel/random/entropy_avail</pre><p><strong>TLS, SHA, and AES Encryption</strong></p><p>TLS, SHA hashing, and AES encryption all rely on cryptographic randomness. Poor entropy can compromise TLS session keys (man-in-the-middle attacks), weaken encryption keys, and salt for SHA-based password hashing</p><p><strong>Haveged ensures:</strong></p><ul><li>Session keys are unpredictable.</li><li>AES keys are strong and unique.</li><li>Salts for hashing remain robust.</li></ul><p>For example, below OS/Kernel randomness feeds entropy to Keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*LuqAn122dmPSY7OAkS8QcA.png" /><figcaption>Kernel entropy/ Hevedge</figcaption></figure><p><strong>Kerberos Authentication</strong></p><p>Kerberos tickets are generated using random session keys. Low entropy can allow attackers to predict ticket values, enabling replay or impersonation attacks.</p><p><strong>Haveged ensures:</strong></p><ul><li>Random session keys for Kerberos tickets.</li><li>Secure authentication in cloud and on-prem environments.</li><li>Reduced risk of offline attacks on TGTs (Ticket Granting Tickets</li></ul><blockquote><strong>Without sufficient entropy, every encryption risks becoming predictable — if your random source dries up, even the strongest algorithms will produce the same keys again and again.</strong></blockquote><p><strong>Containers and Cloud Security</strong></p><p>Containers and VMs often have limited entropy, especially immediately after booting. This can cause delays in cryptographic operations or weak key generation. Haveged is lightweight, making it ideal for:</p><ul><li>Kubernetes nodes</li><li>Docker containers</li><li>Cloud VMs</li></ul><p>Haveged is included in container entrypoints or init scripts to avoid entropy starvation.</p><h3><strong>Common Cases:</strong></h3><p><strong>Large clusters reported:</strong> API server pods slow to start, etcd TLS cert generation blocking</p><p><strong>&gt;&gt;&gt;Root cause: </strong>Low entropy inside cloud VMs.</p><p><strong>Microservices that:</strong> Generate TLS certs at startup, Use Java / OpenSSL, Containers stuck in Init state, Random startup delays</p><p><strong>&gt;&gt;&gt;Enterprise fix:</strong> Install haveged on the host.</p><p><strong>In badly designed systems:</strong> Multiple VMs boot from the same image, Keys generated before enough entropy exists</p><p><strong>&gt;&gt;&gt;Result:</strong> Identical or predictable keys across machines.</p><blockquote><strong>Enterprises don’t think about entropy until something breaks.</strong></blockquote><p>For example can install the havedge and put it as an entrypoint.</p><pre>RUN apt-get update &amp;&amp; apt-get install -y haveged</pre><pre>#!/bin/sh<br>haveged &amp;<br>exec &quot;$@&quot;</pre><p>In cloud and containerized environments, entropy is not guaranteed. Haveged doesn’t make encryption stronger; it makes randomness available when the system has none. Without it, cryptography waits… or worse, repeats.</p><p><strong>Conclusion:</strong></p><p>In cloud and containerized environments, entropy is a silent but critical component of security.</p><p><strong>Haveged ensures:</strong></p><ol><li>Faster, secure key generation</li><li>Strong TLS/AES encryption</li><li>Reliable Kerberos authentication</li><li>Better overall cryptographic resilience</li></ol><blockquote><strong><em>By integrating Haveged into your servers, containers, and cloud environments, you strengthen the foundation of system security with minimal overhead.</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f749b36b4f65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux capabilities with capsh: beyond root privileges]]></title>
            <link>https://medium.com/@habibullah.127.0.0.1/linux-capabilities-with-capsh-beyond-root-privileges-fc18cf3cd933?source=rss-efba4c9b0f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc18cf3cd933</guid>
            <category><![CDATA[systemd]]></category>
            <category><![CDATA[linux-capabilities]]></category>
            <category><![CDATA[linux-security]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Habibullah    ]]></dc:creator>
            <pubDate>Fri, 23 Jan 2026 18:27:32 GMT</pubDate>
            <atom:updated>2026-01-23T18:27:32.832Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why is the root vs non-root distinction outdated?</h4><p>Traditionally, Linux security was based on a binary trust model:</p><p><strong>root (UID 0)</strong> → can do everything</p><p><strong>non-root user → </strong>can do almost nothing</p><p>This model worked when Systems were simple, a few services ran on a machine, and Security threats were limited.</p><p>Now, let’s understand the problem with the root. The problem with root is that once a process becomes root, it can:</p><p><strong>&gt;&gt;&gt;</strong> Mount filesystems</p><p><strong>&gt;&gt;&gt;<em> </em></strong>Load kernel modules</p><p><strong>&gt;&gt;&gt;</strong> Change network configuration</p><p><strong>&gt;&gt;&gt;</strong> Read/write any file</p><p><strong>&gt;&gt;&gt;</strong> Bypass all permission checks</p><blockquote>In short, it’s almost dangerous to have this much power. <strong>Power is always dangerous; it attracts the worst.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D4eD-R8iElrPIUZMgayWKA.png" /><figcaption>linux capabilities | capsh | linux| root vs non root|linux security</figcaption></figure><p>From a security perspective, this creates two major security threats:</p><p><strong>1- Huge attack surface: </strong>A Service running on root is compromised, which means the whole system loses control.</p><p><strong>2-No principle of least privilege: </strong>Many services only need one privilege.</p><p>To fix this all-or-nothing problem, Linux has POSIX capabilities.</p><p>Instead of giving all privileges to UID 0, Linux splits root’s power into small, well-defined units, called capabilities. Examples:</p><p>cap_net_bind_service → bind to ports</p><p>cap_net_raw → use raw sockets</p><p>cap_sys_admin → mount, namespaces, kernel-level action</p><p>cap_setuid → change user IDs</p><p>Each capability represents one power specifically, so instead of saying this process is root trust, it is fully.</p><p>Linux can say this process is not root, but it is allowed to do one specific thing.</p><p>These capabilities are enforced by the kernel and checked during syscalls.</p><h3><strong>capsh</strong></h3><p>Where does the capability shell stand in all of this?</p><p>Capability shell is a tool that helps us to directly interact with these capabilities.</p><p>It does not create new security features — instead, it lets us:</p><ul><li>Inspect what the kernel sees</li><li>Modify capability sets for a process</li><li>Simulate real-world security models (containers, daemons)</li></ul><blockquote>Think of capsh as :<strong><em>A microscope for Linux process privileges.</em></strong></blockquote><h4><strong>Inspect — What can a process do?</strong></h4><p>This shows:</p><ul><li>What privileges does the shell currently have</li><li>What can it enable later</li><li>What the kernel will never allow (bounding set)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*ri8EZbmmWqrqdqMbYemA0A.png" /><figcaption>capsh — print</figcaption></figure><p>The power of a user is defined not by their name, but by the discrete capabilities the kernel permits their processes to exercise.</p><h4><strong>Drop — Enforce least privileges</strong></h4><p>capsh — drop=cap_sys_admin — print</p><p>Even though the shell runs as root:</p><ul><li>The dropped capability is <strong>gone</strong></li><li>The kernel will deny related syscalls.</li></ul><p>What am I without my soul, a body?</p><blockquote><strong>Root without capabilities is not real root.</strong></blockquote><p>Dropping capabilities is how:</p><ul><li>Containers harden workloads</li><li>Services limit damage after compromise</li><li>Security policies reduce blast radius</li></ul><h3>Capability Sets — How the Kernel Thinks</h3><p>To really understand capabilities, you need to understand <strong>capability sets</strong>. Every Linux process carries multiple sets, and the kernel checks them during sensitive system calls.</p><p>What can the process be used for right now?</p><p><strong>&gt;&gt;&gt; Effective:</strong> If a capability is <em>not</em> in the effective set, the syscall will fail — even if the capability exists elsewhere.</p><p><em>“Effective = active powers”</em></p><p><strong>&gt;&gt;&gt;Permitted:</strong> What the process may enable in the future. Think of it as a ceiling for the effective set.</p><p><strong>&gt;&gt;&gt;Inheritable:</strong> Capabilities that can be<strong> </strong>passed to child processes during exec(). By default, this set is usually empty unless explicitly configured.</p><p><strong>&gt;&gt;&gt;Bounding Set:</strong> The absolute maximum capabilities a process (and its children) can ever obtain. Once a capability is removed from the bounding set:</p><p>It can never be regained, not even by root. This is one of the strongest security controls in Linux</p><p><strong>&gt;&gt;&gt;Ambiant Set: </strong>Allows non-root processes to retain capabilities across exec without using setuid.This is heavily used by:</p><p>systemd services</p><p>containers</p><p>modern daemons</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*7Hj93uS3WK1CU9r4P1soaA.png" /></figure><blockquote>“<strong>The kernel does not care who you <em>are</em>.<br> It only cares what capabilities your process has.”</strong></blockquote><p>For example, dropping capabilities for root, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*oKqQbiwiNr2nqnLVhqtclQ.png" /><figcaption>capsh — drop=cap_sys_admin — print</figcaption></figure><p>Even if you are root:</p><p>&gt; mount() will fail.</p><p>&gt; Namespace creation will fail.</p><p>&gt; Many “admin” syscalls will be denied.</p><blockquote><strong>Security is not about who you are.<br> It’s about what you are allowed to do.</strong></blockquote><ul><li><strong>Containers (Docker/Kubernetes):</strong> Pods run with most capabilities dropped; removing cap_sys_admin is key to preventing container escapes.</li><li><strong>Kubernetes SecurityContext:</strong> Fine-grained control using “add” and “drop” capabilities instead of running containers as root.</li><li><strong>Systemd &amp; CI/CD agents:</strong> Services get only what they need (e.g., cap_net_bind_service) without full root access.</li><li><strong>Zero-Trust workloads:</strong> Capabilities enforce least privilege at the kernel level, reducing blast radius after compromise.</li></ul><blockquote><em>Modern infrastructure is secured not by who runs the process, but by which capabilities the kernel allows it to use.It’s about precisely defining power.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc18cf3cd933" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Hadoop: A Deep Dive into Distributed Data Processing]]></title>
            <link>https://medium.com/@habibullah.127.0.0.1/mastering-hadoop-a-deep-dive-into-distributed-data-processing-7bcf57e8ebfb?source=rss-efba4c9b0f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bcf57e8ebfb</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[hadoop]]></category>
            <category><![CDATA[hdfs]]></category>
            <category><![CDATA[hdfs-architecture]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Habibullah    ]]></dc:creator>
            <pubDate>Sat, 22 Mar 2025 16:59:46 GMT</pubDate>
            <atom:updated>2025-03-22T16:59:46.359Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Overview</strong></h3><p>Hadoop is an open-source framework for the parallel distributed storage and processing of large datasets. Developed by the Apache Software Foundation, it provides a scalable, fault-tolerant architecture that enables organizations to handle <strong>Big Data</strong> efficiently. At its core, Hadoop follows a <strong>MapReduce programming model</strong> and uses <strong>HDFS (Hadoop Distributed File System)</strong> for storage, ensuring seamless data processing across multiple nodes.</p><h3>Business Scenarios Where Hadoop is Used</h3><p>Hadoop is widely used in industries dealing with massive data volumes. Some everyday use cases include:</p><ol><li><strong>Telecom Industry</strong> — Call Data Records (CDR) processing, subscriber analytics, Billing systems, and fraud detection.</li><li><strong>Banking &amp; Finance</strong> — Risk modeling, real-time transaction monitoring, and fraud detection.</li><li><strong>E-commerce &amp; Retail</strong> — Recommendation engines, inventory management, and user behavior analysis.</li></ol><p>4.<strong> Social Media &amp; Web Analytics</strong> — Log processing, sentiment analysis, and targeted advertising.</p><h3>Key Features of Hadoop</h3><ul><li><strong>Scalability</strong> →Handles petabytes of data across multiple worker nodes.</li><li><strong>Fault Tolerance</strong> →Data replication across multiple nodes ensures reliability even if nodes fail.</li><li><strong>Cost-Effective</strong> →Uses commodity hardware, reducing infrastructure costs.</li><li><strong>High Throughput</strong> →Supports parallel processing with <strong>MapReduce</strong> processing.</li><li><strong>Flexibility</strong> →Can process structured, semi-structured, and unstructured data.</li></ul><h3>Hadoop Architecture</h3><p>Hadoop follows a <strong>Master-Slave</strong> architecture containing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ouEqy_US3JSXT3jHjT7Ypw.png" /><figcaption>Hadoop | Hadoop Architecture | HDFS</figcaption></figure><h3><strong>Main Components of Hadoop</strong></h3><p>1-<strong>HDFS (Hadoop Distributed File System)</strong></p><p>Stores large files across multiple machines. Composed of <strong>NameNode (Master)</strong> and <strong>DataNodes (Slaves OR Worker Nodes)</strong>.</p><p>2-<strong>MapReduce Framework</strong></p><p>A programming model that processes data in two steps: <strong>Map</strong> (splitting &amp; filtering) and <strong>Reduce</strong> (aggregating results).</p><p>3-<strong>YARN (Yet Another Resource Negotiator)</strong></p><p>Manages resource allocation and job scheduling across the cluster.</p><h3><strong>Architecture Components and their roles:</strong></h3><p>Below is a visual representation of the Hadoop architecture:</p><p>Hadoop follows a <strong>Master-Slave</strong> architecture, consisting of <strong>Master Nodes</strong> and <strong>Worker Nodes</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4AcIiGm3GATCv0MZzlw7VA.png" /><figcaption>Hadoop | Hadoop Architecture | HDFS | MapReduce | Yarn</figcaption></figure><h3><strong>1-Master Node Components</strong></h3><p>The Master node is responsible for <strong>coordinating</strong> the cluster, managing storage (HDFS), and scheduling jobs (YARN).</p><h4><strong>NameNode &amp; Secondary NameNode</strong></h4><p><strong>NameNode → </strong>Manages metadata and keeps track of file system hierarchy. It does not store actual data but maintains references to where files are stored.</p><p><strong>Secondary NameNode → </strong>Periodically saves metadata snapshots to prevent loss in case of NameNode failure.</p><h4><strong>YARN (Resource Manager)</strong></h4><p>Manages cluster resources and schedules application execution. Ensures optimal utilization by allocating CPU, memory, and processing power to different jobs.</p><h4><strong>MapReduce Server (Job History Server)</strong></h4><p>Stores logs and execution history of completed MapReduce jobs. Helps in debugging and analyzing past jobs</p><h3><strong>2-Worker Node Components</strong></h3><p>Worker nodes perform the actual data storage and processing tasks.</p><h4><strong>DataNode</strong></h4><p>Stores actual data blocks. Continuously communicates with the NameNode to report block locations and status.</p><h4><strong>Node Manager (YARN)</strong></h4><p>Manages resources on each worker node. Communicate with the YARN Resource Manager for job execution.</p><h4><strong>Application Master</strong></h4><p>Manages the lifecycle of applications running on Hadoop. Requests resources from YARN and monitors execution.</p><h4><strong>MapReduce Task Containers</strong></h4><p>Execute the Map and Reduce tasks within allocated containers. Tasks are dynamically assigned based on available resources.</p><h3>How These Components Work Together?</h3><ol><li><strong>Data Ingestion</strong>: Files are split into blocks and distributed across DataNodes.</li><li><strong>Job Execution</strong>: YARN assigns resources, and MapReduce processes data in parallel.</li><li><strong>Fault Tolerance</strong>: If a node fails, Hadoop reassigns tasks and retrieves data from replicated copies.</li></ol><p>Let’s explore every aspect of each module to see how things are working.</p><h3><strong>HDFS Internals</strong>:</h3><h4><strong>1. Block Storage and replication:</strong></h4><p>→ Files in HDFS are split into <strong>blocks (default 128MB/256MB)</strong> and distributed across <strong>DataNodes</strong>.</p><p>→ Each block is <strong>replicated (default factor: 3)</strong> to ensure data redundancy.</p><p>→ The <strong>NameNode</strong> keeps track of block locations, while <strong>DataNodes</strong> store actual data.</p><h4><strong>2. Write Pipeline in HDFS</strong></h4><p>To understand the pipeline in Hadoop first, you need to understand the rack awareness concept of Hadoop.</p><blockquote><strong>Note***: What is rack awareness in Hadoop?</strong></blockquote><blockquote><em>Rack awareness is a feature where the system is aware of the physical network topology, allowing it to distribute data and tasks intelligently across racks to improve fault tolerance, network performance, and overall cluster efficiency</em></blockquote><p>When a file is written:</p><p>→ The <strong>client</strong> contacts the <strong>NameNode</strong> for block allocation.</p><p>→ The NameNode selects <strong>three DataNodes</strong> (based on rack awareness).</p><p>→ Data flows from the <strong>client → first DataNode → second DataNode → third DataNode</strong> in a pipeline.</p><p>→ Once all DataNodes acknowledge the write, the block is considered <strong>successfully stored</strong>.</p><h4><strong>3. Read Process in HDFS</strong></h4><p>→ The client queries the <strong>NameNode</strong> to get block locations.</p><p>→ Data is fetched from the nearest available <strong>DataNode (data locality principle)</strong> to reduce network overhead.</p><h3><strong>YARN:</strong></h3><p>Yet another resource negotiator is the Hadoop resource management layer part, used for job scheduling.</p><h4><strong>1. Components of YARN:</strong></h4><p><strong>→ Resource Manager (RM)</strong> →Allocates cluster resources and schedules applications.</p><p><strong>→ Node Manager (NM)</strong> →Runs on each worker node, and manages resources locally.</p><p><strong>→ Application Master (AM)</strong> →Manages the execution of a specific application.</p><h4><strong>2. How Resource Allocation Works?</strong></h4><p>→ The <strong>Application Master</strong> requests resources from the <strong>Resource Manager</strong>.</p><p>→ The <strong>Scheduler</strong> in the resource manager assigns CPU &amp; memory based on availability and priority.</p><p><strong>→ Node Managers</strong> launch the allocated containers to execute the tasks.</p><h4><strong>3. Scheduling Policies in YARN</strong></h4><p><strong>→ FIFO Scheduler</strong> — Jobs are executed in First-In-First-Out order.</p><p><strong>→ Capacity Scheduler</strong> — Ensures fair resource allocation among multiple users.</p><p><strong>→ Fair Scheduler</strong> — Dynamically adjusts resources for fairness.</p><h3><strong>How Fault Tolerance Works in Hadoop?</strong></h3><p>Hadoop is designed to handle node failures without <strong>losing data or job progress</strong>.</p><h4><strong>1. HDFS Fault Tolerance</strong></h4><p><strong>→ Data Replication:</strong> If a DataNode fails, other replicas provide the missing data.</p><p><strong>→ Automatic Re-replication:</strong> The NameNode detects missing blocks and <strong>re-replicates</strong> them.</p><h4><strong>2. MapReduce Fault Tolerance</strong></h4><p><strong>→ Task Retry:</strong> Failed tasks are <strong>automatically restarted</strong> on another node.</p><p><strong>→ Speculative Execution:</strong> If a task is running slow, a duplicate is launched on another node.</p><h4><strong>3. Yarn Fault Tolerance</strong></h4><p><strong>→ Application Master Recovery:</strong> If the Application Master fails, it <strong>restarts automatically</strong>.</p><p><strong>→ Resource Manager HA:</strong> A standby RM takes over if the active one crashes.</p><h3><strong>How do Checkpoints help in fault tolerance?</strong></h3><blockquote><strong>Note***: what are checkpoints in Hadoop?</strong></blockquote><p>Checkpoints help in <strong>preventing metadata loss</strong> and <strong>speeding up NameNode recovery</strong>. Role of secondary NameNode</p><p>The <strong>Secondary NameNode</strong> takes periodic <strong>snapshots (checkpoints)</strong> of the <strong>NameNode‚ metadata</strong>.</p><p>These snapshots are stored as <strong>FsImage</strong> (file system image) and <strong>edit logs</strong>.</p><h4><strong>How its work?</strong></h4><ol><li>The <strong>Secondary NameNode</strong> merges the latest <strong>FsImage</strong> with the edit logs.</li><li>It saves the <strong>cleaned snapshot</strong> and provides it to the <strong>NameNode during recovery</strong>.</li><li>This <strong>prevents loss of metadata</strong> in case of NameNode failure.</li></ol><h3>Hadoop Data Flow &amp; Internal Communication Protocols:</h3><p>Hadoop operates as a distributed system where <strong>clients, NameNodes, DataNodes, and YARN components</strong> interact using various <strong>protocols</strong> for authentication, data transfer, and resource management. Below is a detailed step-by-step breakdown of how Hadoop handles <strong>data read, write, and internal communication</strong>(RPC) with a <strong>focus on protocols</strong> used at each stage.</p><blockquote><strong>RPC***=</strong> Remote procedure call acts like a low-level transport protocol for carrying data packets between communicating programs. It does this using a client-server model.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LGxadbEE_w1Dds6pAP3y7A.png" /><figcaption>Hadoop Communication protocols | RPC | HDFS | Hadoop</figcaption></figure><h3>Writing/Reading Data to HDFS (Hadoop RPC + HDFS Data Transfer Protocol)</h3><h4>Step 1: Client Requests File Upload</h4><p>The client <strong>contacts NameNode</strong> via <strong>Hadoop RPC</strong> to create a new file. NameNode checks Does the file already exist? Does the client have <strong>write permissions</strong>?</p><p><strong>Protocol Used </strong>= RPC</p><h4>Step 2: Data Transfer to DataNodes</h4><p>The <strong>client splits the file into blocks</strong> (default: 128MB each and also this is configurable). <strong>HDFS Data Transfer Protocol</strong> establishes a <strong>pipeline</strong> to transfer data.</p><p>Client → DataNode1 → DataNode2 → DataNode3</p><p>Each DataNode <strong>forwards the block</strong> to the next node to maintain replication (default: 3 copies).</p><p><strong>Protocols Used:</strong> HDFS Data Transfer Protocol, TCP/IP</p><h4>Step 3: DataNode Acknowledgement</h4><p>Each DataNode <strong>sends an ACK</strong> to the client via <strong>Hadoop RPC</strong> confirming block storage. The client <strong>notifies the NameNode</strong> that the writing is complete.</p><p><strong>Protocol Used </strong>= RPC</p><blockquote><strong>Why we are studying protocols?</strong></blockquote><blockquote>Protocols are the silent architects of distributed systems — understanding them is the key to unlocking how data moves, transforms, and scales efficiently.</blockquote><h3>Internal Node Communication (IPC + ZooKeeper + Netty)</h3><h4><strong>→ Heartbeats &amp; Block Reports (IPC + RPC)</strong></h4><p>DataNodes <strong>send heartbeats</strong> to the NameNode every <strong>3 seconds</strong> via <strong>Hadoop IPC (Inter-Process Communication)</strong>. Every 6 hours, DataNodes sends a <strong>Block Report</strong> to inform the NameNode about stored data.</p><p><strong>Protocols Used:</strong> IPC (for intra-cluster communication), Hadoop RPC</p><p><strong>Benefit:</strong> Keeps <strong>NameNode updated</strong> on cluster health.</p><h4><strong>→ Leader Election &amp; Cluster Coordination (ZooKeeper Protocol)</strong></h4><p>If the <strong>NameNode fails</strong>, Hadoop <strong>automatically elects a new leader</strong> using <strong>Apache ZooKeeper</strong>. ZooKeeper ensures that <strong>only one active NameNode</strong> manages metadata at a time.</p><p><strong>Protocols Used:</strong> <strong>ZooKeeper Consensus Protocol</strong></p><p><strong>Benefit:</strong> Ensures <strong>high availability</strong> and prevents metadata conflicts.</p><h4><strong>→ YARN Resource Management (Netty + RPC)</strong></h4><p><strong>Clients submit jobs</strong> to YARN’s <strong>Resource Manager via RPC</strong>. <strong>ResourceManager communicates with NodeManagers</strong> using <strong>Netty</strong> (an asynchronous RPC framework).</p><p><strong>NodeManagers allocate containers</strong> for running tasks.</p><p><strong>Protocols Used:</strong> Netty (for async messaging), RPC (for job scheduling)</p><h3>Fault Tolerance &amp; Checkpoints (ZooKeeper + Secondary NameNode + Replication Protocols)</h3><h4><strong>Handling NameNode Failure</strong></h4><p>The <strong>Secondary NameNode</strong> periodically stores <strong>checkpoints</strong> (metadata snapshots) of the <strong>active NameNode</strong>. If the <strong>primary NameNode fails</strong>, it can be restored from the latest checkpoint.</p><p><strong>Protocols Used:</strong> <strong>ZooKeeper for failover, HDFS Checkpoint Protocol</strong></p><h4><strong>Handling DataNode Failure</strong></h4><p>If a DataNode goes down, the <strong>NameNode detects the failure</strong> due to <strong>missing heartbeats</strong>. NameNode <strong>re-replicates lost data</strong> to other DataNodes using <strong>HDFS Replication Protocol</strong>.</p><p><strong>Protocols Used:</strong> <strong>HDFS Replication Protocol, TCP/IP</strong></p><h3>Conclusion</h3><p>Hadoop has revolutionized the way we handle large-scale data processing by providing a distributed, scalable, and fault-tolerant framework. With its core components — HDFS for storage, YARN for resource management, and MapReduce for processing — it ensures efficient data handling across clusters. The seamless communication between nodes, enabled by Hadoop’s robust RPC mechanisms and ZooKeeper coordination, makes it a powerful solution for big data challenges.</p><p>Understanding Hadoop’s internals is crucial for anyone working with large datasets, as it helps in optimizing performance, ensuring reliability, and leveraging its full potential. Whether in telecom, finance, or AI-driven analytics, Hadoop remains a key player in the world of big data.</p><p><strong><em>Mastering Hadoop isn’t just about using it — it’s about understanding how it works under the hood. Keep exploring, keep questioning, and let the data guide you forward!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bcf57e8ebfb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stateful vs. Stateless Applications: How Docker Volumes Make a Difference]]></title>
            <link>https://medium.com/@habibullah.127.0.0.1/stateful-vs-stateless-applications-how-docker-volumes-make-a-difference-e8e63324c2d8?source=rss-efba4c9b0f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8e63324c2d8</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[stateful-and-stateless]]></category>
            <category><![CDATA[stateful-vs-stateless]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[docker-volume]]></category>
            <dc:creator><![CDATA[Habibullah    ]]></dc:creator>
            <pubDate>Tue, 04 Feb 2025 18:16:48 GMT</pubDate>
            <atom:updated>2025-02-04T18:16:48.468Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OmtEDepONxEtPkhzdCYo3A.png" /><figcaption>Stateful vs stateless applications | Docker Volumes | Docker | Cotainer</figcaption></figure><h3>Why are we studying docker volumes?</h3><p>When you create and run a Docker container, any data written inside it is lost as soon as the container stops or is removed.</p><p>This ephemeral nature of container storage creates challenges when dealing with persistent data, such as databases, logs, or application state files.</p><h4>Why Is Container Storage Ephemeral?</h4><ol><li><strong>Container Lifecycle:</strong> A container is designed to be lightweight and temporary, meaning its filesystem is reset when the container is restarted.</li><li><strong>Isolation:</strong> Each container runs in an isolated environment, making sharing data across multiple containers difficult.</li><li><strong>Stateless Design:</strong> Many containerized applications follow a stateless model, meaning their state is not preserved across restarts unless explicitly stored elsewhere.</li></ol><h3>What Are Stateful Applications?</h3><p>A <strong>stateful application</strong> requires data persistence between different sessions or requests. The application&#39;s state is stored and must be retained even if the application restarts.</p><h4>Examples:</h4><ul><li><strong>Databases</strong> (MySQL, PostgreSQL, MongoDB) → Data needs to be stored persistently.</li><li><strong>User Sessions</strong> (e.g., Shopping Cart in an E-commerce website) → User data should be maintained across requests.</li><li><strong>Message Queues</strong> (e.g., Kafka, RabbitMQ) → Messages are stored until processed.</li></ul><h4>How Stateful Apps Use Docker Volumes:</h4><p>Stateful applications need <strong>Docker volumes</strong> to ensure data persists beyond container restarts. Example with MySQL:</p><pre>docker run -d --name mysql -v mysql_data:/var/lib/mysql mysql</pre><ul><li>The mysql_data volume ensures database files persist.</li><li>If the container restarts, the database remains intact.</li></ul><blockquote><strong>To overcome the limitations for stateful applications, Docker provides volumes a way to persist data beyond the container’s lifecycle.</strong></blockquote><h3>What Are Stateless Applications?</h3><p>A <strong>stateless application</strong> does not retain any user or session data between requests. Each request is processed independently without relying on past data.</p><h4>Examples:</h4><ul><li><strong>Web Servers</strong> (NGINX, Apache): Serve static files without storing session data.</li><li><strong>REST APIs</strong>: Process requests without keeping track of previous user interactions.</li><li><strong>Microservices: </strong>Stateless design enables scalability and resilience.</li></ul><h4>How Stateless Apps Work in Docker:</h4><p>Stateless applications do not need Docker volumes for persistence. They are often deployed in scalable environments like Kubernetes, where any instance can handle incoming requests.</p><pre>docker run -d --name web_server nginx</pre><ul><li>The NGINX server serves requests without needing persistent storage.</li><li>Multiple instances can be created for load balancing.</li></ul><h3>What Are Docker Volumes?</h3><p>Docker <strong>volumes</strong> are storage mechanisms managed by Docker to persist data even after a container stops or is removed. Unlike container filesystems, volumes are stored outside the container in /var/lib/docker/volumes/ (default location) and can be shared between multiple containers.</p><h3>How Do Docker Volumes Work?</h3><ul><li>A volume is created separately or when a container is started.</li><li>It is mounted inside the container at a specified path.</li><li>Any data written to this path is stored in the volume, ensuring persistence.</li></ul><p><strong>Creating and Using a Named Volume</strong></p><pre>docker volume create my_volume<br>docker run -d --name my_container -v my_volume:/data nginx</pre><ul><li>This creates a volume named my_volume.</li><li>It is mounted at /data inside the container.</li><li>Any data written to /data is persistently stored in my_volume, even if the container stops.</li></ul><p><strong>Sharing a Volume Between Multiple Containers</strong></p><ul><li>Both containers share the shared_data volume.</li><li>Any changes made by one container will be available to the other.</li></ul><p><strong>Removing a container</strong></p><pre>docker volume rm my_volume # Remove the my_volume<br>docker volume prune   # Removes all unused volumes</pre><h3>Conclusion!</h3><ul><li><strong>Docker volumes</strong> solve the problem of ephemeral storage by ensuring <strong>data persists</strong> beyond container lifecycles.</li><li><strong>Stateful applications</strong> (like databases) need persistent storage using volumes.</li><li><strong>Stateless applications</strong> (like web servers) do not require persistent storage, making them <strong>easier to scale</strong>.</li></ul><blockquote><strong>“Some things are meant to last, like your data. Others are better left ephemeral, like forgotten mistakes. Choose persistence where it matters!”</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8e63324c2d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Data Persistence: A Deep Dive into Docker Volumes and Kubernetes PV, PVC]]></title>
            <link>https://medium.com/@habibullah.127.0.0.1/mastering-data-persistence-a-deep-dive-into-docker-volumes-and-kubernetes-pv-pvc-b268f8da8fb1?source=rss-efba4c9b0f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/b268f8da8fb1</guid>
            <category><![CDATA[pv]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker-volume]]></category>
            <category><![CDATA[pvc]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Habibullah    ]]></dc:creator>
            <pubDate>Tue, 09 Jul 2024 21:32:31 GMT</pubDate>
            <atom:updated>2024-07-09T21:32:31.018Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D2FMol6iuMG3MQfeRWD_1Q.png" /><figcaption>Docker Volumes | K8’s PV | Kubernetes PVC</figcaption></figure><p><strong>Importance of Persistent Storage in Containerized environments:</strong></p><p>In containerized environments, where applications are broken down into smaller, portable units known as containers, persistent storage plays a critical role in maintaining data integrity, ensuring application reliability, and enabling stateful workloads. Here’s why persistent storage is important:</p><p><strong>Data Persistence</strong>: Unlike traditional virtual machines, containers are ephemeral by nature, meaning they don’t retain data once they are terminated. Persistent storage allows containers to store and retrieve data even after they are restarted or moved across different hosts.</p><p><strong>Stateful Applications</strong>: Many modern applications, such as databases, content management systems, and messaging queues, require persistent storage to maintain their state. Without persistent storage, these applications would lose critical data every time they restart or scale up/down.</p><p><strong>Data Sharing and Collaboration</strong>: In containerized environments, multiple containers may need access to the same set of data. Persistent storage provides a centralized location for storing shared data, facilitating collaboration among different components of an application stack.</p><p><strong>Data Integrity and Compliance</strong>: In industries where data integrity and regulatory compliance are paramount, such as finance and healthcare, persistent storage ensures that data is securely stored and can be audited for compliance purposes.</p><p><strong>High Availability and Disaster Recovery</strong>: By storing data persistently, organizations can implement high availability and disaster recovery strategies. Data redundancy and replication techniques can be applied to ensure continuous access to critical data even in the event of hardware failures or disasters.</p><h4><strong>Docker Volumes:</strong></h4><p>Docker volumes are a mechanism for persisting data generated by and used by Docker containers. They enable data to be shared between containers, as well as between the host machine and containers. Docker volumes are separate from the container’s filesystem and can persist even if the container is removed. They provide a way to manage data in Dockerized applications, allowing for greater flexibility and scalability.</p><h3>Docker Volumes (continued)</h3><p>There are several types of Docker volumes:</p><ol><li><strong>Anonymous Volumes</strong>: These are volumes that Docker creates automatically when a container starts. They are not explicitly named, making them difficult to manage if the container is deleted and restarted.</li><li><strong>Named Volumes</strong>: These volumes are explicitly created and managed by users. Named volumes can be reused by multiple containers and are not deleted automatically when a container stops.</li><li><strong>Host Volumes</strong>: These bind-mount a directory from the Docker host into a container. While this is useful for sharing data between the host and the container, it can be less secure and less portable compared to other volume types.</li></ol><p>Using Docker volumes involves several commands:</p><ul><li>To create a volume:</li></ul><pre>docker volume create &lt;volume_name&gt;</pre><ul><li>To list volumes:</li></ul><pre>docker volume ls</pre><ul><li>To inspect a volume:</li></ul><pre>docker volume inspect &lt;volume_name&gt;</pre><ul><li>To remove a volume:</li></ul><pre>docker volume rm &lt;volume_name&gt;</pre><p>Docker volumes can be used in more complex scenarios to enhance the functionality and flexibility of containerized applications.</p><h4>Volume Drivers</h4><p>Docker supports a variety of volume drivers that allow integration with external storage solutions. These drivers enable Docker volumes to leverage features provided by network-attached storage (NAS), cloud storage, or other external systems.</p><p><strong>Local Volume Driver</strong>: By default, Docker uses the local driver to create volumes on the host machine. While suitable for many scenarios, local volumes are limited to a single host.</p><p><strong>Network Volume Drivers</strong>: These drivers allow volumes to be stored on networked storage systems, enabling data sharing across different hosts. Examples include NFS, GlusterFS, and CIFS.</p><p><strong>Cloud Volume Drivers</strong>: Cloud providers often offer drivers that integrate Docker volumes with their storage services. Examples include AWS EFS (Elastic File System), Azure Files, and Google Cloud Filestore.</p><h4>Best Practices for Using Docker Volumes</h4><p><strong>Volume Naming Conventions</strong>: Use meaningful names for volumes to enhance clarity and maintainability, especially in environments with numerous volumes.</p><p><strong>Backup and Recovery</strong>: Regularly back up volumes, particularly those storing critical data. Use snapshot and backup features provided by external storage solutions.</p><p><strong>Security</strong>: Implement security best practices such as encryption at rest, secure access controls, and regular audits to protect sensitive data.</p><p><strong>Performance Optimization</strong>: Choose the appropriate storage backend and configure volume options to optimize performance based on your application’s requirements.</p><p><strong>Monitoring and Logging</strong>: Use monitoring tools to track volume usage, performance metrics, and potential issues. Implement logging for audit trails and troubleshooting.</p><h3>Kubernetes Persistent Volumes (PV)</h3><p>In Kubernetes, Persistent Volumes are resources in a cluster that provides storage to Pods. PVs are independent of the lifecycle of Pods, allowing data to persist even if the Pods using the PVs are deleted.</p><h4><strong>Key Features of PVs:</strong></h4><p><strong>Lifecycle</strong>: PVs have their own lifecycle, separate from Pods. This ensures that data stored in a PV is retained even if a Pod is terminated.</p><p><strong>Types of Storage</strong>: PVs can be backed by various storage systems, such as NFS, iSCSI, cloud provider storage systems (like AWS EBS, GCP Persistent Disks), and more.</p><p><strong>Provisioning</strong>: PVs can be statically or dynamically provisioned. Static provisioning requires an admin to create PVs manually, while dynamic provisioning allows Kubernetes to automatically create PVs as needed.</p><p><strong>Example PV: </strong>Some of the key parameters we defined in PV creation are like storage capacity, access mode and PVC Policy etc.</p><pre>apiVersion: v1<br>kind: PersistentVolume<br>metadata:<br>  name: my-pv <br>spec:<br>  capacity:<br>    storage: 10Gi #Specifies the size of the PV.<br>  accessModes:<br>    - ReadWriteOnce #Defines how the volume can be mounted by the host.<br>  persistentVolumeReclaimPolicy: Retain #Specifies what happens to the PV when the PVC is deleted <br>  storageClassName: manual<br>  nfs:<br>    path: /path/to/nfs<br>    server: nfs-server.example.com</pre><h3>Kubernetes Persistent Volume Claims (PVC)</h3><p>Persistent Volume Claims are requests for storage by users. A PVC specifies the desired size and access mode for the storage. PVCs enable users to abstract away the underlying storage details and focus on their storage needs.</p><p><strong>Binding</strong>: When a PVC is created, Kubernetes attempts to find a matching PV and binds them together. If no suitable PV exists, the PVC remains unbound until a suitable PV becomes available.</p><p><strong>Access Modes</strong>: PVCs can request different access modes, such as ReadWriteOnce (RWO), ReadOnlyMany (ROX), and ReadWriteMany (RWX).</p><p><strong>Storage Classes</strong>: PVCs can specify a storage class, which defines the quality of service, such as performance characteristics, for the storage.</p><h4>Best Practices for Managing Persistent Storage</h4><p><strong>Use Version Control</strong>: Track changes to your storage configuration using version control systems like Git. This allows for easier rollback and collaboration.</p><p><strong>Automate Backups</strong>: Implement automated backup solutions to ensure data is regularly backed up and can be restored quickly.</p><p><strong>Monitor Storage Usage</strong>: Regularly monitor storage usage to anticipate and address potential capacity issues before they impact application performance.</p><p><strong>Implement Security Measures</strong>: Ensure that data stored in volumes is encrypted, and access is controlled through robust authentication and authorization mechanisms.</p><p><strong>Choose the Right Storage Class</strong>: Use appropriate storage classes based on your performance and availability requirements to optimize cost and efficiency.</p><p><strong>Conclusion:</strong></p><p>Docker Volumes offer flexibility and scalability, allowing you to decouple storage from the container lifecycle, share data between containers, and leverage various storage back ends. By utilizing advanced features like volume drivers and plugins, you can integrate Docker with external storage solutions and optimize your application’s storage performance and reliability.</p><p>Kubernetes PVs and PVCs take persistent storage to the next level by abstracting storage management and enabling dynamic provisioning, access control, and multi-tenancy. With Kubernetes, you can automate storage provisioning, enforce security measures, and ensure data persistence across different environments and workloads.</p><p>By following best practices such as using version control, automating backups, monitoring storage usage, and implementing security measures, you can build a resilient and scalable storage infrastructure.</p><p>Embrace the power of Docker Volumes and Kubernetes PVs and PVCs to master data persistence and take your containerized applications to new heights.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b268f8da8fb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Efficient Log Management with rsyslog: From Concepts to Implementation]]></title>
            <link>https://medium.com/@habibullah.127.0.0.1/efficient-log-management-with-rsyslog-from-concepts-to-implementation-5743fbf73675?source=rss-efba4c9b0f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/5743fbf73675</guid>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[logging-and-monitoring]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[rsyslog]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[Habibullah    ]]></dc:creator>
            <pubDate>Sat, 23 Mar 2024 07:09:37 GMT</pubDate>
            <atom:updated>2024-03-23T07:09:37.087Z</atom:updated>
            <content:encoded><![CDATA[<p>In the era of system administration and DevOps, managing logs efficiently is crucial for monitoring, troubleshooting, and maintaining a system&#39;s health. rsyslog emerges as a powerful tool in this domain, offering a comprehensive solution for centralized logging management. In this guide, we&#39;ll delve into the concepts, architecture, client-server model, operational workflow, and practical setup of rsyslog for streamlining log management across distributed systems.</p><p><strong>Concepts of Logging and rsyslog</strong>: Before diving into the complexities of rsyslog, it&#39;s essential to understand the fundamental concepts of logging. Logging involves the recording of events, messages, and activities generated by various components within a system. These logs serve as a valuable source of information for diagnosing issues, tracking system behavior, and ensuring compliance with regulatory requirements.</p><p>rsyslog, an enhanced version of the traditional syslog utility introduces several advanced features and capabilities. Its modular architecture enables efficient processing, filtering, and forwarding of log messages, making it a preferred choice for system administrators and DevOps professionals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2cL2-AQQuWAK9OolrEuXtA.png" /><figcaption>rsyslog | rsyslog configuration | Logs Collection | Centralized Logs Collection</figcaption></figure><h4><strong>Architecture of rsyslog:</strong></h4><p>At its core, rsyslog operates on a “<strong><em>client-server model”</em></strong>, where it functions as both a client and a server to facilitate the transmission of log messages between systems.</p><p>1-Input Modules: Responsible for collecting log messages from different resources. Responsible for collecting log messages from various sources, such as local files, system logs, or remote devices.</p><p>2-Message Modification: Allows for the application of filters, templates, and message modifications to modify log messages according to specific requirements.</p><p>3-Output Modules: Facilitates the forwarding of processed log messages to their designated destinations, including local files, databases, or remote servers.</p><p>4-Rules Configuration: Enables administrators to define rules and policies for processing, filtering, and forwarding log messages based on predefined criteria.</p><h4><strong>How rsyslog Works:</strong></h4><p>The operational workflow of rsyslog involves the following steps:</p><p><strong>Collecting Logs</strong>: Log messages are collected from different sources, either locally or remotely, using input modules configured within rsyslog.</p><p><strong>Processing Logs</strong>: Upon receipt, log messages undergo processing, which may include filtering based on severity, content, or source, as well as message modification and formatting.</p><p><strong>Forwarding Logs</strong>: Processed log messages are then forwarded to their designated destinations, such as local storage, databases, or remote servers, based on configured rules and output modules.</p><p><strong>Reliability and Security</strong>: rsyslog ensures the reliable and secure transmission of log messages using protocols like <strong>UDP, TCP</strong>, or <strong>TLS</strong>, as well as encryption and authentication mechanisms.</p><h3>Setting Up rsyslog Client-Server Configuration:</h3><p>Configuring rsyslog for centralized logging involves the following steps:</p><p>First you to install rsyslog on both client and server. In case Debian based linux you can use these steps to install ryslog on both client and server.</p><pre>#Step 01<br>sudo apt-get update<br><br>#Step 02<br>sudo apt-get install rsyslog </pre><p>We can verify that rsyslog is successfully installed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GWOXH3_yzF-BnpEL1sNqVA.png" /><figcaption>Rsyslog | Install rsyslog | syslog</figcaption></figure><h4><strong>1-Server Configuration</strong>:</h4><p>Edit the <strong>rsyslog.conf </strong>file at <strong>/etc/rsyslog.conf</strong> on the server to define input sources, message processing rules, and output destinations. Restart the rsyslog service to apply the configuration changes.</p><p>To configure rsyslog as a server to collect logs from remote clients, you&#39;ll need to enable the TCP or UDP input modules and configure them to listen on the appropriate port. Here&#39;s what you can change in your configuration:</p><p><strong>Enable TCP/UDP syslog reception:</strong></p><p>Edit configuration file using any editor like Vim OR Nano and Make changes like this in <strong><em>rsyslog.conf</em></strong> file for TCP syslog reception module and input configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rd9G5r16rrVDcpfqAzD5WA.png" /><figcaption>rsyslog configuration | rsyslog.conf | rsyslog TCP configuration</figcaption></figure><p>And for TCP syslog reception module make changes like this in <strong><em>rsyslog.conf</em></strong> file and input configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kYXRa9M7K1p0VrlRAMrrIg.png" /><figcaption>rsyslog configuration | rsyslog.conf | rsyslog UDP configuration</figcaption></figure><p>By default, rsyslog listens only on the local host. If you want to listen on all network interfaces, ensure you have not configured any specific listening IP address. If you want to restrict listening to a specific interface, specify the IP address in the input configuration. For example, to listen on a specific interface with TCP:</p><pre>input(type=&quot;imtcp&quot; port=&quot;514&quot; address=&quot;xx.xx.xx.xx&quot;)</pre><p><strong>Firewall Rules and Port:</strong></p><p>Ensure firewall rules allow inbound traffic on the configured syslog port (default is <strong>514</strong> for both TCP and UDP).</p><p>After making changes in configuration file now restart the rsyslog service for the changes to take affect:</p><pre>sudo systemctl restart rsyslog</pre><p>With these changes in rsyslog server configuration, your rsyslog server should now be ready to receive logs from remote clients over TCP and/or UDP protocols. Make sure your clients are configured to send logs to the appropriate IP address and port.</p><h4><strong>2-Client Configuration</strong>:</h4><p>Similarly, configure the <strong>rsyslog.conf</strong> file located at <strong>/etc/rsyslog.conf</strong> on client systems to specify the remote rsyslog server(s) for forwarding log messages. Optionally, apply local filters or modifications before forwarding. Restart the rsyslog service on clients.</p><p>To configure client open the /etc/rsyslog.conf file using any editor like Vim OR Nano on your client machine for editing.</p><p>Add the following lines at the end of the file to specify the server where logs should be sent. Replace xx.xx.xx.xx:zz with the actual IP address of your rsyslog server and port:</p><p>To send logs over TCP use double “<strong><em>@@</em></strong>”.</p><pre>*.* @@xx.xx.xx.xx:514</pre><p>To send logs over UDP use single “<strong><em>@</em></strong>”.</p><pre>*.* @xx.xx.xx.xx:514</pre><p>Save the file and exit the editor.Restart the rsyslog service to apply the changes:</p><pre>sudo systemctl restart rsyslog</pre><p>With these changes, your client machine should now be configured to send logs to your rsyslog server at the specified IP address.</p><h4>Best Practices and Tips</h4><p><strong>Log Message Format Optimization</strong>:Standardize log message formats across different systems to ease parsing and analysis.Utilize structured logging formats like JSON or key-value pairs to enhance readability and enable easier querying and filtering.</p><p><strong>Remote Logging</strong>:Centralize log collection by configuring rsyslog to forward logs from multiple sources to a central server.Use TCP for remote logging to ensure reliable log delivery and minimize the risk of message loss compared to UDP.Implement encryption (e.g., TLS) for secure transmission of log data over networks, especially in environments with sensitive information.</p><p><strong>Security Considerations</strong>:Apply access controls and authentication mechanisms to restrict access to rsyslog configuration and log data, especially in multi-user or multi-tenant environments.Regularly update rsyslog and related components to patch security vulnerabilities and ensure compliance with security best practices.</p><h4>Rsyslog integration with monitoring systems:</h4><p>Rsyslog is a powerful logging system used in Unix and Linux systems for logging system messages. It can be integrated with various monitoring and analytics platforms like Elasticsearch, Logstash, Kibana (ELK stack), Splunk, Grafana, etc., to enhance log analysis and visualization capabilities.</p><p><strong>Set up Elasticsearch</strong>:Install and configure Elasticsearch on your server. Follow the official Elasticsearch documentation for installation instructions.</p><p><strong>Configure rsyslog to Forward Logs to Elasticsearch</strong>:Edit the rsyslog configuration file (/etc/rsyslog.conf) to specify Elasticsearch as the destination for your logs.Add an action in the rsyslog configuration to forward logs to Elasticsearch. This typically involves using the omelasticsearch module. Here&#39;s an example configuration:</p><pre>action(type=&quot;omelasticsearch&quot; server=&quot;xx.xx.xx.xx&quot; serverport=&quot;9200&quot; template=&quot;json-template&quot; searchIndex=&quot;rsyslog-index&quot; bulkmode=&quot;on&quot;)</pre><p>Replace xx.xx.xx.xx and <strong><em>9200</em></strong> with the appropriate Elasticsearch server and port.</p><p>Make sure Elasticsearch is running and accessible from your rsyslog server.Restart the rsyslog service to apply the configuration changes.Verify that logs are being forwarded to Elasticsearch by checking the Elasticsearch index for incoming log data.</p><p><strong>Install Grafana</strong>:Install Grafana on a separate server or the same server where Elasticsearch is installed. Follow the official Grafana documentation for installation instructions.</p><p><strong>Configure Grafana Data Source</strong>:Configure Grafana to connect to Elasticsearch as a data source. In the Grafana UI, add a new Elasticsearch data source.Enter the Elasticsearch URL and any authentication details if required. Test the connection to ensure it’s working.</p><p>Once the data source is configured, you can create dashboards in Grafana to visualize your log data stored in Elasticsearch.</p><p><strong>Conclusion: </strong>By understanding the fundamental principles of logging and leveraging the advanced features of rsyslog, such as its modular architecture and client-server model, organizations can streamline their log management processes effectively.However, efficient log management goes beyond just setting up rsyslog. It requires adherence to best practices and continuous optimization efforts. Standardizing log message formats, centralizing log collection, prioritizing security considerations, and integrating with monitoring systems are all crucial steps in this journey.</p><blockquote>“Log management might not be the sexiest part of your job, but it’s the backbone of a well-oiled machine. So, don’t sleep on the power of rsyslog! Dive in, get your hands dirty, and watch as your systems run smoother than ever before. Keep hustling, keep optimizing, and keep logging like a boss!”</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5743fbf73675" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Signals: The Hidden Language of DevOps Automation in k8 and Docker]]></title>
            <link>https://medium.com/@habibullah.127.0.0.1/signals-the-hidden-language-of-devops-automation-in-k8-and-docker-5c25f602247c?source=rss-efba4c9b0f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c25f602247c</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Habibullah    ]]></dc:creator>
            <pubDate>Sun, 03 Mar 2024 03:02:03 GMT</pubDate>
            <atom:updated>2024-03-03T03:02:03.566Z</atom:updated>
            <content:encoded><![CDATA[<p>In Linux, signals serve as a fundamental means of inter-process communication (IPC), allowing processes to notify each other of events or requests asynchronously. They are essentially software interrupts that can be sent to a process to trigger specific actions or to convey information about events occurring within the system.</p><p>Signals serve as a notification mechanism, informing a process about various events occurring within the system. These events could range from the termination of child processes to the availability of data on a socket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xKdwNLczPcHttjmm3zYZuA.png" /><figcaption>Kubernetes | Docker | Signals in Linux</figcaption></figure><p>How Linux signals are related to Kubernetes pod status and to Docker entry points ?</p><p>First we understand how signals work in Linux?</p><ul><li><strong>Signal Generation</strong>: Signals are generated by the kernel, by hardware, or by other processes. For example, a process can send a signal to another process using the “kill”command or programmatically using system calls like “kill()”.</li><li><strong>Signal Handling</strong>: Each process can specify how it handles various signals by setting up signal handlers. Signal handlers are functions that are executed when a signal is received. These handlers can perform custom actions, such as cleanup tasks or changing the behavior of the process.</li><li><strong>Default Actions</strong>: If a process does not specify a custom signal handler, the default action for the signal is taken. For example, the default action for the “<strong><em>SIGTERM</em></strong>”signal is to terminate the process.</li></ul><p>Inter-process communication (IPC) using signals typically involves one process sending a signal to another process to notify it of an event or request. For example, a parent process might send a “<strong><em>SIGUSR1</em></strong>&quot; signal to its child process to instruct it to perform a specific action.</p><p>Now relate these concepts with Docker and Kubernetes.</p><p><strong>Signals in Docker:</strong></p><p>Docker is a containerization platform that allows you to package applications and their dependencies into containers. Each Docker container has an entry point, which is the command or script that is executed when the container starts.</p><p>Signals can also be used within Docker containers, particularly in the context of the entry point script or command. For example, the entry point script of a Docker container might include signal handling logic to gracefully shut down the application running inside the container when it receives a specific signal, such as “<strong><em>SIGTERM”</em></strong>.</p><p>In Docker, the entry point is the command or script that is executed when the container starts. Signals can be utilized within the entry point script to handle shutdown signals gracefully. For Example there are two files, Dockerfile and entrypoint.sh.</p><pre># Dockerfile<br>FROM ubuntu<br><br># Copy entry point script<br>COPY entrypoint.sh /entrypoint.sh<br><br># Set entry point<br>ENTRYPOINT [&quot;/entrypoint.sh&quot;]</pre><pre># entrypoint.sh<br>#!/bin/bash<br><br># Define a signal handler function for SIGTERM<br>handle_signal() {<br>    echo &quot;Received SIGTERM signal, shutting down gracefully&quot;<br>    # Perform cleanup tasks here<br>    exit 0<br>}<br><br># Register the signal handler function<br>trap &#39;handle_signal&#39; SIGTERM<br><br># Start the main application<br>echo &quot;Starting application&quot;<br># Replace this with your actual application command<br>sleep infinity</pre><p>In this example, the entry point script “<strong><em>entrypoint.sh</em></strong>” registers a signal handler for “<strong><em>SIGTERM”</em></strong> using the “<strong><em>trap</em></strong>” command. When Docker sends a “<strong><em>SIGTERM”</em></strong> signal to the container, the entry point script executes the signal handler function, allowing the application to shut down gracefully.</p><p><strong>Signals in Kubernetes:</strong></p><p>In Kubernetes, pods are the smallest deploy able units that can be created and managed. A pod can contain one or more containers. Each pod in Kubernetes has a status, which indicates the current condition of the pod, such as <strong><em>Pending</em></strong>, <strong><em>Running</em></strong>, <strong><em>Succeeded</em></strong> or <strong><em>Failed</em></strong>.</p><p>Signals can be used internally by Kubernetes to manage pod status. For example, when a pod is scheduled to be terminated, Kubernetes sends signals to the containers within the pod to notify them of the impending termination, allowing them to perform cleanup tasks.</p><p>In Kubernetes, pods have different statuses indicating their current state. Signals can be used within Kubernetes to manage pod status transitions gracefully.</p><p>For example, when Kubernetes decides to terminate a pod, it sends a SIGTERM signal to the main process running inside the container. The container runtime then allows some time (configured by terminationGracePeriodSeconds) for the main process to gracefully shut down before forcibly terminating it with a SIGKILL signal.</p><p><strong>Four Golden Signals in Devops:</strong></p><p>Monitoring plays a crucial role in maintaining system health, detecting issues early, and ensuring a seamless user experience. Google introduced the concept of the Four Golden Signals in their Site Reliability Engineering (SRE) guide, providing a framework for effective monitoring strategies.</p><p><strong>1-Latency:</strong></p><p>Latency refers to the time taken for a system to respond to a request. It is a critical metric for measuring the responsiveness and performance of your applications. High latency can lead to poor user experience and dissatisfaction. Monitoring latency helps in identifying bottlenecks in the system, such as slow database queries, network issues, or resource constraints.</p><p>For example in a web application, you can monitor latency by tracking the response time for HTTP requests. Tools like <strong>Prometheus </strong>or <strong>Grafana</strong> can be utilized to collect and visualize latency metrics over time.By setting thresholds and alerts, you can proactively detect any spikes in latency and take corrective actions, such as optimizing database queries or scaling resources.</p><p><strong>2-Traffic:</strong></p><p>Traffic refers to the volume of requests or transactions processed by your system. Monitoring traffic helps in understanding the load on your infrastructure and capacity planning. Sudden spikes or drops in traffic can indicate changes in user behavior, marketing campaigns, or unexpected events.</p><p>For example you can monitor incoming requests per second or throughput metrics. By analyzing traffic patterns, you can anticipate peak loads and scale your infrastructure accordingly using auto-scaling mechanisms provided by cloud providers or container orchestration platforms like Kubernetes.</p><p><strong>3-Errors:</strong></p><p>Errors represent the rate of failed requests or transactions within your system. Monitoring errors is crucial for identifying bugs, misconfiguration, or external dependencies issues that impact the reliability of your applications.</p><p>For example Implementing centralized logging with tools like <strong>Splunk</strong> allows you to capture error logs and analyze error rates over time. By setting up alerts for critical errors or exceptions, you can promptly investigate and remediate issues before they escalate.</p><p><strong>4-Saturation:</strong></p><p>Saturation refers to the utilization of resources within your system, such as CPU, memory, disk, or network bandwidth. Monitoring saturation helps in identifying resource constraints and capacity bottlenecks before they impact performance.</p><p>For example Utilizing infrastructure monitoring tools like <strong>Nagios</strong> you can monitor system resource metrics such as CPU utilization, memory usage, and disk I/O. By setting up thresholds for resource utilization, you can detect instances of high saturation and take proactive measures such as load balancing, vertical scaling, or optimizing resource-intensive processes.</p><p><strong>Conclusion!</strong></p><p>In conclusion, signals serve as the hidden language of DevOps automation, facilitating seamless communication and coordination between processes in Docker and Kubernetes environments. Understanding how signals work in Linux, and their integration within Docker containers and Kubernetes pods, is crucial for ensuring reliable and efficient operations.</p><p>In Docker, signals can be utilized within entry point scripts to gracefully handle application shutdowns, while in Kubernetes, signals manage pod status transitions, enabling orderly termination and cleanup. By adhering to best practices, such as implementing signal handlers and testing signal handling mechanisms, DevOps teams can mitigate risks such as data corruption and ensure the smooth operation of their containerized applications.</p><p>Furthermore, the adoption of monitoring strategies, such as Google’s Four Golden Signals, enables DevOps practitioners to maintain system health, detect issues early, and optimize performance. By leveraging signals alongside robust monitoring practices, organizations can enhance their DevOps workflows, drive continuous improvement, and deliver a seamless user experience.</p><blockquote><strong><em>In wrapping up, remember: signals aren’t just the whispers of automation — they’re the secret handshake of DevOps.</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c25f602247c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harden your Linux server: Best practices for securing SSH,User Privileges, firewall configurations]]></title>
            <link>https://medium.com/@habibullah.127.0.0.1/harden-your-linux-server-best-practices-for-securing-ssh-user-privileges-firewall-configurations-b3c7f1007543?source=rss-efba4c9b0f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3c7f1007543</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[linux-server]]></category>
            <category><![CDATA[ssh]]></category>
            <dc:creator><![CDATA[Habibullah    ]]></dc:creator>
            <pubDate>Sat, 02 Mar 2024 11:00:02 GMT</pubDate>
            <atom:updated>2024-03-02T11:00:02.732Z</atom:updated>
            <content:encoded><![CDATA[<p>Securing your Linux server is of prime importance in today’s digital landscape where cyber threats are constantly evolving. Among the critical components to safeguard is the SSH (Secure Shell) service, which allows remote access to your server, and firewall configurations, which control network traffic. This guide explores best practices for hardening SSH, and firewall configurations on your Linux server to mitigate potential security risks effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WyPl_gFfapaVGrbDTIxKBA.png" /><figcaption>Harden Linux Server | Security Hardening | Secure Server | Protect Linux Server</figcaption></figure><p><strong>1-Update regularly:</strong></p><p>Ensure that your Linux distribution and all installed packages are regularly updated to patch known vulnerabilities.<br>Utilize package managers like apt, yum, or dnf(Next generation of YUM) to apply updates promptly as per required Linux distribution.<br>Regular updates help to close security loopholes and keep your server protected against emerging threats.</p><p>Update Debian/Ubuntu based Linux.</p><pre>sudo apt update<br>sudo apt upgrade</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ke74dTrDmiRb8J-j5zuIhw.png" /><figcaption>Update Debian/Ubuntu based Linux.</figcaption></figure><p>Update Cent-OS based Linux</p><pre>sudo yum update</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q3f_OK7PS2xlj6nFFPo3GA.png" /><figcaption>Update Cent-OS based Linux</figcaption></figure><p><strong>2-Strong Passwords and SSH Keys:</strong></p><p>Enforce the use of strong, complex passwords for SSH authentication.<br>Consider implementing two-factor authentication (2FA) to add an extra layer of security.<br>Preferably, use SSH key pairs for authentication instead of passwords, as they offer greater security.<br>Securely manage and store SSH private keys, and regularly rotate them as a security best practice.</p><p>Generate an ssh key pair to login to server:</p><pre>ssh-keygen -t rsa -b 4096</pre><p>Copy the public key to server:</p><pre>ssh-copy-id username@server_ip</pre><p>Disable password authentication and enable only SSH key-based authentication by editing this file using vi editor /etc/ssh/sshd_config:</p><pre>PasswordAuthentication no<br>PermitRootLogin no</pre><p>Now run the command to reload ssh service to make the changes affective.</p><pre>sudo systemctl reload sshd</pre><p><strong>3-Modify SSH Port:</strong></p><p>Modify ssh port at /etc/ssh/sshd_config, the default port of ssh is 22 we can modify it to our desired port:</p><pre>Port 2222</pre><p>We can use iptables to allow ssh access only from specific IP addresses like this, just change the trusted_ip_address to the ip from which you want to allow to access the server.</p><pre>sudo iptables -A INPUT -p tcp --dport 2222 -s trusted_ip_address -j ACCEPT<br>sudo iptables -A INPUT -p tcp --dport 2222 -j DROP<br>sudo iptables-save &gt; /etc/iptables/rules.v4</pre><p>Now run the command to reload ssh service to make the changes affective.</p><pre>sudo systemctl reload sshd</pre><p><strong>4-Using Firewalls to protect server</strong></p><p>For Debian based Linux distors:</p><p>“<strong>ufw</strong>” is designed to be an easy-to-use interface for managing iptables firewall rules on Ubuntu/Debian systems. These commands specifically allow inbound traffic on ports 80 (HTTP) and 443 (HTTPS), which are essential for web servers. Enabling ufw at the end ensures that these rules are enforced.</p><pre>udo ufw allow 80/tcp<br>udo ufw allow 443/tcp<br>sudo ufw enable</pre><p>For Cent-OS based Linux distros:</p><p>“<strong>firewalld</strong>” is a dynamic firewall management tool used in CentOS/RHEL systems. These commands configure the firewall to allow incoming traffic on ports 80 (HTTP) and 443 (HTTPS) in the ‘public’ zone, which is typically used for connections from the internet. The — permanent flag makes these changes persistent across firewall restarts, and — reload ensures that the new rules are activated without restarting the firewall service.</p><pre>sudo firewall-cmd --zone=public --add-service=http --permanent<br>sudo firewall-cmd --zone=public --add-service=https --permanent<br>sudo firewall-cmd --reload</pre><p><strong>5-Disable Root login</strong></p><p>Prohibit direct root login via SSH to minimize the risk of unauthorized access.Instead, create a standard user account with sudo privileges for administrative tasks. This practice mitigates brute-force attacks targeting the root account.</p><p>Create a new user with name you want:</p><pre>sudo adduser &lt;username&gt;</pre><p>Assign administrative privileges to the user:</p><pre>sudo usermod -aG sudo &lt;username&gt;</pre><p>Open the SSH server configuration file /etc/ssh/sshd_config and change disable root login.</p><pre>PermitRootLogin no</pre><p>Now reload the ssh service again using “sudo systemctl reload sshd”.</p><p><strong>6-Enabling Only One User for Login</strong></p><p>This could involve modifying the SSH configuration file as well. The tool may use the AllowUsers directive to specify the username allowed for SSH login. It would list only one user account here, but you can as many you want.</p><p>Edit this file /etc/ssh/sshd_config using any editor like nano or vi.</p><p>Within the SSH configuration file, locate the “AllowUsers” directive. If it doesn&#39;t exist, you can add it. This directive specifies which users are allowed to connect via SSH. Add the username of the user you want to allow for SSH login after the “AllowUsers”directive. If you want to allow only the user “habibi”, your directive would look like:</p><pre>AllowUsers habibi</pre><p>If you want to allow multiple users to login to your server, you can list them separated by spaces:</p><pre>AllowUsers habibi habibi2 habibi3</pre><p>Now Restart the ssh service “sudo systemctl reload sshd” to make the changes take affect.</p><p><strong>7-Effective Monitoring strategies:</strong></p><p><strong>System Activity Monitoring:</strong> Utilize tools like auditd, a Linux audit framework, to monitor system calls, file accesses, and other critical activities. Set up alerts for suspicious events to promptly respond to potential security threats.</p><p><strong>Network Traffic Analysis: </strong>Deploy intrusion detection systems (IDS) and network monitoring tools to monitor incoming and outgoing network traffic. Analyze network logs to identify unauthorized connections, port scans, or other malicious activities.</p><p><strong>Log File Monitoring:</strong> Regularly review system logs, including syslog, auth.log, and kernel logs, for signs of unauthorized access, privilege escalation, or abnormal system behavior. Consider implementing log management solutions for centralized log aggregation and analysis.</p><p><strong>File Integrity Monitoring:</strong> Implement file integrity monitoring (FIM) tools to monitor changes to critical system files and directories. Any unauthorized modifications could indicate a security breach or malware infection.</p><p><strong>User Activity Monitoring:</strong> Monitor user login/logout events, sudo commands, and privilege escalation attempts to detect suspicious user behavior or insider threats.</p><p><strong>8-Regular Backup Strategy for your linux server :</strong></p><p>Implement a comprehensive backup strategy to ensure data integrity and availability in case of security breaches or system failures. Backup your data regularly and store it securely, preferably offsite.</p><p>For Example,here is is a simplified shell script “script.sh” to create a daily backup of the directory, deleting the oldest backup after seven days. The script will run every day at 10 in the morning.</p><pre>#!/bin/bash<br>backup_dir=&quot;/path/to/backup/directory&quot;<br>source_dir=&quot;/habibi&quot;<br>create_backup() { # Function to create backup.<br>    mkdir -p &quot;$backup_dir&quot;<br>    timestamp=$(date +%Y%m%d%H%M%S)<br>    tar -czf &quot;$backup_dir/habibi_backup_$timestamp.tar.gz&quot; &quot;$source_dir&quot;<br>}<br>delete_oldest_backup() {# Function to delete oldest backup of 7 days.<br>    cd &quot;$backup_dir&quot; || exit<br>    backup_count=$(ls -1 | grep habibi_backup | wc -l)<br>    if [ &quot;$backup_count&quot; -gt 7 ]; then<br>        oldest_backup=$(ls -1t | grep habibi_backup | tail -n 1)<br>        rm &quot;$oldest_backup&quot;<br>    fi<br>}<br>create_backup<br>delete_oldest_backup</pre><p>Now Setup the cron job to run this script every day at at 10(You can choose whatever time you want to take backup of server).</p><p>To add this cron job, open your crontab file by running “crontab -e” and paste the above line at the end of the file. Save and exit the editor. This will schedule the script to execute daily at 10:00 AM.</p><pre>0 10 * * * /path/to/your/script.sh</pre><p>In conclusion, securing your Linux server involves many different aspects, like SSH, user privileges, firewalls, monitoring, and backups. By following the steps outlined in this guide, including regular updates, strong passwords and SSH keys, changing SSH ports, setting up firewalls, disabling root login, monitoring system activities, and creating backups, you can make your server much safer. It’s important to stay alert and take action to protect your server from evolving threats.</p><p>Just stick to the tips I’ve given you: update regularly, use tough passwords and SSH keys, tweak those SSH ports, set up firewalls, say no to root login, keep an eye on what’s happening, and don’t forget those backups. Stay sharp and stay ahead of the game — ain’t nobody got time for cyber threats messing with your server!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3c7f1007543" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Minikube: A Step-by-Step Tutorial for Kubernetes Enthusiasts]]></title>
            <link>https://medium.com/@habibullah.127.0.0.1/demystifying-minikube-a-step-by-step-tutorial-for-kubernetes-enthusiasts-6646c9999588?source=rss-efba4c9b0f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/6646c9999588</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[minikube]]></category>
            <category><![CDATA[minikube-install-ubuntu]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubectl]]></category>
            <dc:creator><![CDATA[Habibullah    ]]></dc:creator>
            <pubDate>Sun, 14 Jan 2024 10:23:23 GMT</pubDate>
            <atom:updated>2024-01-14T10:23:23.827Z</atom:updated>
            <content:encoded><![CDATA[<p>In the expansive landscape of Kubernetes development, Minikube emerges as a powerful ally for developers seeking a streamlined and accessible way to create and manage Kubernetes clusters. Whether you’re a novice in the Kubernetes universe or an experienced developer looking for a hassle-free local development environment, Minikube is your gateway to a seamless experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OS2XpqczRUMGUS3QbkRuMg.png" /><figcaption>Minikube | Minikube Installation | Minikube Commands</figcaption></figure><p><strong>Minikube?</strong></p><p>At its core, Minikube is a lightweight, open-source tool designed to run Kubernetes clusters on a single machine. It simplifies the process of setting up, managing, and testing Kubernetes applications by providing a local, isolated environment that mirrors the behavior of a full-scale Kubernetes cluster.</p><p><strong>Why Minikube Matters?</strong></p><p><strong>Ease of Use:</strong> Minikube abstracts away the complexities of configuring a full-scale Kubernetes cluster, allowing developers to focus on building and deploying applications.</p><p><strong>Local Development:</strong> With Minikube, you can develop and test Kubernetes applications on your local machine before deploying them to a production environment. This accelerates the development cycle and enhances iteration speed.</p><p><strong>Learning and Experimentation:</strong> Minikube serves as an ideal playground for learning Kubernetes concepts and experimenting with different configurations. It provides a risk-free environment for developers to explore and understand Kubernetes intricacies.</p><h3><strong>Minikube Installation on Linux:</strong></h3><h4><strong>Step 1: Prerequisites</strong></h4><p>Ensure that you have a hypervisor installed on your system. Minikube supports various hypervisors such as VirtualBox, KVM, and others.</p><pre>sudo apt-get install virtualbox </pre><h4>Step 2: Install kubectl</h4><p>Install “kubectl”, the command-line tool for interacting with Kubernetes clusters. You can install it using a package manager, e.g., for Ubuntu:</p><pre>sudo apt-get update &amp;&amp; sudo apt-get install -y kubectl</pre><h4><strong>Step 3: Download and Install Minikube</strong></h4><p>Find the latest stable release, copy the link to the binary for your architecture, and download it using curl.</p><pre>curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64</pre><h4>Step 5: Move Minikube to the Executable Path</h4><p>Make the Minikube binary executable and move it to a directory included in your PATH.</p><pre>sudo chmod +x minikube-linux-amd64<br>sudo mv minikube-linux-amd64 /usr/local/bin/minikube</pre><h4>Step 6: Verify Installation</h4><p>Confirm that Minikube is installed correctly by running:</p><pre>minikube version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zgIzpCHSlmTFZizdJBQ1nQ.png" /><figcaption>Minikube Installation</figcaption></figure><h4>Step 7: Start Minikube</h4><p>Initiate Minikube with your preferred hypervisor. For VirtualBox, the command would be:</p><pre>minikube start --vm-driver=virtualbox</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FNRqLMoqR8Sp22EaHXhsWA.png" /><figcaption>Minikube Installation | Minikube start</figcaption></figure><h4>Step 8: Verify Kubernetes Cluster</h4><p>Check the status of your Minikube cluster:</p><pre>minikube status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ft3_sdDNih61Ehx3RYvFkA.png" /><figcaption>Minikube Installation | Minikube status</figcaption></figure><h4><strong>Accessing Kubernetes Dashboard:</strong></h4><p>Now you can access the Kubernetes dashboard using.</p><pre>minikube dashbaord</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PLkOur8Q5NCpIRulOT4s4A.png" /><figcaption>Minikube Installation | Minikube dashboard</figcaption></figure><p>This is how minikube dashboard will look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2FNKHWEoYnfdI6V4qkPnqA.png" /><figcaption>Minikube Dashboard | Minikube Installation</figcaption></figure><p>Congratulations! You’ve successfully installed Minikube on your Linux machine. In the upcoming sections, we’ll delve into practical usage, deploying applications, and leveraging the power of Minikube for Kubernetes development.</p><h3>Deploying Applications:</h3><p>For Example: we’ll deploy the popular web server nginx. You can use any other containerized application.</p><h4><strong>Step 01: Run Deployment Command:</strong></h4><p>Open your terminal and run the following command to deploy nginx to your Minikube cluster:</p><p>This command creates a deployment named “habibi-nginx”using the nginx Docker image.</p><pre>kubectl create deployment habibi-nginx --image=nginx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eoEqOgLuWW21TaULebRFhw.png" /><figcaption>Kubernetes deployment</figcaption></figure><h4><strong>Step 02: Get Deployments:</strong></h4><p>Confirms that the deployment is running and shows the desired and current replicas.</p><pre>kubectl get deployments</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wWhQpMNJqOfQS5wWx9kGbQ.png" /><figcaption>Kubernetes Deployment</figcaption></figure><h4><strong>Step 03: Expose the Deployment:</strong></h4><p>Create a service and exposes it externally to internet via NodePort.</p><pre>kubectl expose deployment habibi-nginx --type=NodePort --port=80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQmGpxjiQ23yHnikoqd_uA.png" /><figcaption>Kubernetes Deployment | Minikube</figcaption></figure><h4><strong>Step 04: Check Service Status:</strong></h4><p>Confirm that the service is running:</p><pre>kubectl get services</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eKkHjzlm5iYTMF_-Nm3kdA.png" /><figcaption>Minikube | Minikube Service</figcaption></figure><h4><strong>Access the Nginx Application:</strong></h4><p>Open a web browser and navigate to “http://&lt;minikube-ip&gt;:&lt;nodeport&gt;”(replace &lt;minikube-ip&gt;and “nodeport”with your Minikube IP and the NodePort from the previous step). You should see the default Nginx welcome page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ohveyaXLCJxkRUH6yGW3Q.png" /><figcaption>Minikube | Nginx</figcaption></figure><h3>Scaling Deployment:</h3><p><strong>Scale the Deployment: </strong>Increase the number of replicas for the deployment. For example, scale to 2 replicas:</p><pre>kubectl scale deployment my-nginx --replicas=2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gVg65B8fLoELcrJyg_hzFQ.png" /><figcaption>Scaling Deployment | Minikube | Kubernetes</figcaption></figure><p>Here we can also check in the minikube dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lkrAUzs78bApBSxIYsWliQ.png" /><figcaption>Minikube Dashboard</figcaption></figure><p>Congratulations! You’ve successfully deployed a simple application (nginx) to Minikube and learned how to scale the deployment.</p><p><strong>Common Commands:</strong></p><p>Get detailed information about a pod:</p><pre>kubectl describe pod &lt;pod-name&gt;</pre><p>View the recent events related to your pod to identify any issues:</p><pre>kubectl get events --sort-by=&#39;.metadata.creationTimestamp&#39;</pre><p>Examine the pod’s configuration to ensure it is correctly defined:</p><pre>kubectl get pod &lt;pod-name&gt; -o yaml</pre><p>Verify the resource usage of your pod using:</p><pre>kubectl top pod &lt;pod-name&gt;</pre><p><strong>Conclusion:</strong></p><p>At its core, Minikube presents itself as a lightweight, open-source tool tailored for running Kubernetes clusters on a single machine. By simplifying the intricate tasks of setup, management, and testing of Kubernetes applications, Minikube provides a local, isolated environment that faithfully mirrors the behavior of a fully-fledged Kubernetes cluster.</p><p>Minikube alleviates the complexities of configuring a full-scale Kubernetes cluster, allowing developers to direct their focus towards the essential tasks of building and deploying applications.With Minikube, the ability to develop and test Kubernetes applications on your local machine before venturing into a production environment accelerates the development cycle, fostering a culture of rapid iteration and refinement.</p><p>Congratulations on demystifying Minikube — may your Kubernetes endeavors continue to thrive in this era of containerized innovation! Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6646c9999588" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes: Understanding the basic components of Kubernetes]]></title>
            <link>https://medium.com/@habibullah.127.0.0.1/kubernetes-understanding-the-basic-components-of-kubernetes-f4b1e9781465?source=rss-efba4c9b0f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4b1e9781465</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubernetes-architecture]]></category>
            <category><![CDATA[ingress]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[k8s]]></category>
            <dc:creator><![CDATA[Habibullah    ]]></dc:creator>
            <pubDate>Sat, 13 Jan 2024 18:18:51 GMT</pubDate>
            <atom:updated>2024-01-13T18:18:51.696Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JqVo3aYEn9Xaqcftg3hQOg.png" /><figcaption>Kubernetes | K8’s | K8’s Architecture | MIniKube</figcaption></figure><p><strong>Definition</strong></p><p>Kubernetes is the most popular open source container orchestration tool developed by google.Automates many processes involved in deploying, managing and scaling containerized applications.It’s the most used container orchestration tool and also known as K8 or Kube.</p><p><strong>Need for K8</strong></p><p>Kubernetes is like the conductor of an orchestra, making sure all the different instruments (or components) play in harmony. As applications grow and become more complex, managing them manually can be like juggling flaming torches — it’s impressive until something goes wrong. Kubernetes swoops in to save the day by automating the deployment, scaling, and management of containerized applications.</p><p>Think of it as your personal assistant for handling containers. It ensures that your apps run consistently across different environments, scales effortlessly to meet demand, and recovers gracefully from failures. Plus, it plays well with various cloud providers and technologies, making it a versatile tool for modern app development.</p><p>The Trend from <strong>“Monolithic to Micro services” </strong>brings a multitude of benefits, but it also introduces new challenges in terms of managing and orchestrating numerous containerized services.Micro-services provide a more flexible and scalable approach. Each micro-service can be developed, deployed, and scaled independently. But with great power comes great complexity.In essence, Kubernetes is like the wise sage overseeing a bustling city of containers, ensuring they communicate effectively, scale efficiently, and stay resilient in the face of challenges. So, as the trend towards micro-services continues, the need for Kubernetes grows hand in hand to maintain order in the containerized chaos.</p><p><strong>Core Components of Kubernetes:</strong></p><p>Kubernetes is like a well-organized city with various components working together to keep things running smoothly. Here are some of the main components:</p><p><strong>1-Pod:</strong></p><p>An abstraction over container</p><p>The smallest deploy-able unit in Kubernetes.</p><p>Represents a single instance of a running process in a cluster.</p><p>Usually 1 application/container per Pod.</p><p>Pods are ephemeral.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rgv-_USC1Isl2Kfi2BH8uw.png" /><figcaption>Kubernetes Pods | Pods | K8s Pod</figcaption></figure><p><strong>2-Deployment:</strong></p><p>Blueprint for Pods.</p><p>We work with deployments and by defining the number of replicas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8TD9QhEU3M5ueXe1Lw9CIg.png" /><figcaption>Kubernetes deployment</figcaption></figure><p><strong>3-Volume:</strong></p><p>Provides a way for Pods to store data persistently.</p><p>Lives as long as the Pod exists, preserving data between restarts.</p><p><strong>4-Service:</strong></p><p>Enables network access to a set of Pods.</p><p>Provides a stable IP address and DNS name for a set of Pods, even if they are replaced or moved.</p><p><strong>5-Ingress:</strong></p><p>Manages external access to services within a cluster.</p><p>Allows the definition of rules for external access, such as routing traffic to different services based on the host or path.</p><p><strong>6-Config Map:</strong></p><p>Allows you to decouple configuration artifacts from image content to keep containerized applications portable.</p><p><strong>7-Secret:</strong></p><p>Stores sensitive information, such as passwords, OAuth tokens, and API keys.</p><p>Encrypted and only accessible to the Pods that use them.</p><p><strong>8-Namespace:</strong></p><p>Provides a way to divide cluster resources between multiple users or teams.</p><p>Helps in organizing and isolating resources within a cluster.</p><h3><strong>Kubernetes Architecture:</strong></h3><p>A Kubernetes cluster consists of a set of worker machines, called “Nodes”. There are two types of nodes in Kubernetes cluster.</p><p><strong>1-Master Node</strong></p><p><strong>2-Worker Node</strong></p><p><strong>Architecture:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3AJnCuuvf7kOfeEtMJd_RQ.png" /><figcaption>Kubernetes Architecture | K8 | K8 Architecture</figcaption></figure><p><strong>Master Node:</strong></p><p><strong>API Server:</strong></p><p>Serves as the entry point for the Kubernetes control plane.</p><p>Validates and processes requests, and communicates with the etcd cluster to store the cluster state.</p><p><strong>Controller Manager:</strong></p><p>Maintains the desired state of the cluster.</p><p>Detects and responds to any changes in the cluster state.</p><p><strong>Scheduler:</strong></p><p>Assigns Pods to Nodes based on resource requirements and other constraints.</p><p><strong>etcd:</strong></p><p>A distributed key-value store that stores the configuration data of the cluster.</p><p>Serves as the “source of truth” for the cluster.</p><p><strong>Worker Node:</strong></p><p><strong>Kubelet:</strong></p><p>Ensures that containers are running in a Pod.</p><p>Communicates with the API server to receive instructions.</p><p><strong>Kube Proxy:</strong></p><p>Maintains network rules on nodes.</p><p>Enables communication between Pods and services.</p><p><strong>Container Runtime Interface:</strong></p><p>Software responsible for running containers (e.g., Docker).</p><p>Pulls container images and runs containers.</p><h3><strong>Kubernetes Service:</strong></h3><p>In the Kubernetes ecosystem, Pods come and go, responding to scaling demands or handling failures. Services act as a persistent interface, abstracting away the ephemeral nature of Pods. They ensure that clients can reliably access applications running within Pods without having to worry about their specific locations or changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*906tT7JyHoAQ86v2Kxh5rA.png" /><figcaption>Kubernetes Services | K8 Service</figcaption></figure><p><strong>Types of services:</strong></p><p><strong>1-Cluster IP:</strong></p><p>Default type, providing internal cluster-wide communication.Ensures a stable IP address and DNS name for Pods within the cluster.Ideal for services that need to communicate exclusively within the Kubernetes cluster.</p><p><strong>2-Node IP:</strong></p><p>Exposes a service on a static port on each node’s IP.Allows external access to the service using the node’s IP and the static port.Useful for scenarios where external access is required, but it comes with some security considerations.</p><p><strong>3-Load Balancer:</strong></p><p>Utilizes an external load balancer to distribute traffic across multiple nodes.Well-suited for scenarios where external load balancing is necessary, like in cloud environments.</p><p><strong>4-External Name:</strong></p><p>Maps the service to an external DNS name, allowing Pods to access services outside the cluster.Useful for integrating with external services without exposing internal details.</p><h3><strong>Kubernetes Ingress:</strong></h3><p>In the expansive cityscape of Kubernetes, where micro services thrive, Ingress acts as the gateway, managing external access to services within the cluster. Picture Ingress as the city’s traffic director, allowing you to define rules and efficiently route external requests to the right services.Ingress provides a streamlined way to expose services to the outside world while allowing for flexible routing based on various parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yh5HB7o-6OBKLNkj0YWGug.png" /><figcaption>Kubernetes Ingress | Ingress</figcaption></figure><p><strong>Rule Based Routing:</strong></p><p>Ingress allows you to define rules for external access, such as routing traffic to different services based on the host or path.This flexibility is crucial in scenarios where multiple services coexist, each catering to specific functionalities.</p><p><strong>TLS Termination:</strong></p><p>Ingress supports TLS termination, enabling the secure handling of encrypted traffic at the edge.This is vital for applications requiring secure communication with clients, ensuring data integrity and confidentiality.</p><p><strong>Load Balancing:</strong></p><p>Ingress controllers often come with built-in load balancing capabilities, distributing incoming traffic across the underlying service instances.This aids in optimizing resource utilization and maintaining high availability.</p><h3><strong>Kubernetes Volume</strong></h3><p>In the dynamic landscape of container orchestration, Kubernetes Volumes emerge as a pivotal solution to bridge the gap between ephemeral containers and the need for persistent storage. As applications scale and evolve, the ability to preserve and share data across container instances becomes essential, and Kubernetes Volumes provide a seamless way to achieve this.</p><p>Kubernetes Volumes serve as the persistent storage abstraction for Pods, ensuring that data outlives the lifespan of individual containers. They enable containers within a Pod to share and access data, providing a flexible and scalable approach to handle various storage requirements.</p><p><strong>Lifecycle Independence:</strong></p><p>Volumes outlive the containers running within a Pod. This means that data persists even if a container is terminated, allowing for seamless data continuity.</p><p><strong>Pods Oriented:</strong></p><p>Volumes are defined at the Pod level, making them accessible to all containers within the Pod. This ensures that data is shared among co-located containers.</p><p><strong>Conclusion:</strong></p><p>In conclusion, delving into the fundamental components of Kubernetes, from Pods to Ingress and Volumes, unveils the intricate orchestration capabilities that empower modern application deployment and management. Kubernetes, often referred to as K8s or Kube, stands as a testament to the evolution of containerized environments, offering a robust solution for orchestrating and scaling applications seamlessly.</p><p>While this article provides a snapshot of Kubernetes essentials, it merely scratches the surface of this vast topic. Kubernetes is a sprawling landscape with myriad features, extensions, and best practices that continue to evolve. The exploration of its architecture, services, ingress, and volumes is an introduction to the depth of possibilities within the Kubernetes ecosystem.</p><p>The journey to master K8s is ongoing, and as the saying goes, “K8 is a vast topic and can’t be covered in one article, but the attempt to unravel its complexities is a step towards unlocking its full potential.”</p><blockquote>“Let’s kube up a new microservice”.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4b1e9781465" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>