<?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 Priyam Sanodiya on Medium]]></title>
        <description><![CDATA[Stories by Priyam Sanodiya on Medium]]></description>
        <link>https://medium.com/@priyamsanodiya340?source=rss-64f1668870bf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WE02M1HOlWGoij6_7Jfb2w.png</url>
            <title>Stories by Priyam Sanodiya on Medium</title>
            <link>https://medium.com/@priyamsanodiya340?source=rss-64f1668870bf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 16:34:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@priyamsanodiya340/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 Run Just Got Smarter: Building Highly Available Multi-Region Applications Is Now Easier…]]></title>
            <link>https://medium.com/@priyamsanodiya340/cloud-run-just-got-smarter-building-highly-available-multi-region-applications-is-now-easier-24d802917fa0?source=rss-64f1668870bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/24d802917fa0</guid>
            <dc:creator><![CDATA[Priyam Sanodiya]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 05:06:47 GMT</pubDate>
            <atom:updated>2026-07-28T05:08:31.421Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀 Cloud Run Just Got Smarter: Building Highly Available Multi-Region Applications Is Now Easier Than Ever</h3><p><em>Published: July 2026</em></p><p>High availability has always been one of the biggest challenges in cloud-native application design. Every engineering team wants their applications to remain available even when an entire cloud region experiences an outage. While Google Cloud has long supported multi-region architectures, implementing automatic failover for Cloud Run services required careful planning and additional operational effort.</p><p>Google Cloud has now introduced a significant enhancement to <strong>Cloud Run</strong> that makes building highly available, multi-region applications much simpler.</p><p>With the introduction of <strong>Readiness Probes</strong> and <strong>Service Health</strong>, Cloud Run can now automatically detect unhealthy services and redirect traffic to healthy regions within seconds when used with Application Load Balancers.</p><p>Let’s explore what these new capabilities mean and why they matter for modern cloud applications.</p><h3>Why High Availability Matters</h3><p>Imagine you’ve deployed your application in a single Google Cloud region.</p><pre>Users<br>   │<br>   ▼<br>Cloud Run (Mumbai)</pre><p>Everything works perfectly — until the region experiences an outage.</p><p>Suddenly:</p><ul><li>Your API becomes unavailable.</li><li>Customers cannot access your application.</li><li>Revenue and user trust are affected.</li><li>Engineers scramble to recover the service.</li></ul><p>For production workloads, relying on a single region creates a <strong>Single Point of Failure (SPOF)</strong>.</p><p>The obvious solution is deploying the application across multiple regions.</p><pre>Users<br>      │<br>      ▼<br>Global Load Balancer<br>   │           │<br>   ▼           ▼<br>Mumbai     Singapore<br>   │           │<br>Cloud Run  Cloud Run</pre><p>If one region becomes unavailable, traffic should automatically move to another healthy region.</p><p>That’s exactly what Google’s latest Cloud Run enhancements are designed to improve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sZqJzZ6Bo_uMsNYGRxLv5A.png" /></figure><h3>Multi-Region Cloud Run Services</h3><p>Google recently introduced <strong>Multi-Region Cloud Run Services</strong>, allowing developers to deploy the same service configuration across multiple regions with minimal effort.</p><p>Instead of deploying the application separately in every region, developers can now manage multiple regional deployments as a single logical service.</p><p>This greatly simplifies:</p><ul><li>Deployment</li><li>Configuration management</li><li>Version consistency</li><li>Operational maintenance</li></ul><p>However, deployment is only one part of the availability story.</p><p>The bigger question is:</p><blockquote><strong><em>How does the system know when a region is unhealthy?</em></strong></blockquote><p>That’s where the new features come in.</p><h3>Feature 1: Readiness Probes</h3><p>Readiness Probes introduce instance-level health checking for Cloud Run containers.</p><p>Each Cloud Run instance periodically reports whether it is actually ready to serve requests.</p><p>Instead of assuming that a running container is healthy, Cloud Run now continuously verifies its readiness.</p><p>For example:</p><pre>Region: Mumbai</pre><pre>Instance 1 ✅ Ready<br>Instance 2 ✅ Ready<br>Instance 3 ❌ Not Ready<br>Instance 4 ✅ Ready</pre><p>Cloud Run immediately knows which instances can safely receive traffic.</p><p>This is especially useful during:</p><ul><li>New deployments</li><li>Application startup</li><li>Dependency failures</li><li>Database connection issues</li><li>Configuration problems</li></ul><p>A container that isn’t ready simply won’t receive production traffic.</p><h3>Feature 2: Service Health</h3><p>While readiness probes monitor individual instances, production traffic is routed at the <strong>service level</strong>, not the instance level.</p><p>Google introduced <strong>Service Health</strong> to solve this.</p><p>Cloud Run aggregates the health status of all instances within a region to determine the overall health of the service.</p><p>Example:</p><pre>Mumbai</pre><pre>Instance 1 ✅<br>Instance 2 ❌<br>Instance 3 ❌<br>Instance 4 ❌</pre><pre>↓</pre><pre>Overall Service Health:<br>UNHEALTHY</pre><p>Meanwhile:</p><pre>Singapore</pre><pre>Instance 1 ✅<br>Instance 2 ✅<br>Instance 3 ✅<br>Instance 4 ✅</pre><pre>↓</pre><pre>Overall Service Health:<br>HEALTHY</pre><p>Instead of evaluating every container individually, the infrastructure now understands the health of the entire regional service.</p><h3>Automatic Regional Failover</h3><p>The real magic happens when Service Health integrates with the <strong>Global External Application Load Balancer</strong>.</p><p>Previously:</p><pre>Users</pre><pre>↓</pre><pre>Load Balancer</pre><pre>↓</pre><pre>Traffic still sent to unhealthy region</pre><p>Now:</p><pre>Users</pre><pre>↓</pre><pre>Global Load Balancer</pre><pre>↓</pre><pre>Checks Service Health</pre><pre>↓</pre><pre>Mumbai ❌</pre><pre>↓</pre><pre>Automatically routes traffic</pre><pre>↓</pre><pre>Singapore ✅</pre><p>This failover happens automatically, reducing downtime without requiring manual intervention.</p><p>For organisations running customer-facing applications, this can significantly improve availability during regional incidents.</p><h3>Serverless Network Endpoint Groups (Serverless NEGs)</h3><p>Another important enhancement is the integration with <strong>Serverless Network Endpoint Groups (NEGs).</strong></p><p>A Serverless NEG connects the Load Balancer to a Cloud Run service.</p><p>Previously, the Load Balancer primarily knew where the service existed.</p><p>Now it also understands whether the service is healthy.</p><pre>Load Balancer</pre><pre>↓</pre><pre>Serverless NEG</pre><pre>↓</pre><pre>Cloud Run Service</pre><p>Because the NEG now exposes service health, the Load Balancer can make much smarter routing decisions.</p><h3>Public vs Private Applications</h3><p>These capabilities benefit both internet-facing and internal applications.</p><h3>Public Applications</h3><p>Examples include:</p><ul><li>Customer websites</li><li>Public APIs</li><li>SaaS platforms</li><li>Mobile application backends</li></ul><p>Architecture:</p><pre>Internet<br>↓<br>Global External Load Balancer<br>↓<br>Cloud Run<br>↓<br>Multiple Regions</pre><p>If one region fails, users are transparently served from another healthy region.</p><h3>Private Applications</h3><p>Internal enterprise applications also benefit.</p><p>Examples include:</p><ul><li>HR portals</li><li>ERP systems</li><li>Finance applications</li><li>Internal dashboards</li></ul><p>Architecture:</p><pre>Employees<br>↓<br>Cross-Regional Internal Load Balancer<br>↓<br>Cloud Run<br>↓<br>Multiple Regions</pre><p>Automatic failover works here as well, improving business continuity for internal services.</p><h3>Important Architecture Considerations</h3><p>Although Cloud Run now makes failover easier, designing a resilient application still requires careful planning.</p><h3>1. Eliminate Single Points of Failure</h3><p>Running Cloud Run in multiple regions is only one part of the solution.</p><p>If your database exists in only one region, your application still depends on that single location.</p><p>A resilient architecture should include redundancy across every layer.</p><h3>2. Plan Data Replication</h3><p>Consider what happens when users write data.</p><p>If data exists only in the failed region, failover alone isn’t enough.</p><p>Choose replication strategies that align with your Recovery Point Objective (RPO) and business requirements.</p><h3>3. Consider Data Residency</h3><p>Many organisations must comply with regional data residency regulations.</p><p>Google Cloud already offers managed multi-region services such as:</p><ul><li>Firestore</li><li>Cloud Storage</li><li>Cloud SQL</li><li>Spanner</li></ul><p>These services integrate well with multi-region Cloud Run architectures while helping organisations meet compliance requirements.</p><h3>A Real-World Scenario</h3><p>Imagine you’re operating a global e-commerce platform.</p><pre>Customers<br>↓<br>Global Load Balancer<br>↓<br>Cloud Run<br>Mumbai<br>Singapore<br>LondonUnder normal conditions:</pre><ul><li>Mumbai serves Asia</li><li>Singapore handles Southeast Asia</li><li>London serves Europe</li></ul><p>Now suppose the Mumbai region experiences an outage.</p><p>Readiness probes detect failing instances.</p><p>↓</p><p>Service Health marks the regional service as unhealthy.</p><p>↓</p><p>The Global Load Balancer automatically stops routing traffic there.</p><p>↓</p><p>Traffic shifts to Singapore and London.</p><p>Customers continue browsing and purchasing products with little or no interruption.</p><p>From a user’s perspective, nothing appears to have happened.</p><h3>Why This Announcement Matters</h3><p>This release isn’t just another feature update.</p><p>It significantly reduces the operational complexity of building highly available serverless applications.</p><p>Instead of implementing custom monitoring and failover mechanisms, engineers can now rely on native Cloud Run capabilities.</p><p>The result is:</p><ul><li>Faster regional failure detection</li><li>Automatic traffic failover</li><li>Simpler multi-region deployments</li><li>Improved application availability</li><li>Less operational overhead</li></ul><p>For teams adopting cloud-native architectures, these enhancements make Cloud Run an even stronger choice for production workloads.</p><h3>Final Thoughts</h3><p>Google Cloud continues to invest heavily in making serverless platforms production-ready for enterprise-scale applications.</p><p>With <strong>Readiness Probes</strong>, <strong>Service Health</strong>, and improved <strong>multi-region failover</strong>, Cloud Run now offers a more resilient and operationally simpler way to build highly available applications.</p><p>While true resilience still depends on designing redundant databases, storage, networking, and data replication strategies, these new capabilities remove much of the complexity involved in detecting failures and routing traffic automatically.</p><p>If you’re already building on Cloud Run — or considering a move to serverless — these updates are well worth exploring.</p><p>The future of resilient serverless applications just became a lot easier.</p><h3>Key Takeaways</h3><ul><li>✅ Multi-Region Cloud Run deployments are easier to manage.</li><li>✅ Readiness Probes monitor individual Cloud Run instances.</li><li>✅ Service Health aggregates instance health at the regional service level.</li><li>✅ Global and Internal Application Load Balancers can automatically fail over traffic to healthy regions.</li><li>✅ Serverless NEGs now expose service health to enable intelligent traffic routing.</li><li>✅ Designing resilient applications still requires multi-region databases, storage, and replication.</li></ul><p><strong>Thanks for reading!</strong></p><p>If you enjoyed this article, consider sharing it with fellow cloud engineers and DevOps enthusiasts. Follow me for more deep dives into Google Cloud Platform, Kubernetes, Cloud Infrastructure, Site Reliability Engineering (SRE), and cloud-native architecture.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24d802917fa0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting Multiple Websites on a Single Apache Server Using Virtual Hosts]]></title>
            <link>https://medium.com/@priyamsanodiya340/hosting-multiple-websites-on-a-single-apache-server-using-virtual-hosts-5b475d1d760b?source=rss-64f1668870bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b475d1d760b</guid>
            <dc:creator><![CDATA[Priyam Sanodiya]]></dc:creator>
            <pubDate>Tue, 16 Jun 2026 11:22:08 GMT</pubDate>
            <atom:updated>2026-06-16T11:22:08.677Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>One of the most powerful features of Apache Web Server is its ability to host multiple websites on a single server and IP address. This is achieved through a feature called <strong>Virtual Hosting</strong>, which allows Apache to serve different websites based on the domain name requested by the user.</p><p>In real-world production environments, hosting providers and organizations often run dozens or even hundreds of websites on a single server. Instead of provisioning a separate server for every website, Apache intelligently routes incoming requests to the correct website using the HTTP Host header.</p><p>In this tutorial, we’ll learn how to host <strong>three different websites on a single Apache server</strong> running on Ubuntu/Linux and make them accessible through their own DNS names:</p><ul><li>site1.local</li><li>site2.local</li><li>site3.local</li></ul><p>All three websites will run on the same server and use the standard HTTP port (80).</p><h3>Understanding Virtual Hosts</h3><p>When a user enters a URL such as:</p><p><a href="http://site1.local/">http://site1.local</a></p><p>their browser sends an HTTP request containing a Host header:</p><p>Host: site1.local</p><p>Apache examines this header and determines which website configuration should respond.</p><p>This process is called <strong>Name-Based Virtual Hosting</strong>.</p><h3>Architecture Overview</h3><pre>Apache Server<br>                          │<br>          ┌───────────────┼───────────────┐<br>          │               │               │<br>          ▼               ▼               ▼<br>      site1.local     site2.local     site3.local<br>          │               │               │<br>          ▼               ▼               ▼<br>      Website 1      Website 2      Website 3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZyekeZQ2ItSG1XdU2SZQmQ.png" /></figure><p>All websites share:</p><ul><li>Same Server</li><li>Same Apache Service</li><li>Same Port (80)</li><li>Same Public IP</li></ul><p>Only the domain name changes.</p><h3>Prerequisites</h3><p>Before starting, ensure:</p><ul><li>Ubuntu/Debian Linux Server</li><li>Apache Installed</li><li>Root or sudo access</li><li>Basic Linux command knowledge</li></ul><p>Update packages:</p><pre>sudo apt update</pre><p>Install Apache:</p><pre>sudo apt install apache2 -y</pre><p>Verify Apache is running:</p><pre>sudo systemctl status apache2</pre><h3>Creating Website Directories</h3><p>Each website should have its own document root.</p><p>Create directories:</p><pre>sudo mkdir -p /var/www/site1.local<br>sudo mkdir -p /var/www/site2.local<br>sudo mkdir -p /var/www/site3.local</pre><p>Directory structure:</p><pre>/var/www/<br>├── site1.local<br>├── site2.local<br>└── site3.local</pre><p>This separation keeps website files organized and manageable.</p><h3>Creating Sample Web Pages</h3><h3>Website 1</h3><pre>&lt;h1&gt;Welcome to Site 1&lt;/h1&gt;<br>&lt;p&gt;Hosted using Apache Virtual Hosts.&lt;/p&gt;</pre><h3>Website 2</h3><pre>&lt;h1&gt;Welcome to Site 2&lt;/h1&gt;<br>&lt;p&gt;Hosted using Apache Virtual Hosts.&lt;/p&gt;</pre><h3>Website 3</h3><pre>&lt;h1&gt;Welcome to Site 3&lt;/h1&gt;<br>&lt;p&gt;Hosted using Apache Virtual Hosts.&lt;/p&gt;</pre><p>Save each file as:</p><pre>index.html</pre><p>inside its respective directory.</p><h3>Configuring Apache Virtual Hosts</h3><p>Apache stores website configurations inside:</p><pre>/etc/apache2/sites-available/</pre><h3>Virtual Host for Site 1</h3><pre>&lt;VirtualHost *:80&gt;</pre><pre>    ServerName site1.local<br>    DocumentRoot /var/www/site1.local</pre><pre>    ErrorLog ${APACHE_LOG_DIR}/site1-error.log<br>    CustomLog ${APACHE_LOG_DIR}/site1-access.log combined</pre><pre>&lt;/VirtualHost&gt;</pre><h3>Virtual Host for Site 2</h3><pre>&lt;VirtualHost *:80&gt;</pre><pre>    ServerName site2.local<br>    DocumentRoot /var/www/site2.local</pre><pre>    ErrorLog ${APACHE_LOG_DIR}/site2-error.log<br>    CustomLog ${APACHE_LOG_DIR}/site2-access.log combined</pre><pre>&lt;/VirtualHost&gt;</pre><h3>Virtual Host for Site 3</h3><pre>&lt;VirtualHost *:80&gt;</pre><pre>    ServerName site3.local<br>    DocumentRoot /var/www/site3.local</pre><pre>    ErrorLog ${APACHE_LOG_DIR}/site3-error.log<br>    CustomLog ${APACHE_LOG_DIR}/site3-access.log combined</pre><pre>&lt;/VirtualHost&gt;</pre><p>Each configuration tells Apache which website directory should be served for a specific domain name.</p><h3>Enabling the Virtual Hosts</h3><p>Enable all configurations:</p><pre>sudo a2ensite site1.local.conf<br>sudo a2ensite site2.local.conf<br>sudo a2ensite site3.local.conf</pre><p>Disable the default Apache site:</p><pre>sudo a2dissite 000-default.conf</pre><p>Validate the configuration:</p><pre>sudo apachectl configtest</pre><p>Expected output:</p><pre>Syntax OK</pre><p>Restart Apache:</p><pre>sudo systemctl restart apache2</pre><h3>Configuring Local DNS Resolution</h3><p>Since these domains do not exist publicly, we’ll map them locally.</p><p>Edit:</p><pre>sudo nano /etc/hosts</pre><p>Add:</p><pre>127.0.0.1 site1.local<br>127.0.0.1 site2.local<br>127.0.0.1 site3.local</pre><p>This tells the operating system to resolve these domain names to the local machine.</p><h3>Testing the Websites</h3><p>Open the browser:</p><pre>http://site1.local</pre><p>Result:</p><pre>Welcome to Site 1</pre><p>Open:</p><pre>http://site2.local</pre><p>Result:</p><pre>Welcome to Site 2</pre><p>Open:</p><pre>http://site3.local</pre><p>Result:</p><pre>Welcome to Site 3</pre><p>All websites are being served from a single Apache instance.</p><h3>Verifying Virtual Host Configuration</h3><p>Apache provides a useful troubleshooting command:</p><pre>sudo apachectl -S</pre><p>Expected output:</p><pre>*:80 site1.local<br>*:80 site2.local<br>*:80 site3.local</pre><p>This confirms Apache successfully loaded all virtual host configurations.</p><h3>Why Virtual Hosts Matter</h3><p>Virtual hosting is widely used because it:</p><ul><li>Reduces infrastructure costs</li><li>Maximizes server utilization</li><li>Simplifies management</li><li>Supports hosting multiple applications</li><li>Allows easy scaling</li></ul><p>Many shared hosting providers rely heavily on virtual hosts to serve thousands of customer websites from a relatively small number of servers.</p><h3>Key Concepts Learned</h3><p>Throughout this project, we explored:</p><h3>Apache Web Server</h3><p>A powerful open-source web server used to host websites and applications.</p><h3>Virtual Hosts</h3><p>A mechanism that allows Apache to serve multiple websites from a single server.</p><h3>ServerName</h3><p>A directive that identifies which domain name belongs to a specific website.</p><h3>DocumentRoot</h3><p>The directory containing website files.</p><h3>DNS Resolution</h3><p>The process of converting domain names into IP addresses.</p><h3>Hosts File</h3><p>A local DNS override mechanism used for testing custom domains.</p><h3>Conclusion</h3><p>Hosting multiple websites on a single Apache server is a fundamental skill for Linux administrators and DevOps engineers. Using Apache Virtual Hosts, we successfully deployed three independent websites while using only one server, one IP address, and one Apache service.</p><p>This approach is widely used in production environments because it is cost-effective, scalable, and easy to manage.</p><p>As a next step, you can enhance this setup by:</p><ul><li>Configuring HTTPS with SSL certificates</li><li>Hosting applications instead of static websites</li><li>Using reverse proxies</li><li>Deploying websites inside Docker containers</li><li>Automating Apache configuration with Ansible or Terraform</li></ul><p>Mastering Virtual Hosts is an important milestone in understanding how web hosting works in real-world infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b475d1d760b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Hello World Website with Apache on Ubuntu in Google Cloud Platform (GCP)]]></title>
            <link>https://medium.com/@priyamsanodiya340/deploying-a-hello-world-website-with-apache-on-ubuntu-in-google-cloud-platform-gcp-2ff00fff8064?source=rss-64f1668870bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ff00fff8064</guid>
            <dc:creator><![CDATA[Priyam Sanodiya]]></dc:creator>
            <pubDate>Sat, 13 Jun 2026 17:43:03 GMT</pubDate>
            <atom:updated>2026-06-13T17:43:03.750Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Web servers are one of the fundamental building blocks of modern infrastructure. Whether you’re hosting a personal website, an enterprise application, or a microservice, understanding how to deploy and configure a web server is an essential skill for system administrators and DevOps engineers.</p><p>In this tutorial, we’ll deploy a simple “Hello World” website using the Apache Web Server on an Ubuntu virtual machine running in Google Cloud Platform (GCP). Instead of using the default HTTP port (80), we’ll configure Apache to serve content on port <strong>8888</strong>, exposing it to the internet through a custom firewall rule.</p><p>By the end of this guide, you’ll understand:</p><ul><li>How to create a virtual machine in GCP</li><li>How to install and manage Apache Web Server</li><li>How Apache handles ports and virtual hosts</li><li>How GCP firewall rules work</li><li>How to expose a web application on a custom port</li></ul><h3>Understanding the Architecture</h3><p>Before diving into the implementation, let’s understand the request flow.</p><pre>User Browser<br>     │<br>     ▼<br>Internet<br>     │<br>     ▼<br>GCP Firewall Rule (TCP 8888)<br>     │<br>     ▼<br>Ubuntu VM Instance<br>     │<br>     ▼<br>Apache Web Server<br>     │<br>     ▼<br>Hello World Web Page</pre><p>When a user enters the server’s public IP address followed by port 8888, the request travels through the internet, reaches the GCP firewall, and is forwarded to the Apache service running on the Ubuntu VM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fB7HvHBy_zbwiMIc_MYNYA.png" /></figure><h3>Step 1: Create an Ubuntu VM in GCP</h3><p>Login to the Google Cloud Console and navigate to:</p><pre>Compute Engine → VM Instances → Create Instance</pre><p>Configure the VM with the following settings:</p><ul><li>Name: apache-demo</li><li>Machine Type: e2-micro</li><li>Operating System: Ubuntu 22.04 LTS</li><li>Region: Any preferred region</li></ul><p>Enable:</p><ul><li>Allow HTTP Traffic</li><li>Allow HTTPS Traffic</li></ul><p>Click <strong>Create</strong> and wait for the VM to become available.</p><h3>Step 2: Connect to the Virtual Machine</h3><p>Once the VM is running, connect using the browser-based SSH terminal provided by GCP.</p><p>Alternatively, use the gcloud CLI:</p><pre>gcloud compute ssh apache-demo</pre><p>After connecting, update the system packages.</p><pre>sudo apt update<br>sudo apt upgrade -y</pre><p>Keeping packages updated is a best practice for security and stability.</p><h3>Step 3: Install Apache Web Server</h3><p>Apache is one of the most widely used web servers in the world.</p><p>Install Apache using:</p><pre>sudo apt install apache2 -y</pre><p>Verify the installation:</p><pre>sudo systemctl status apache2</pre><p>Expected output:</p><pre>active (running)</pre><p>Check the installed version:</p><pre>apache2 -v</pre><h3>Step 4: Verify the Default Apache Website</h3><p>Apache automatically deploys a default website after installation.</p><p>Find the VM’s public IP address and open:</p><pre>http://&lt;PUBLIC-IP&gt;</pre><p>You should see the default Apache welcome page.</p><p>This confirms that:</p><ul><li>Apache is running</li><li>The VM is reachable</li><li>Networking is working correctly</li></ul><h3>Step 5: Configure Apache to Listen on Port 8888</h3><p>By default, Apache listens on port 80.</p><p>To use port 8888, edit the Apache ports configuration file:</p><pre>sudo vi/etc/apache2/ports.conf</pre><p>Replace:</p><pre>Listen 80</pre><p>With:</p><pre>Listen 8888</pre><p>Save the file.</p><h3>Step 6: Update the Virtual Host Configuration</h3><p>Apache uses Virtual Hosts to determine which website should respond to incoming requests.</p><p>Edit the default virtual host:</p><pre>sudo vi /etc/apache2/sites-available/000-default.conf</pre><p>Change:</p><pre>&lt;VirtualHost *:80&gt;</pre><p>To:</p><pre>&lt;VirtualHost *:8888&gt;</pre><p>Save and exit.</p><h3>Step 7: Create the Hello World Website</h3><p>Remove the default page:</p><pre>sudo rm /var/www/html/index.html</pre><p>Create a new page:</p><pre>sudo vi /var/www/html/index.html</pre><p>Add the following HTML:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Hello World&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Hello World from Apache on GCP!&lt;/h1&gt;<br>    &lt;p&gt;Server is successfully running on port 8888.&lt;/p&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Save the file.</p><h3>Step 8: Validate Apache Configuration</h3><p>Before restarting the service, validate the configuration syntax.</p><pre>sudo apachectl configtest</pre><p>Expected result:</p><pre>Syntax OK</pre><p>This helps identify configuration errors before they impact the service.</p><h3>Step 9: Restart Apache</h3><p>Apply the new configuration:</p><pre>sudo systemctl restart apache2</pre><p>Verify that Apache is listening on port 8888:</p><pre>sudo ss -tulpn | grep 8888</pre><p>Expected output:</p><pre>LISTEN 0 511 *:8888</pre><p>This confirms Apache is now bound to the new port.</p><h3>Step 10: Create a GCP Firewall Rule</h3><p>Although Apache is listening on port 8888, external traffic will still be blocked by Google Cloud’s firewall.</p><p>Navigate to:</p><pre>VPC Network → Firewall → Create Firewall Rule</pre><p>Configure:</p><pre>Name: allow-apache-8888<br>Direction: Ingress<br>Action: Allow<br>Source IP Range: 0.0.0.0/0<br>Protocols and Ports: tcp:8888</pre><p>Create the rule.</p><p>This allows incoming traffic from the internet to reach port 8888 on the VM.</p><h3>Step 11: Test the Deployment</h3><p>Open your browser and navigate to:</p><pre>http://&lt;PUBLIC-IP&gt;:8888</pre><p>If everything is configured correctly, you should see:</p><pre>Hello World from Apache on GCP!<br>Server is successfully running on port 8888.</pre><p>Congratulations! Your website is now live.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RTlf8sp_gxQT9o5ftRVwdw.png" /></figure><h3>Troubleshooting Tips</h3><h3>Check Apache Status</h3><pre>sudo systemctl status apache2</pre><h3>Verify Listening Ports</h3><pre>sudo ss -tulpn | grep 8888</pre><h3>Test Locally on the Server</h3><pre>curl localhost:8888</pre><h3>Verify Firewall Rules</h3><pre>gcloud compute firewall-rules list</pre><p>These commands are commonly used by system administrators and DevOps engineers when diagnosing connectivity issues.</p><h3>Key Concepts Learned</h3><p>During this deployment, we explored several important concepts:</p><h3>Apache Web Server</h3><p>Apache receives HTTP requests and serves web content to users.</p><h3>Ports</h3><p>Ports identify specific network services. Port 80 is standard HTTP, while port 8888 is commonly used for custom web applications and testing environments.</p><h3>Virtual Hosts</h3><p>Virtual Hosts allow Apache to host multiple websites or services on different ports or domains.</p><h3>Firewall Rules</h3><p>Firewalls control incoming and outgoing network traffic. Without the appropriate firewall rule, users cannot access your application even if the service is running.</p><h3>Cloud Infrastructure</h3><p>Google Cloud Platform provides scalable virtual machines that can host applications accessible from anywhere in the world.</p><h3>Conclusion</h3><p>Deploying a simple website may seem basic, but it introduces many foundational concepts used daily in cloud engineering, Linux administration, and DevOps roles. In this tutorial, we created an Ubuntu virtual machine in GCP, installed Apache, configured it to listen on a custom port, deployed a web page, and exposed it securely through a firewall rule.</p><p>Understanding these fundamentals is essential before moving on to advanced topics such as Nginx, load balancing, reverse proxies, SSL certificates, Docker containers, Kubernetes, and CI/CD pipelines.</p><p>The next step in your learning journey could be deploying the same application using Nginx, containerizing it with Docker, or automating the entire setup using Infrastructure as Code tools such as Terraform.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ff00fff8064" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kodekloud 100 Days of DevOps: My Journey Through Days 1–10]]></title>
            <link>https://medium.com/@priyamsanodiya340/kodekloud-100-days-of-devops-my-journey-through-days-1-10-a77a41888e5d?source=rss-64f1668870bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a77a41888e5d</guid>
            <dc:creator><![CDATA[Priyam Sanodiya]]></dc:creator>
            <pubDate>Thu, 18 Sep 2025 15:26:39 GMT</pubDate>
            <atom:updated>2025-09-23T15:30:14.245Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to my recap of the first 10 days of the 100 Days of DevOps challenge by KodeKloud!. Over these 10 days, I’ve handled tasks in the fictional Datacenter for the fictional xFusionCorp Industries, from creating users with specific requirements to scripting website backups. In this post, I’ll dive into the nitty-gritty of each task, sharing the exact commands, scripts, and troubleshooting steps I used to succeed.</p><p>Below, I broke down each task with step-by-step commands and scripts. Grab a coffee and let’s get hands-on!.</p><h3>DAY 1 — Create a user with a non-interactive shell on the server “App-server-3”.</h3><p><strong><em>Solution</em></strong></p><ul><li>ssh into the server using the simple sample command:</li></ul><pre>ssh user@server_ip # e.g ssh john@172.168.xx.xx</pre><ul><li>Create the user using the command:</li></ul><pre>sudo useradd -m -s /usr/sbin/nologin username</pre><p><strong><em>sudo</em></strong><em>: Run as superuser (required for user creation).</em></p><p><strong><em>useradd</em></strong><em>: Command to add a new user.</em></p><p><strong><em>-m</em></strong><em>: Create a home directory for the user (/home/user).</em></p><p><strong><em>s /usr/sbin/nologin</em></strong><em>: Sets the shell to a non-interactive shell. This prevents the user from logging in to a shell session.</em></p><p>This is commonly used for service accounts or restricted users (like for running cron jobs or daemons) that don’t need interactive shell access.</p><p><strong>DAY 2 — As part of the temporary assignment to the Nautilus project, a developer requires access for a limited duration. To ensure smooth access management, a temporary user account with an expiry date is needed. Here’s what you need to do:</strong><br>“<strong><em>Create a user named james on App Server 1 in Stratos Datacenter. Set the expiry date to 2024–04–15, ensuring the user is created in lowercase as per standard protocol.</em></strong>”</p><p><strong><em>Solution</em></strong></p><ul><li>ssh into the server</li><li>Use the useradd command with the -e option to set an expiry date:</li></ul><pre>sudo useradd -e 2024-04-15 james</pre><p><strong>DAY 3 — Following security audits, the xFusionCorp Industries security team has rolled out new protocols, including the restriction of direct root SSH login.</strong><br>“<strong><em>Your task is to disable direct SSH root login on all app servers within the Stratos Datacenter.”</em></strong></p><p><strong><em>Solution</em></strong></p><ul><li>ssh into the server</li><li>Log in as root using:</li></ul><pre>sudo -i</pre><ul><li>The SSH configuration file is typically located at <strong><em>“/etc/ssh/ssh_config”</em></strong>. Open it with a text editor (nano/vim) and modify the <strong><em>PermitRootLogin </em></strong>setting.</li><li>Look for the <strong><em>PermitRootLogin </em></strong>directive. It may be commented out (with a #) or set to yes. Change it to: <strong><em>PermitRootLogin no</em></strong></li><li>Save the changes and exit the editor.</li><li>Restart the SSH daemon to apply the changes using:</li></ul><pre>systemctl restart sshd</pre><p><strong>DAY 4 — In a bid to automate backup processes, the xFusionCorp Industries sysadmin team has developed a new bash script named xfusioncorp.sh. While the script has been distributed to all necessary servers, it lacks executable permissions on App Server 1 within the Stratos Datacenter.</strong><br><strong><em>“Your task is to grant executable permissions to the /tmp/xfusioncorp.sh script on App Server 1. Additionally, ensure that all users have the capability to execute it”.</em></strong></p><p><strong><em>Solution</em></strong></p><ul><li>ssh into the server</li><li>Grant executable privilege to all users using the command:</li></ul><pre>chmod a+x /tmp/xfusioncorp.sh or chmod 755 /tmp/xfusioncorp.sh</pre><ul><li>Confirm the permission using the command:</li></ul><pre>ls -l /tmp/xfusioncorp.sh</pre><p><strong>DAY 5 — Following a security audit, the xFusionCorp Industries security team has opted to enhance application and server security with SELinux. To initiate testing, the following requirements have been established for App server 3 in the Stratos Datacenter:</strong><br><strong><em>• Install the required SELinux packages.<br>• Permanently disable SELinux for the time being; it will be re-enabled after necessary configuration changes.<br>• No need to reboot the server, as a scheduled maintenance reboot is already planned for tonight.<br>• Disregard the current status of SELinux via the command line; the final status after the reboot should be disabled.</em></strong></p><p><strong><em>Solution</em></strong></p><ul><li>ssh into the server</li><li>Install Required SELinux Packages. SELinux requires specific packages for management and functionality. Install them using the respective package manager:</li></ul><pre>yum install -y selinux-policy selinux-policy-targeted libselinux-utils setools-console</pre><p><strong><em>selinux-policy and selinux-policy-targeted</em></strong>: Provide SELinux policy frameworks.</p><p><strong><em>libselinux-utils</em></strong>: Includes tools like sestatus and setenforce.</p><p><strong><em>setools-console</em></strong>: Provides utilities for analyzing SELinux policies.</p><ul><li>Verify SELinux Package Installation. Check if the packages are installed:</li></ul><pre>rpm -q selinux-policy selinux-policy-targeted libselinux-utils setools-console</pre><ul><li>You should see version numbers for each package. If any are missing, re-run the installation command or troubleshoot repository issues.</li><li>Permanently Disable SELinux. To ensure SELinux is disabled after the scheduled reboot, modify the SELinux configuration file:</li></ul><pre>vi /etc/selinux/config</pre><ul><li>Find the line starting with <strong><em>SELINUX=</em></strong> and change it to: <strong><em>SELINUX=disabled</em></strong></li><li>Since no reboot is needed now, set SELinux to permissive mode for the current session to align with the “disable for the time being” requirement:</li></ul><pre>setenforce 0</pre><ul><li>Verify the current status:</li></ul><pre>sestatus</pre><ul><li>Check the configuration file to ensure SELinux will be disabled after the reboot:</li></ul><pre>grep SELINUX= /etc/selinux/config</pre><ul><li>Output should be: <strong><em>SELINUX=disabled</em></strong></li></ul><p><strong>DAY 6 — The Nautilus system admins team has prepared scripts to automate several day-to-day tasks. They want them to be deployed on all app servers in Stratos DC on a set schedule. Before that they need to test similar functionality with a sample cron job. Therefore, perform the steps below:</strong></p><p><strong><em>a. Install cronie package on all Nautilus app servers and start crond service.</em></strong></p><p><strong><em>b. Add a cron */5 * * * * echo hello &gt; /tmp/cron_text for root user.</em></strong></p><p><strong><em>Solution</em></strong></p><ul><li>Access each Nautilus app server using ssh and use root privilege</li><li>On each server, Install the cronie package using the respective command:</li></ul><pre>yum install -y cronie</pre><ul><li>Verify the installation using:</li></ul><pre>rpm -q cronie</pre><ul><li>Start and enable the crond service:</li></ul><pre>systemctl start crond<br>systemctl enable crond</pre><ul><li>Verify the service is running:</li></ul><pre>systemctl status crond</pre><ul><li>Add the cron job for the root user, Edit the root user’s crontab:</li></ul><pre>crontab -e</pre><ul><li>Add the cron job:</li></ul><pre>*/5 * * * * echo hello &gt; /tmp/cron_text</pre><p><strong><em>Explanation of the cron schedule:</em></strong></p><p><strong><em>*/5:</em></strong> Runs every 5 minutes.</p><p><strong><em>* * * *</em></strong>: Wildcards for hour, day, month, and day of week (runs every hour, every day, etc.).</p><p><strong><em>echo hello &gt; /tmp/cron_text</em></strong>: Writes “hello” to /tmp/cron_text, overwriting the file each time.</p><ul><li>Save and exit</li><li>Check the crontab to ensure the job was added:</li></ul><pre>crontab -l</pre><ul><li>Wait a few minutes and verify the cron job is working:</li></ul><pre>cat /tmp/cron_text</pre><ul><li>Check the file’s timestamp to confirm it updates:</li></ul><pre>ls -l /tmp/cron_text</pre><ul><li>Repeat for all app servers.</li></ul><p><strong>DAY 7 — The system admins team of xFusionCorp Industries has set up some scripts on jump host that run on regular intervals and perform operations on all app servers in Stratos Datacenter. To make these scripts work properly we need to make sure the thor user on jump host has password-less SSH access to all app servers through their respective sudo users (i.e tony for app server 1). Based on the requirements, perform the following:</strong></p><p><strong><em>“Set up a password-less authentication from user thor on jump host to all app servers through their respective sudo users.”</em></strong></p><p><strong><em>Solution</em></strong></p><ul><li>Ensure that you are on the thor user on the jump host server, if not, ssh into the server.</li><li>Generate an SSH key pair for the thor user (if not already present). Check if an SSH key pair exists using the command:</li></ul><pre>ls ~/.ssh/id_rsa</pre><ul><li>if no key exists, generate a new RSA key pair using the command:</li></ul><pre>ssh-keygen -t rsa -b 4096</pre><ul><li>Press Enter to accept the default file location (~/.ssh/id_rsa) and leave the passphrase empty for password-less access.</li><li>Verify the key pair, using the command: <strong><em>ls ~/.ssh/. </em></strong>You should see <strong><em>id_rsa (priv key) &amp; id_rsa.pub (pub key).</em></strong></li><li>Copy the public key to each app server. For each app server, copy thor’s public key to the respective sudo user’s ~/.ssh/authorized_keys file. From the jump host server (thor), run the command:</li></ul><pre>ssh-copy-id user@&lt;app-server-1-ip&gt; e.g ssh-copy-id john@172.168.xx.xx</pre><p>The command will prompt you for the tony user’s password on App Server 1. Enter it. It will create the ~/.ssh directory and authorized_keys file (if they don’t exist) in tony’s home directory on App Server 1, set correct permissions, and append thor’s public key to authorized_keys. If it works: You’ll see a message like:</p><p><strong><em>Number of key(s) added: 1</em></strong></p><ul><li>Now try logging into the app server using ssh</li><li>If set up correctly, you should log in directly without being prompted for a password.</li></ul><p><strong>DAY 8 — During the weekly meeting, the Nautilus DevOps team discussed about the automation and configuration management solutions that they want to implement. While considering several options, the team has decided to go with Ansible for now due to its simple setup and minimal pre-requisites. The team wanted to start testing using Ansible, so they have decided to use jump host as an Ansible controller to test different kind of tasks on rest of the servers.</strong></p><p><strong><em>Install ansible version 4.8.0 on Jump host using pip3 only. Make sure Ansible binary is available globally on this system, i.e all users on this system are able to run Ansible commands.</em></strong></p><p><strong><em>Solution</em></strong></p><ul><li>ssh into the jump host server</li><li>Verify if python3 &amp; pip3 are installed using the commands:</li></ul><pre>python3 --version<br>pip3 --version</pre><ul><li>If not installed, install using the commands:</li></ul><pre>yum install -y python3 <br>yum install -y python3 pip</pre><ul><li>Upgrade pip3 to the latest version to avoid potential issues, using the command:</li></ul><pre>pip3 install --upgrade pip</pre><ul><li>Install Ansible version 4.8.0 specifically using pip3, using the command:</li></ul><pre>pip3 install ansible==4.8.0</pre><ul><li>Verify Ansible Installation, using the command:</li></ul><pre>ansible --version</pre><ul><li>To Ensure Ansible Binary is Available Globally, start by checking where pip3 is installed in the Ansible library using the command:</li></ul><pre>which ansible</pre><p>It typically installs to /usr/local/bin/ansible, which is usually in the system PATH.</p><ul><li>Ensure <strong><em>/usr/local/bin</em></strong> is in the system PATH for all users, by checking the PATH using the command:</li></ul><pre>echo $PATH</pre><p>It should include /usr/local/bin</p><ul><li>Switch to another user to confirm global access and check if ansible is available using the command: <strong><em>ansible — version</em></strong></li><li>Run a basic Ansible command to ensure it is working:</li></ul><pre>ansible all -i &quot;localhost,&quot; -m ping -c local</pre><p>DAY 9 — There is a critical issue going on with the Nautilus application in Stratos DC. The production support team identified that the application is unable to connect to the database. After digging into the issue, the team found that mariadb service is down on the database server.</p><p><strong><em>“Look into the issue and fix the same”</em></strong></p><p><strong><em>Solution</em></strong></p><ul><li>ssh to the database server where the MariaDB service is running</li><li>· If needed, switch to root or use sudo: <strong>s<em>udo -i</em></strong></li><li>Verify the MariaDB Service Status:</li></ul><pre>sudo systemctl status mariadb.service</pre><p>Look for:</p><p>The Active line (likely Active: failed).</p><p>The Process line showing the exit code (e.g., code=exited, status=1/FAILURE).</p><p>Any specific error messages, such as “Cannot open datafile” or “InnoDB error.”</p><ul><li>Check the systemd journal and MariaDB error logs for detailed clues about the failure. Run the journal command to view MariaDB-specific logs:</li></ul><pre>sudo journalctl -xeu mariadb.service</pre><ul><li>Check the MariaDB error log file (typically /var/log/mariadb/mariadb.log):</li></ul><pre>sudo cat /var/log/mariadb/mariadb.log</pre><p>Based on common MariaDB issues, but for this case, Corrupted InnoDB Log Files or Data Directory</p><ul><li>Stop the MariaDB service (if not already stopped):</li></ul><pre>sudo systemctl stop maridb</pre><ul><li>Back up the data directory to prevent data loss:</li></ul><pre>sudo cp -r /var/lib/mysql /var/lib/mysql.bak</pre><ul><li>Remove corrupted InnoDB log files:</li></ul><pre>sudo rm /var/lib/mysql/ib_logfile*</pre><ul><li>Try starting MariaDB:</li></ul><pre>sudo systemctl start mariadb</pre><p>· If it still fails, reinitialize the data directory (warning: this recreates the database structure, potentially losing data unless backed up):</p><pre>sudo mv /var/lib/mysql /var/lib/mysql.bak2<br>sudo mysql_install_db --user=mysql --datadir=/var/lib/mysql<br>sudo systemctl start mariadb</pre><ul><li>Check the status: <strong><em>sudo systemctl status mariadb</em></strong></li></ul><p><strong>DAY 10 — <em>The production support team of xFusionCorp Industries is working on developing some bash scripts to automate different day to day tasks. One is to create a bash script for taking websites backup. They have a static website running on App Server 2 in Stratos Datacenter, and they need to create a bash script named media_backup.sh which should accomplish the following tasks. (Also remember to place the script under /scripts directory on App Server 2).</em></strong></p><p><strong>a. Create a zip archive named xfusioncorp_media.zip of /var/www/html/media directory.</strong></p><p><strong>b. Save the archive in /backup/ on App Server 2. This is a temporary storage, as backups from this location will be clean on weekly basis. Therefore, we also need to save this backup archive on Nautilus Backup Server.</strong></p><p><strong>c. Copy the created archive to Nautilus Backup Server server in /backup/ location.</strong></p><p><strong>d. Please make sure script won’t ask for password while copying the archive file. Additionally, the respective server user (for example, tony in case of App Server 1) must be able to run it.</strong></p><p><strong><em>Solution</em></strong></p><ul><li>ssh into the app server</li><li>Ensure the “/scripts” directory exists on the App Server to store the script, using:</li></ul><pre>ls -ld /scripts</pre><ul><li>If it doesn’t exist, create it, using:</li></ul><pre>mkdir /scripts</pre><ul><li>Ensure the user has permissions:</li></ul><pre>sudo chown user:user /scripts<br>sudo chmod 755 /scripts</pre><ul><li>Create the <strong><em>media_backup.sh</em></strong> Script that creates a zip archive, saves it locally, and copies it to the Backup Server. Create and edit the script using:</li></ul><pre>nano /scripts/media_backup.sh</pre><ul><li>Add the following script content:</li></ul><pre>#!/bin/bash</pre><pre># Script: blog_backup.sh<br># Purpose: Backup /var/www/html/blog directory, save locally, and copy to Nautilus Backup Server</pre><pre># Variables<br>SOURCE_DIR=&quot;/var/www/html/media&quot;<br>BACKUP_DIR=&quot;/backup&quot;<br>ARCHIVE_NAME=&quot;xfusioncorp_media.zip&quot;<br>BACKUP_SERVER=&quot;xxx.xx.xxx.xxx&quot;  #Replace with actual backup server hostname/IP<br>BACKUP_SERVER_DIR=&quot;/backup&quot;<br>BACKUP_SERVER_USER=&quot;user&quot;  #Replace with actual backup server user<br># Step 1: Create zip archive of /var/www/html/media<br>echo &quot;Creating backup archive: $BACKUP_DIR/$ARCHIVE_NAME&quot;<br>if [ ! -d &quot;$SOURCE_DIR&quot; ]; then<br>    echo &quot;Error: Source directory $SOURCE_DIR does not exist.&quot;<br>    exit 1<br>fi<br>zip -r &quot;$BACKUP_DIR/$ARCHIVE_NAME&quot; &quot;$SOURCE_DIR&quot; || {<br>    echo &quot;Error: Failed to create zip archive.&quot;<br>    exit 1<br>}<br># Step 2: Verify local backup directory exists<br>if [ ! -d &quot;$BACKUP_DIR&quot; ]; then<br>    echo &quot;Creating local backup directory: $BACKUP_DIR&quot;<br>    sudo mkdir -p &quot;$BACKUP_DIR&quot;<br>    sudo chown tony:tony &quot;$BACKUP_DIR&quot;<br>fi<br># Step 3: Copy archive to Nautilus Backup Server<br>echo &quot;Copying archive to $BACKUP_SERVER:$BACKUP_SERVER_DIR&quot;<br>scp &quot;$BACKUP_DIR/$ARCHIVE_NAME&quot; &quot;$BACKUP_SERVER_USER@$BACKUP_SERVER:$BACKUP_SERVER_DIR&quot; || {<br>    echo &quot;Error: Failed to copy archive to backup server.&quot;<br>    exit 1<br>}</pre><pre>echo &quot;Backup completed successfully!&quot;<br>exit 0</pre><ul><li>Save and exit</li><li>Ensure the script is executable by the user:</li></ul><pre>chmod +x /scripts/media_backup.sh</pre><ul><li>Set Up Passwordless SSH to Nautilus Backup Server. Configure SSH key-based authentication so scp doesn’t prompt for a password when copying to the Backup Server.</li><li>Generate an SSH key pair for the user on the App Server (if not already present) using the command:</li></ul><pre>ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa -N &quot;&quot;</pre><ul><li>Copy the public key to the Backup Server, using the command:</li></ul><pre>ssh-copy-id user@&lt;backup-server-ip&gt;</pre><ul><li>On the Backup Server, ensure <strong><em>/backup</em></strong> exists and the user has write permissions. Create <strong><em>/backup</em></strong> if needed, using the commands:</li></ul><pre>sudo mkdir -p /backup<br>sudo chown steve:steve /backup<br>sudo chmod 755 /backup</pre><ul><li>Log out: <strong><em>exit</em></strong></li><li>Verify Directory and Permissions. Ensure all required directories exist and have correct permissions.</li><li>Check /var/www/html/blog exists:</li></ul><pre>ls -ld /var/www/html/media</pre><ul><li>Check /backup on the App Server:</li></ul><pre>ls -ld /backup</pre><ul><li>Run the script to ensure it works:</li></ul><pre>/scripts/media_backup.sh</pre><p>Expected output should be like:</p><p><strong><em>Creating backup archive: /backup/xfusioncorp_blog.zip</em></strong></p><p><strong><em>Copying archive to </em></strong><a href="/service/mailto:steve@stbkp01.stratos.xfusioncorp.com:/backup"><strong><em>steve@stbkp01.stratos.xfusioncorp.com:/backup</em></strong></a></p><p><strong><em>Backup completed successfully!</em></strong></p><ul><li>Verify the local backup:</li></ul><pre>ls -l /backup/xfusioncorp_media.zip</pre><p>What an exhilarating start to the <strong>100 Days of DevOps</strong> challenge! These first 10 days have been a whirlwind of learning. The hands-on labs from KodeKloud have made complex concepts feel approachable and fun, building my confidence to tackle more challenges ahead.</p><p>I expect and hope to finish this journey and share more insights as I progress through the next 90 days. Whether you’re a beginner or a seasoned pro, I hope my detailed commands, scripts, and troubleshooting tips inspire you to dive into DevOps or take on your own learning challenge. Check out my full solutions above, and let me know in the comments, what’s your favorite DevOps tool or tip?.</p><p><strong>Stay tuned for Days 11–20!</strong> Connect with me on LinkedIn (<a href="https://www.linkedin.com/in/priyam-sanodiya/">priyam-sanodiya</a>) for more on my little DevOps journey. 🚀</p><p>#100DaysOfDevOps #KodeKloud #DevOps #KeepLearning</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a77a41888e5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins Pipeline as Code + Kubernetes — Step-by-Step Guide]]></title>
            <link>https://medium.com/@priyamsanodiya340/jenkins-pipeline-as-code-kubernetes-step-by-step-guide-a0c2171c8bb5?source=rss-64f1668870bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0c2171c8bb5</guid>
            <dc:creator><![CDATA[Priyam Sanodiya]]></dc:creator>
            <pubDate>Thu, 11 Sep 2025 17:57:50 GMT</pubDate>
            <atom:updated>2025-09-11T17:58:44.663Z</atom:updated>
            <content:encoded><![CDATA[<h3>Jenkins Pipeline as Code + Kubernetes — Step-by-Step Guide</h3><h3>🚀 Introduction</h3><p>Jenkins is a powerful tool for automation — whether it’s machine learning workflows, cloud deployments, or CI/CD for modern apps. But here’s the catch: while Jenkins automates end-to-end tasks <strong>after jobs are created</strong>, <strong>job creation itself has traditionally been manual</strong>.</p><p>Two major challenges:</p><ol><li><strong>Job creation is manual</strong> (through the Web UI).</li><li><strong>Dependency on other teams</strong> (Dev → Ops → Jenkins admins to create jobs).</li></ol><p>The solution? <strong>Pipeline as Code (PAC)</strong>. With PAC, job definitions live as code in a Git repository. This removes manual intervention, eliminates team dependency, and makes pipelines reusable and version-controlled.</p><p>In this blog, we’ll cover:</p><ul><li>The concept of Pipeline as Code</li><li>Launching Jenkins on Kubernetes</li><li>Creating pipelines declaratively</li><li>Writing Jenkinsfiles</li><li>A real-world project example</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*fKEPW7zbpy5ee-y4.png" /></figure><h3>🔑 What is Pipeline as Code?</h3><p>Pipeline as Code allows Jenkins jobs to be <strong>defined, stored, and versioned as code</strong> in source control (e.g., GitHub). Instead of manually creating multiple jobs (pull → build → test → deploy), you define them as <strong>stages</strong> in a Jenkinsfile.</p><p>Benefits:</p><ul><li>Version-controlled pipeline definitions</li><li>Reproducible builds</li><li>Faster onboarding (code-driven, not UI-driven)</li><li>Removes Dev–Ops dependency</li></ul><h3>⚙️ Ways to Create Jenkins Jobs</h3><ol><li><strong>Web UI</strong> → Manual, slow.</li><li><strong>CLI</strong> → Faster but less flexible.</li><li><strong>API</strong> → Useful for automation scripts.</li><li><strong>Pipeline as Code</strong> → Best practice for modern automation.</li></ol><h3>⚙️ Launching Jenkins on Kubernetes</h3><p>Let’s run Jenkins inside Kubernetes for scalability.</p><ol><li><strong>Prerequisites</strong>:</li></ol><ul><li>Minikube or any Kubernetes cluster.</li><li>Docker installed.</li></ul><ol><li><strong>Deploy Jenkins Pod</strong>:</li></ol><pre>kubectl create deployment myj1 --image=jenkins/jenkins</pre><ol><li><strong>Expose Jenkins service</strong>:</li></ol><pre>kubectl expose deployment myj1 --type=NodePort --port=8080</pre><ol><li><strong>Access Jenkins</strong>:</li></ol><pre>minikube service myj1 --url</pre><ol><li>Navigate to &lt;minikube-ip&gt;:&lt;nodeport&gt; in your browser.</li><li><strong>Unlock Jenkins</strong>:<br> Get the admin password:</li></ol><pre>kubectl logs &lt;jenkins-pod-name&gt;</pre><ol><li>Use this to log in, then install suggested plugins.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*az8tEOQZbq03bQAG" /></figure><h3>⚙️ Pipeline as Code in Jenkins</h3><h3>Declarative Pipeline Basics</h3><p>A declarative Jenkinsfile has this structure:</p><pre>pipeline {<br>    agent any<br>    stages {<br>        stage(&#39;Build&#39;) {<br>            steps {<br>                echo &#39;Building the project...&#39;<br>            }<br>        }<br>        stage(&#39;Test&#39;) {<br>            steps {<br>                sh &#39;echo Running tests...&#39;<br>            }<br>        }<br>        stage(&#39;Deploy&#39;) {<br>            steps {<br>                echo &#39;Deploying the application...&#39;<br>            }<br>        }<br>    }<br>}</pre><ul><li><strong>pipeline</strong> → top-level block.</li><li><strong>agent</strong> → where the job runs (any, none, or specific label).</li><li><strong>stages</strong> → contains multiple stages.</li><li><strong>stage</strong> → must have a name + steps.</li><li><strong>steps</strong> → actual commands (echo, sh, etc.).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H9UFs-G7xevq7MMmmZbwAQ.jpeg" /></figure><h3>⚙️ Integrating with GitHub (SCM)</h3><p>Instead of writing Jenkinsfile directly in the UI, store it in GitHub:</p><ol><li>Push both <strong>app code + Jenkinsfile</strong> to your repo.</li><li>In Jenkins, configure the pipeline job to point to SCM.</li><li>Provide the <strong>Script Path</strong> (e.g., Jenkinsfile).</li><li>Enable <strong>triggers</strong> so Jenkins rebuilds on every Git commit.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mgQqGEOltVN9uBFU48zXZQ.jpeg" /></figure><h3>🌍 Real-World Example</h3><p>Take this project: <a href="https://github.com/vimallinuxworld13/jenkins-docker-maven-java-webapp">jenkins-docker-maven-java-webapp</a> citeturn0search0</p><p>Pipeline stages include:</p><ol><li>Pulling source code from SCM.</li><li>Building with Maven.</li><li>Creating a Docker image.</li><li>Pushing to Docker Hub.</li><li>Deploying into a testing environment.</li></ol><p>This project demonstrates <strong>end-to-end CI/CD</strong> with Jenkins Pipeline as Code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pqbb3n9zE5WMwk98Axartg.jpeg" /></figure><h3>✅ Benefits of Jenkins Pipeline as Code</h3><ul><li>Removes manual job creation.</li><li>Eliminates Dev–Ops dependency.</li><li>Source-controlled pipelines.</li><li>Easier debugging and auditing.</li><li>Scales with Kubernetes.</li></ul><h3>📌 Next Steps</h3><ul><li>Explore <strong>scripted pipelines</strong> for advanced use cases.</li><li>Secure Jenkins deployment with TLS.</li><li>Create custom agent images with Docker + Maven + Java.</li><li>Scale Jenkins on Kubernetes with Helm.</li></ul><p>💡 With Pipeline as Code, Jenkins becomes a truly <strong>code-first automation platform</strong>, enabling faster, more reliable DevOps workflows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0c2171c8bb5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Provisioning in Jenkins with Docker]]></title>
            <link>https://medium.com/@priyamsanodiya340/dynamic-provisioning-in-jenkins-with-docker-a176252c4890?source=rss-64f1668870bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a176252c4890</guid>
            <dc:creator><![CDATA[Priyam Sanodiya]]></dc:creator>
            <pubDate>Tue, 09 Sep 2025 15:09:32 GMT</pubDate>
            <atom:updated>2025-09-09T15:09:32.934Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Published on Medium — Draft Version</em></p><h3>🚀 Introduction</h3><p>In Jenkins, a multinode cluster with <strong>static nodes</strong> has a major drawback — even when no jobs are running, the slave nodes remain active, consuming resources unnecessarily. This leads to inefficiency and higher costs.</p><p><strong>Dynamic provisioning</strong> solves this problem. With it, Jenkins provisions slave nodes <strong>on-demand</strong>. Whenever a job is triggered:</p><ul><li>Jenkins master launches a slave.</li><li>The slave registers with the master and executes the job</li><li>Once the job completes, the slave automatically terminates.</li></ul><p>This makes the cluster <strong>scalable, efficient, and cost-effective.</strong></p><h3>🔑 Key Concepts</h3><ul><li><strong>Master node:</strong> Schedules and manages jobs.</li><li><strong>Slave node (Agent):</strong> Executes the job. Must have Java + SSH enabled.</li><li><strong>Dynamic provisioning:</strong> Slaves are created only when needed and destroyed afterwards.</li><li><strong>Supported platforms:</strong> Docker, Kubernetes, AWS EC2, and more.</li></ul><h3>⚙️ Step 1: Install Required Plugins</h3><ol><li>Navigate to <strong>Manage Jenkins → Manage Plugins</strong>.</li><li>Install the plugin that enables Jenkins to connect with your target platform.</li></ol><ul><li>For Docker-based provisioning → <strong>Docker Plugin</strong>.</li><li>For AWS → <strong>Amazon EC2 Plugin</strong>.</li></ul><ol><li>After installation, go to <strong>Manage Jenkins → Clouds</strong>, and you will now see Docker or EC2 as an option.</li></ol><p>📸 <em>[Insert screenshot: Jenkins Manage Plugins section]</em></p><h3>⚙️ Step 2: Launch and Configure Docker Host</h3><ol><li>Launch a VM (or EC2 instance) to act as your <strong>Docker host</strong>.</li><li>Install and enable Docker services:</li></ol><pre>sudo yuminstall docker -y <br>sudo systemctl enable docker <br>sudo systemctl start docker</pre><ol><li>Ensure the <strong>Jenkins master node</strong> can reach this Docker host over the network.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CHyoK1Hz10mUZXmCdJQnCw.jpeg" /></figure><h3>⚙️ Step 3: Enable Docker Remote Access (Socket Binding)</h3><p>By default, Docker only supports local access. Jenkins, however, needs <strong>remote API access</strong>.</p><ol><li>Edit the Docker service file:</li></ol><pre>sudo vim /usr/lib/systemd/system/docker.service</pre><ol><li>Find the line with fd:// (default local binding).</li><li>Replace/add the following to enable TCP socket on port 4243:</li></ol><pre>-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U5i6Rgp2i1xCmq1ym-t3TQ.jpeg" /></figure><p>Reload and restart Docker:</p><pre>sudo systemctl daemon-reload sudo systemctl restart docker</pre><p>Now Docker listens for requests on port <strong>4243</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rX-65Qzp98PxILNqjFfWGg.jpeg" /></figure><h3>⚙️ Step 4: Connect Jenkins Master to Docker Host</h3><ol><li>Go to <strong>Manage Jenkins → Configure Clouds</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VZzh31VrPoTJ2o4_uqr1eg.jpeg" /></figure><ol><li>Add a new <strong>Docker Cloud</strong>.</li><li>Enter your Docker host details:</li></ol><pre>tcp://&lt;docker-host-ip&gt;:4243</pre><ol><li>Click <strong>Test Connection</strong>.</li></ol><ul><li>If it fails, check AWS inbound rules. Allow port 4243 in the <strong>Security Group</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cijat02WkmVMD-rVzKhjog.jpeg" /></figure><h3>⚙️ Step 5: Define Templates for Slave Nodes</h3><ol><li>In <strong>Docker Cloud</strong>, add a new <strong>Template</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ieroc544miOetCkvriF0Dg.jpeg" /></figure><p>2. Configure:</p><ul><li><strong>Docker image</strong>: Prebuilt image with Java + SSH enabled.</li><li><strong>Workspace details</strong>.</li><li><strong>Launch method</strong>: SSH.</li></ul><p>3. Example image:</p><pre>docker pull jenkins/agent</pre><p>4. Add SSH credentials and set <strong>Host Key Verification Strategy</strong> → Non-verifying.</p><p>5. Set pull strategy to <strong>Never pull</strong> (unless needed).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f9KfsZPKKJvV4HxOAa7eAQ.jpeg" /></figure><h3>⚙️ Step 6: Test with a Job</h3><ol><li>Create a <strong>Freestyle job</strong>.</li><li>Restrict it to run on the new <strong>Docker Cloud/Agent</strong>.</li><li>Run the job.</li></ol><ul><li>Jenkins provisions a new container.</li><li>Job executes on the container.</li><li>Slave terminates after completion.</li></ul><p>⚠️ If the job fails with Java version issues → use the recommended Jenkins agent image (e.g., jenkins/agent:jdk11).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDsBY1FZ1rD-rZrRCt4Zsw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HLOZMy44J4cV0NnKXoroEQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFd1Yd34Oe-K09UcEW2LXg.jpeg" /></figure><h3>✅ Benefits of Dynamic Provisioning</h3><ul><li><strong>Efficiency:</strong> Agents run only when needed.</li><li><strong>Scalability:</strong> Handle fluctuating workloads seamlessly.</li><li><strong>Cost optimization:</strong> No more idle nodes.</li><li><strong>Flexibility:</strong> Works with Docker, EC2, and Kubernetes.</li></ul><h3>📌 Featured Image Suggestion</h3><blockquote><em>A visual of Jenkins logo + Docker whale + auto-scaling containers.</em></blockquote><h3>🔮 Next Steps</h3><ul><li>Secure Docker API using TLS instead of plain TCP.</li><li>Build custom agent images with required toolchains.</li><li>Explore Kubernetes plugin for large-scale dynamic provisioning.</li></ul><p>💡 With dynamic provisioning, Jenkins becomes smarter, cloud-native, and highly resource-efficient.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a176252c4890" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Mastering Jenkins — Day 5: Parameterized Jobs, Passing Data Between Jobs & Automating…]]></title>
            <link>https://medium.com/@priyamsanodiya340/mastering-jenkins-day-5-parameterized-jobs-passing-data-between-jobs-automating-aaf6cbdfc52b?source=rss-64f1668870bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/aaf6cbdfc52b</guid>
            <dc:creator><![CDATA[Priyam Sanodiya]]></dc:creator>
            <pubDate>Mon, 08 Sep 2025 17:33:37 GMT</pubDate>
            <atom:updated>2025-09-08T17:33:37.354Z</atom:updated>
            <content:encoded><![CDATA[<h3>🔧 Mastering Jenkins — Day 5: Parameterized Jobs, Passing Data Between Jobs &amp; Automating End-to-End CI/CD</h3><h3>Introduction</h3><p>In this post you’ll learn how to build a simple, reliable Jenkins-driven CI/CD pipeline that:</p><ol><li>builds a Docker image,</li><li>tags and pushes both a versioned and latest image to Docker Hub,</li><li>triggers downstream test jobs (and passes build metadata when needed), and</li><li>deploys to Kubernetes. The walkthrough uses a mix of Freestyle jobs and a recommended Pipeline-as-Code example so you can pick the approach that fits your environment.</li></ol><p>This write-up is based on a hands-on Jenkins lab: creating aajob2, experimenting with parameters and environment variables, installing the Parameterized Trigger plugin, pushing images with both v${BUILD_NUMBER} and latest tags, and creating pipeline views for visibility.</p><h3>Prerequisites</h3><ul><li>A running Jenkins master (and agents if you need builds on specific machines). ssh or web UI access to Jenkins.</li><li>Jenkins user account with admin privileges for installing plugins and creating jobs.</li><li>Docker installed on the Jenkins node(s) that will build and push images.</li><li>A Docker Hub account (or any container registry) and credentials stored in Jenkins Credentials.</li><li>kubectl configured on the Jenkins node that will perform deployments (or use a Kubernetes plugin).</li><li>Plugins we will use: Parameterized Trigger Plugin, Credentials Binding (optional, recommended), Build Pipeline Plugin and/or Delivery Pipeline Plugin (for views). Install via <strong>Manage Jenkins → Manage Plugins</strong>.</li></ul><h3>Step 1 — Log in to Jenkins &amp; create a simple job</h3><ol><li>Open your Jenkins UI and log in with your username and password.</li><li>Click <strong>New Item</strong>, enter a name aajob2, choose <strong>Freestyle project</strong>, then <strong>OK</strong>.</li><li>In <strong>Build</strong> section, add an <strong>Execute shell</strong> build step and enter:</li></ol><pre>echo &quot;priyam&quot;</pre><ol><li>Save the job and click <strong>Build Now</strong>.</li><li>Open the build’s <strong>Console Output</strong> — you should see priyam printed.</li></ol><p>This simple test verifies your Jenkins build node and shell execution path.</p><h3>Step 2 — Make the job parameterized (string parameter)</h3><ol><li>Open aajob2 → <strong>Configure</strong>.</li><li>Check <strong>This project is parameterized</strong>.</li><li>Click <strong>Add Parameter</strong> → <strong>String Parameter</strong>.</li></ol><ul><li><strong>Name:</strong> x</li><li><strong>Default value:</strong> linuxworld</li><li><strong>Description:</strong> optional</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*ANRELMLSNM9lWodfzFOaxA.png" /></figure><p>4. In the same <strong>Execute shell</strong> step, update the command to:</p><pre>echo &quot;${x}th&quot;</pre><ol><li>Save and <strong>Build with Parameters</strong>.</li></ol><ul><li>If you use the default it prints linuxworldth.</li><li>If you provide priyam it prints priyamth (because we appended th).</li></ul><p>This demonstrates how parameters make jobs reusable and flexible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*G8aXURljcbDt81RrAX0a1g.png" /></figure><h3>Step 3 — Inspect and use Jenkins environment variables</h3><p>Jenkins exposes many useful environment variables during a build. Example common ones:</p><ul><li>JOB_NAME — the job’s name</li><li>BUILD_NUMBER — the build’s numeric id</li><li>BUILD_ID, BUILD_TAG, WORKSPACE, etc.</li></ul><p>Add a debug build step to print them:</p><pre>echo &quot;JOB_NAME=$JOB_NAME&quot;<br>echo &quot;BUILD_NUMBER=$BUILD_NUMBER&quot;<br>echo &quot;BUILD_TAG=$BUILD_TAG&quot;</pre><p>Knowing BUILD_NUMBER is crucial: we’ll use it to tag Docker images as v${BUILD_NUMBER} so every build produces an immutable tag.</p><h3>Step 4 — Build a Docker image and push both v${BUILD_NUMBER} and latest</h3><p><strong>Why two tags?</strong></p><ul><li>v${BUILD_NUMBER} is immutable and uniquely identifies a build. Good for traceability and rollbacks.</li><li>latest is convenient for downstream jobs or environments that always want the newest image.</li></ul><p><strong>Freestyle job (Execute shell) example</strong> — keep credentials safe (use Jenkins Credentials and the Credentials Binding plugin):</p><pre># Build and tag with build number<br>docker build -t ${IMAGE}:v${BUILD_NUMBER} .</pre><pre># Also tag as latest<br>docker tag ${IMAGE}:v${BUILD_NUMBER} ${IMAGE}:latest</pre><pre># Push both tags<br>docker push ${IMAGE}:v${BUILD_NUMBER}<br>docker push ${IMAGE}:latest</pre><p><strong>Important security note:</strong> never hardcode credentials. Use Jenkins credentials store and the <strong>Credentials Binding Plugin</strong> to inject DOCKER_USER and DOCKER_PASS as environment variables, or use pipeline credential helpers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*oy6Bz2Y3yioKl_Th11oHvA.png" /></figure><h3>Step 5 — Triggering downstream jobs and passing parameters (Parameterized Trigger plugin)</h3><p>Jenkins does not pass parameters between jobs by default. The Parameterized Trigger plugin fixes that.</p><p><strong>Install:</strong> Manage Jenkins → Manage Plugins → Available → search <strong>Parameterized Trigger</strong> → Install and restart Jenkins if required.</p><p><strong>Configure upstream job to pass build info:</strong></p><ol><li>In your build job (e.g., DockerProjectToBuild) go to <strong>Post-build Actions</strong>.</li><li>Click <strong>Trigger parameterized build on other projects</strong>.</li><li>Enter the downstream job name (e.g., testjob).</li><li>Under <strong>Add Parameter</strong> → <strong>Predefined parameters</strong>, add:</li></ol><pre>MYBUILD_JOBID=$BUILD_NUMBER</pre><ol><li>Save.</li></ol><p><strong>In </strong><strong>testjob</strong></p><ul><li>Add a build step <strong>Execute shell</strong> with:</li></ul><pre>echo &quot;MYBUILD_JOBID=$MYBUILD_JOBID&quot;</pre><p>When DockerProjectToBuild succeeds, it will trigger testjob and pass MYBUILD_JOBID containing the build number of the upstream job.</p><h3>Step 6 — Alternative: rely on latest tag instead of passing IDs</h3><p>If you push :latest alongside :v${BUILD_NUMBER}, downstream jobs (test/production) can simply pull image:latest and avoid passing build IDs. This is simpler but less deterministic — the latest tag changes over time.</p><p><strong>Test job pull example:</strong></p><pre>docker pull mydockeruser/myapp:latest<br># run tests against the container</pre><p><strong>Tradeoffs</strong></p><ul><li>Passing explicit build IDs makes tests reproducible (you can always pull a specific v123).</li><li>Using latest is easier for continuous environments where you always want the newest build.</li></ul><h3>🔹 Step 7: Full Workflow (Build → Test → Production)</h3><p>Here’s the <strong>end-to-end CI/CD flow</strong>:</p><ol><li><strong>Build Job</strong></li></ol><ul><li>Builds Docker image.</li><li>Tags with both v${BUILD_NUMBER} and latest.</li><li>Pushes image to DockerHub.</li></ul><p><strong>2. Test Job</strong></p><ul><li>Always pulls the <strong>latest image</strong>.</li><li>Runs test containers.</li></ul><p><strong>3. Production Job</strong></p><ul><li>Deploys image into <strong>Kubernetes</strong> using a mydeploy.yml file.</li><li>Example:</li></ul><pre>cat &gt; mydeploy.yml &lt;&lt;EOF <br>apiVersion: apps/v1 <br>kind: Deployment <br>metadata:   <br>  name: myapp <br>  spec:   replicas: 1    <br>  selector:     <br>    matchLabels:       <br>      app: myapp   <br>  template:     <br>    metadata:       <br>      labels:         <br>        app: myapp     <br>    spec:       <br>      containers:       <br>      - name: myapp         <br>        image: yourrepo/app:latest EOF</pre><pre><br>kubectl apply -f mydeploy.yml</pre><p>👉 Now every code push triggers:<br> <strong>GitHub → Jenkins Build → DockerHub → Test → Kubernetes Deployment.</strong></p><h3>Step 8 — Creating Views &amp; Visual Pipeline (Build Pipeline / Delivery Pipeline)</h3><ol><li><strong>Install plugins</strong> if not present: <em>Build Pipeline Plugin</em> and <em>Delivery Pipeline Plugin</em> via <strong>Manage Jenkins → Manage Plugins</strong>.</li><li>From the Jenkins dashboard, click <strong>New View</strong>.</li><li>Name it (e.g., My App Pipeline) and choose either <strong>Build Pipeline View</strong> or <strong>Delivery Pipeline View</strong>.</li><li>Configure the initial job (the first job in the chain, e.g., DockerProjectToBuild) and save.</li></ol><p>You will now have a visual representation of the job chain and can monitor build flow at a glance.</p><h3>Troubleshooting &amp; best practices</h3><ul><li><strong>Restart Jenkins after plugin install</strong> if the UI doesn’t reflect the new functionality.</li><li><strong>Use credentials store</strong>: never hardcode usernames/passwords in scripts or Jenkinsfiles.</li><li><strong>Use immutable tags</strong> for reproducible deployments (v${BUILD_NUMBER}) and push latest for convenience.</li><li><strong>Agent configuration</strong>: Ensure the Jenkins agent that runs Docker commands has Docker and kubectl installed and configured.</li><li><strong>Clean up images</strong> occasionally to avoid storage explosion on build nodes.</li><li><strong>Use timeouts and retries</strong> for flaky network operations like docker push and kubectl apply.</li><li><strong>Logging</strong>: always echo important variables (JOB_NAME, BUILD_NUMBER) at the start of scripts to help debugging.</li></ul><h3>Example: Passing and validating parameters between jobs</h3><p><strong>Upstream (DockerProjectToBuild) Post-build Predefined parameter:</strong></p><pre>MYBUILD_JOBID=$BUILD_NUMBER</pre><p><strong>Downstream (</strong><strong>testjob) build step</strong>:</p><pre>echo &quot;Received MYBUILD_JOBID=$MYBUILD_JOBID&quot;<br># Optionally pull the exact image<br>docker pull mydockeruser/myapp:v${MYBUILD_JOBID}</pre><p>If you prefer not to pass the ID, the testjob can simply pull mydockeruser/myapp:latest.</p><h3>Conclusion</h3><p>You now have an end-to-end pattern for Jenkins-driven CI/CD that is practical and production-ready:</p><ol><li>Use BUILD_NUMBER to version images.</li><li>Push both v${BUILD_NUMBER} and latest tags to a registry.</li><li>Use the Parameterized Trigger plugin when you need reproducible downstream builds that depend on upstream metadata.</li><li>Prefer Pipeline-as-Code (Jenkinsfile) for repeatability and easier maintenance.</li></ol><p>Would you like this draft converted into a ready-to-publish Medium-format Markdown (with images placeholders and social blurb), or shortened for a quick blog post? I can also generate the Jenkinsfile as a downloadable file if you want.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaf6cbdfc52b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Mastering Jenkins — Day 4: Step-by-Step Guide to GitHub Webhooks & Kubernetes Deployments]]></title>
            <link>https://medium.com/@priyamsanodiya340/mastering-jenkins-day-4-step-by-step-guide-to-github-webhooks-kubernetes-deployments-b1bd1e3def37?source=rss-64f1668870bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1bd1e3def37</guid>
            <dc:creator><![CDATA[Priyam Sanodiya]]></dc:creator>
            <pubDate>Sat, 06 Sep 2025 16:13:59 GMT</pubDate>
            <atom:updated>2025-09-06T16:13:59.814Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀 Mastering Jenkins — Day 4: Step-by-Step Guide to GitHub Webhooks &amp; Kubernetes Deployments</h3><p>Welcome back to <strong>Day 4</strong> of our Jenkins series!<br> In this session, we’re taking Jenkins beyond simple jobs and Docker builds. We’ll set up a <strong>real-world CI/CD pipeline</strong> where:</p><ul><li>GitHub triggers Jenkins jobs automatically</li><li>Jenkins distributes workloads across multiple AWS nodes</li><li>Kubernetes is used for production deployment</li><li>The entire process runs end-to-end without manual intervention</li></ul><p>Let’s dive into the <strong>step-by-step setup</strong>.</p><h3>🔹 Step 1: Understanding Jenkins CI/CD Workflow</h3><p>Before we jump into configurations, let’s recap how Jenkins fits into DevOps workflows:</p><ol><li>Developers <strong>write code</strong> and push to GitHub.</li><li>Jenkins <strong>monitors GitHub</strong> for changes.</li><li>On code push, Jenkins <strong>triggers a build job</strong>.</li><li>Jenkins <strong>compiles, tests, and packages</strong> the application.</li><li>If tests pass, Jenkins <strong>deploys artifacts</strong> to staging or production.</li></ol><p>👉 This ensures <strong>Continuous Integration (CI)</strong> and <strong>Continuous Deployment (CD)</strong>.</p><h3>🔹 Step 2: Creating Jenkins Jobs</h3><p>In Jenkins, a <strong>job</strong> is a unit of work (build, test, deploy).</p><ul><li>To create a new job:</li><li>Go to <strong>Dashboard → New Item</strong></li><li>Name it (e.g., DockerProjectToTest)</li><li>Select <strong>Freestyle Project</strong></li><li>Add configurations:</li><li><strong>Source Code Management</strong> → Git repo</li><li><strong>Build Triggers</strong> → Manual / Scheduled / GitHub webhook</li><li><strong>Build Steps</strong> → Shell commands (compile, test, deploy)</li><li><strong>Build Server</strong>: Compiles developer code into deployable software packages.</li><li><strong>Test Server</strong>: Executes tests to verify software quality and functionality.</li><li><strong>Production/Deploy Server</strong>: Hosts the live version of the software for end-users.</li></ul><p>👉 Example build step:</p><pre>echo &quot;Running Docker container test&quot;<br>docker ps</pre><p>Jobs can also be <strong>Upstream (dependency job)</strong> or <strong>Downstream (dependent job)</strong>, letting you chain multiple jobs together.</p><h3>🔹 Step 3: Setting Up Master-Slave Architecture</h3><p>For this project, we’ve built a Jenkins infrastructure on <strong>AWS Cloud</strong> consisting of:</p><ul><li><strong>Jenkins Master</strong></li><li>The central Jenkins server where the Jenkins software runs.</li><li>Manages jobs, configurations, and orchestration.</li><li><strong>Jenkins Slave Nodes</strong></li><li>Two additional servers launched in AWS to support the master.</li><li>Handle tasks like building, testing, and deploying software.</li><li>Enable workload distribution and scalability in the cloud.</li></ul><p>Our Jenkins Master node is fully operational. You can access it by logging in with your Jenkins username and password.</p><h3>Reconfiguration (Optional)</h3><p>If you have previously set up a Jenkins cluster with two slave nodes, you can reconfigure it by adjusting:</p><ul><li>Node labels and assignments.</li><li>Build executor counts.</li><li>Security and credentials for communication between master and slaves.</li></ul><h3>Configure a Slave Node:</h3><ol><li>Go to <strong>Manage Jenkins → Nodes → New Node</strong>.</li><li>Give it a name (e.g., slave1).</li><li>Set <strong>Remote Root Directory</strong> → /home/jenkins.</li><li>Assign <strong>Labels</strong> → e.g., mybuild (used later to target jobs).</li><li>Enter <strong>Host IP</strong>, SSH credentials.</li><li>Save and launch the agent.</li></ol><p>👉 Repeat for slave2 and slave3 as needed.</p><p>⚡ Tip: Always set the <strong>label</strong> and <strong>remote directory</strong> correctly — this ensures jobs know where to run.</p><h3>🔹 Step 4: Connecting GitHub with Jenkins (Webhooks)</h3><p>Instead of manually triggering builds, let’s automate it with GitHub webhooks.</p><h3>In Jenkins:</h3><ol><li>Go to your job → <strong>Configure → Build Triggers</strong>.</li><li>Enable <strong>GitHub hook trigger for GITScm polling</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PZHcIlVUKIpOE-_X8-OtvA.png" /></figure><h3>In GitHub:</h3><ol><li>Go to <strong>Repo → Settings → Webhooks</strong>.</li><li>Click <strong>Add Webhook</strong>.</li><li>Enter Payload URL:</li></ol><pre>http://&lt;JENKINS_SERVER_PUBLIC_IP&gt;/github-webhook/</pre><ol><li>Set <strong>Content type</strong> → application/json.</li><li>Save.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*oHBHMYEZqN9c7Z0HiWMBiA.png" /></figure><p>✅ Now, whenever you push code → Jenkins job starts automatically.</p><h3>🔹 Step 5: Adding Slave3 for Kubernetes Deployments</h3><p>We now prepare a third Jenkins node dedicated for Kubernetes deployments.</p><h3>On AWS:</h3><ol><li>Launch a new EC2 instance.</li><li>Install <strong>Java</strong>.</li></ol><pre>sudo yum install java-11-openjdk -y</pre><h3>On Jenkins Master:</h3><ol><li>Go to <strong>Manage Jenkins → Nodes → New Node</strong>.</li><li>Create slave3.</li><li>Configure:</li></ol><ul><li>Remote Root Directory → /home/jenkins</li><li>Label → mykubernetes</li><li>Host → Public IP of the instance</li><li>Credentials → SSH key</li></ul><p>⚡ Make sure the <strong>Security Group</strong> allows traffic (SSH + Jenkins).</p><h3>🔹 Step 6: Installing kubectl on Slave3</h3><p>To manage Kubernetes, install kubectl on slave3:</p><pre>chmod +x kubectl<br>sudo mv kubectl /usr/bin/</pre><p>Now, securely copy the Kubernetes config (admin.conf) to slave3:</p><pre>chmod 600 my.key<br>scp -i my.key admin.conf ec2-user@&lt;slave3-public-ip&gt;:/home/ec2-user/</pre><p>Verify Kubernetes connection:</p><pre>kubectl get nodes --kubeconfig admin.conf</pre><p>✅ If you see your Kubernetes cluster nodes → configuration is successful.</p><h3>🔹 Step 7: Creating a Jenkins Production Deployment Job</h3><p>Now let’s configure a <strong>production job</strong> in Jenkins.</p><ol><li>Create a new freestyle project → ProductionDeploy.</li><li>Assign label → mykubernetes.</li><li>Set build trigger → <strong>Trigger only if build is stable</strong>.</li><li>In build step, add deployment script:</li></ol><pre>kubectl delete myweb --kubeconfig /home/ec2-user/admin.conf<br>kubectl create deployment myweb --image priyam930/new:v1 --kubeconfig /home/ec2-user/admin.conf</pre><p>This job will:</p><ul><li>Create Kubernetes deployments.</li></ul><p>⚠️ Important: Delete old deployments before re-applying.</p><h3>🔹 Step 8: Running the Full CI/CD Pipeline</h3><p>Now let’s see the end-to-end flow in action:</p><ol><li>Developer pushes code → GitHub.</li><li>GitHub webhook triggers Jenkins build job.</li><li>Jenkins builds &amp; tests → If success, marks job as <strong>stable</strong>.</li><li>Jenkins triggers downstream job (test, ProductionDeploy).</li><li>Slave3 runs Kubernetes deployment .</li><li>New pods + services are created in Kubernetes.</li></ol><p>🎉 Congratulations — you now have a <strong>fully automated GitHub → Jenkins → Kubernetes pipeline</strong>!</p><h3>🔹 Key Learnings from Day 4</h3><p>✔ Jenkins jobs can be chained for full automation.<br> ✔ Remote directory + label = must-have for slave configuration.<br> ✔ Webhooks enable <strong>real-time CI/CD</strong> with GitHub.<br> ✔ Jenkins can deploy directly to Kubernetes clusters.<br> ✔ AWS + Jenkins + Kubernetes = scalable DevOps pipeline.</p><p>Stay tuned — Jenkins mastery is leveling up! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1bd1e3def37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Mastering Jenkins — Day 3: Master-Slave Architecture, Distributed Builds & End-to-End Automation]]></title>
            <link>https://medium.com/@priyamsanodiya340/mastering-jenkins-day-3-master-slave-architecture-distributed-builds-end-to-end-automation-9c15c42b6b7a?source=rss-64f1668870bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c15c42b6b7a</guid>
            <dc:creator><![CDATA[Priyam Sanodiya]]></dc:creator>
            <pubDate>Fri, 05 Sep 2025 17:00:06 GMT</pubDate>
            <atom:updated>2025-09-05T17:00:06.226Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀 Mastering Jenkins — Day 3: Master-Slave Architecture, Distributed Builds &amp; End-to-End Automation</h3><p>Welcome back to <strong>Day 3 of our Jenkins learning journey!</strong><br> In the last session, we installed Jenkins on AWS and explored the basics of automation. Today, we’re diving deeper into <strong>Jenkins architecture, job execution, distributed builds, and end-to-end automation</strong> with Docker and GitHub.</p><h3>🔹 Understanding Jenkins Jobs and Base OS Dependencies</h3><p>Jenkins itself is just an <strong>automation server</strong> — it doesn’t come bundled with tools like Docker, Git, or Maven. This means if your Jenkins job requires a command (e.g., docker ps) but your <strong>base operating system</strong> doesn’t have Docker installed, the job will fail.</p><p>For example:</p><ol><li>Create a new <strong>freestyle job</strong>.</li><li>In the build step, add an <strong>execute shell</strong> command like:</li></ol><pre>docker ps</pre><p>3. Run the job → Jenkins fails because Docker is not installed on the base system.</p><p>👉<strong> Lesson learned:</strong> Jenkins relies on the underlying OS for required tools and system resources. If your OS has <strong>2GB RAM</strong> but your job requires <strong>3GB</strong>, it will fail.</p><h3>🔹 Single-Node vs Distributed Architecture</h3><p>By default, Jenkins runs on a <strong>single node</strong> (the same system where it is installed). But in real-world use cases, this isn’t scalable.</p><p>This is where <strong>Master-Slave Architecture</strong> comes into play:</p><ul><li><strong>Jenkins Master:</strong> Controls scheduling, manages jobs, and provides the UI.</li><li><strong>Jenkins Slaves (Nodes):</strong> Execute the jobs, each equipped with their own tools and resources.</li><li><strong>Benefit:</strong> Users only interact with the master, while jobs are distributed across multiple slaves for parallel execution.</li></ul><p>Example: If you configure <strong>4 build executors</strong>, Jenkins can run <strong>4 jobs in parallel</strong>.</p><h3>🔹 Setting Up Master-Slave Architecture in Jenkins</h3><p>To configure distributed builds, you need <strong>three instances</strong> with Jenkins installed:</p><ul><li><strong>1 Master Node</strong></li><li><strong>2 Slave Nodes</strong></li></ul><h3>Step1: Add a Slave Node</h3><ol><li>Go to <strong>Manage Jenkins → Nodes → New Node</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NIymyxhFvi_FCq_0SaZYQA.png" /></figure><p>2. Give a name and configure the node.</p><p>3. Choose between:</p><ul><li><strong>Static Node</strong> → Always active</li><li><strong>Dynamic Node</strong> → Starts only when required</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNsMPswzQH0oZ2KgXO9Gbg.png" /></figure><h3>Step 2: Configure Communication</h3><ul><li>Jenkins uses <strong>SSH</strong> to connect with slaves.</li><li>Requirements:</li><li>SSH enabled</li><li>Slave’s IP address</li><li>Username &amp; password / private key credentials</li></ul><p>You can add credentials in <strong>Manage Jenkins → Credentials</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-2FQFSdlgdYuHhAjI3C2sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YojVr9L1ajAPV_LSx9j9ZQ.png" /></figure><h3>✅ Important Configurations</h3><ul><li><strong>Remote Root Directory:</strong></li><li>This is the workspace location on the slave machine where Jenkins will store job files, build artifacts, and logs.</li><li>Example: /home/jenkins</li><li>If not set correctly, builds may fail or Jenkins won’t be able to use the node.</li><li><strong>Labels:</strong></li><li>Labels help identify and categorize nodes (e.g., docker, production, test).</li><li>When configuring jobs, you can specify a label so that Jenkins knows <strong>which node</strong> should run that job.</li><li>Example:</li><li>Slave 1 → Label: docker</li><li>Slave 2 → Label: production</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fVM-QqOcxVdmG5bsSpFCRA.png" /></figure><p>👉 Without proper labels and a valid remote directory, the <strong>master-slave setup will not work reliably</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lc9UygvzetY47Wj79K0gnQ.png" /></figure><h3>Step 3: Handle Common Errors</h3><ul><li><strong>Slave Fails to Launch →</strong> Ensure authentication is allowed.</li><li><strong>Missing Java Agent →</strong> Install Java on the slave.</li><li><strong>Java Version Incompatibility →</strong> Download and install a compatible version (e.g., via .rpm from Oracle/AdoptOpenJDK).</li></ul><p>Once configured, your slaves will be ready to accept jobs from the master!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JabX_h-Oeik5-Q4SPZMDpQ.png" /></figure><h3>🔹 Real-World Example: Docker Build &amp; Push</h3><p>Now let’s put our setup to use.</p><ol><li>Create a job on <strong>Slave 1</strong> to build a Docker image.</li></ol><ul><li>Run Docker build commands.</li><li>Push the image to <strong>Docker Hub</strong> (after logging in).</li><li>Example:</li></ul><pre>docker build -t mydockerhub/myapp:v1 . <br>docker push mydockerhub/myapp:v1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*Pl5XJubUUDW3l2Es3-mGZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GW8HYaUPQMMklPxn0tJCew.png" /></figure><ol><li>Create another job on <strong>Slave 2</strong> (Production Node) to launch the container.</li></ol><ul><li>Run Docker run commands to deploy the image from Docker Hub.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KVROHDPH9u20dHMlZbQRZw.png" /></figure><h3>🔹 End-to-End Automation with Upstream &amp; Downstream Jobs</h3><p>Now, let’s connect both jobs together:</p><ul><li><strong>Job 1 (Build Job):</strong> Runs on Slave 1 → Builds &amp; pushes the Docker image.</li><li><strong>Job 2 (Deploy Job):</strong> Runs on Slave 2 → Pulls &amp; launches the Docker container.</li></ul><p>Configure Job 2 as a <strong>downstream project</strong> of Job 1.<br> This way, whenever <strong>Job 1 completes successfully</strong>, Job 2 will <strong>automatically trigger</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLlaPm7_78ZGH9kk6BgaMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GsUtTRd3Dk4eKUW6q1R5Nw.png" /></figure><p>Result → <strong>CI/CD pipeline achieved!</strong></p><ul><li>Developer pushes code to GitHub.</li><li>Jenkins Job 1 builds &amp; pushes the Docker image.</li><li>Jenkins Job 2 automatically deploys the updated image in production.</li></ul><h3>🔹 Key Takeaways from Day 3</h3><p>✔ Jenkins jobs depend on the base OS → Install required tools first.<br> ✔ Single-node Jenkins is limited → Use Master-Slave architecture for scalability.<br> ✔ Nodes can be static or dynamic depending on workload.<br> ✔ Common issues with slaves often relate to <strong>authentication &amp; Java versions</strong>.<br> ✔ Upstream &amp; downstream jobs enable <strong>end-to-end automation pipelines</strong>.</p><h3>🎯 What’s Next?</h3><p>In the next session, we’ll explore:</p><ul><li>Automating CI/CD workflows in a more scalable way.</li></ul><p>Stay tuned — Jenkins mastery is just getting started! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c15c42b6b7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins : Day 2 — Creating Our First Job & Connecting Jenkins with GitHub & Automating Builds]]></title>
            <link>https://medium.com/@priyamsanodiya340/jenkins-day-2-creating-our-first-job-connecting-jenkins-with-github-automating-builds-890841aea98e?source=rss-64f1668870bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/890841aea98e</guid>
            <dc:creator><![CDATA[Priyam Sanodiya]]></dc:creator>
            <pubDate>Thu, 04 Sep 2025 15:31:44 GMT</pubDate>
            <atom:updated>2025-09-04T15:31:44.052Z</atom:updated>
            <content:encoded><![CDATA[<h3>Jenkins : Day 2 — Creating Our First Job &amp; Connecting Jenkins with GitHub &amp; Automating Builds</h3><p>In <a href="#">Day 1 of the Jenkins Masterclass</a>, we introduced Jenkins, set up an AWS EC2 instance, and prepared the environment.</p><h3>Setting up Jenkins on AWS</h3><p>We launched a Linux EC2 instance, installed <strong>Java</strong>, and then deployed Jenkins on top of it. Once installed, we connected to the instance and checked the Jenkins service status:</p><pre>sudo su – root<br>systemctl status jenkins</pre><p>If Jenkins is running, we can access it through the <strong>public IP</strong> of the EC2 instance by appending port <strong>8080</strong> in the browser:</p><pre>http://&lt;public-ip&gt;:8080</pre><p>This opens the Jenkins dashboard, where we can start creating automation jobs.</p><h3>Why Use Jenkins?</h3><p>Manually running commands repeatedly is inefficient. For example, imagine you want to run the date or cal command every two minutes. Doing this manually would be tedious. Jenkins automates such repetitive tasks.</p><p>With Jenkins, we create <strong>jobs</strong> (also called <em>items</em> or <em>projects</em>) to execute tasks automatically.</p><h3>Creating Your First Job in Jenkins</h3><ol><li>Go to the <strong>Dashboard</strong>.</li><li>Click on <strong>New Item</strong> (or <em>Create a Job</em>).</li><li>Provide a <strong>job name</strong>.</li><li>Select <strong>Freestyle Project</strong>.</li><li>Click <strong>OK</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJ4jaziSZS8-oKWPotF8lw.png" /></figure><p>Now Jenkins will ask you to configure the job. In the <strong>Build Steps</strong>, choose <strong>Execute Shell</strong>. Here, we can type commands (like date or cal) in sequence. Jenkins will execute them in the given order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4u7qj26sJWEvETTOia6A3g.png" /></figure><p>Finally, click <strong>Save</strong>. Congratulations! 🎉 You’ve just created your first Jenkins job.</p><h3>Running and Monitoring a Job</h3><p>After creating a job, you need to <strong>build</strong> it manually:</p><ol><li>Open the job page.</li><li>Click on <strong>Build Now</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*7VPLcgLtVJRkWvh4zRlzMA.png" /></figure><ol><li>Check the <strong>Build History</strong> section.</li></ol><ul><li>A <strong>green mark</strong> indicates a successful build.</li><li>Each build is assigned a unique number.</li><li>If you make changes to a job, Jenkins creates a <strong>new build number</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*y3ONcxdvQhqeS_cFSNt5CA.png" /></figure><p>To view job details:</p><ul><li>Click on the build number → <strong>Console Output</strong>.</li><li>Here, you’ll see all the command executions and results.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0H1m6I044OgKqm7XMEr-tA.png" /></figure><h3>Handling Job Failures</h3><p>Sometimes, jobs fail. For example, if you type an incorrect command and save the job, the next build will fail. In <strong>Build History</strong>, failed jobs are shown clearly.</p><p>To troubleshoot:</p><ul><li>Click on the failed job.</li><li>Go to <strong>Console Output</strong>.</li><li>Check the error logs to understand why the job failed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0H1m6I044OgKqm7XMEr-tA.png" /></figure><p>Example: If a command is missing in the OS, Jenkins will throw an error. For instance, running vlc without installing it will fail. You’ll need to install missing packages using:</p><pre>yum install &lt;package-name&gt;</pre><h3>Advanced Example: Sleep and Process Monitoring</h3><p>Let’s say you want Jenkins to pause before executing a command. You can use the <strong>sleep</strong> command:</p><pre>sleep 30<br>date</pre><p>This job will wait 30 seconds before running the date command.</p><p>Meanwhile, on the Linux terminal, you can monitor Jenkins processes with:</p><pre>ps -aux | grep jenkins</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*26BV0QRxCM2fNFx02r88Pw.png" /></figure><p>You’ll notice a new process during job execution. Once completed, the process stops.</p><p>Behind the scenes, Jenkins runs shell scripts on the <strong>same operating system</strong> where it is installed. This is why missing commands in the OS lead to failures.</p><h3>Understanding Jenkins Users</h3><p>When you install Jenkins, it creates a dedicated <strong>Jenkins Linux user</strong>. This user is used to execute jobs. Remember:</p><ul><li>Every Linux user has limited privileges.</li><li>Only the <strong>root user</strong> has complete access.</li><li>Jenkins jobs run with the permissions of the Jenkins user unless configured otherwise.</li></ul><p>You can verify Jenkins installation with:</p><pre>rpm -q jenkins</pre><p><strong>Now it’s time to connect Jenkins with GitHub, run our first job, and explore how automation works using triggers.</strong></p><p>By the end of this article, you’ll know how to:</p><ul><li>Push code from your local machine to GitHub</li><li>Configure Jenkins to pull and build that code.</li><li>Install required plugins for GitHub integration</li><li>Automate jobs with <strong>Build Triggers</strong> (Periodic &amp; Poll SCM)</li></ul><h3>🔹 Step 1: Pushing Code to GitHub</h3><p>Before Jenkins can pull code, we first need to push something to GitHub.</p><ol><li><strong>Copy the Project URL</strong></li></ol><ul><li>From your GitHub repository, copy the HTTPS or SSH URL.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*pf9G-APEi8crogA2uJt0Vw.png" /></figure><ol><li><strong>Download the project (clone)</strong></li></ol><pre>git clone &lt;project-url&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LS8XKXsM1FZklhbputzblg.png" /></figure><p>This will download all the files, including the README.md.</p><ol><li><strong>Create a new file</strong><br> Let’s create a simple index.html file with a line of HTML.</li></ol><ul><li>&lt;h1&gt;Hello from Jenkins!&lt;/h1&gt;</li></ul><p><strong>3. Check Git status</strong></p><pre>git status</pre><p>Git will show that your new file is untracked.</p><p><strong>4. Add &amp; Commit</strong></p><pre>git add index.html<br>git commit -m &quot;Added index.html file&quot;</pre><p>This saves your changes locally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1W-K9Vg4gU7Xn0oa3DQlcA.png" /></figure><p><strong>5. Push to GitHub</strong></p><pre>git push origin main</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DQ5eBtDmIcp2-pIWdFUyLw.png" /></figure><p>✅ Now your file is uploaded to GitHub.</p><h3>🔹 Step 2: Creating a Job in Jenkins</h3><p>Now let’s tell Jenkins to pull this code.</p><ol><li>In Jenkins dashboard → click <strong>New Item</strong> → select <strong>Freestyle Project</strong>.</li><li>Name the job (e.g., GitHub_Integration_Test).</li><li>Go to <strong>Source Code Management → Git</strong>.</li><li>Paste the GitHub project URL.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qiwN6L20e7XSuetzgoSZnw.png" /></figure><p>But here’s the catch: ❌ You’ll see an error if Jenkins doesn’t have the Git plugin or Git command installed.</p><h3>🔹 Step 3: Installing Plugins in Jenkins</h3><p>Jenkins works like a smartphone 📱 — if you want a new feature, you need an app (plugin).</p><ul><li>Go to <strong>Manage Jenkins → Plugins</strong></li><li>Search for <strong>Git Plugin</strong></li><li>Install it</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zNbMot-xd-YgkhznakHp6Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ke3jiduJbOtdLsmG-COjLg.png" /></figure><h3>🔹 Step 4: Installing Git on the Server</h3><p>Even with the plugin, Jenkins still needs Git installed on the server itself.</p><p>On your AWS EC2 instance:</p><pre>sudo yum install git -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZjgXDLUtTPAQHRj7lBM4yQ.png" /></figure><p>After installation, go back to Jenkins and re-enter your GitHub project URL. ✅ Now Jenkins can pull the code.</p><h3>🔹 Step 5: Running the Job</h3><ul><li>Save the job configuration</li><li>Click <strong>Build Now</strong></li></ul><p>Jenkins will:</p><ul><li>Pull your code into a <strong>workspace folder</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dqbdThwIjhq2pCfU_YOROA.png" /></figure><ul><li>Store all downloaded files</li><li>Show logs in <strong>Console Output</strong></li></ul><p>If you see a success message → 🎉 You’ve successfully connected Jenkins with GitHub.</p><h3>🔹 Step 6: Adding a Build Step (Deploy Example)</h3><p>Let’s make Jenkins do something with the code.</p><ul><li>Go to your job → <strong>Configure</strong></li><li>Scroll to <strong>Build → Execute Shell</strong></li><li>Add a command, for example:</li></ul><pre>sudo yum install httpd<br>sudo cp * /var/www/html/<br>sudo systemctl start httpd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2ncJNJiN4O5nKJ9XhnnGw.png" /></figure><p>This install the apache webserver and copies files to your web server directory.<br> When you run the job → Jenkins updates the website automatically (e.g., color change in HTML).</p><h3>🔹 Step 7: Automating with Triggers</h3><p>Right now, you still have to click <strong>Build Now</strong> every time. That’s not true automation. Jenkins fixes this with <strong>Triggers</strong>.</p><h3>🔸 Option 1: Build Periodically</h3><p>Think of it like an alarm clock ⏰.</p><ul><li>Example: Run every day at 7 AM.</li></ul><p>Syntax:</p><pre>0 7 * * *</pre><p>But this method is wasteful. Even if no code changes happen, Jenkins runs every day.</p><h3>🔸 Option 2: Poll SCM</h3><p>This one’s smarter. Jenkins checks GitHub and only runs if there’s new code.</p><p>Syntax (run check every minute):</p><pre>* * * * *</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Idq_Jealr246TyE2R93I4A.png" /></figure><p>✅ Difference:</p><ul><li>Build Periodically → Runs regardless of code changes</li><li>Poll SCM → Runs only when code changes</li></ul><p>👉 Best practice: Use <strong>Poll SCM</strong> for efficiency.</p><h3>🔹 Step 8: Full Automation in Action</h3><p>Now, when a developer pushes new code to GitHub:</p><ol><li>Jenkins detects the change automatically (via Poll SCM).</li><li>Pulls the latest code.</li><li>Builds and deploys it.</li><li>You don’t even need to log in — Jenkins runs the job for you.</li></ol><p>This is the <strong>real power of CI/CD</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQ6GjgxFiQifIFHqfqrKIA.png" /></figure><h3>🏆 Key Takeaways</h3><ul><li>Git + Jenkins = Automated builds</li><li>Plugins extend Jenkins like apps on a smartphone</li><li>Triggers (Poll SCM &gt; Build Periodically) make builds automatic</li><li>We now have a <strong>basic CI/CD pipeline</strong>:<br> Developer → GitHub → Jenkins → Build → Deploy</li></ul><p>Step by step, you’ll master Jenkins and build a fully automated pipeline.</p><p>✍️ <em>This is Day 2 of the Jenkins series. Follow along for more hands-on DevOps automation!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=890841aea98e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>