<?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"><channel><title><![CDATA[Kubekode Blogs]]></title><description><![CDATA[Docker, Kubernetes, Web Development, Programming, Coding, Hacking, DevOps, App Development, Java, Python, JavaScript, Nodejs, React, Google, AWS, Amazon, Jobs, Tech, Technology, Database, Ansible.]]></description><link>https://blog.kubekode.io</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1698198642448/He44qlHG8.png</url><title>Kubekode Blogs</title><link>https://blog.kubekode.io</link></image><generator>RSS for Node</generator><lastBuildDate>Thu, 19 Nov 2026 03:25:09 GMT</lastBuildDate><atom:link href="https://blog.kubekode.io/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Kafka setup on Mac]]></title><description><![CDATA[✅ Follow these steps to set up and run the demo properly on your Mac. 🔹 1️⃣ Install Homebrew (if not installed) First, make sure Homebrew is installed on…]]></description><link>https://blog.kubekode.io/kafka-setup-on-mac</link><guid isPermaLink="true">https://blog.kubekode.io/kafka-setup-on-mac</guid><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Sun, 20 Apr 2025 17:29:42 GMT</pubDate><content:encoded><![CDATA[<p>✅ <strong>Follow these steps to set up and run the demo properly on your Mac.</strong></p>
<p><strong>🔹 1️⃣ Install Homebrew (if not installed)</strong></p>
<p>First, make sure <strong>Homebrew</strong> is installed on your Mac. Run:</p>
<pre><code class="lang-javascript">/bin/bash -c <span class="hljs-string">"$(curl -fsSL &lt;https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh&gt;)"</span>
</code></pre>
<p>✅ <strong>To check if Homebrew is installed</strong>, run:</p>
<pre><code class="lang-javascript">brew --version
</code></pre>
<p><strong>🔹 2️⃣ Install &amp; Start Apache Kafka on macOS</strong></p>
<p>1️⃣ <strong>Install Kafka using Homebrew</strong></p>
<pre><code class="lang-javascript">brew install kafka
</code></pre>
<p>2️⃣ <strong>Start Zookeeper (Kafka requires Zookeeper)</strong></p>
<pre><code class="lang-javascript">brew services start zookeeper
</code></pre>
<p>3️⃣ <strong>Start Kafka Broker</strong></p>
<pre><code class="lang-javascript">brew services start kafka
</code></pre>
<p>✅ <strong>Check if Kafka is running:</strong></p>
<pre><code class="lang-javascript">zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties &amp;
kafka-server-start /usr/local/etc/kafka/server.properties &amp;
</code></pre>
<p><em>(You should see Kafka running without errors.)</em></p>
<p><strong>🔹 3️⃣ Create a Kafka Topic (twitter-stream)</strong></p>
<pre><code class="lang-javascript">kafka-topics --create --topic twitter-stream --bootstrap-server localhost:<span class="hljs-number">9092</span> --partitions <span class="hljs-number">1</span> --replication-factor <span class="hljs-number">1</span>
</code></pre>
<p>✅ <strong>Verify topic creation:</strong></p>
<pre><code class="lang-bash">kafka-topics --list --bootstrap-server localhost:9092
</code></pre>
<p><em>(You should see twitter-stream in the list.)</em></p>
<p><strong>🔹 4️⃣ Start Kafka Producer (Simulate Live Tweets)</strong></p>
<p>✅ <strong>Send mock tweets into the Kafka topic:</strong></p>
<pre><code class="lang-javascript">kafka-<span class="hljs-built_in">console</span>-producer --topic twitter-stream --bootstrap-server localhost:<span class="hljs-number">9092</span>
</code></pre>
<p>✅ <strong>Manually enter some messages to simulate tweets:</strong></p>
<pre><code class="lang-javascript">{<span class="hljs-string">"user"</span>: <span class="hljs-string">"Alice"</span>, <span class="hljs-string">"tweet"</span>: <span class="hljs-string">"I love Spark Streaming!"</span>}
{<span class="hljs-string">"user"</span>: <span class="hljs-string">"Bob"</span>, <span class="hljs-string">"tweet"</span>: <span class="hljs-string">"Kafka is amazing for real-time data."</span>}
</code></pre>
<p><em>(These messages will be sent to the twitter-stream topic.)</em></p>
]]></content:encoded></item><item><title><![CDATA[Apache Kafka: From Zero to First Topic]]></title><description><![CDATA[Imagine you’re building a next‑generation streaming platform. Every time a user uploads a video, you need to: Generate thumbnails in multiple resolutions…]]></description><link>https://blog.kubekode.io/apache-kafka-from-zero-to-first-topic</link><guid isPermaLink="true">https://blog.kubekode.io/apache-kafka-from-zero-to-first-topic</guid><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Sun, 20 Apr 2025 17:16:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1745169390520/483e7317-68a2-44b6-b18f-0d0807f357ba.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1>Introduction</h1>
<p><a class="embed-card" href="https://www.youtube.com/watch?v=5VMmLjaUqdk&amp;t=12s">https://www.youtube.com/watch?v=5VMmLjaUqdk&amp;t=12s</a></p>

<p>Imagine you’re building a next‑generation streaming platform. Every time a user uploads a video, you need to:</p>
<ul>
<li><p>Generate thumbnails in multiple resolutions</p>
</li>
<li><p>Scan for inappropriate content</p>
</li>
<li><p>Update personalized recommendation feeds</p>
</li>
<li><p>Log upload events for real‑time analytics</p>
</li>
</ul>
<p>If you tried to perform all these steps <strong>synchronously</strong>—making the user’s browser wait until each task completes—you’d quickly run into timeouts, blocked resources, and frustrated users staring at loading spinners. Instead, you want to say:</p>
<blockquote>
<p>“Thanks! Your video is on its way—check back in a moment.”</p>
</blockquote>
<p>Behind the scenes, you enqueue each job so that specialized workers can pick them up and process independently. This decoupling keeps your APIs snappy and your backend resilient.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745165220273/51bef8da-d379-404c-bd34-6588a5435c5f.png" alt="" style="display:block;margin:0 auto" />

<p><strong>Why Kafka?</strong></p>
<ul>
<li><p><strong>Massive throughput</strong>: absorb millions of events per second without breaking a sweat.</p>
</li>
<li><p><strong>Durable, replayable log</strong>: retain your data for hours, days, or weeks, and replay history if you ever need to debug or rebuild a downstream service.</p>
</li>
<li><p><strong>Multi‑consumer fan‑out</strong>: let transcoding, captioning, analytics, and notification services all consume the same stream independently.</p>
</li>
</ul>
<p>In this blog, you’ll learn how to:</p>
<ol>
<li><p><strong>Install and start Kafka</strong> on your laptop in under five minutes</p>
</li>
<li><p><strong>Create topics</strong>, publish JSON messages, and consume them via the CLI</p>
</li>
<li><p><strong>Integrate Kafka</strong> into a simple Node.js app using KafkaJS</p>
</li>
<li><p><strong>Understand Kafka’s architecture</strong>—topics, partitions, brokers, and consumer groups</p>
</li>
<li><p><strong>Plan for scale</strong> with partitions, replication, and multi‑cluster setups</p>
</li>
</ol>
<p>By the end, you’ll have a working Kafka setup and the key concepts to architect real‑world, event‑driven systems. Ready? Let’s dive in!</p>
<h1>Synchronous vs. Asynchronous Processing</h1>
<p>Before we dive into Kafka, it’s crucial to understand <strong>why</strong> we need asynchronous workflows—and how they differ from the traditional synchronous model.</p>
<h3>Quick Recap of Synchronous Calls</h3>
<p>In a <strong>synchronous</strong> interaction, the client sends a request and <strong>waits</strong> for the server to complete processing before it can continue.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745160004775/7be45801-410a-478f-87c0-b93978b454d8.png" alt="" style="display:block;margin:0 auto" />

<p><strong>Characteristics:</strong></p>
<ul>
<li><p><strong>Blocking:</strong> The client (or HTTP connection) remains open until the server responds.</p>
</li>
<li><p><strong>Resource‑intensive:</strong> Server threads or containers stay occupied for the entire duration.</p>
</li>
<li><p><strong>Timeout risk:</strong> If processing takes too long (e.g., &gt;30 s), HTTP timeouts may abort the request.</p>
</li>
</ul>
<hr />
<h3>Why Long‑Running Tasks Demand Async</h3>
<p>Consider a task that takes <strong>10 minutes</strong> to complete—such as video transcoding or generating a complex report. In a synchronous model:</p>
<ul>
<li><p><strong>User frustration:</strong> They stare at a spinner or progress bar for minutes.</p>
</li>
<li><p><strong>HTTP limits:</strong> Most load balancers and browsers will time out long‑running requests.</p>
</li>
<li><p><strong>Scalability issues:</strong> Server resources (CPU, threads) stay tied up, reducing overall throughput.</p>
</li>
</ul>
<p>To avoid these pitfalls, we shift to <strong>asynchronous</strong> processing.</p>
<hr />
<h3>Asynchronous Programming</h3>
<p>With <strong>asynchronous</strong> design, the flow becomes:</p>
<ol>
<li><p><strong>Client</strong> sends a request.</p>
</li>
<li><p><strong>Server</strong> immediately responds: “Your job is queued (ID 123).”</p>
</li>
<li><p><strong>Server</strong> enqueues a task message in a broker.</p>
</li>
<li><p><strong>Client</strong> is free to continue or poll status later.</p>
</li>
<li><p><strong>Worker</strong> pulls the message, processes it, then sends a completion notification.</p>
</li>
</ol>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745165648499/b9f7794e-cc9b-45a2-a4a6-d8e040d9b560.png" alt="" style="display:block;margin:0 auto" />

<p>But we don’t send the request to worker directly, instead we use a message broker in between:</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745165776415/266bf123-4883-4147-b27b-cc5486209c72.png" alt="" style="display:block;margin:0 auto" />

<h3>Why Introduce a Message Broker?</h3>
<p>You might ask: <em>Why not call the worker directly?</em> A message broker in between gives you:</p>
<ol>
<li><p><strong>Reliability</strong></p>
<ul>
<li>If the producer (API) crashes after enqueueing, the job isn’t lost—workers still see it.</li>
</ul>
</li>
<li><p><strong>Retry &amp; Dead‑Letter</strong></p>
<ul>
<li>Failed tasks remain in the broker and can be retried or moved to a dead‑letter queue for inspection.</li>
</ul>
</li>
<li><p><strong>Decoupling</strong></p>
<ul>
<li>Producers and consumers can scale, deploy, and evolve independently without tight coupling.</li>
</ul>
</li>
<li><p><strong>Load Buffering</strong></p>
<ul>
<li>Spikes in incoming jobs are smoothed out—workers process at their own pace.</li>
</ul>
</li>
<li><p><strong>Visibility &amp; Monitoring</strong></p>
<ul>
<li>You get a central queue of all pending and processed jobs for auditing and metrics.</li>
</ul>
</li>
</ol>
<h1>What Is a Message Broker?</h1>
<p>A <strong>message broker</strong> is middleware that sits between the parts of your system that <strong>produce</strong> work and the parts that <strong>consume</strong> it. Instead of coupling your API directly to your workers, you hand off tasks as messages to the broker. Workers pull messages when they’re ready, process them, and then acknowledge completion.</p>
<hr />
<h3>Role of the Message Broker</h3>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745165966135/f6521e93-1d6c-46b5-a983-07095d61a915.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><p><strong>Intermediary</strong><br />Acts as a buffer and router for messages, decoupling producers and consumers.</p>
</li>
<li><p><strong>Durable Store</strong><br />Persists messages until they’re successfully processed.</p>
</li>
<li><p><strong>Traffic Smoother</strong><br />Absorbs spikes by queueing messages for later processing.</p>
</li>
</ul>
<hr />
<h3>Key Benefits</h3>
<ol>
<li><p><strong>Reliability</strong></p>
<ul>
<li>Messages aren’t lost if producers or consumers crash—they remain in the broker until acknowledged.</li>
</ul>
</li>
<li><p><strong>Retry Capability</strong></p>
<ul>
<li>Failed processing attempts leave messages in place (or move them to a dead‑letter queue) for automatic retries.</li>
</ul>
</li>
<li><p><strong>Decoupling</strong></p>
<ul>
<li>Producers and consumers evolve, scale, and deploy independently—no direct dependencies.</li>
</ul>
</li>
<li><p><strong>Load Buffering</strong></p>
<ul>
<li>Surges in incoming work are absorbed, preventing downstream overload.</li>
</ul>
</li>
<li><p><strong>Observability</strong></p>
<ul>
<li>Centralized visibility into pending, in‑flight, and failed messages for monitoring and metrics.</li>
</ul>
</li>
</ol>
<hr />
<h3>Producer vs. Consumer Terminology</h3>
<table>
<thead>
<tr>
<th>Role</th>
<th>Definition</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Producer</strong></td>
<td>The component (API, service, microservice) that <strong>publishes</strong> messages into the broker.</td>
</tr>
<tr>
<td><strong>Consumer</strong></td>
<td>The worker or service that <strong>subscribes</strong> to, <strong>pulls</strong>, and <strong>processes</strong> messages from the broker.</td>
</tr>
</tbody></table>
<ul>
<li><p><strong>Producer Responsibilities</strong></p>
<ul>
<li><p>Create and publish well‑formed messages (e.g., JSON payloads).</p>
</li>
<li><p>Handle broker connection errors and retries on publish.</p>
</li>
</ul>
</li>
<li><p><strong>Consumer Responsibilities</strong></p>
<ul>
<li><p>Subscribe to one or more queues/topics.</p>
</li>
<li><p>Process messages exactly once (or at‑least once) and acknowledge upon success.</p>
</li>
<li><p>Handle poison messages and route to dead‑letter queues if necessary.</p>
</li>
</ul>
</li>
</ul>
<h1>Message Queues vs. Message Streams</h1>
<p>Not all message brokers behave the same. They fall into two broad patterns: <strong>message queues</strong> for one‑to‑one delivery, and <strong>message streams</strong> for one‑to‑many delivery. Choose the right pattern based on your use case.</p>
<hr />
<h3>One‑to‑One Delivery: Message Queues</h3>
<p>A <strong>message queue</strong> ensures each message is delivered to exactly one consumer. Once that consumer processes the message, it’s removed from the queue.</p>
<h4>Characteristics</h4>
<ul>
<li><p><strong>Exclusive consumption</strong>: Each message is consumed (and deleted) by a single worker.</p>
</li>
<li><p><strong>Linear scaling</strong>: Add more consumers to increase processing throughput; each picks a unique message.</p>
</li>
<li><p><strong>Simple retry semantics</strong>: Failed messages can be re‑queued or sent to a dead‑letter queue.</p>
</li>
</ul>
<h4>Typical Use Cases</h4>
<ul>
<li><p><strong>Task offloading</strong>: Video transcoding, image resizing, email sending.</p>
</li>
<li><p><strong>Work queues</strong>: Distribute independent jobs among a pool of workers.</p>
</li>
</ul>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745166186615/63f20b2c-9a26-4f57-8a7c-996a871b0505.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h3>One‑to‑Many Delivery: Message Streams</h3>
<p>A <strong>message stream</strong> (or log) allows multiple, independent consumer groups to each read the full sequence of messages—without removing them.</p>
<h4>Characteristics</h4>
<ul>
<li><p><strong>Broadcast semantics</strong>: Every consumer group sees every message.</p>
</li>
<li><p><strong>Configurable retention</strong>: Messages stay available for a defined window (e.g., 7 days).</p>
</li>
<li><p><strong>Replayability</strong>: Consumers can rewind their offset to reprocess history.</p>
</li>
</ul>
<h4>Typical Use Cases</h4>
<ul>
<li><p><strong>Event‑driven architectures</strong>: Multiple services (analytics, auditing, notifications) consume the same events.</p>
</li>
<li><p><strong>Real‑time analytics</strong>: Dashboards, stream processing engines, machine‑learning pipelines.</p>
</li>
</ul>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745166360169/cf9af67d-9ece-4dbf-9821-8a03d4ec1a12.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h3>4.3 When to Choose Which</h3>
<table>
<thead>
<tr>
<th>Criteria</th>
<th>Message Queue</th>
<th>Message Stream</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Delivery model</strong></td>
<td>One‑to‑one</td>
<td>One‑to‑many</td>
</tr>
<tr>
<td><strong>Retention</strong></td>
<td>Deleted on successful consume</td>
<td>Retained for a time or size window</td>
</tr>
<tr>
<td><strong>Reprocessing</strong></td>
<td>Harder (message gone)</td>
<td>Easy (rewind offset)</td>
</tr>
<tr>
<td><strong>Scaling</strong></td>
<td>Add more consumers</td>
<td>Add consumer groups &amp; partitions</td>
</tr>
<tr>
<td><strong>Use cases</strong></td>
<td>Job queues, background tasks</td>
<td>Event sourcing, analytics, pub/sub</td>
</tr>
</tbody></table>
<ul>
<li><p><strong>Choose a message queue</strong> when you have discrete jobs that each need processing by exactly one worker—e.g., transcoding video files or sending transactional emails.</p>
</li>
<li><p><strong>Choose a message stream</strong> when the same data must feed multiple independent consumers, and you want the ability to replay history—e.g., clickstream analytics, audit logs, or multi‑service event dissemination.</p>
</li>
</ul>
<h1>Introduction to Apache Kafka</h1>
<p>Apache Kafka is a <strong>distributed streaming platform</strong> built to handle real‑time data feeds with high throughput, low latency, and strong durability guarantees. It combines the best of message queues (decoupling, reliability) and publish‑subscribe systems (fan‑out, replay) into a single, scalable log‑based architecture.</p>
<hr />
<h3>Kafka as a Distributed Stream Platform</h3>
<ul>
<li><p><strong>Append‑Only Log</strong><br />Kafka stores each topic as an ordered, immutable sequence of records. Producers <em>append</em> to the log; consumers <em>read</em> at their own pace.</p>
</li>
<li><p><strong>Partitioning for Scale</strong><br />Topics are sharded into <strong>partitions</strong>, each hosted on one of many brokers. More partitions = more parallelism.</p>
</li>
<li><p><strong>Replication for Durability</strong><br />Each partition is replicated across multiple brokers. If one broker fails, another replica seamlessly takes over.</p>
</li>
<li><p><strong>Consumer Offset Tracking</strong><br />Consumers maintain their own <strong>offset</strong> within each partition. They decide when to commit, rewind, or skip messages.</p>
</li>
<li><p><strong>Retention Policies</strong><br />Messages are retained for a configurable window (time‑based or size‑based), enabling replay and auditability.</p>
</li>
</ul>
<h3>Real‑World Use‑Cases</h3>
<ol>
<li><p><strong>GPS Telemetry (e.g., Ride‑hail Apps)</strong></p>
<ul>
<li><p><strong>Challenge:</strong> Thousands of drivers send location pings every few seconds.</p>
</li>
<li><p><strong>Solution:</strong> Write all pings to Kafka instantly; batch‑persist to database every few minutes to avoid overwhelming your datastore.</p>
</li>
</ul>
</li>
<li><p><strong>Video Upload Pipelines</strong></p>
<ul>
<li><p><strong>Challenge:</strong> An upload triggers transcoding, thumbnail generation, content scanning, and analytics logging.</p>
</li>
<li><p><strong>Solution:</strong> Upload service publishes a single “videoUploaded” event; multiple downstream services consume and process concurrently.</p>
</li>
</ul>
</li>
<li><p><strong>Website Clickstreams</strong></p>
<ul>
<li><p><strong>Challenge:</strong> Track user clicks and page views in real time for personalization and A/B testing.</p>
</li>
<li><p><strong>Solution:</strong> Front‑end pushes events to Kafka; real‑time dashboards and recommendation engines consume the same stream.</p>
</li>
</ul>
</li>
<li><p><strong>IoT Sensor Networks</strong></p>
<ul>
<li><p><strong>Challenge:</strong> Millions of sensors emit temperature/humidity data at high frequency.</p>
</li>
<li><p><strong>Solution:</strong> Sensors publish readings to Kafka; stream processors aggregate, detect anomalies, and drive alerting systems.</p>
</li>
</ul>
</li>
</ol>
<h1>Kafka Core Concepts &amp; Internals</h1>
<p>To master Kafka, you need to understand its foundational building blocks: <strong>topics</strong>, <strong>partitions</strong>, <strong>offsets</strong>, and how <strong>brokers</strong>, <strong>leaders/followers</strong>, and <strong>consumer groups</strong> work together to deliver a scalable, fault‑tolerant stream platform.</p>
<h3>Topics, Partitions &amp; Offsets</h3>
<h4>Topics</h4>
<p>A <strong>topic</strong> is a named feed to which records are appended. Think of it as a log file for a particular event type (e.g., <code>user-signups</code>, <code>order-events</code>).</p>
<h4>Partitions</h4>
<p>Each topic is split into one or more <strong>partitions</strong>, which are independent, ordered logs. Partitions allow you to:</p>
<ul>
<li><p><strong>Parallelize</strong> consumption: multiple consumers can read different partitions concurrently.</p>
</li>
<li><p><strong>Scale</strong> producers: you can spread writes across brokers.</p>
</li>
</ul>
<h4>Offsets</h4>
<p>An <strong>offset</strong> is a sequential ID assigned to each message within its partition. Consumers use offsets to track their position in the log:</p>
<ul>
<li><p><strong>Commit offset</strong> when a message is processed.</p>
</li>
<li><p><strong>Rewind</strong> by resetting to an earlier offset for replay or recovery.</p>
</li>
</ul>
<h3>Brokers, Leaders/Followers &amp; Consumer Groups</h3>
<h4>Brokers</h4>
<p>A <strong>broker</strong> is a Kafka server instance that hosts one or more partitions. A Kafka <strong>cluster</strong> is a set of brokers working together.</p>
<ul>
<li>More brokers → more capacity and fault tolerance.</li>
</ul>
<h4>Leaders &amp; Followers</h4>
<p>Within each partition:</p>
<ul>
<li><p>One broker acts as the <strong>leader</strong> (handles all reads/writes).</p>
</li>
<li><p>Other brokers host <strong>follower</strong> replicas, staying in sync with the leader.</p>
</li>
</ul>
<p>If the leader fails, a follower is automatically promoted—ensuring continuity.</p>
<h4>Consumer Groups</h4>
<p>A <strong>consumer group</strong> is a set of consumers identified by a <strong>group ID</strong>. Kafka guarantees:</p>
<ul>
<li><p><strong>Each partition</strong> is consumed by <strong>exactly one</strong> consumer in the group.</p>
</li>
<li><p><strong>Rebalance</strong> on group membership changes (consumers join/leave).</p>
</li>
</ul>
<p>This provides horizontal scaling and fault tolerance for message processing.</p>
<p>With these core concepts—topics as logs, partitions for parallelism, offsets for position tracking, brokers for storage, leader/follower replication for durability, and consumer groups for scale—you’re now equipped to design and run Kafka clusters that power real‑time, event‑driven applications.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745166934155/31e52ee3-6b3d-489e-a360-f70197d17b7e.png" alt="" style="display:block;margin:0 auto" />

<h1>Kafka Cluster Architecture</h1>
<p>A Kafka <strong>cluster</strong> is a coordinated group of server processes (brokers) managed by a controller layer (ZooKeeper or KRaft), designed for high availability and fault tolerance. Below is an overview of its key components and behaviours.</p>
<h3>Controllers: ZooKeeper vs. KRaft</h3>
<ul>
<li><p><strong>ZooKeeper (pre‑3.3)</strong></p>
<ul>
<li><p>An external service that stores Kafka’s metadata (topics, partitions, ACLs).</p>
</li>
<li><p>Manages leader elections: when a broker fails, ZooKeeper selects new partition leaders.</p>
</li>
<li><p>Requires a separate ensemble of ZooKeeper nodes (odd number, e.g., 3 or 5).</p>
</li>
</ul>
</li>
<li><p><strong>KRaft (Kafka Raft, 3.3+)</strong></p>
<ul>
<li><p>Built‑in consensus layer replacing ZooKeeper.</p>
</li>
<li><p>Brokers themselves form a quorum, storing metadata in an internal “controller” role.</p>
</li>
<li><p>Simplifies deployment: no external ZooKeeper cluster needed.</p>
</li>
</ul>
</li>
</ul>
<h3>Brokers &amp; Partition Placement</h3>
<p>Each <strong>broker</strong> in the cluster hosts zero or more <strong>partitions</strong> for each topic. Kafka distributes partitions across brokers to balance load.</p>
<h3>Replication for Durability</h3>
<p>Kafka replicates each partition across multiple brokers:</p>
<ul>
<li><p><strong>Replication Factor</strong></p>
<ul>
<li><p>Configurable per topic (e.g., <code>replication-factor=3</code>).</p>
</li>
<li><p>Ensures up to two broker failures without data loss.</p>
</li>
</ul>
</li>
<li><p><strong>Leader &amp; Followers</strong></p>
<ul>
<li><p><strong>Leader</strong>: Handles all reads and writes for that partition.</p>
</li>
<li><p><strong>Followers</strong>: Continuously fetch and replicate the leader’s log.</p>
</li>
</ul>
</li>
</ul>
<h3>Failover &amp; High Availability</h3>
<p>When a broker hosting a partition leader goes down:</p>
<ol>
<li><p><strong>Controller</strong> detects the broker failure via ZooKeeper/KRaft heartbeat.</p>
</li>
<li><p><strong>Controller</strong> elects a new leader from the in‑sync replicas (ISRs).</p>
</li>
<li><p><strong>Clients</strong> automatically redirect reads and writes to the new leader.</p>
</li>
</ol>
<p>With controllers orchestrating the cluster, brokers storing and serving partitions, replication safeguarding data, and automatic failover maintaining availability, Kafka’s architecture delivers a robust foundation for real‑time, mission‑critical streaming applications.</p>
<img src="https://www.researchgate.net/publication/326564203/figure/fig2/AS:849339324837888@1579509683392/Kafkas-architecture-illustrated-with-3-partitions-3-replicas-and-5-brokers.ppm" alt="Kafka's architecture (illustrated with 3 partitions, 3 replicas and 5... |  Download Scientific Diagram" />

<h1>Installing &amp; Getting Started</h1>
<p>Before we can publish or consume any messages, we need a running Kafka cluster on our machine. Follow these steps to install Java, download Kafka, and launch either the classic ZooKeeper‑backed broker or the newer KRaft mode.</p>
<h4>Java Requirement</h4>
<p>Kafka runs on the JVM, so you’ll need <strong>Java 11 or newer</strong> installed:</p>
<pre><code class="language-bash"># Verify your Java version
java -version
# Example output: openjdk version "11.0.16" 2022‑07‑19 LTS
</code></pre>
<h4>Download &amp; Unpack Kafka</h4>
<ol>
<li><p><strong>Download the latest Kafka release</strong> (e.g., 3.4.0):</p>
<pre><code class="language-bash">curl -O https://downloads.apache.org/kafka/3.4.0/kafka_2.13-3.4.0.tgz
</code></pre>
</li>
<li><p><strong>Extract the archive</strong>:</p>
<pre><code class="language-bash">tar -xzf kafka_2.13-3.4.0.tgz
cd kafka_2.13-3.4.0
</code></pre>
</li>
<li><p><strong>Directory layout</strong> (abbreviated):</p>
<pre><code class="language-bash">kafka_2.13-3.4.0/
├── bin/            # CLI scripts
├── config/         # Default configs (broker, ZooKeeper)
├── libs/           # Kafka and dependencies
└── logs/           # (created at runtime)
</code></pre>
</li>
</ol>
<h4>Starting Kafka in ZooKeeper Mode</h4>
<blockquote>
<p><strong>Note:</strong> This is the “classic” mode available in all Kafka versions prior to 3.3 (or when you choose not to enable KRaft).</p>
</blockquote>
<ol>
<li><p><strong>Launch ZooKeeper</strong> (broker metadata store):</p>
<pre><code class="language-bash">bin/zookeeper-server-start.sh config/zookeeper.properties &amp;
</code></pre>
</li>
<li><p><strong>Start the Kafka broker</strong>:</p>
<pre><code class="language-bash">bin/kafka-server-start.sh config/server.properties &amp;
</code></pre>
</li>
<li><p><strong>Verify both processes</strong> are running (on macOS/Linux):</p>
<pre><code class="language-bash">ps aux | grep -E 'zookeeper|kafka-server'
</code></pre>
</li>
<li><p><strong>Check broker logs</strong> (<code>logs/server.log</code>) for a “started” message.</p>
</li>
</ol>
<h1>Command‑Line Quickstart Demo</h1>
<p>Let’s verify your Kafka installation end‑to‑end using the built‑in CLI tools. We’ll:</p>
<ol>
<li><p><strong>Create</strong> a topic named <code>test-topic</code> with 3 partitions.</p>
</li>
<li><p><strong>Produce</strong> a couple of JSON messages into it.</p>
</li>
<li><p><strong>Consume</strong> all messages from the beginning.</p>
</li>
</ol>
<pre><code class="language-bash">
# 1. Create “test-topic” with 3 partitions and replication factor 1
bin/kafka-topics.sh --create \
  --topic test-topic \
  --bootstrap-server localhost:9092 \
  --partitions 3 \
  --replication-factor 1

# 2. Produce two JSON messages
echo '{"user":"alice","action":"login"}' | \
  bin/kafka-console-producer.sh --topic test-topic --bootstrap-server localhost:9092

echo '{"user":"bob","action":"purchase","item":"book"}' | \
  bin/kafka-console-producer.sh --topic test-topic --bootstrap-server localhost:9092

# 3. Consume all messages from the beginning
bin/kafka-console-consumer.sh \
  --topic test-topic \
  --bootstrap-server localhost:9092 \
  --from-beginning
</code></pre>
<h2>Node.js App Integration Demo</h2>
<p>In this section, we’ll build a minimal Node.js app that:</p>
<ol>
<li><p><strong>Produces</strong> JSON messages into <code>test-topic</code></p>
</li>
<li><p><strong>Consumes</strong> messages from <code>test-topic</code> in real time</p>
</li>
</ol>
<p>We’ll use the <strong>kafkajs</strong> library for simplicity and clarity.</p>
<h3>Project Setup</h3>
<ol>
<li><p><strong>Create a new directory</strong> and initialize npm:</p>
<pre><code class="language-bash">mkdir hello-kafka
cd hello-kafka
npm init -y
</code></pre>
</li>
<li><p><strong>Install kafkajs</strong>:</p>
<pre><code class="language-bash">npm install kafkajs
</code></pre>
</li>
</ol>
<h3>Producer (<code>producer.js</code>)</h3>
<p>Create a file named <code>producer.js</code> with the following content:</p>
<pre><code class="language-javascript">const { Kafka } = require('kafkajs');

// 1. Configure the client to connect to our local broker
const kafka = new Kafka({
  clientId: 'my-producer',
  brokers: ['localhost:9092']
});

// 2. Create a producer instance
const producer = kafka.producer();

async function runProducer() {
  // 3. Establish connection
  await producer.connect();

  // 4. Send messages to 'test-topic'
  await producer.send({
    topic: 'test-topic',
    messages: [
      { key: 'alice', value: JSON.stringify({ action: 'login', timestamp: Date.now() }) },
      { key: 'bob',   value: JSON.stringify({ action: 'purchase', item: 'book', timestamp: Date.now() }) }
    ]
  });

  console.log('Messages sent successfully');

  // 5. Disconnect when done
  await producer.disconnect();
}

runProducer().catch(error =&gt; {
  console.error('Error in producer:', error);
  process.exit(1);
});
</code></pre>
<h3>Consumer (<code>consumer.js</code>)</h3>
<p>Create a file named <code>consumer.js</code> with the following content:</p>
<pre><code class="language-javascript">const { Kafka } = require('kafkajs');

// 1. Configure the client to connect to our local broker
const kafka = new Kafka({
  clientId: 'my-consumer',
  brokers: ['localhost:9092']
});

// 2. Create a consumer instance in the group 'demo-group'
const consumer = kafka.consumer({ groupId: 'demo-group' });

async function runConsumer() {
  // 3. Establish connection
  await consumer.connect();

  // 4. Subscribe to our topic from the very beginning
  await consumer.subscribe({ topic: 'test-topic', fromBeginning: true });

  console.log('🔔 Consumer is running and listening for messages...');

  // 5. Process each incoming message
  await consumer.run({
    eachMessage: async ({ partition, message }) =&gt; {
      const prefix = `Partition ${partition} | Offset ${message.offset}`;
      console.log(`${prefix} | Key: ${message.key.toString()} | Value: ${message.value.toString()}`);
    }
  });
}

runConsumer().catch(error =&gt; {
  console.error('Error in consumer:', error);
  process.exit(1);
});
</code></pre>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745169035325/62d7b2e0-5ee4-4f91-b217-5b7f5ba589bd.png" alt="" style="display:block;margin:0 auto" />

<p><strong>Next steps to deepen your Kafka expertise:</strong></p>
<ul>
<li><p><strong>Schema Management:</strong> Explore Confluent Schema Registry with Avro/Protobuf.</p>
</li>
<li><p><strong>Stream Processing:</strong> Build real‑time transforms using Kafka Streams or ksqlDB.</p>
</li>
<li><p><strong>Exactly‑Once Semantics:</strong> Understand idempotent producers and transactional messaging.</p>
</li>
<li><p><strong>Operational Best Practices:</strong> Monitor with Prometheus/Grafana, configure security (TLS/SASL), and perform rolling upgrades.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Cloud System Design: Choosing Between Kubernetes, Serverless, and VMs]]></title><description><![CDATA[Have you ever wondered what’s the best way to deploy and manage your applications in the cloud? Should you go with the container orchestration power of…]]></description><link>https://blog.kubekode.io/cloud-system-design-choosing-between-kubernetes-serverless-and-vms</link><guid isPermaLink="true">https://blog.kubekode.io/cloud-system-design-choosing-between-kubernetes-serverless-and-vms</guid><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:34:30 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1743964406753/bdb05f01-67f9-4d58-8719-ed51fc9faa25.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you ever wondered what’s the best way to deploy and manage your applications in the cloud?</p>
<p>Should you go with the container orchestration power of <strong>Kubernetes</strong>, the simplicity of <strong>Serverless</strong>, or the flexibility of <strong>Virtual Machines (VMs)</strong>?</p>
<p>In this blog, we’ll break down these technologies and go a step further by exploring <strong>real-world scenarios</strong>, <strong>flowcharts</strong>, and <strong>system design principles</strong> to help you make informed choices.</p>
<h2 id="heading-why-cloud-technology-matters-in-system-design">Why Cloud Technology Matters in System Design?</h2>
<p>Modern applications need to scale, recover, and respond to changing workloads efficiently. Choosing the right cloud technology isn't just about cost—it's about aligning with your app’s <strong>architecture</strong>, <strong>traffic patterns</strong>, and <strong>team capabilities</strong>.</p>
<h2 id="heading-understanding-the-technologies">🛠️ Understanding the Technologies</h2>
<h3 id="heading-kubernetes">🚢 Kubernetes</h3>
<p>Kubernetes is an open-source platform that automates the deployment, scaling, and management of <strong>containerized applications</strong>.</p>
<p><strong>Key Features:</strong></p>
<ul>
<li><p>Auto-healing containers</p>
</li>
<li><p>Load balancing</p>
</li>
<li><p>Rolling updates</p>
</li>
<li><p>Strong ecosystem</p>
</li>
</ul>
<p><strong>Real-World Example:</strong> Think of an <strong>e-commerce platform</strong> with microservices like <code>cart</code>, <code>checkout</code>, and <code>inventory</code>. Kubernetes can auto-scale these services during sales events and restart failed containers automatically.</p>
<h3 id="heading-serverless-eg-aws-lambda-azure-functions">⚡ Serverless (e.g., AWS Lambda, Azure Functions)</h3>
<p>Serverless computing abstracts away server management. You just write the code, and the cloud provider takes care of provisioning and scaling.</p>
<p><strong>Key Features:</strong></p>
<ul>
<li><p>No server management</p>
</li>
<li><p>Pay-as-you-go pricing</p>
</li>
<li><p>Instant scalability</p>
</li>
<li><p>Event-driven</p>
</li>
</ul>
<p><strong>Example:</strong> You upload a file to an <strong>S3 bucket</strong>. This event triggers an AWS <strong>Lambda</strong> function that resizes the image and stores it in another bucket. You only pay for the compute time used.</p>
<p><strong>Flow:</strong></p>
<ol>
<li><p>File uploaded to S3</p>
</li>
<li><p>Lambda function is triggered</p>
</li>
<li><p>Image is processed</p>
</li>
<li><p>Output saved to DynamoDB or sent to SQS</p>
</li>
</ol>
<h3 id="heading-virtual-machines-vms">🖥️ Virtual Machines (VMs)</h3>
<p>VMs offer complete control over an operating system. They are ideal for <strong>legacy applications</strong> that can't be containerized.</p>
<p><strong>Use Case:</strong> Migrating a traditional <strong>ERP system</strong> to the cloud? Use VMs to recreate the environment without changing the application code.</p>
<h2 id="heading-cloud-system-design-principles">🔍 Cloud System Design Principles</h2>
<h3 id="heading-event-driven-architecture">📌 Event-Driven Architecture</h3>
<ul>
<li><p>Decouples producers and consumers</p>
</li>
<li><p>Enables scalability and fault tolerance</p>
</li>
</ul>
<p><strong>Example:</strong> Order service emits an event. Payment and Notification services subscribe and process it independently.</p>
<h3 id="heading-asynchronous-programming">🔄 Asynchronous Programming</h3>
<ul>
<li><p>Allows non-blocking operations</p>
</li>
<li><p>Ideal for background tasks and queues</p>
</li>
</ul>
<h3 id="heading-scalability">📈 Scalability</h3>
<ul>
<li><p>Use horizontal scaling, event queues, and Kubernetes autoscalers</p>
</li>
<li><p>Decouple services to avoid bottlenecks</p>
</li>
</ul>
<h2 id="heading-real-world-system-design-scenarios">🌍 Real-World System Design Scenarios</h2>
<h3 id="heading-1-e-commerce-with-event-driven-serverless-architecture">1. 🛒 E-Commerce with Event-Driven Serverless Architecture</h3>
<p><strong>Scenario:</strong> After a user places an order:</p>
<ul>
<li><p>The <strong>Payment Service</strong> must process it immediately.</p>
</li>
<li><p>The <strong>Notification Service</strong> can be slightly delayed.</p>
</li>
</ul>
<p><strong>Solution:</strong></p>
<ul>
<li><p><strong>Synchronous call</strong> to the Payment API</p>
</li>
<li><p><strong>Asynchronous event</strong> sent to a message queue (like SQS)</p>
</li>
<li><p>The notification service subscribes and processes when ready</p>
</li>
</ul>
<p><strong>Flowchart:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743948741038/08a9caa4-605e-4638-b3de-8177b1144d9f.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p>Order placed</p>
</li>
<li><p>Call Payment API (synchronously)</p>
</li>
<li><p>On success, publish event to SQS</p>
</li>
<li><p>Show the success page</p>
</li>
<li><p>The notification service sends email/SMS</p>
</li>
</ol>
<p><strong>Why This Works:</strong></p>
<ul>
<li><p>Immediate processing for critical paths</p>
</li>
<li><p>Loose coupling for scalability</p>
</li>
</ul>
<h3 id="heading-2-real-time-chat-app-with-kubernetes">2. 💬 Real-Time Chat App with Kubernetes</h3>
<p><strong>Scenario:</strong> A real-time chat app with services like <code>users</code>, <code>messages</code>, and <code>notifications</code>.</p>
<p><strong>Solution Using Kubernetes:</strong></p>
<ul>
<li><p>Deploy each service as a <strong>microservice</strong></p>
</li>
<li><p>Use <strong>Ingress Controller</strong> for routing</p>
</li>
<li><p>Use <strong>Horizontal Pod Autoscaler</strong> for scaling <code>messages</code> service</p>
</li>
<li><p>Store secrets in <strong>ConfigMaps</strong> and <strong>Secrets</strong></p>
</li>
<li><p>Monitor with <strong>Prometheus</strong> and <strong>Grafana</strong></p>
</li>
</ul>
<p><strong>Flowchart:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743948797059/02d9aebc-adb1-499c-a907-35d18809eca9.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p>User sends a message</p>
</li>
<li><p>Routed via Ingress to <code>messages</code> service</p>
</li>
<li><p><code>Messages</code> calls <code>users</code> service for validation</p>
</li>
<li><p>Message saved to DB (e.g., MongoDB)</p>
</li>
<li><p><code>Notifications</code> service sends real-time alert</p>
</li>
<li><p>Kubernetes auto-scales as needed</p>
</li>
</ol>
<h3 id="heading-3-healthcare-management-system-on-vms-with-load-balancer">3. Healthcare Management System on VMs with Load Balancer</h3>
<p>You’re managing a <strong>healthcare management system</strong> used by hospitals to manage patient records, appointments, and billing. The application is a <strong>monolithic Java app</strong> that can't be easily containerized or split into microservices (yet). Still, it needs to scale to handle the load from multiple hospitals accessing it concurrently.</p>
<h3 id="heading-solution-using-vms-load-balancer">Solution Using VMs + Load Balancer:</h3>
<ol>
<li><p>Deploy the monolithic Java application on <strong>multiple VMs</strong> (e.g., EC2 instances in AWS).</p>
</li>
<li><p>Use a <strong>cloud load balancer</strong> (like AWS ELB or GCP Load Balancer) in front of the VMs to:</p>
<ul>
<li><p>Distribute incoming HTTP requests</p>
</li>
<li><p>Check VM health using health checks</p>
</li>
<li><p>Automatically reroute traffic in case of a VM failure</p>
</li>
</ul>
</li>
<li><p>Store data in a <strong>centralized database</strong> (like Amazon RDS or Cloud SQL).</p>
</li>
<li><p>Use <strong>auto-scaling groups</strong> to spin up or down VMs based on CPU or request load.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743950195657/a40e87ba-76b2-455b-b463-251b1e3f4f45.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-hybrid-approach-why-mix-technologies">The Hybrid Approach: Why Mix Technologies?</h2>
<h3 id="heading-kubernetes-for-microservices">Kubernetes for Microservices</h3>
<p>Amazon EKS (Elastic Kubernetes Service) is used for running key microservices:</p>
<ul>
<li><p><strong>Authentication, Course Management, and User Profiles:</strong> These are critical, stateful components that benefit from Kubernetes' robust scheduling and orchestration.</p>
</li>
<li><p><strong>Real-Time Communication:</strong> A dedicated chat service using WebSockets can dynamically scale with demand.</p>
</li>
</ul>
<p>Kubernetes allows us to define:</p>
<ul>
<li><p><strong>Deployments:</strong> Manage application updates and scaling.</p>
</li>
<li><p><strong>Services:</strong> Expose applications internally within the cluster.</p>
</li>
<li><p><strong>Ingress Controllers:</strong> Handle external access with defined routing rules, ports, and security configurations.</p>
</li>
</ul>
<h3 id="heading-serverless-for-event-driven-processing">Serverless for Event-Driven Processing</h3>
<p>For tasks that are intermittent and require rapid scaling:</p>
<ul>
<li><p><strong>Video Uploads &amp; Transcoding:</strong> Users upload videos to an S3 bucket. This event triggers AWS Lambda functions that validate files and enqueue processing tasks via Amazon SQS. Workers (Lambda functions or Fargate tasks) then transcode videos using AWS Elemental MediaConvert.</p>
</li>
<li><p><strong>Cost Efficiency:</strong> With serverless architectures, you pay only when the code executes, making it ideal for unpredictable workloads.</p>
</li>
</ul>
<h3 id="heading-vms-for-legacy-and-stateful-workloads">VMs for Legacy and Stateful Workloads</h3>
<p>Not every component fits neatly into containers:</p>
<ul>
<li><p><strong>Legacy Exam Scoring Engine:</strong> A traditional binary application that is challenging to containerize runs on Amazon EC2. Auto Scaling Groups (ASGs) ensure that the workload scales, while an Application Load Balancer (ALB) efficiently distributes traffic.</p>
</li>
<li><p><strong>Isolation and Control:</strong> VMs allow greater control over the runtime environment and are better suited for applications that require specific OS-level configurations.</p>
</li>
</ul>
<h2 id="heading-the-edupro-architecture-a-detailed-walkthrough">The EduPro Architecture: A Detailed Walkthrough</h2>
<p>Imagine a scenario where EduPro must support multiple functionalities:</p>
<ol>
<li><p><strong>User Interaction &amp; Frontend Delivery:</strong></p>
<ul>
<li><p>Users access EduPro through their browsers.</p>
</li>
<li><p><strong>Amazon CloudFront</strong> serves static assets, ensuring low latency globally.</p>
</li>
<li><p><strong>AWS API Gateway</strong> manages incoming API requests, providing security and request validation before routing traffic to the backend.</p>
</li>
</ul>
</li>
<li><p><strong>Microservices Layer on Amazon EKS:</strong></p>
<ul>
<li><p><strong>Ingress Controller:</strong> Acts as the entry point into the Kubernetes cluster, managing SSL termination and routing based on URL paths.</p>
</li>
<li><p><strong>Service Deployments:</strong></p>
<ul>
<li><p><strong>Auth Service:</strong> Handles login and token management.</p>
</li>
<li><p><strong>Course Service:</strong> Manages course content and metadata.</p>
</li>
<li><p><strong>User Profile Service:</strong> Maintains user data and personalization.</p>
</li>
<li><p><strong>Chat Service:</strong> Supports real-time messaging using WebSocket protocols.</p>
</li>
</ul>
</li>
<li><p><strong>Kubernetes Networking:</strong> Each service is exposed using ClusterIP services with dedicated ports (e.g., 8080 for auth, 8081 for course management), while the Ingress Controller maps external requests (e.g., <code>/auth</code>, <code>/course</code>) to these services.</p>
</li>
</ul>
</li>
<li><p><strong>Video Processing Using Serverless Components:</strong></p>
<ul>
<li><p>When a user uploads a video, it is stored in an <strong>Amazon S3</strong> bucket.</p>
</li>
<li><p>An S3 event triggers an <strong>AWS Lambda</strong> function that validates the video and sends a processing request to an <strong>Amazon SQS</strong> queue.</p>
</li>
<li><p>A transcoding worker (either another Lambda function or a Fargate task) picks up the job, processes the video using <strong>AWS Elemental MediaConvert</strong>, and stores the final version back in S3.</p>
</li>
</ul>
</li>
<li><p><strong>Legacy Exam Scoring via EC2:</strong></p>
<ul>
<li><p><strong>Legacy Application:</strong> Hosted on EC2 instances within an Auto Scaling Group.</p>
</li>
<li><p><strong>Load Balancing:</strong> An ALB routes exam submission requests to the EC2 fleet.</p>
</li>
<li><p><strong>Integration:</strong> Results from the legacy exam engine are then passed back to the Kubernetes layer via secure internal APIs for display to the user.</p>
</li>
</ul>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743962125683/414d0e64-499b-4d8e-85df-ac3047383a3d.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-decision-framework-and-trade-offs">🧭 Decision Framework and Trade-Offs</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>Kubernetes</td><td>Serverless</td><td>VMs</td></tr>
</thead>
<tbody>
<tr>
<td><strong>Scalability</strong></td><td>High</td><td>Automatic</td><td>Medium</td></tr>
<tr>
<td><strong>Cost Efficiency</strong></td><td>Medium</td><td>High</td><td>Low</td></tr>
<tr>
<td><strong>Operational Overhead</strong></td><td>High</td><td>Low</td><td>Medium</td></tr>
<tr>
<td><strong>Best For</strong></td><td>Microservices</td><td>Event-Driven Apps</td><td>Legacy Systems</td></tr>
</tbody>
</table>
</div><p><strong>Key Questions to Ask:</strong></p>
<ul>
<li><p>Does your app need <strong>real-time</strong> or can it tolerate <strong>delays</strong>?</p>
</li>
<li><p>Are you optimizing for <strong>cost</strong>, <strong>control</strong>, or <strong>speed to market</strong>?</p>
</li>
<li><p>Do you need <strong>fine-grained scaling</strong> or <strong>hands-off infrastructure</strong>?</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>We explored <strong>Kubernetes</strong>, <strong>Serverless</strong>, and <strong>VMs</strong> through real-world lenses and design principles.</p>
<p>There’s <strong>no one-size-fits-all</strong>. Each option comes with strengths and trade-offs. Your decision should be based on:</p>
<ul>
<li><p><strong>Application architecture</strong></p>
</li>
<li><p><strong>Traffic patterns</strong></p>
</li>
<li><p><strong>Team expertise</strong></p>
</li>
</ul>
<h2 id="heading-whats-next">What’s Next?</h2>
<p>In the next blog/video, we’ll <strong>design a complete microservices architecture</strong> using Kubernetes, including CI/CD and observability setup.</p>
<p>📣 <strong>Tell us</strong> in the comments:<br /><em>Which one do you prefer for your next project and why?</em></p>
]]></content:encoded></item><item><title><![CDATA[Learn these to become a better software engineer]]></title><description><![CDATA[Whether you’re a software engineer, DevOps engineer, or cloud architect, mastering fundamental engineering concepts is crucial for building scalable…]]></description><link>https://blog.kubekode.io/learn-these-to-become-a-better-software-engineer</link><guid isPermaLink="true">https://blog.kubekode.io/learn-these-to-become-a-better-software-engineer</guid><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Wed, 19 Mar 2025 17:09:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1742404157247/acbb1eae-b759-45dd-a66a-83ce14fcbf02.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Whether you’re a software engineer, DevOps engineer, or cloud architect, mastering fundamental engineering concepts is crucial for building <strong>scalable, resilient, and high-performing</strong> systems. This blog covers <strong>75 essential concepts</strong>, explaining why they matter and how they fit into modern engineering.</p>
<h3 id="heading-1-10-cloud-amp-microservices-deployment"><strong>1-10: Cloud &amp; Microservices Deployment</strong></h3>
<p>1. <strong>Microservices Deployment</strong> - Deploying services independently with <strong>Docker, Kubernetes, ECS, or VMs</strong>.</p>
<p>2. <strong>Automated CI/CD Pipelines</strong> - Continuous integration &amp; deployment using <strong>Jenkins, GitHub Actions, GitLab CI, ArgoCD</strong>.</p>
<p>3. <strong>Blue-Green Deployments</strong> - Having two environments, one live (Blue) and one idle (Green), to <strong>reduce downtime</strong>.</p>
<p>4. <strong>Canary Deployments</strong> - Rolling out features to <strong>a small percentage of users</strong> before full deployment.</p>
<p>5. <strong>A/B Testing</strong> - Testing two different versions of an application to determine <strong>which performs better</strong>.</p>
<p>6. <strong>Auto-Scaling Applications</strong> - Scaling based on demand using <strong>Kubernetes HPA, AWS ASG, or GCP Autoscaler</strong>.</p>
<p>7. <strong>Database Clustering</strong> - Running databases in clusters for <strong>high availability and redundancy</strong> (MySQL Cluster, PostgreSQL HA).</p>
<p>8. <strong>Disaster Recovery Planning</strong> - Creating <strong>backup &amp; failover strategies</strong> for handling outages.</p>
<p>9. <strong>Edge Computing</strong> - Processing data closer to users <strong>to reduce latency</strong> (Cloudflare Workers, AWS Lambda@Edge).</p>
<p>10. <strong>Hybrid Cloud Management</strong> - Combining <strong>on-premise &amp; cloud</strong> (AWS Outposts, Azure Arc, Anthos).</p>
<h3 id="heading-11-20-aiml-data-amp-serverless-computing"><strong>11-20: AI/ML, Data, &amp; Serverless Computing</strong></h3>
<p>11. <strong>Machine Learning Model Serving</strong> - Deploying ML models with <strong>SageMaker, TensorFlow Serving, MLflow</strong>.</p>
<p>12. <strong>Big Data Processing</strong> - Using <strong>Apache Spark, Hadoop, Flink</strong> for large-scale data processing.</p>
<p>13. <strong>Event-Driven Architecture</strong> - Using <strong>Kafka, RabbitMQ, AWS SNS/SQS</strong> for asynchronous workflows.</p>
<p>14. <strong>Serverless Functions</strong> - Running functions without managing infrastructure <strong>(AWS Lambda, Azure Functions, GCP Cloud Functions)</strong>.</p>
<p>15. <strong>Real-Time Analytics</strong> - Processing real-time data streams <strong>(Apache Flink, Kinesis, Kafka Streams, Spark Streaming)</strong>.</p>
<p>16. <strong>Application Modernization</strong> - Moving from <strong>monolithic to microservices</strong> architectures.</p>
<p>17. <strong>Multi-Tenant Architecture</strong> - Designing applications for multiple customers <strong>while maintaining isolation</strong>.</p>
<p>18. <strong>Infrastructure as Code (IaC)</strong> - Managing infrastructure with code <strong>(Terraform, Pulumi, AWS CDK, CloudFormation)</strong>.</p>
<p>19. <strong>Continuous Monitoring</strong> - Observability with <strong>Prometheus, Grafana, Datadog, New Relic</strong>.</p>
<p>20. <strong>Log Aggregation</strong> - Centralized logging using <strong>ELK Stack, Loki, OpenSearch, Fluentd</strong>.</p>
<h3 id="heading-21-30-security-amp-networking"><strong>21-30: Security &amp; Networking</strong></h3>
<p>21. <strong>Content Delivery Network (CDN)</strong> - Caching &amp; distributing content closer to users <strong>(Cloudflare, AWS CloudFront)</strong>.</p>
<p>22. <strong>API Gateway</strong> - Managing API traffic, security, and authentication <strong>(Kong, Apigee, AWS API Gateway)</strong>.</p>
<p>23. <strong>Web Application Firewall (WAF)</strong> - Protecting applications from attacks <strong>(AWS WAF, Cloudflare WAF, ModSecurity)</strong>.</p>
<p>24. <strong>Security Scanning</strong> - Automated security testing <strong>(SAST, DAST, SonarQube, Trivy)</strong>.</p>
<p>25. <strong>Data Backup &amp; Restore</strong> - Creating disaster recovery backups <strong>(S3, RDS Snapshots, Azure Blob Backup)</strong>.</p>
<p>26. <strong>Service Mesh</strong> - Handling microservices communication with <strong>Istio, Linkerd, Consul</strong>.</p>
<p>27. <strong>API Rate Limiting</strong> - Controlling API access <strong>to prevent abuse</strong>.</p>
<p>28. <strong>Policy Management</strong> - Enforcing policies <strong>using Open Policy Agent (OPA), Kyverno</strong>.</p>
<p>29. <strong>Secret Management</strong> - Storing credentials securely <strong>(HashiCorp Vault, AWS Secrets Manager, Doppler)</strong>.</p>
<p>30. <strong>Configuration Management</strong> - Managing settings <strong>with Helm, ConfigMaps, Parameter Store</strong>.</p>
<h3 id="heading-31-40-cloud-amp-kubernetes-networking"><strong>31-40: Cloud &amp; Kubernetes Networking</strong></h3>
<p>31. <strong>Network Isolation</strong> - Creating secure networks <strong>(VPCs, Private Link, Security Groups)</strong>.</p>
<p>32. <strong>Load Balancing</strong> - Distributing traffic across servers <strong>(Nginx, HAProxy, AWS ELB, Cloud Load Balancer)</strong>.</p>
<p>33. <strong>Persistent Storage</strong> - Managing stateful storage in <strong>Kubernetes (EBS, EFS, Rook, Ceph)</strong>.</p>
<p>34. <strong>Service Discovery</strong> - Finding services dynamically <strong>(Consul, etcd, Kubernetes DNS)</strong>.</p>
<p>35. <strong>Job Scheduling</strong> - Running periodic jobs <strong>(Kubernetes CronJobs, Apache Airflow, Cloud Scheduler)</strong>.</p>
<p>36. <strong>Self-Healing Applications</strong> - Auto-recovery from failures <strong>using Kubernetes, Auto-healing EC2</strong>.</p>
<p>37. <strong>Resource Quotas</strong> - Managing resource limits <strong>to prevent overuse</strong>.</p>
<p>38. <strong>Cost Optimization</strong> - Reducing cloud costs using <strong>Spot Instances, Reserved Instances, Auto-Scaling</strong>.</p>
<p>39. <strong>Dev Environments</strong> - Using <strong>local Kubernetes (kind, minikube) or cloud-based dev spaces</strong>.</p>
<p>40. <strong>CI/CD Pipelines with GitOps</strong> - Managing CI/CD with <strong>ArgoCD, FluxCD, Tekton</strong>.</p>
<h3 id="heading-41-50-observability-amp-high-availability"><strong>41-50: Observability &amp; High Availability</strong></h3>
<p>41. <strong>High Availability (HA)</strong> - Ensuring <strong>zero downtime with multi-region deployments</strong>.</p>
<p>42. <strong>Rolling Updates &amp; Zero Downtime</strong> - Deploying updates without downtime.</p>
<p>43. <strong>Multi-Cluster Management</strong> - Managing multiple Kubernetes clusters <strong>(Karmada, Anthos, Rancher)</strong>.</p>
<p>44. <strong>Application Health Checks</strong> - Using <strong>liveness and readiness probes</strong>.</p>
<p>45. <strong>Cluster Autoscaling</strong> - Scaling Kubernetes clusters dynamically.</p>
<p>46. <strong>Distributed Tracing</strong> - Tracking requests across services <strong>(Jaeger, OpenTelemetry)</strong>.</p>
<p>47. <strong>Environment Replication</strong> - Creating identical environments for <strong>dev, staging, prod</strong>.</p>
<p>48. <strong>Compliance Auditing</strong> - Ensuring <strong>SOC2, HIPAA, ISO 27001 compliance</strong>.</p>
<p>49. <strong>Performance Testing</strong> - Using <strong>k6, JMeter, Locust</strong>.</p>
<p>50. <strong>ChatOps Integration</strong> - Automating alerts &amp; commands <strong>via Slack, Discord, MS Teams</strong>.</p>
<h2 id="heading-51-100-advanced-concepts-devops-data-infra-security-cloud"><strong>51-100: Advanced Concepts (DevOps, Data, Infra, Security, Cloud)</strong></h2>
<p><strong>🔹 Infrastructure &amp; Deployment</strong></p>
<p>51. Backup &amp; Disaster Recovery</p>
<p>52. Immutable Infrastructure</p>
<p>53. Multi-Cloud Deployment</p>
<p>54. Resource Management</p>
<p>55. Centralized Monitoring</p>
<p>56. Service Level Objectives (SLOs)</p>
<p>57. Data Replication</p>
<p>58. Feature Flags &amp; Progressive Rollouts</p>
<p>59. Kubernetes Security (RBAC, Pod Security)</p>
<p>60. Self-Hosted CI/CD Systems</p>
<p><strong>🔹 Security &amp; Compliance</strong></p>
<p>61. Security Compliance (SOC2, GDPR)</p>
<p>62. API Management &amp; Security</p>
<p>63. Data Encryption (TLS, mTLS, KMS)</p>
<p>64. IAM Best Practices</p>
<p>65. WebAuthn &amp; Passwordless Authentication</p>
<p><strong>🔹 Databases &amp; Data Engineering</strong></p>
<p>66. Message Queues (Kafka, RabbitMQ)</p>
<p>67. Distributed Databases</p>
<p>68. Data Warehousing (Snowflake, BigQuery)</p>
<p>69. Data Lake Implementation</p>
<p>70. Serverless Databases (Aurora, DynamoDB)</p>
<p><strong>🔹 Scaling &amp; Performance</strong></p>
<p>71. Horizontal &amp; Vertical Scaling</p>
<p>72. Real-Time Data Streaming</p>
<p>73. Load Testing</p>
<p>74. Edge AI &amp; Machine Learning</p>
<p>75. API Gateway Performance</p>
<hr />
<p>Mastering these <strong>100 essential concepts</strong> will help you become a <strong>better software engineer, DevOps practitioner, or cloud architect</strong>.</p>
<p>💬 <strong>What concepts do you find most challenging?</strong> Let me know in the comments!</p>
]]></content:encoded></item><item><title><![CDATA[Distributed SQL Databases: The Future of Scalable, Resilient Transactions]]></title><description><![CDATA[In today’s data-driven world, organizations demand high availability, global scalability, and transactional consistency in their databases. Traditional…]]></description><link>https://blog.kubekode.io/distributed-sql-databases-the-future-of-scalable-resilient-transactions</link><guid isPermaLink="true">https://blog.kubekode.io/distributed-sql-databases-the-future-of-scalable-resilient-transactions</guid><category><![CDATA[Databases]]></category><category><![CDATA[System Design]]></category><category><![CDATA[software development]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Mon, 24 Feb 2025 05:17:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1740374196801/70f698bb-6b9e-407b-b8d7-043e5d8b9e78.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction"><strong>Introduction</strong></h3>
<p>In today’s data-driven world, organizations demand <strong>high availability, global scalability, and transactional consistency</strong> in their databases. Traditional <strong>relational databases (RDBMS)</strong> like MySQL and PostgreSQL struggle to meet these demands due to their monolithic, single-node architectures. This is where <strong>Distributed SQL databases</strong> step in.</p>
<p><strong>Distributed SQL</strong> combines the best of relational databases (ACID compliance, SQL queries) with the scalability and fault tolerance of distributed systems. It enables enterprises to <strong>scale horizontally, ensure high availability, and support global data distribution</strong> while maintaining strong consistency.</p>
<p>In this blog, we’ll explore:</p>
<p>• The <strong>limitations of traditional databases</strong></p>
<p>• How <strong>Distributed SQL databases work</strong></p>
<p>• Key <strong>architectural components</strong></p>
<p>• <strong>Real-world use cases</strong></p>
<p>• The <strong>business impact of database modernization</strong></p>
<h2 id="heading-1-the-rise-of-the-modern-data-first-enterprise"><strong>1. The Rise of the Modern Data-First Enterprise</strong></h2>
<p>Today’s enterprises generate vast amounts of data across different regions. Applications demand:</p>
<p>• <strong>High Availability (HA):</strong> No single point of failure.</p>
<p>• <strong>Elastic Scalability:</strong> Ability to handle millions of transactions per second.</p>
<p>• <strong>Global Data Distribution:</strong> Low-latency access across geographies.</p>
<p>• <strong>Strong Consistency:</strong> ACID-compliant transactions.</p>
<p>Legacy transactional databases were not designed for this scale. They rely on <strong>vertical scaling</strong>, where increasing CPU/RAM improves performance, but there’s a limit.</p>
<p>Companies like <strong>Google, Amazon, Netflix, and Uber</strong> need databases that <strong>scale dynamically</strong>, maintain <strong>strong consistency</strong>, and work across multiple data centers. <strong>Distributed SQL</strong> is the answer.</p>
<h2 id="heading-2-where-legacy-transactional-databases-fall-short"><strong>2. Where Legacy Transactional Databases Fall Short</strong></h2>
<p>Traditional RDBMS like MySQL, PostgreSQL, and Oracle have served well for decades. However, they come with <strong>limitations</strong>:</p>
<p>• <strong>Single-node bottleneck:</strong> Cannot scale beyond one server.</p>
<p>• <strong>Replication overhead:</strong> Master-slave or active-passive setups create lag.</p>
<p>• <strong>Failover complexity:</strong> Recovery from failures is slow and may cause downtime.</p>
<p>• <strong>Sharding difficulties:</strong> Manual partitioning (sharding) across multiple databases is hard to manage.</p>
<p>These challenges hinder modern applications, which require <strong>fault tolerance, automatic failover, and distributed transactions</strong>.</p>
<h2 id="heading-3-distributed-sql-rethinking-transactional-databases"><strong>3. Distributed SQL: Rethinking Transactional Databases</strong></h2>
<p><strong>What is Distributed SQL?</strong></p>
<p>A <strong>Distributed SQL database</strong> is a relational database that:</p>
<p>✅ <strong>Scales horizontally (out)</strong> across multiple nodes.</p>
<p>✅ <strong>Maintains ACID compliance</strong> across distributed clusters.</p>
<p>✅ <strong>Supports SQL queries</strong> and relational data models.</p>
<p>✅ <strong>Ensures fault tolerance</strong> with automatic failover.</p>
<p>✅ <strong>Distributes data intelligently</strong> across multiple regions.</p>
<h3 id="heading-how-it-works"><strong>How It Works</strong></h3>
<p>Instead of a single-node architecture, Distributed SQL databases use <strong>multiple nodes</strong> in a cluster, each responsible for a portion of the data. These nodes work together to provide:</p>
<p>• <strong>Automatic sharding</strong></p>
<p>• <strong>Distributed transactions</strong></p>
<p>• <strong>Replication and failover</strong></p>
<p>• <strong>Strong consistency (via consensus protocols like Raft or Paxos)</strong></p>
<p>📌 <strong>Examples of Distributed SQL Databases:</strong></p>
<p>• <strong>Google Spanner</strong></p>
<p>• <strong>CockroachDB</strong></p>
<p>• <strong>YugabyteDB</strong></p>
<p>• <strong>TiDB</strong></p>
<p>• <strong>Amazon Aurora Global Database</strong></p>
<h2 id="heading-4-distributed-sql-in-action-exploring-top-use-cases"><strong>4. Distributed SQL in Action: Exploring Top Use Cases</strong></h2>
<h3 id="heading-use-case-1-global-e-commerce-platforms"><strong>Use Case 1: Global E-commerce Platforms</strong></h3>
<p>💡 <strong>Challenge:</strong></p>
<p>• Customers access the platform from different regions.</p>
<p>• Need <strong>low-latency</strong> transactions.</p>
<p>• Require <strong>high availability</strong> to avoid downtime.</p>
<p>🔹 <strong>Solution:</strong></p>
<p>• Distributed SQL databases replicate data <strong>across multiple regions</strong>.</p>
<p>• Global customers experience <strong>fast query responses</strong> with <strong>data locality</strong>.</p>
<p>• Auto-failover ensures <strong>zero downtime</strong> during failures.</p>
<h3 id="heading-use-case-2-financial-services-amp-payments"><strong>Use Case 2: Financial Services &amp; Payments</strong></h3>
<p>💡 <strong>Challenge:</strong></p>
<p>• Strict <strong>consistency</strong> requirements (no double-spending).</p>
<p>• <strong>High throughput</strong> for transaction processing.</p>
<p>• <strong>Data integrity</strong> for audits and compliance.</p>
<p>🔹 <strong>Solution:</strong></p>
<p>• Distributed SQL ensures <strong>ACID-compliant</strong> transactions.</p>
<p>• Sharded architecture allows <strong>massive parallel processing</strong>.</p>
<p>• Multi-region replication ensures <strong>99.999% uptime</strong>.</p>
<h3 id="heading-use-case-3-saas-and-multi-tenant-applications"><strong>Use Case 3: SaaS and Multi-Tenant Applications</strong></h3>
<p>💡 <strong>Challenge:</strong></p>
<p>• Need to <strong>serve millions of users</strong> without performance degradation.</p>
<p>• Users demand <strong>real-time analytics</strong> and dashboards.</p>
<p>• Downtime or data loss is <strong>not acceptable</strong>.</p>
<p>🔹 <strong>Solution:</strong></p>
<p>• Distributed SQL enables <strong>multi-tenancy</strong> with isolated partitions.</p>
<p>• Horizontally scalable to <strong>handle growing workloads</strong>.</p>
<p>• Ensures <strong>instant failover and high availability</strong>.</p>
<h2 id="heading-5-architecture-of-a-distributed-sql-database"><strong>5. Architecture of a Distributed SQL Database</strong></h2>
<p>A <strong>Distributed SQL database</strong> has multiple components working together:</p>
<p><strong>📌 High-Level Architecture</strong></p>
<p>🖥 <strong>Client Application</strong> → Sends SQL queries</p>
<p>📊 <strong>Distributed SQL Query Engine</strong> → Routes queries across nodes</p>
<p>🔀 <strong>Data Distribution Layer</strong> → Automatically shards and replicates data</p>
<p>🗄 <strong>Storage Layer</strong> → Ensures durability and persistence</p>
<p>🔄 <strong>Consensus Protocol (Raft/Paxos)</strong> → Ensures strong consistency</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740374119324/02a5c757-1650-47e6-807d-806d991074cc.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-6-measuring-the-business-impact-of-database-modernization"><strong>6. Measuring the Business Impact of Database Modernization</strong></h2>
<p>Enterprises adopting Distributed SQL databases <strong>gain competitive advantages</strong>:</p>
<p>📌 <strong>Reduced Downtime</strong> → No single point of failure, ensuring <strong>99.999% availability</strong>.</p>
<p>📌 <strong>Faster Performance</strong> → <strong>Geographically distributed</strong> for low-latency queries.</p>
<p>📌 <strong>Cost Efficiency</strong> → <strong>Eliminates expensive vertical scaling</strong> and licenses.</p>
<p>📌 <strong>Developer Productivity</strong> → Uses standard <strong>SQL</strong>, no need to learn NoSQL query languages.</p>
<p>📌 <strong>Regulatory Compliance</strong> → Ensures <strong>data consistency, security, and auditing</strong>.</p>
<h1 id="heading-conclusion"><strong>Conclusion</strong></h1>
<p>Distributed SQL databases are redefining how modern applications handle <strong>scalability, availability, and transactional consistency</strong>. As enterprises migrate to <strong>cloud-native architectures</strong>, Distributed SQL offers the best of both worlds—<strong>relational data models with distributed scalability</strong>.</p>
<p><strong>Key Takeaways:</strong></p>
<p>✔ <strong>Overcomes the limitations of traditional RDBMS.</strong></p>
<p>✔ <strong>Provides automatic sharding and global scalability.</strong></p>
<p>✔ <strong>Ensures strong consistency and fault tolerance.</strong></p>
<p>✔ <strong>Enables real-time, high-performance transactions.</strong></p>
<p>As businesses continue to evolve, <strong>Distributed SQL is the future of transactional databases</strong>.</p>
]]></content:encoded></item><item><title><![CDATA[Java from scratch: Variables & Datatypes]]></title><description><![CDATA[Data is important part in a program, program should hold the data in the memory while the execution of the program. Variables are meant for storing data…]]></description><link>https://blog.kubekode.io/java-from-scratch-variables-datatypes</link><guid isPermaLink="true">https://blog.kubekode.io/java-from-scratch-variables-datatypes</guid><category><![CDATA[Java]]></category><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Sun, 07 Jul 2024 07:18:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1720336641270/b65a15c3-021c-4aa8-ae59-fb994e437868.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-data-types">Data Types</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>type</td><td>Size</td><td>Range</td><td>Default</td><td></td></tr>
</thead>
<tbody>
<tr>
<td>byte</td><td>1</td><td>-128 to 127</td><td>0</td><td></td></tr>
<tr>
<td>short</td><td>2</td><td>-32768 to 32767</td><td>0</td><td></td></tr>
<tr>
<td>int</td><td>4</td><td>-2147483648 to -2147483647</td><td>0</td><td></td></tr>
<tr>
<td>long</td><td>8</td><td>-</td><td>0</td><td></td></tr>
<tr>
<td>float</td><td>4</td><td>+_ 1.4E-45 to +_ 3.4E+38</td><td>o.of</td><td></td></tr>
<tr>
<td>double</td><td>8</td><td>+_ 439E-324 to +_ 1.7E+308</td><td>ood</td><td></td></tr>
<tr>
<td>char</td><td>2</td><td>0 to 65535</td><td>\40000</td><td></td></tr>
<tr>
<td>boolean</td><td>?</td><td>true/false</td><td>false</td></tr>
</tbody>
</table>
</div><ul>
<li><p>Data is important part in a program, program should hold the data in the memory while the execution of the program.</p>
</li>
<li><p>Variables are meant for storing data. In java first we can declare the variable and then store the data into it.</p>
</li>
<li><p>Variables will have some data types, the type of data we're going to store into the variable.</p>
</li>
</ul>
<h3 id="heading-primitive-data-types">Primitive Data Types</h3>
<ul>
<li>Basic data types in java that is built in given in the compiler of java.</li>
</ul>
<ol>
<li><p><code>integral</code> - can have any numerical value without decimal point.</p>
<ol>
<li><p><code>byte</code></p>
</li>
<li><p><code>short</code></p>
</li>
<li><p><code>int</code></p>
</li>
<li><p><code>long</code></p>
</li>
</ol>
</li>
<li><p><code>Floating Point</code> - can have numeric value with decimal points.</p>
<ol>
<li><p><code>float</code></p>
</li>
<li><p><code>double</code></p>
</li>
</ol>
</li>
<li><p><code>char</code> - for storing characters.</p>
</li>
<li><p><code>boolean</code> - for storing true and false.</p>
<ul>
<li><p>In Java <code>true</code> means true and <code>false</code> means false, not 1 or 0.</p>
</li>
<li><p>How many bytes it takes(1 bit mostly), exactly we can't say, it depends on JVM.</p>
</li>
</ul>
</li>
</ol>
<blockquote>
<p>For other languages we've unicode only for english we have ASCII codes. <a target="_blank" href="http://unicode.org">unicode.org</a> Java supports Unicode for supporting all other languages.(It uses char)</p>
</blockquote>
<h2 id="heading-check-size-and-range-of-data-types">Check Size and Range of Data Types</h2>
<pre><code class="lang-java">javap java.lang.Integer
</code></pre>
<pre><code class="lang-java"><span class="hljs-keyword">import</span> java.lang.*;
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DateSizeRange</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
        System.out.println(<span class="hljs-string">"Int Min Value"</span>+Integer.MIN_VALUE);
        System.out.println(<span class="hljs-string">"Int Max Value"</span>+Integer.MAX_VALUE);
        System.out.println(<span class="hljs-string">"Int Bytes"</span>+Integer.BYTES);
    }
}
</code></pre>
<h6 id="heading-output">Output</h6>
<pre><code class="lang-plaintext">Int Min Value-2147483648
Int Max Value2147483647
Int Bytes4
</code></pre>
<h2 id="heading-what-are-variables">What are Variables?</h2>
<ul>
<li><p>Variables are names given to the data.</p>
</li>
<li><p>Or variables are used for storing data.</p>
</li>
<li><p>A variable must have some data type.</p>
</li>
</ul>
<h4 id="heading-example">Example</h4>
<pre><code class="lang-plaintext">byte b=5; // 1 byte
int i=175; // 4 bytes
float f=25.3f; // 4 bytes
char c='A'; // 2 bytes
</code></pre>
<ul>
<li><p>We can change the value of the variable later in our program, we can put other data in the variable.</p>
</li>
<li><p>Whenever we want to use a variable (ex <code>b</code>) it must be declared first.</p>
</li>
<li><p>we can't use a variable unless we initialize it.</p>
</li>
</ul>
<h3 id="heading-declaration-and-inititalization">Declaration and Inititalization</h3>
<pre><code class="lang-plaintext">byte b; // declaration
byte c=5; // initialization
</code></pre>
<h3 id="heading-how-much-memory-a-variable-will-occupy">How much memory a variable will occupy?</h3>
<ul>
<li>It depends on it's data type.</li>
</ul>
<pre><code class="lang-java"><span class="hljs-keyword">import</span> java.lang.*;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Variable</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
        <span class="hljs-comment">// declare a variable</span>
        <span class="hljs-keyword">byte</span> b;
        <span class="hljs-comment">// System.out.println("Display b: "+b); throw error</span>
        b=<span class="hljs-number">5</span>;
        System.out.println(<span class="hljs-string">"Display b: "</span>+b); <span class="hljs-comment">// will display 5</span>
        <span class="hljs-keyword">int</span> a = <span class="hljs-number">145</span>;
        System.out.println(a);
    }
}
</code></pre>
<h2 id="heading-rules-for-variable-names">Rules for variable names</h2>
<ol>
<li>Case Sensitive</li>
</ol>
<pre><code class="lang-plaintext">int amount;
int Amount; // different
</code></pre>
<ol start="2">
<li><p>Contains Alphabets, Numbers, <code>_</code> or <code>$</code></p>
</li>
<li><p>Starts with Alphabet, <code>_</code> or <code>$</code></p>
</li>
<li><p>Should not be a keyword</p>
</li>
</ol>
<h4 id="heading-keywords">Keywords</h4>
<ul>
<li><p>Here's the list of keyWords in java</p>
<ul>
<li><p>abstract</p>
</li>
<li><p>continue</p>
</li>
<li><p>for</p>
</li>
<li><p>new</p>
</li>
<li><p>switch</p>
</li>
<li><p>assert</p>
</li>
<li><p>default</p>
</li>
<li><p>goto</p>
</li>
<li><p>package</p>
</li>
<li><p>synchronized</p>
</li>
<li><p>boolean</p>
</li>
<li><p>do</p>
</li>
<li><p>if</p>
</li>
<li><p>private</p>
</li>
<li><p>this</p>
</li>
<li><p>break</p>
</li>
<li><p>double</p>
</li>
<li><p>implements</p>
</li>
<li><p>protected</p>
</li>
<li><p>throw</p>
</li>
<li><p>byte</p>
</li>
<li><p>else</p>
</li>
<li><p>import</p>
</li>
<li><p>public</p>
</li>
<li><p>throws</p>
</li>
<li><p>case</p>
</li>
<li><p>enum</p>
</li>
<li><p>instanceof</p>
</li>
<li><p>return</p>
</li>
<li><p>transient</p>
</li>
<li><p>catch</p>
</li>
<li><p>extends</p>
</li>
<li><p>int</p>
</li>
<li><p>short</p>
</li>
<li><p>try</p>
</li>
<li><p>char</p>
</li>
<li><p>final</p>
</li>
<li><p>interface</p>
</li>
<li><p>static</p>
</li>
<li><p>void</p>
</li>
<li><p>class</p>
</li>
<li><p>finally</p>
</li>
<li><p>long</p>
</li>
<li><p>strictfp</p>
</li>
<li><p>volatile</p>
</li>
<li><p>const</p>
</li>
<li><p>float</p>
</li>
<li><p>native</p>
</li>
<li><p>super</p>
</li>
<li><p>while</p>
</li>
</ul>
</li>
</ul>
<ol start="5">
<li><p>Should not be a class name, if claas is also in use</p>
</li>
<li><p>No limit on lenght of name</p>
</li>
<li><p>Follow Camel Cases</p>
</li>
</ol>
<h4 id="heading-camel-case">Camel Case</h4>
<ul>
<li>first letter of a word should be capital, except of the first letter.</li>
</ul>
<pre><code class="lang-plaintext">byte rollNumber;
</code></pre>
<h2 id="heading-what-are-literals">What are literals?</h2>
<ul>
<li>Literals are constant values used in a program.</li>
</ul>
<pre><code class="lang-plaintext">z = 5 * X + 7 * y
// here 5,7 are literals.
int value=25;
// 25 is a literal
double price=153.75;
// 153.75 is literal
area=3.1425 * radius * radius;
// 3.1425 is literal
</code></pre>
<ul>
<li><p><code>5</code> is integer literal.</p>
</li>
<li><p><code>153.75</code> is double literal.</p>
</li>
<li><p><code>3.1425</code> is double literal.</p>
</li>
<li><p><code>A</code> is char literal.</p>
</li>
<li><p><code>Java</code> is string literal.</p>
</li>
</ul>
<blockquote>
<p>Every number having decimal by default is double.</p>
</blockquote>
<h4 id="heading-literals">Literals</h4>
<ul>
<li><p>byte - int</p>
</li>
<li><p>short - int</p>
</li>
<li><p>int - int</p>
</li>
<li><p>long - L or I</p>
</li>
<li><p>float - F or f</p>
</li>
<li><p>double - D or d</p>
</li>
<li><p>char - ''</p>
</li>
<li><p>boolean - true/false</p>
</li>
</ul>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Literal</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
        <span class="hljs-keyword">long</span> l = <span class="hljs-number">999999999999999L</span>;
        <span class="hljs-comment">// int i = 125L; // can't be assigned to int</span>
        System.out.println(l);
    }

}
</code></pre>
<h2 id="heading-check-binary-bits-of-an-integer">Check Binary Bits of an Integer</h2>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Checkbinarybits</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
        <span class="hljs-keyword">int</span> x = -<span class="hljs-number">5</span>;
        System.out.println(Integer.toBinaryString(x));
    }
}
</code></pre>
<h2 id="heading-float-and-character-datatypes-in-detail">Float and Character Datatypes in Detail</h2>
<h3 id="heading-floating-point">Floating point</h3>
<ul>
<li>Float datatypes don't store decimal actually in the memory but they represent it as a decimal.</li>
</ul>
<pre><code class="lang-plaintext">163.52
163.52 X 100/100
16352 X 1/100
16352 X 10^-2
16352 - mantisa
10^-2 - exponent
or 16352E-2
</code></pre>
<ul>
<li><p>float takes 4 bytes.</p>
</li>
<li><p>It follows IEEE 754 standard(Followed by every electronic device)</p>
</li>
<li><p>What about double?</p>
<ul>
<li><p>Upto 6 digits after decimal, float is fine, but it we want more digits</p>
</li>
<li><p>we need to use double.</p>
</li>
</ul>
</li>
<li><p>Float - 6-7 digits after decimal</p>
</li>
<li><p>Double - 14-15 digits after decimal</p>
</li>
</ul>
<h3 id="heading-character">Character</h3>
<ul>
<li><p>ASCII standard</p>
</li>
<li><p>Every programming language supports <code>Unicodes</code>.</p>
</li>
<li><p>For ex:</p>
</li>
</ul>
<pre><code class="lang-plaintext">A - 65
Z - 90
a - 97
z - 122
</code></pre>
<ul>
<li>2 bytes for a character</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Day 32: Deploying a application on private subnet]]></title><description><![CDATA[#90daysofdevops]]></description><link>https://blog.kubekode.io/day-32-deploying-a-application-on-private-subnet</link><guid isPermaLink="true">https://blog.kubekode.io/day-32-deploying-a-application-on-private-subnet</guid><category><![CDATA[AWS]]></category><category><![CDATA[vpc]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[Vishesh Ghule]]></dc:creator><pubDate>Sun, 28 Jan 2024 16:17:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706435371405/c86aaff1-56fe-4605-b6de-87e08b11549d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction">🚀Introduction</h3>
<p>In this blog, we will run an HTML file within a private subnet as depicted in the provided screenshots. Follow the instructions exactly as shown in the images.</p>
<hr />
<p>The VPC public and private subnet architecture is shown below, like this we are going to create in this blog.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706439466551/196a05ef-60a9-4424-bf31-2ff62b89fcf5.jpeg" alt class="image--center mx-auto" /></p>
<hr />
<h3 id="heading-step1-create-vpc"><strong>🔸</strong>Step1: Create VPC</h3>
<p>Select <strong>VPC and more</strong> option it will create &amp; attach everything for you such as subnet, route table, internet gateway, and NAT gateway.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706435709153/c2a71299-6bb3-4bc1-a827-1305e9a70c58.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706435893311/058ed515-2604-407e-ac3a-d7b001c2c22e.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706435905646/17edce10-84c5-4635-a998-7564733f7697.png" alt class="image--center mx-auto" /></p>
<p>Now, you have created a VPC 👆</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436013562/33da7576-c94b-499d-b449-ffc9c776e9a3.png" alt class="image--center mx-auto" /></p>
<p>This is a resource architecture of your VPC.👆</p>
<hr />
<h3 id="heading-step2-launch-template-amp-create-autoscaling-group"><strong>🔸</strong>Step2: Launch template &amp; Create autoscaling group</h3>
<p><strong>Launch template</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436096629/31fc941c-dc3b-4881-93b9-b2e14e32c742.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436181983/b668ff5a-0c40-466f-ae97-42135a2ed7a3.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436199497/786f5238-9c59-4a6f-aa5d-322972123615.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436245060/d80d94d5-aab2-46e4-a90d-fc1a0227951a.png" alt class="image--center mx-auto" /></p>
<p>It is same as creating like ec2 instance.👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436283419/a0188457-d118-47c7-9318-777913db9224.png" alt class="image--center mx-auto" /></p>
<p><strong>Create auto scaling group👇</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436298916/b6df293e-696a-49d1-941f-1f405dad2381.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436408241/96a36a5d-69b8-443d-9b79-c82bd5297f1e.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436434686/666dad7e-bb98-4836-9760-6b46a99a7709.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436445633/3761e432-a5fa-484d-8767-0b67756da567.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436506785/a4b7fcb0-081d-45fd-979b-8af6c24538b8.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436523134/b4ab9480-a51b-402a-a4df-459e25fba161.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436534171/8d7ab9e2-af19-4720-8203-ab8cf44846cf.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436551782/0c7a89ab-46aa-4e57-add4-56675279e6ca.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436611513/ccaa2a28-2d1d-42d4-ba87-b52fb861bed4.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436623621/86329575-afab-4a9f-918a-42ec2d3ee2bb.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436658609/1d0e8131-e939-4339-9640-9406e756fda0.png" alt class="image--center mx-auto" /></p>
<p>Now you have created auto sacling group👆</p>
<hr />
<h3 id="heading-step3-now-launch-instance"><strong>🔸</strong>Step3: Now launch instance</h3>
<p>Now, go ahead and check if two private instances have been created. Next, create a public instance to do bastion host.👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436871600/3871e615-ee21-4f76-9987-53caff8b7e0a.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436877969/e1fb4c68-cc97-4569-90e4-7d2f755c65ce.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436889651/608e6a79-332c-4e91-be9b-bc3b1b05d61f.png" alt class="image--center mx-auto" /></p>
<p><strong>Copy your pem file from your local terminal to public subnet</strong></p>
<p>use this command to copy</p>
<p><code>scp -i /your/pem/file/path /your/pem/file/path/ ubuntu@&lt;your public instance IP&gt;:/home/ubuntu</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706436904323/0503bf60-662f-4aa6-ac28-31a63c6f6997.png" alt class="image--center mx-auto" /></p>
<p>After copying pem file👆 now do ssh your public instance in your local terminal👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437157097/a929010d-1bc1-45f4-9e59-d1cbfb17b969.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437178255/2a98b0d9-6bd8-4e5b-9918-a49470634f6f.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437247843/914f3dd3-cbf7-455f-85d1-0d1f6f66224a.png" alt class="image--center mx-auto" /></p>
<p>Now do ssh in private instance 👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437461212/7bbf6ba9-e3ba-4fb4-94d5-2c3e475014a8.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437473677/92784724-8cf1-4301-97a9-297984b7a7af.png" alt class="image--center mx-auto" /></p>
<p>After doing ssh of private instance, create file or download any python project. This is only for example purposes.👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437487755/78f9022e-9f0f-4313-991b-82689706da0b.png" alt class="image--center mx-auto" /></p>
<hr />
<h3 id="heading-step4-now-create-target-group-amp-load-balancer"><strong>🔸</strong>Step4: Now create target group &amp; Load balancer</h3>
<p><strong>Create target group👇</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437732774/3174649f-cbef-479d-9380-15706e068752.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437741639/c00cfc3c-f69a-48c6-8534-9bd13d4ef464.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437753459/2d5439e7-062a-4310-a66a-7911b92c5c45.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437767683/b80e1576-bac6-41cc-bc9e-52f4bf4acb0e.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437805595/8052d3a2-b7a0-40cf-b37c-9e30571c4df6.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437835600/18b16c41-453b-46ed-96f9-ef11b7627ca3.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437846229/58f4fdb9-aa7d-43a8-be23-0ac1c2b9be60.png" alt class="image--center mx-auto" /></p>
<p><strong>Create Load balancer👇</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437857732/fb435cc8-4bfa-4730-bbfc-2cd84ea99448.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437941670/9bb6fcfa-dcd3-4a96-8d39-c8f05a91f512.png" alt class="image--center mx-auto" /></p>
<p>Select application load balancer👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706437955180/ad016fe3-c60c-4306-af7e-a3aa0d2ec812.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438002245/f528bc6a-b498-4de1-bb3b-3a2c87eee14d.png" alt class="image--center mx-auto" /></p>
<p>Always select public subnet here, otherwise it will show error👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438026329/dea1e96c-8413-4f2a-bb68-b40fa0003c24.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438088665/9d6282f1-76f0-4169-a0c5-a0607c226f2f.png" alt class="image--center mx-auto" /></p>
<p>keep http 80 as default👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438100740/0fa4601f-b68c-4ba3-8885-7f090fd8addb.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438121959/8f19189a-5000-462c-acc8-902fdcc8a430.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438217724/7fca1586-8938-474a-a51c-fd12b78d1938.png" alt class="image--center mx-auto" /></p>
<p>It takes some time for the load balancer to become active, so please wait for 2-3 minutes.👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438227652/7c448300-ca45-468e-950b-e80daa79531e.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438318659/3b0f0d6a-7b81-455a-8c17-41dca06214cd.png" alt class="image--center mx-auto" /></p>
<p>Go in listeners and rules, scroll down and you will get error like this, to solve this error edit security group👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438329286/992c36c8-318f-433e-b268-25545788f446.png" alt class="image--center mx-auto" /></p>
<p>You will see there is an option of security beside the listeners &amp; rules.👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438438758/638ea6bc-e185-4477-a92b-37ff0d1bb185.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438548793/4849f2fa-eccf-4fa6-aa5f-a12fed199e9f.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438557729/5227e8c7-c374-4899-b227-46fe119f2035.png" alt class="image--center mx-auto" /></p>
<p>Add rule</p>
<p>Type &gt; HTTP</p>
<p>Source &gt; Anywhere IPv4👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438573513/d478c1fc-99a2-4a07-851b-defb01fe5517.png" alt class="image--center mx-auto" /></p>
<p>Now you can see that the error which was there before is no longer present👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706438959544/e2f9a66f-1c7b-4905-ab74-de5dab35be0f.png" alt class="image--center mx-auto" /></p>
<p>Go into the private instance where you had SSH and type this command👇</p>
<p><code>python3 -m http.server 8000</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706439087872/2b4a0d4a-4822-4cea-8f77-3d00b217e042.png" alt class="image--center mx-auto" /></p>
<p>Now go in listeners and rule👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706439109678/896502e4-8303-419e-b5cb-074cb8231923.png" alt class="image--center mx-auto" /></p>
<p>Copy DNS name and paste it on chrome👇</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706439124683/1175a86b-1e6f-4c27-b2ac-fdb6a7a4543c.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706439153756/7d6e9ea2-7eb0-43f1-a69f-ef6ed5a22738.png" alt class="image--center mx-auto" /></p>
<hr />
<p><strong><em>Thanks for reading to the end; I hope you gained some knowledge.❤️🙌</em></strong></p>
<p><a target="_blank" href="https://www.linkedin.com/in/vishesh-ghule/">Linkedln</a></p>
<p><a target="_blank" href="https://twitter.com/VisheshGhule">Twitter</a></p>
<p><a target="_blank" href="https://github.com/VisheshGhule">Github</a></p>
]]></content:encoded></item><item><title><![CDATA[Day 27: AWS IAM]]></title><description><![CDATA[#90daysofdevops]]></description><link>https://blog.kubekode.io/day-27-aws-iam</link><guid isPermaLink="true">https://blog.kubekode.io/day-27-aws-iam</guid><category><![CDATA[Devops]]></category><category><![CDATA[AWS IAM]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[Vishesh Ghule]]></dc:creator><pubDate>Wed, 27 Dec 2023 17:53:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1703697411627/b4ce7dce-2e29-4464-b567-95a41122d6b6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>✨️<em>Introduction</em></strong></p>
<p>IAM stands for Identity and Access Management. It is like a central manager that helps you control who can enter your cloud, access AWS resources and what they can do once inside.</p>
<ul>
<li><p><strong>Identity:</strong> IAM helps you manage the identities (like usernames or service accounts) that can interact with your AWS resources.</p>
</li>
<li><p><strong>Access:</strong> It determines what actions (like reading, writing, or deleting data) each identity is allowed to perform on AWS services.</p>
</li>
</ul>
<hr />
<h3 id="heading-features-of-iam">🔸<strong>Features of IAM:</strong></h3>
<ol>
<li><p><strong>Control Who Does What:</strong> IAM lets you decide who can access AWS resources and what they can do with them.</p>
</li>
<li><p><strong>Extra Security with MFA:</strong> You can add an extra layer of security by requiring users to use a second form of verification, like a smartphone app, along with their password.</p>
</li>
<li><p><strong>Simplify Access for Services:</strong> IAM allows AWS services to access other services securely, reducing the need for secret keys.</p>
</li>
<li><p><strong>Fine-Tune Permissions:</strong> You can specify exactly what each user or group can access, ensuring they only have the permissions they need.</p>
</li>
<li><p><strong>Access Advisor Insights:</strong> IAM provides insights into permissions, helping you see what users and services are using and adjust permissions accordingly.</p>
</li>
</ol>
<hr />
<h3 id="heading-iam-identities-are-categorized-into-three-types">🔸<strong>IAM Identities are categorized into three types:</strong></h3>
<ol>
<li><p>IAM users</p>
</li>
<li><p>IAM Groups</p>
</li>
<li><p>IAM Roles</p>
</li>
</ol>
<h3 id="heading-iam-users">🔹IAM Users<em>:</em></h3>
<p><strong>IAM users</strong> are individual entities within your AWS account. They are human users, applications, or services that need to interact with your AWS resources. Here's a breakdown of IAM users:</p>
<ul>
<li><p><strong>Identification</strong>: Each IAM user has a unique username, which is used for authentication. When creating an IAM user, you can choose a username that helps you identify the user, such as "John" or "MarketingApp."</p>
</li>
<li><p><strong>Access Credentials</strong>: IAM users can have access credentials, including a password or access keys (Access Key ID and Secret Access Key) for programmatic access. Passwords are used for the AWS Management Console, while access keys are for programmatic access through APIs or AWS CLI.</p>
</li>
<li><p><strong>Permissions</strong>: Users can have policies attached to them that define what actions they can perform and on which AWS resources. These policies control their level of access to AWS services.</p>
</li>
<li><p><strong>Multi-Factor Authentication (MFA)</strong>: You can enable MFA for IAM users, which adds an extra layer of security. It requires users to provide a second authentication factor, typically from a hardware token or a smartphone app, in addition to their password.</p>
</li>
</ul>
<h3 id="heading-iam-groups">🔹IAM Groups:</h3>
<p><strong>IAM groups</strong> are collections of IAM users. They are a way to simplify the management of permissions for multiple users who require the same level of access. Here's how IAM groups work:</p>
<ul>
<li><p><strong>Group Membership</strong>: Users can be added to one or more groups. This is useful when you have a set of users who share similar job roles or responsibilities, as they can be added to a group that defines their common permissions.</p>
</li>
<li><p><strong>Policy Attachment</strong>: Instead of attaching policies to individual users, you attach policies to IAM groups. All users in the group inherit the permissions defined in the group's policies. This makes it easier to ensure that users with similar roles have consistent access.</p>
</li>
<li><p><strong>Scalability and Efficiency</strong>: IAM groups make it more efficient to manage permissions. If you need to change permissions for multiple users at once, you can update the group's policies, and all group members receive the changes.</p>
</li>
</ul>
<h3 id="heading-iam-roles">🔹IAM Roles:</h3>
<p><strong>IAM roles</strong> are a bit different from users and groups. They are meant for scenarios where permissions need to be granted to AWS services, temporary access for trusted entities, or cross-account access. Here's how IAM roles work:</p>
<ul>
<li><p><strong>Trust Relationships</strong>: Roles are defined with trust relationships, specifying which entities or services can assume the role. For example, you can create a role that allows an EC2 instance to access an S3 bucket.</p>
</li>
<li><p><strong>Temporary Permissions</strong>: Roles provide temporary access. When a user or service assumes a role, they receive temporary security credentials, which are valid for a limited time. This adds a layer of security, and you can set specific permissions for the duration of the role's use.</p>
</li>
<li><p><strong>Cross-Account Access</strong>: Roles are used when you want to give another AWS account access to your resources. The other account assumes the role to access your resources securely, without having to share access keys.</p>
</li>
</ul>
<p>In summary, IAM users are individual entities with their own credentials and permissions. IAM groups help manage users with similar permissions collectively. IAM roles are used to grant temporary, controlled access to AWS services or entities and can be utilized for cross-account access. Together, these IAM components allow you to efficiently manage and secure access to your AWS resources.</p>
<hr />
<h3 id="heading-important-terms-associated-with-iam-roles">🔸<strong>Important Terms associated with IAM Roles:</strong></h3>
<p>D<strong>elegation</strong>: is a process of granting permission to the user to allow to the AWS resources that we control.</p>
<p>Delegation is <strong>set up by the trusted account(which owns the AWS resources)</strong> and <strong>the trusting account (which needs access to AWS resources).</strong></p>
<p>Trusting &amp; Trusted account is categorized into three:</p>
<ol>
<li><p>Same account.</p>
</li>
<li><p>Two different accounts under the same organization.</p>
</li>
<li><p>Two different accounts which are owned by different organizations.</p>
</li>
</ol>
<p>To delegate permission to access the resources, the IAM role is created in the trusting account by two policies.</p>
<p><em>In AWS Identity and Access Management (IAM), "Permission Policy" and "Trust Policy" are two important policy types associated with IAM roles. Let's explore each of these policies:</em></p>
<ol>
<li><p><strong>Permission Policy (Attached to IAM Role)</strong>:</p>
<ul>
<li><p><strong>What it is</strong>: A permission policy, often referred to simply as a "role policy" or "IAM policy," is a document that specifies the actions (permissions) a role is allowed or denied when it's assumed by an entity (such as an AWS service or a federated user).</p>
</li>
<li><p><strong>Where it's used</strong>: Permission policies are attached to IAM roles. When an entity assumes the role, it inherits the permissions defined in the attached permission policies.</p>
</li>
<li><p><strong>What it contains</strong>: A permission policy consists of one or more permissions statements, each of which includes an "Effect" (Allow or Deny), an "Action" (the specific AWS actions that are allowed or denied), and a "Resource" (the AWS resource to which the permissions apply).</p>
</li>
<li><p><strong>Example</strong>: A permission policy might include a statement that allows the <code>s3:GetObject</code> action on all objects within a specific Amazon S3 bucket resource.</p>
</li>
</ul>
</li>
<li><p><strong>Trust Policy (Attached to IAM Role)</strong>:</p>
<ul>
<li><p><strong>What it is</strong>: A trust policy is a document that defines which AWS entities or accounts are allowed to assume a specific IAM role. It establishes trust relationships between the role and the trusted entities.</p>
</li>
<li><p><strong>Where it's used</strong>: Trust policies are attached to IAM roles to specify who is authorized to assume that role.</p>
</li>
<li><p><strong>What it contains</strong>: A trust policy typically includes a "Principal" element that specifies the trusted entity or entities (such as another AWS account, an AWS service, or a federated user) and an "Action" element that defines the action used for assuming the role (usually "sts: AssumeRole").</p>
</li>
</ul>
</li>
</ol>
<p>a. <strong>Federation</strong>: Process of creating the trust relationship between external service provider and AWS.</p>
<p>b. <strong>Trust Policy: (JSON Format)</strong> to define who is <strong>allowed to use this role</strong>. (written in IAM Policy language)</p>
<p>c. <strong>Permission Policy: (JSON Format)</strong> to define the actions and resources <strong>that the role can use.</strong> (written in IAM Policy language)</p>
<p>d. <strong>Permissions Boundary</strong>: (an advanced feature of AWS) which limits the maximum permission that a role can have, which is applied to both IAM User &amp; role.</p>
<p>e. <strong>Principal</strong>: can be IAM User, Role or AWS account root user. Here Permission is granted in two ways.</p>
<ol>
<li><p>Attach a Permission Policy to the role.</p>
</li>
<li><p>services that support resource-based policies, can identify the principal in the principal element of policy attached to the resource.</p>
</li>
</ol>
<p>f. <strong>Cross Account access : (Roles Vs Resource-Based Policies) —</strong> allows you to grant access to the resource in one account to the trusted principal in another account.</p>
<hr />
<h3 id="heading-iam-roles-and-use-cases">🔸IAM Roles and Use Cases:</h3>
<p>Two ways to use the roles:</p>
<ol>
<li><p><strong>IAM Console:</strong> When IAM users work in the IAM console and want to use the role, then they can access the permission of the role temporarily by giving up their original permission of the role, when the user exits the role's original permission is restored.</p>
</li>
<li><p><strong>Programmatic Access</strong>: An AWS Service such as an EC2 Instance can use role by requesting temporarily security credentials using the programmatic requests to AWS.</p>
</li>
</ol>
<p>An IAM Role can be used in the following ways:</p>
<ol>
<li><p>IAM User</p>
</li>
<li><p>Applications and services</p>
</li>
<li><p>Federated Users.</p>
</li>
</ol>
<p>Following are the cases of Roles:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703698238073/ad803a42-7385-4d43-93c9-708c6d613c94.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p>Switch to a role as an IAM user in one AWS account to access another account that you own.</p>
</li>
<li><p>Providing access to an AWS Service.</p>
</li>
<li><p>Providing access to external authenticated users. (sometimes users have identities outside of AWS such as corporate directory, if such users want to work with AWS resources then they should have security credentials. In such a situation role is to specify the permission for third-party identity providers[IDP]).</p>
</li>
</ol>
<ul>
<li><p><strong>Web-Identity federation —</strong> Users do not require any custom sign-in or user identities. Users can use any external identity provider (Facebook, amazon, google..), after login users get <strong>an authentication token</strong>, and they can <strong>exchange an authentication token for receiving temporary security credentials</strong>.</p>
</li>
<li><p><strong>SAML—</strong>based Federation <strong>(Security Assertion Markup language)</strong> is an open framework that many identity providers use, which provides a single sign-on to access the AWS Management console.</p>
</li>
</ul>
<p>4. Providing access to third parties: (when third party want to access the AWS resources then they can use roles to delegate access to them without sharing security credentials).</p>
<p>💎<strong>Creating IAM Roles:</strong></p>
<p>Step 1:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703698365046/1503d8e8-9038-474e-a4ac-5820950fd65e.png" alt class="image--center mx-auto" /></p>
<p>Step 2:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703698436145/006ae2d8-1a22-4d03-a535-5fecb076fd3e.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703698463658/6a911b54-a256-476b-b08c-c71d2d6cc6cb.png" alt class="image--center mx-auto" /></p>
<p>Attach policies if required (JSON format Trust , Permission Policy)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703698556594/b74630c7-7360-40de-8986-5907b15c1db9.png" alt class="image--center mx-auto" /></p>
<p>Step : 3: Add Role Name , Description … and create role will create.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703698594722/d4102890-c6bb-4f8b-b640-c049d0ea696f.png" alt class="image--center mx-auto" /></p>
<p>Step 4: Creating IAM roles for an IAM User. (sample where you can do same)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703698636028/4fbe843d-268d-401d-ab37-a11d08a0070e.png" alt class="image--center mx-auto" /></p>
<hr />
<p><strong><em>Thanks for reading to the end; I hope you gained some knowledge.❤️🙌</em></strong></p>
<p><a target="_blank" href="https://www.linkedin.com/in/vishesh-ghule/">Linkedln</a></p>
<p><a target="_blank" href="https://twitter.com/VisheshGhule">Twitter</a></p>
<p><a target="_blank" href="https://github.com/VisheshGhule">Github</a></p>
]]></content:encoded></item><item><title><![CDATA[Day 24: AWS EC2]]></title><description><![CDATA[#90daysofdevops]]></description><link>https://blog.kubekode.io/day-24-aws-ec2</link><guid isPermaLink="true">https://blog.kubekode.io/day-24-aws-ec2</guid><category><![CDATA[Devops]]></category><category><![CDATA[Linux]]></category><category><![CDATA[AWS]]></category><category><![CDATA[ec2]]></category><dc:creator><![CDATA[Vishesh Ghule]]></dc:creator><pubDate>Sun, 03 Dec 2023 19:08:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1701626487100/208d8718-1003-4e58-b091-437ea47d3003.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>✨️As we all know what is EC2 instance and how can we use it, in this blog we will discuss more on types of EC2 instances, pricing models and security of EC2 instances</strong></p>
<h3 id="heading-types-of-ec2-computing-instances"><strong>🔸Types of EC2 Computing Instances:</strong></h3>
<p><strong>AWS offers 7 types of instances which are as follows:</strong></p>
<h3 id="heading-1-general-purpose-instances-t-series"><strong>1. General Purpose Instances (T-Series):</strong></h3>
<ul>
<li><p><strong>Use Cases</strong>: These instances are suitable for a broad range of workloads, including web servers, development environments, and small to medium databases. They are cost-effective for applications with varying workloads.</p>
</li>
<li><p><strong>Instance Types</strong>:</p>
<ul>
<li><code>t2.nano</code>, <code>t2.micro</code>, <code>t2.small</code>, <code>t2.medium</code>, <code>t2.large</code>, <code>t2.xlarge</code>, <code>t2.2xlarge</code>, <code>t3.nano</code>, <code>t3.micro</code>, <code>t3.small</code>, <code>t3.medium</code>, <code>t3.large</code>, <code>t3.xlarge</code>, <code>t3.2xlarge</code>, <code>t4g.nano</code>, <code>t4g.micro</code>, <code>t4g.small</code>, <code>t4g.medium</code>, <code>t4g.large</code>, <code>t4g.xlarge</code>, <code>t4g.2xlarge</code></li>
</ul>
</li>
<li><p><strong>Key Features</strong>: Burstable CPU performance, suitable for workloads with periodic high CPU demands.</p>
</li>
</ul>
<hr />
<h3 id="heading-2-c-series-compute-optimized-instances"><strong>2. (C-Series): Compute Optimized Instances</strong></h3>
<ul>
<li><p><strong>Use Cases</strong>: These instances are optimized for compute-intensive workloads like high-performance web servers, batch processing, and scientific modeling.</p>
</li>
<li><p><strong>Instance Types</strong>:</p>
<ul>
<li><code>c4.large</code>, <code>c4.xlarge</code>, <code>c4.2xlarge</code>, <code>c4.4xlarge</code>, <code>c4.8xlarge</code>, <code>c5.large</code>, <code>c5.xlarge</code>, <code>c5.2xlarge</code>, <code>c5.4xlarge</code>, <code>c5.9xlarge</code>, <code>c5.12xlarge</code>, <code>c5.18xlarge</code>, <code>c5.24xlarge</code>, <code>c6g.nano</code>, <code>c6g.micro</code>, <code>c6g.small</code>, <code>c6g.medium</code>, <code>c6g.large</code>, <code>c6g.xlarge</code>, <code>c6g.2xlarge</code></li>
</ul>
</li>
<li><p><strong>Key Features</strong>: High CPU performance, ideal for compute-bound applications.</p>
</li>
</ul>
<hr />
<h3 id="heading-3-memory-optimized-instances-r-series-and-x-series"><strong>3. Memory Optimized Instances (R-Series and X-Series):</strong></h3>
<ul>
<li><p><strong>Use Cases</strong>: Memory-optimized instances are best suited for in-memory databases, big data processing, and applications that require substantial RAM.</p>
</li>
<li><p><strong>Instance Types</strong>:</p>
<ul>
<li><code>r3.large</code>, <code>r3.xlarge</code>, <code>r3.2xlarge</code>, <code>r3.4xlarge</code>, <code>r3.8xlarge</code>, <code>r4.large</code>, <code>r4.xlarge</code>, <code>r4.2xlarge</code>, <code>r4.4xlarge</code>, <code>r4.8xlarge</code>, <code>r4.16xlarge</code>, <code>r5.large</code>, <code>r5.xlarge</code>, <code>r5.2xlarge</code>, <code>r5.4xlarge</code>, <code>r5.8xlarge</code>, <code>r5.12xlarge</code>, <code>r5.16xlarge</code>, <code>r5.24xlarge</code>, <code>x1.16xlarge</code>, <code>x1.32xlarge</code>, <code>x1e.xlarge</code>, <code>x1e.2xlarge</code>, <code>x1e.4xlarge</code>, <code>x1e.8xlarge</code>, <code>x1e.16xlarge</code>, <code>x1e.32xlarge</code></li>
</ul>
</li>
<li><p><strong>Key Features</strong>: High memory capacity, suitable for data-intensive and memory-bound applications.</p>
</li>
</ul>
<hr />
<h3 id="heading-4-storage-optimized-instances-i-series-and-d-series"><strong>4. Storage Optimized Instances (I-Series and D-Series):</strong></h3>
<ul>
<li><p><strong>Use Cases</strong>: Storage-optimized instances are designed for applications that require high-speed, low-latency storage, such as NoSQL databases and data warehousing.</p>
</li>
<li><p><strong>Instance Types</strong>:</p>
<ul>
<li><code>i3.large</code>, <code>i3.xlarge</code>, <code>i3.2xlarge</code>, <code>i3.4xlarge</code>, <code>i3.8xlarge</code>,<code>i3.16xlarge</code>, <code>i3.metal</code>, <code>d2.xlarge</code>, <code>d2.2xlarge</code>, <code>d2.4xlarge</code>, <code>d2.8xlarge</code></li>
</ul>
</li>
<li><p><strong>Key Features</strong>: High-speed, high-capacity storage for data-intensive applications.</p>
</li>
</ul>
<hr />
<h3 id="heading-5-accelerated-computing-instances-p-series-g-series-f-series-and-inf1"><strong>5. Accelerated Computing Instances (P-Series, G-Series, F-Series, and Inf1):</strong></h3>
<ul>
<li><p><strong>Use Cases</strong>: These instances are equipped with GPUs or specialized hardware for tasks like machine learning, graphics rendering, and video encoding.</p>
</li>
<li><p><strong>Instance Types</strong>:</p>
<ul>
<li><code>p2.xlarge</code>, <code>p2.8xlarge</code>, <code>p2.16xlarge</code>, <code>p3.2xlarge</code>, <code>p3.8xlarge</code>, <code>p3.16xlarge</code>, <code>p4d.24xlarge</code>, <code>g3s.xlarge</code>, <code>g3.4xlarge</code>, <code>g3.8xlarge</code>, <code>g3.16xlarge</code>, <code>g4dn.xlarge</code>, <code>g4dn.2xlarge</code>, <code>g4dn.4xlarge</code>, <code>g4dn.8xlarge</code>, <code>g4dn.12xlarge</code>, <code>g4dn.16xlarge</code>, <code>g4ad.4xlarge</code>, <code>f1.2xlarge</code>, <code>f1.4xlarge</code>, <code>f1.16xlarge</code>, <code>inf1.xlarge</code>, <code>inf1.2xlarge</code>, <code>inf1.6xlarge</code></li>
</ul>
</li>
<li><p><strong>Key Features</strong>: Specialized hardware for tasks that require GPU or FPGA acceleration.</p>
</li>
</ul>
<hr />
<h3 id="heading-6-networking-instances-n-series"><strong>6. Networking Instances (N-Series):</strong></h3>
<ul>
<li><p><strong>Use Cases</strong>: Instances in this category offer high-speed, low-latency networking capabilities, making them ideal for applications that require substantial network performance.</p>
</li>
<li><p><strong>Instance Types</strong>:</p>
<ul>
<li><code>n1-standard-1</code>, <code>n1-standard-2</code>, <code>n1-standard-4</code>, <code>n1-standard-8</code>, <code>n1-standard-16</code>, <code>n1-highmem-2</code>, <code>n1-highmem-4</code>, <code>n1-highmem-8</code>, <code>n1-highmem-16</code>, <code>n1-highcpu-2</code>, <code>n1-highcpu-4</code>, <code>n1-highcpu-8</code>, <code>n1-highcpu-16</code></li>
</ul>
</li>
<li><p><strong>Key Features</strong>: High-speed networking for applications that rely heavily on network performance.</p>
</li>
</ul>
<hr />
<h3 id="heading-7-arm-based-instances-a1-series-m6g-series-c6g-series-r6g-series-t4g-series"><strong>7. Arm-Based Instances (A1-Series, M6g-Series, C6g-Series, R6g-Series, T4g-Series):</strong></h3>
<ul>
<li><p><strong>Use Cases</strong>: These instances use ARM processors and are optimized for cost-effective performance in various workloads, including web servers and containerized applications.</p>
</li>
<li><p><strong>Instance Types</strong>: Numerous instance types available across different series.</p>
</li>
<li><p><strong>Key Features</strong>: Cost-effective performance, ideal for ARM-compatible workloads.</p>
</li>
</ul>
<hr />
<h3 id="heading-burstable-performance-instances"><strong>🔸Burstable Performance Instances</strong></h3>
<p><em>T2 instances</em> are burstable instances, meaning the CPU performs at a baseline, say 20% of its capability. When your application needs more than 20% of the performance of the CPU, the CPU enters into a burst mode giving the higher performance for a limited amount of time, therefore work happens faster.</p>
<ul>
<li><p>You get these credits when your CPU is idle.</p>
</li>
<li><p>Each CPU credit gives a burst of 1 minute to the CPU.</p>
</li>
<li><p>If your CPU credits are not used they are credited to your account and they stay there for 24 hours.</p>
</li>
<li><p>Based on your credit balance, you can decide whether the t2 instance, should be scaled up or down.</p>
</li>
<li><p>These bursts happen at a cost, every time a burst happens in a CPU, CPU credits are used.</p>
</li>
</ul>
<p>Let’s understand this through an example. Suppose in a company they have to follow the following tasks:</p>
<p><strong><em>1.Analysis of customer’s data</em></strong></p>
<p>Customer’s website activity, etc. should all be monitored in real-time. There will be times when the traffic on the website will be minimal, therefore using a very powerful processor should not be considered, as it will become expensive for the company because it will not be used for every hour of the day. Hence, for this task, we might take <strong>t2 instances</strong> because they give <strong>Burstable CPU performance</strong> i.e. when the traffic is more the CPU performance will be increased accordingly to meet the requirements.</p>
<p><strong><em>2. auto-response emailing system</em></strong></p>
<p>It should be quick, therefore we would require systems, where the response time is as short as possible. This could be achieved by using <strong>EBS-optimized instances</strong>, as they offer high IOPS and hence, low latencies.</p>
<p><strong><em>3. The search engine on our website</em></strong></p>
<p>It should be able to sort the keywords and return relevant results, therefore we might have 2 servers for this. One is the database and the other server for processing the keywords. Therefore, the communication between these servers should be at the maximum possible rate. To achieve this, we can put them in a placement group and for that, we have to use <strong>Cluster Networking Instances.</strong></p>
<p><strong><em>4. Some processes in every organization are highly confidential</em></strong></p>
<p>Because these processes give us an edge over other companies, no matter how secure the servers, maybe, some policies are still made to be sure. Therefore, we might use <strong>Dedicated Instances</strong> for these kinds of processes.</p>
<ul>
<li><strong><em>Auto Scaling</em></strong></li>
</ul>
<p><em>Auto Scaling</em> is a service designed by AWS EC2, which automatically launches or terminates EC2’s instances based on user-defined policies, schedules, and health checks.</p>
<ul>
<li><strong>Elastic Load Balancing</strong></li>
</ul>
<p><em>Elastic Load Balancing</em> (ELB) automatically distributes incoming application traffic across multiple EC2 instances, in multiple Availability Zones.</p>
<p>Availability zones are places where Amazon has set up its servers. Since they have customers from the whole globe, they have set up multiple Availability zones to reduce the latency.</p>
<p><em>Elastic IP Addresses</em> are static IP addresses that are associated with your AWS account, they can be used to mask the failure of an instance by automatically remapping your address to another working instance in your account.</p>
<ul>
<li><strong>Understanding the EC2 Price Model :</strong></li>
</ul>
<p>There are 3 common types of Billing for EC2</p>
<ul>
<li><p>On-Demand</p>
</li>
<li><p>Reserved</p>
</li>
<li><p>Spot</p>
</li>
</ul>
<ul>
<li><p><strong>On-Demand Instances</strong>: Offer flexibility with no upfront costs but are generally more expensive for continuous, predictable workloads.</p>
</li>
<li><p><strong>Reserved Instances</strong>: Provide significant cost savings for workloads with a steady or predictable usage pattern but require an upfront commitment.</p>
</li>
<li><p><strong>Spot Instances</strong>: Offer the most cost-effective option but come with the caveat of potential interruptions. They are suitable for workloads that can handle these interruptions and don't require continuous, predictable usage.</p>
</li>
</ul>
<hr />
<p><strong><em>Thanks for reading to the end; I hope you gained some knowledge.❤️🙌</em></strong></p>
<p><a target="_blank" href="https://www.linkedin.com/in/vishesh-ghule/">Linkedln</a></p>
<p><a target="_blank" href="https://twitter.com/VisheshGhule">Twitter</a></p>
<p><a target="_blank" href="https://github.com/VisheshGhule">Github</a></p>
]]></content:encoded></item><item><title><![CDATA[Day 23 : Virtual Private Cloud (VPC) Part 2]]></title><description><![CDATA[#90daysofdevops]]></description><link>https://blog.kubekode.io/day-23-virtual-private-cloud-vpc-part-2</link><guid isPermaLink="true">https://blog.kubekode.io/day-23-virtual-private-cloud-vpc-part-2</guid><category><![CDATA[AWS]]></category><category><![CDATA[vpc]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[Vishesh Ghule]]></dc:creator><pubDate>Wed, 29 Nov 2023 16:51:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1701276076406/56a5633c-81f1-4add-9b42-4096eedf52d0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction"><strong>✨️</strong>Introduction</h2>
<p><strong>Amazon Virtual Private Cloud (VPC) forms the bedrock of a secure and tailored network within the AWS Cloud. It's essentially a controlled space where various AWS resources, such as EC2 instances and RDS databases, can operate within a defined network setup, giving you extensive control over configurations like IP address ranges, subnets, route tables, and network security. VPC serves as the framework for establishing a secure and private environment within the AWS cloud, ensuring that your applications and resources thrive within a controlled networking space.</strong></p>
<hr />
<h2 id="heading-what-is-amazon-vpc"><strong>🔸What is Amazon VPC?</strong></h2>
<p>Amazon Virtual Private Cloud, or VPC, is a logically isolated section of the AWS Cloud where you can launch AWS resources, like EC2 instances, RDS databases, and more, within a defined network. This network is created and customized by you, providing complete control over IP address ranges, subnets, route tables, and network security. VPC is the foundation that allows you to build a secure and private environment in the AWS cloud.</p>
<hr />
<h2 id="heading-types-of-amazon-vpc"><strong>🔸Types of Amazon VPC</strong></h2>
<h3 id="heading-1-default-vpc"><em>1. Default VPC</em></h3>
<p>When you create an AWS account, a default VPC is automatically set up in each AWS region. It comes with default configurations, including a main route table, a security group, and a network ACL. The default VPC is designed for convenience but may not be the most secure option, as it has default security group rules that allow certain traffic. You can, however, modify and secure the default VPC according to your requirements.</p>
<h3 id="heading-2-custom-vpc">2. Custom VPC</h3>
<p>A custom VPC is one that you create yourself, tailoring it to your organization's specific needs. You have full control over the IP address range, subnet design, and routing configuration. This level of customization is beneficial for enterprises and developers looking to create a network environment that precisely aligns with their applications and security policies.</p>
<h3 id="heading-3-vpc-peering">3. VPC Peering</h3>
<p>VPC peering allows you to connect two VPCs, whether they are in the same region or different regions, in a way that traffic flows privately and securely between them. It's a powerful feature for scenarios where you need resources from separate VPCs to communicate, while still keeping them isolated.</p>
<h3 id="heading-4-transit-gateway">4. Transit Gateway</h3>
<p>For more complex networking needs, Transit Gateway is an ideal solution. It enables you to connect multiple VPCs, on-premises data centers, and remote offices in a hub-and-spoke model. This simplifies network management and helps ensure low latency and secure connections, making it suitable for large-scale enterprise architectures.</p>
<hr />
<h2 id="heading-when-to-use-each-type"><strong>🔸When to Use Each Type</strong></h2>
<ul>
<li><p><strong>Default VPC</strong>: The default VPC is best suited for beginners or those who need a quick and straightforward setup. However, it's crucial to review and adjust its security settings to meet your specific requirements.</p>
</li>
<li><p><strong>Custom VPC</strong>: Custom VPCs are ideal for businesses and projects with unique network requirements. You can build your VPC from the ground up, ensuring that it aligns perfectly with your applications and security needs.</p>
</li>
<li><p><strong>VPC Peering</strong>: Use VPC peering when you have resources in multiple VPCs that need to communicate with each other while remaining separate. This is often the case when you want to maintain network isolation between different teams or projects.</p>
</li>
<li><p><strong>Transit Gateway</strong>: For large enterprises with extensive network needs, Transit Gateway simplifies complex network topologies. It streamlines connectivity between VPCs, data centers, and remote locations, making it the right choice for organizations with a global presence.</p>
</li>
</ul>
<p><strong>Conclusion</strong></p>
<p>Amazon VPC is a fundamental building block in AWS, offering the ability to create a secure, isolated, and highly customizable network environment in the cloud. Understanding the different types of Amazon VPC and when to use them is essential for optimizing your cloud infrastructure to meet your organization's unique requirements. By selecting the right type of VPC, you can ensure that your AWS resources operate in a secure and efficient networking environment, empowering your applications to thrive in the cloud.</p>
<hr />
<h2 id="heading-subnet-and-its-utility"><strong>🔸Subnet And Its Utility</strong></h2>
<p>A subnet is a logical partition of an Amazon Virtual Private Cloud (VPC). It enables you to segment your VPC's IP address range into smaller, more manageable chunks. Subnets are used to organize and isolate resources within your VPC, and they play a crucial role in network architecture for several reasons:</p>
<h3 id="heading-1-resource-isolation">1. Resource Isolation:</h3>
<p>By placing different resources in separate subnets, you can isolate them from one another. For instance, you might have web servers in one subnet and database servers in another, preventing direct access to your database from the internet.</p>
<h3 id="heading-2-availability-zones-azs">2. Availability Zones (AZs):</h3>
<p>Subnets are associated with specific Availability Zones. This allows you to create highly available architectures by distributing your resources across multiple AZs. In case of a failure in one AZ, resources in other AZs remain unaffected.</p>
<h3 id="heading-3-network-segmentation">3. Network Segmentation:</h3>
<p>You can apply different security rules to different subnets. For instance, you can configure your security groups and network access control lists (NACLs) to allow or deny traffic based on subnet associations.</p>
<hr />
<h2 id="heading-what-is-route-table"><strong>🔸What Is Route Table?</strong></h2>
<p>A route table is a set of rules that determine where network traffic is directed within your VPC. Each subnet in a VPC is associated with a specific route table, but you can customize the route table to define the traffic flow. Here's why route tables are important:</p>
<h3 id="heading-1-routing-decisions">1. Routing Decisions:</h3>
<p>A route table contains entries that specify the destination for traffic. For example, a default route might direct all traffic to the Internet through an Internet Gateway.</p>
<h3 id="heading-2-custom-routing">2. Custom Routing:</h3>
<p>You can create custom route tables to define specific routing rules for your subnets. This flexibility allows you to control how traffic flows within your VPC.</p>
<h3 id="heading-3-network-segmentation-1">3. Network Segmentation:</h3>
<p>By manipulating the routes in a route table, you can control which subnets can communicate with one another. This is a powerful security feature that helps prevent unauthorized traffic.</p>
<hr />
<h2 id="heading-what-is-internet-gateway"><strong>🔸What Is Internet Gateway?</strong></h2>
<p>An Internet Gateway (IGW) is a horizontally scaled, redundant, and highly available VPC component that allows communication between your VPC and the Internet. Here's why it's a vital component of AWS networking:</p>
<h3 id="heading-1-internet-connectivity">1. Internet Connectivity:</h3>
<p>The IGW provides a point of entry and exit for traffic between your VPC and the public internet. It enables resources within your VPC to access internet resources or be accessible from the internet.</p>
<h3 id="heading-2-egress-and-ingress">2. Egress and Ingress:</h3>
<p>Traffic leaving your VPC for the Internet must pass through the IGW, while incoming traffic from the Internet first arrives at the IGW. This ensures control and security over both outbound and inbound traffic.</p>
<h3 id="heading-3-default-for-public-subnets">3. Default for Public Subnets:</h3>
<p>In VPCs with public subnets, an Internet Gateway is typically attached to the VPC. This is essential for resources in public subnets to have internet access.</p>
<p><strong>Conclusion</strong></p>
<p>Understanding the core concepts of subnets, route tables, and Internet Gateways is fundamental to creating a secure, efficient, and scalable network architecture on AWS. Subnets provide isolation and organization, route tables control traffic flow, and Internet Gateways enable communication with the public Internet. Together, they form the building blocks of AWS networking, allowing you to design complex, yet highly secure and flexible network environments for your applications and services in the cloud.</p>
<hr />
<p><strong><em>Thanks for reading to the end; I hope you gained some knowledge.❤️🙌</em></strong></p>
<p><a target="_blank" href="https://www.linkedin.com/in/vishesh-ghule/">Linkedln</a></p>
<p><a target="_blank" href="https://twitter.com/VisheshGhule">Twitter</a></p>
<p><a target="_blank" href="https://github.com/VisheshGhule">Github</a></p>
]]></content:encoded></item><item><title><![CDATA[Automation in E-Commerce Websites with Jenkins]]></title><description><![CDATA[In the fast-paced world of e-commerce, where user experience and efficiency are paramount, the need for automation has become more critical than ever…]]></description><link>https://blog.kubekode.io/automation-in-e-commerce-websites-with-jenkins</link><guid isPermaLink="true">https://blog.kubekode.io/automation-in-e-commerce-websites-with-jenkins</guid><category><![CDATA[kuwarp]]></category><category><![CDATA[Jenkins]]></category><category><![CDATA[cicd]]></category><category><![CDATA[Kubernetes]]></category><category><![CDATA[GitHub]]></category><dc:creator><![CDATA[kuwar pratap singh]]></dc:creator><pubDate>Sun, 26 Nov 2023 16:21:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1701015448038/0d9505dd-75f9-4cd4-8602-4e7b162a8790.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the fast-paced world of e-commerce, where user experience and efficiency are paramount, the need for automation has become more critical than ever. Jenkins, an open-source automation server, has emerged as a powerful tool to streamline and enhance the development, deployment, and maintenance processes of e-commerce websites. In this blog, we will explore the steps to achieve complete automation for an e-commerce website using Jenkins.</p>
<h1 id="heading-understand-with-simple-pipeline">Understand with Simple Pipeline:</h1>
<pre><code class="lang-yaml"><span class="hljs-string">pipeline</span> {
    <span class="hljs-string">agent</span> <span class="hljs-string">any</span>

    <span class="hljs-string">environment</span> {
        <span class="hljs-string">//</span> <span class="hljs-string">Define</span> <span class="hljs-string">environment</span> <span class="hljs-string">variables</span> <span class="hljs-string">if</span> <span class="hljs-string">needed</span>
        <span class="hljs-string">APP_NAME</span> <span class="hljs-string">=</span> <span class="hljs-string">"ecommerce-app"</span>
        <span class="hljs-string">GIT_REPO</span> <span class="hljs-string">=</span> <span class="hljs-string">"https://github.com/kuwarp/ecommerce-repo.git"</span>
        <span class="hljs-string">DOCKER_REGISTRY</span> <span class="hljs-string">=</span> <span class="hljs-string">"your-docker-registry"</span>
    }

    <span class="hljs-string">stages</span> {
        <span class="hljs-string">stage('Checkout')</span> {
            <span class="hljs-string">steps</span> {
                <span class="hljs-string">//</span> <span class="hljs-string">Checkout</span> <span class="hljs-string">the</span> <span class="hljs-string">source</span> <span class="hljs-string">code</span> <span class="hljs-string">from</span> <span class="hljs-string">the</span> <span class="hljs-string">Git</span> <span class="hljs-string">repository</span>
                <span class="hljs-string">script</span> {
                    <span class="hljs-attr">git branch:</span> <span class="hljs-string">'main'</span>,
                    <span class="hljs-attr">credentialsId:</span> <span class="hljs-string">'your-git-credentials'</span>,
                     <span class="hljs-attr">url:</span> <span class="hljs-string">GIT_REPO</span>
                }
            }
        }

        <span class="hljs-string">stage('Install</span> <span class="hljs-string">Dependencies')</span> {
            <span class="hljs-string">steps</span> {
                <span class="hljs-string">//</span> <span class="hljs-string">Install</span> <span class="hljs-string">Node.js</span> <span class="hljs-string">dependencies</span>
                <span class="hljs-string">script</span> {
                    <span class="hljs-string">sh</span> <span class="hljs-string">'npm install'</span>
                }
            }
        }

        <span class="hljs-string">stage('Run</span> <span class="hljs-string">Unit</span> <span class="hljs-string">Tests')</span> {
            <span class="hljs-string">steps</span> {
                <span class="hljs-string">//</span> <span class="hljs-string">Run</span> <span class="hljs-string">unit</span> <span class="hljs-string">tests</span> <span class="hljs-string">(replace</span> <span class="hljs-string">with</span> <span class="hljs-string">your</span> <span class="hljs-string">testing</span> <span class="hljs-string">command)</span>
                <span class="hljs-string">script</span> {
                    <span class="hljs-string">sh</span> <span class="hljs-string">'npm test'</span>
                }
            }
        }

        <span class="hljs-string">stage('Build</span> <span class="hljs-string">Docker</span> <span class="hljs-string">Image')</span> {
            <span class="hljs-string">steps</span> {
                <span class="hljs-string">//</span> <span class="hljs-string">Build</span> <span class="hljs-string">Docker</span> <span class="hljs-string">image</span> <span class="hljs-string">and</span> <span class="hljs-string">push</span> <span class="hljs-string">to</span> <span class="hljs-string">registry</span>
                <span class="hljs-string">script</span> {
                    <span class="hljs-string">sh</span> <span class="hljs-string">'docker build -t $DOCKER_REGISTRY/$APP_NAME:latest .'</span>
                    <span class="hljs-string">sh</span> <span class="hljs-string">'docker push $DOCKER_REGISTRY/$APP_NAME:latest'</span>
                }
            }
        }

        <span class="hljs-string">stage('Deploy</span> <span class="hljs-string">to</span> <span class="hljs-string">Staging')</span> {
            <span class="hljs-string">steps</span> {
                <span class="hljs-string">//</span> <span class="hljs-string">Deploy</span> <span class="hljs-string">the</span> <span class="hljs-string">application</span> <span class="hljs-string">to</span> <span class="hljs-string">the</span> <span class="hljs-string">staging</span> <span class="hljs-string">environment</span>
                <span class="hljs-string">script</span> {
                    <span class="hljs-string">sh</span> <span class="hljs-string">'kubectl apply -f k8s/staging.yaml'</span>
                }
            }
        }

        <span class="hljs-string">stage('Run</span> <span class="hljs-string">Smoke</span> <span class="hljs-string">Tests</span> <span class="hljs-bullet">-</span> <span class="hljs-string">Staging')</span> {
            <span class="hljs-string">steps</span> {
                <span class="hljs-string">//</span> <span class="hljs-string">Run</span> <span class="hljs-string">smoke</span> <span class="hljs-string">tests</span> <span class="hljs-string">on</span> <span class="hljs-string">the</span> <span class="hljs-string">staging</span> <span class="hljs-string">environment</span>
                <span class="hljs-string">script</span> {
                    <span class="hljs-string">sh</span> <span class="hljs-string">'npm run smoke-test-staging'</span>
                }
            }
        }

        <span class="hljs-string">stage('Deploy</span> <span class="hljs-string">to</span> <span class="hljs-string">Production')</span> {
            <span class="hljs-string">when</span> {
         <span class="hljs-string">//</span> <span class="hljs-string">Deploy</span> <span class="hljs-string">to</span> <span class="hljs-string">production</span> <span class="hljs-string">only</span> <span class="hljs-string">if</span> <span class="hljs-string">build</span> <span class="hljs-string">is</span> <span class="hljs-string">successful</span> <span class="hljs-string">and</span> <span class="hljs-string">on</span> <span class="hljs-string">the</span> <span class="hljs-string">main</span> <span class="hljs-string">branch</span>
                <span class="hljs-string">expression</span> { <span class="hljs-string">currentBuild.resultIsBetterOrEqualTo('SUCCESS')</span> }
            }
            <span class="hljs-string">steps</span> {
                <span class="hljs-string">//</span> <span class="hljs-string">Deploy</span> <span class="hljs-string">the</span> <span class="hljs-string">application</span> <span class="hljs-string">to</span> <span class="hljs-string">the</span> <span class="hljs-string">production</span> <span class="hljs-string">environment</span>
                <span class="hljs-string">script</span> {
                    <span class="hljs-string">sh</span> <span class="hljs-string">'kubectl apply -f k8s/production.yaml'</span>
                }
            }
        }

        <span class="hljs-string">stage('Run</span> <span class="hljs-string">Smoke</span> <span class="hljs-string">Tests</span> <span class="hljs-bullet">-</span> <span class="hljs-string">Production')</span> {
            <span class="hljs-string">when</span> {
                <span class="hljs-string">//</span> <span class="hljs-string">Run</span> <span class="hljs-string">smoke</span> <span class="hljs-string">tests</span> <span class="hljs-string">on</span> <span class="hljs-string">production</span> <span class="hljs-string">only</span> <span class="hljs-string">if</span> <span class="hljs-string">the</span> <span class="hljs-string">deployment</span> <span class="hljs-string">is</span> <span class="hljs-string">successful</span>
                <span class="hljs-string">expression</span> { <span class="hljs-string">currentBuild.resultIsBetterOrEqualTo('SUCCESS')</span> }
            }
            <span class="hljs-string">steps</span> {
                <span class="hljs-string">//</span> <span class="hljs-string">Run</span> <span class="hljs-string">smoke</span> <span class="hljs-string">tests</span> <span class="hljs-string">on</span> <span class="hljs-string">the</span> <span class="hljs-string">production</span> <span class="hljs-string">environment</span>
                <span class="hljs-string">script</span> {
                    <span class="hljs-string">sh</span> <span class="hljs-string">'npm run smoke-test-production'</span>
                }
            }
        }
    }

    <span class="hljs-string">post</span> {
        <span class="hljs-string">//</span> <span class="hljs-string">Send</span> <span class="hljs-string">notifications</span> <span class="hljs-string">or</span> <span class="hljs-string">perform</span> <span class="hljs-string">cleanup</span> <span class="hljs-string">after</span> <span class="hljs-string">the</span> <span class="hljs-string">pipeline</span> <span class="hljs-string">completes</span>
        <span class="hljs-string">always</span> {
            <span class="hljs-string">echo</span> <span class="hljs-string">'Executed'</span>
        }
        <span class="hljs-string">success</span> {
            <span class="hljs-string">echo</span> <span class="hljs-string">'CI/CD working fine! notification recieved '</span>
        }
        <span class="hljs-string">failure</span> {
            <span class="hljs-string">echo</span> <span class="hljs-string">'Pipeline failed! Send failure notifications.'</span>
        }
    }
}
</code></pre>
<blockquote>
<p>Here are Brief Theory about this given example</p>
</blockquote>
<h1 id="heading-setting-up-jenkins"><strong>Setting Up Jenkins:</strong></h1>
<p>Begin by installing Jenkins on your server or local machine. Jenkins provides a user-friendly interface and supports a variety of plugins to extend its functionality. Once installed, configure Jenkins to connect to your version control system (VCS), such as Git.</p>
<h2 id="heading-automated-build-process"><strong>Automated Build Process:</strong></h2>
<p>Jenkins can automate the build process of your e-commerce website, ensuring that the code is compiled, tested, and packaged consistently. Set up a Jenkins job to monitor your VCS for changes and trigger the build process automatically. This reduces the chances of errors and ensures that the development and testing environments are in sync.</p>
<h3 id="heading-continuous-integration-ci"><strong>Continuous Integration (CI):</strong></h3>
<p>Implement continuous integration using Jenkins to merge code changes from multiple contributors regularly. This helps in detecting and resolving integration issues early in the development cycle. Jenkins can be configured to run automated tests after each integration, providing rapid feedback to developers.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1701015489131/7916f3b6-008a-47b1-b62b-e16df8baacfd.png" alt /></p>
<h3 id="heading-automated-testing"><strong>Automated Testing:</strong></h3>
<p>Jenkins supports a wide range of testing tools and frameworks. Integrate your test suites with Jenkins to execute automated tests automatically. This includes unit tests, integration tests, and end-to-end tests. Automated testing not only improves the reliability of your code but also accelerates the development process by catching bugs early.</p>
<h3 id="heading-deployment-automation"><strong>Deployment Automation:</strong></h3>
<p>Use Jenkins to automate the deployment process of your e-commerce website. Define deployment pipelines that consist of stages such as testing, staging, and production. Jenkins can deploy your application to different environments based on predefined conditions and triggers, ensuring a smooth and controlled release process.</p>
<h3 id="heading-monitoring-and-logging"><strong>Monitoring and Logging:</strong></h3>
<p>Integrate monitoring tools and log management systems into your Jenkins pipeline. This allows you to track the performance of your e-commerce website in real-time. Jenkins can be configured to alert you when specific performance thresholds are breached, enabling proactive resolution of issues.</p>
<h3 id="heading-infrastructure-as-code-iac"><strong>Infrastructure as Code (IaC):</strong></h3>
<p>Leverage Infrastructure as Code principles to automate the provisioning and configuration of your server infrastructure. Tools like Terraform or Ansible can be integrated with Jenkins to ensure that the infrastructure is reproducible and version-controlled.</p>
<h3 id="heading-security-automation"><strong>Security Automation:</strong></h3>
<p>Integrate security scanning tools into your Jenkins pipeline to automatically detect and address security vulnerabilities in your code. This includes static code analysis, dependency scanning, and container security checks.</p>
<h3 id="heading-automated-backups"><strong>Automated Backups:</strong></h3>
<p>Schedule automated backups of your e-commerce website's database and critical files using Jenkins. Regular backups are crucial to ensure data integrity and facilitate quick recovery in case of a system failure.</p>
<h3 id="heading-documentation-and-knowledge-sharing"><strong>Documentation and Knowledge Sharing:</strong></h3>
<p>Document your Jenkins pipeline and automation processes thoroughly. This documentation serves as a valuable resource for both current and future development teams. Foster a culture of knowledge sharing to empower your team members with the skills to maintain and enhance the automation infrastructure.</p>
]]></content:encoded></item><item><title><![CDATA[Day 22: VPC A Deep Dive into Amazon Virtual Private Cloud]]></title><description><![CDATA[#90daysofdevops]]></description><link>https://blog.kubekode.io/day-22-vpc-a-deep-dive-into-amazon-virtual-private-cloud</link><guid isPermaLink="true">https://blog.kubekode.io/day-22-vpc-a-deep-dive-into-amazon-virtual-private-cloud</guid><category><![CDATA[Devops]]></category><category><![CDATA[vpc]]></category><category><![CDATA[AWS]]></category><dc:creator><![CDATA[Vishesh Ghule]]></dc:creator><pubDate>Sun, 26 Nov 2023 12:14:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1700937311151/772c8725-024c-454b-8ce8-ffc632bfe6ed.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>In today's digital age, businesses are increasingly moving their applications and infrastructure to the cloud to take advantage of scalability, flexibility, and cost-efficiency. As one of the leading cloud service providers, Amazon Web Services (AWS) offers a robust solution called Amazon Virtual Private Cloud (Amazon VPC) that enables organizations to create their own isolated virtual networks within the AWS cloud. In this blog post, we will take a comprehensive look at Amazon VPC, its features, benefits, and how it empowers businesses to build secure and scalable cloud architectures.</strong></p>
<hr />
<h2 id="heading-understanding-amazon-vpc"><strong>✨️Understanding Amazon VPC:</strong></h2>
<p>Amazon Virtual Private Cloud (VPC) is a highly customizable and secure networking service provided by AWS. It allows users to provision a logically isolated section of the AWS Cloud where they can launch AWS resources, such as Amazon EC2 instances, databases, and load balancers, within a defined virtual network.</p>
<hr />
<h2 id="heading-key-features-and-benefits"><strong>🔶️Key Features and Benefits:</strong></h2>
<ol>
<li><strong>Network Isolation:</strong></li>
</ol>
<p>With Amazon VPC, businesses can create multiple virtual networks that are completely isolated from one another. This isolation provides enhanced security by allowing organizations to control network traffic and implement granular security policies.</p>
<ol>
<li><strong>Customizable IP Addressing:</strong></li>
</ol>
<p>Amazon VPC enables users to define IP address ranges for their virtual networks, giving them full control over the IP addresses assigned to their resources. This feature allows for seamless integration with existing network infrastructures and easy migration of applications to the cloud.</p>
<ol>
<li><strong>Subnetting:</strong></li>
</ol>
<p>VPC allows users to divide their virtual network into subnets, which are smaller address ranges within the overall IP address range of the VPC. Subnetting enables organizations to compartmentalize their resources and apply different network policies and access controls to each subnet.</p>
<ol>
<li><strong>Connectivity Options:</strong></li>
</ol>
<p>Amazon VPC provides several connectivity options to establish secure connections between the VPC and other networks. These options include Virtual Private Network (VPN) connections, AWS Direct Connect, and VPC peering. These features make it easier to integrate on-premises infrastructure with the cloud environment.</p>
<ol>
<li><a target="_blank" href="https://imransaifi.hashnode.dev/exploring-the-power-of-amazon-vpc-a-deep-dive-into-amazon-virtual-private-cloud#heading-key-features-and-benefits"><strong>Security</strong></a> <strong>and Access Control:</strong></li>
</ol>
<p>Amazon VPC offers robust security features to protect resources and data within the virtual network. Users can leverage security groups and network access control lists (ACLs) to define fine-grained rules that govern inbound and outbound traffic. Additionally, AWS Identity and Access Management (IAM) can be used to manage user access and permissions.</p>
<ol>
<li><strong>Scalability and Elasticity:</strong></li>
</ol>
<p>With Amazon VPC, businesses can easily scale their resources up or down based on demand. The elastic nature of VPC allows organizations to adapt to changing workloads and efficiently allocate resources, ensuring optimal performance and cost savings.</p>
<ol>
<li><strong>Integration with AWS Services:</strong></li>
</ol>
<p>Amazon VPC seamlessly integrates with various AWS services, enabling organizations to build complex architectures with ease. It provides direct connectivity to services like Amazon S3, Amazon RDS, and Amazon Redshift, facilitating data storage, database management, and analytics capabilities.</p>
<hr />
<h2 id="heading-use-cases"><strong>🔶️Use Cases:</strong></h2>
<ol>
<li><a target="_blank" href="https://imransaifi.hashnode.dev/exploring-the-power-of-amazon-vpc-a-deep-dive-into-amazon-virtual-private-cloud#heading-key-features-and-benefits"><strong>Secure</strong></a> <strong>Web Application Hosting:</strong></li>
</ol>
<p>Amazon VPC allows businesses to host web applications securely by isolating them within their own virtual networks. This ensures that sensitive customer data and application resources are protected from unauthorized access.</p>
<ol>
<li><strong>Hybrid Cloud Deployments:</strong></li>
</ol>
<p>Organizations with existing on-premises infrastructure can extend their network into the cloud using Amazon VPC. This facilitates the creation of a hybrid cloud architecture that combines the benefits of both on-premises and cloud environments.</p>
<ol>
<li><strong>Multi-Tier Architectures:</strong></li>
</ol>
<p>With VPC's subnetting capabilities, businesses can design multi-tier architectures, separating web servers, application servers, and database servers into different subnets. This enhances security and improves performance by allowing finer control over network traffic.</p>
<hr />
<h3 id="heading-conclusion">✍️Conclusion:</h3>
<p>Amazon Virtual Private Cloud (Amazon VPC) is a powerful networking service that empowers businesses to create secure, isolated virtual networks within the AWS cloud. With its rich features, flexibility, and integration with other AWS services, Amazon VPC provides organizations with the tools they need to build scalable, resilient, and highly available cloud architectures. By leveraging the capabilities of Amazon VPC, businesses can enhance security, optimize performance, and achieve greater agility in their journey towards the cloud.</p>
<hr />
<p><strong><em>Thanks for reading to the end; I hope you gained some knowledge.❤️🙌</em></strong></p>
<p><a target="_blank" href="https://www.linkedin.com/in/vishesh-ghule/">Linkedln</a></p>
<p><a target="_blank" href="https://twitter.com/VisheshGhule">Twitter</a></p>
<p><a target="_blank" href="https://github.com/VisheshGhule">Github</a></p>
]]></content:encoded></item><item><title><![CDATA[Deploy Website on AWS EC2 instance using CI/CD]]></title><description><![CDATA[Stuck creating a pipeline from GitHub actions to the ec2 instance.]]></description><link>https://blog.kubekode.io/deploy-website-on-aws-ec2-instance-using-cicd-pipelines</link><guid isPermaLink="true">https://blog.kubekode.io/deploy-website-on-aws-ec2-instance-using-cicd-pipelines</guid><category><![CDATA[AWS]]></category><category><![CDATA[github-actions]]></category><category><![CDATA[aws cicd]]></category><category><![CDATA[ec2]]></category><category><![CDATA[technology]]></category><dc:creator><![CDATA[kuwar pratap singh]]></dc:creator><pubDate>Sat, 30 Sep 2023 21:50:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1696110424371/73957bc6-aaad-485f-9bbe-ccce64131762.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Stuck creating a pipeline from GitHub actions to the ec2 instance.</p>
]]></content:encoded></item><item><title><![CDATA[Creating Sub-domain in Google domains]]></title><description><![CDATA[To create a subdomain in Google Domains, you'll need to add DNS records for the subdomain in your domain's DNS settings. Here's a step-by-step guide on how…]]></description><link>https://blog.kubekode.io/creating-sub-domain-in-google-domains</link><guid isPermaLink="true">https://blog.kubekode.io/creating-sub-domain-in-google-domains</guid><category><![CDATA[map subdomain ]]></category><category><![CDATA[Google]]></category><category><![CDATA[Devops]]></category><category><![CDATA[dns]]></category><dc:creator><![CDATA[kuwar pratap singh]]></dc:creator><pubDate>Wed, 16 Aug 2023 18:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/zhZydTyNMPg/upload/2de7f6fb08454629fb096f10da7ebd50.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>To create a subdomain in Google Domains, you'll need to add DNS records for the subdomain in your domain's DNS settings. Here's a step-by-step guide on how to do this:</p>
<ol>
<li><p><strong>Log in to Google Domains:</strong> Go to the Google Domains website (<a target="_blank" href="https://domains.google.com/">https://domains.google.com/</a>) and log in to your Google account if you haven't already.</p>
</li>
<li><p><strong>Select Your Domain:</strong> Click on the domain name for which you want to create a subdomain. This will take you to the domain management dashboard.</p>
</li>
<li><p><strong>Access DNS Settings:</strong> In the left sidebar, click on "DNS." This is where you'll manage your domain's DNS records.</p>
</li>
<li><p><strong>Add a DNS Record for the Subdomain:</strong> To create a subdomain, you typically add either an <code>A</code> or <code>CNAME</code> record, depending on your specific needs.</p>
<ul>
<li><p><strong>Creating a CNAME Subdomain:</strong></p>
<ul>
<li><p>If you want to create a subdomain that points to another domain or hostname, such as "<a target="_blank" href="http://subdomain.example.com">subdomain.example.com</a>" pointing to "<a target="_blank" href="http://www.example.com">www.example.com</a>," you can add a <code>CNAME</code> record.</p>
</li>
<li><p>Click the "+ Add" button next to "Custom resource records."</p>
</li>
<li><p>In the "Name" field, enter the subdomain you want to create (e.g., "subdomain").</p>
</li>
<li><p>In the "Type" field, select "CNAME."</p>
</li>
<li><p>In the "Data" field, enter the domain or hostname to which the subdomain should point (e.g., "<a target="_blank" href="http://www.example.com">www.example.com</a>").</p>
</li>
<li><p>Click the "Add" button to save the <code>CNAME</code> record.</p>
</li>
</ul>
</li>
<li><p><strong>Creating an A Subdomain:</strong></p>
<ul>
<li><p>If you want to create a subdomain that has its own IP address, you can add an <code>A</code> record.</p>
</li>
<li><p>Click the "+ Add" button next to "Custom resource records."</p>
</li>
<li><p>In the "Name" field, enter the subdomain you want to create (e.g., "subdomain").</p>
</li>
<li><p>In the "Type" field, select "A."</p>
</li>
<li><p>In the "Data" field, enter the IP address to which the subdomain should point.</p>
</li>
<li><p>Click the "Add" button to save the <code>A</code> record.</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Save Your Changes:</strong> After adding the DNS record for your subdomain, make sure to click the "Save" or "Save Changes" button in the DNS settings. Your subdomain is now created and should be functional once DNS propagation is complete.</p>
</li>
</ol>
<p>Please note that DNS changes, including the creation of subdomains, can take some time to propagate across the internet. It may take several hours or up to 48 hours for the subdomain to start working correctly. You can use online DNS lookup tools to check the DNS records for your subdomain and verify that it's resolving correctly once propagation is complete.</p>
]]></content:encoded></item><item><title><![CDATA[Important points to pass your GCP ACE Exam]]></title><description><![CDATA[Always recommended to create a new project, when need a new isolated environment. all resources that share common IAM policies need to be grouped together…]]></description><link>https://blog.kubekode.io/important-points-to-pass-your-gcp-ace-exam</link><guid isPermaLink="true">https://blog.kubekode.io/important-points-to-pass-your-gcp-ace-exam</guid><category><![CDATA[Google Cloud Platform]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[Certification]]></category><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Thu, 03 Aug 2023 23:39:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1691105875405/fcfb3a51-0d91-4b6b-9d9d-3c177b3a0467.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-important-points-for-ace-exam">Important points for ACE Exam</h1>
<h3 id="heading-gcp-managementbasicsorganization-etc">GCP Management/Basics/Organization etc.</h3>
<ul>
<li><p>Always recommended to create a new project, when need a new isolated environment.</p>
</li>
<li><p>all resources that share common IAM policies need to be grouped together</p>
<ul>
<li><p>Group by Folders.</p>
</li>
<li><p>projects sharing similar IAM policies can be grouped in a folder and then the IAM policies can be applied at the folder level.</p>
</li>
</ul>
</li>
<li><p>Cloud identity is a part of GSuite or Google Workspace.</p>
</li>
</ul>
<hr />
<h3 id="heading-google-market-place">Google Market Place</h3>
<ul>
<li><p>When need to deploy something quickly which is not a Google’s service like Jenkins/wordpress</p>
<ul>
<li>Google Market Place</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-compute">Compute</h3>
<ul>
<li><p>Preemptible VMs</p>
<ul>
<li>Short-lived and low cost VMs, not permanent.</li>
</ul>
</li>
<li><p>Increasing Memory:</p>
<ul>
<li>Select increasing memory manually when need to increase memory only of a VM instance not choose changing machine type.</li>
</ul>
</li>
<li><p>For Windows Instances</p>
<ul>
<li>use gcloud compute reset-windows-password to retrieve the login credentials for the VM.</li>
</ul>
</li>
<li><p>For Login to VM using SSH without a public IP address</p>
<ul>
<li><code>Cloud Identity Aware Proxy</code> can be used to enable access to VMs that don’t have external IP address or don’t permit Direct access over internet.</li>
</ul>
</li>
<li><p>Using customized SSH Keys logging into Instances</p>
<ul>
<li><p>Metadata managed: Upload the public key to project metadata</p>
</li>
<li><p>OS Login: Upload your publish SSH Key to your OS Login profile.</p>
<ul>
<li><p>To enable: Set <code>enable-oslogin</code> to true in metadata.</p>
</li>
<li><p><code>gcloud compute os-login ssh-keys add</code></p>
</li>
<li><p>OS Login API: POST <a target="_blank" href="https://oslogin.googleapis.com/v1/users/ACCOUNT_EMAIL:importSshPublicKey">https://oslogin.googleapis.com/v1/users/ACCOUNT_EMAIL:importSshPublicKey</a></p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-persistent-disks-andamp-local-ssds">Persistent disks &amp; Local SSDs</h3>
<ul>
<li><p>If asked: cost-effective &amp; primary storage, high IOPS with low cost - Choose Local SSD.</p>
</li>
<li><p>Create a copy of VM</p>
<ul>
<li><p>Create custom image from a snapshot</p>
</li>
<li><p>Create a VM from image</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-vpc-related">VPC Related</h3>
<ul>
<li><p>Largest CIDR range for a custom VPC?</p>
<ul>
<li>10.0.0.0/8</li>
</ul>
</li>
<li><p>Allow traffic from all IP?</p>
<ul>
<li><p>0.0.0.0/0</p>
</li>
<li><p>Remember:</p>
<ul>
<li><p>0.0.0.0/0 - represents all IP addresses</p>
</li>
<li><p>0.0.0.0/32 - represents 1 IP (0.0.0.0)</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p>The <code>172.17.0.0/16</code> range <a target="_blank" href="https://cloud.google.com/sql/docs/mysql/private-ip#network_issues">is reserved in Cloud SQL</a>.</p>
</li>
<li><p><strong>Shared VPC</strong></p>
<ul>
<li><p>Communication between 2 GCP project, different VPCs.</p>
</li>
<li><p>Share the VPC from one project and request that the Compute Engine instances in the other project use this shared VPC.</p>
</li>
<li><p>resources in different projects to talk to each other</p>
</li>
</ul>
</li>
<li><p><strong>VPC Peering</strong></p>
<ul>
<li><p>connect VPC networks across different organizations</p>
</li>
<li><p>Networks in same project, different projects and across projects in different organizations can be peered.</p>
</li>
<li><p>using internal IP addresses</p>
</li>
</ul>
</li>
<li><p><strong>Cloud VPN</strong></p>
<ul>
<li><p>Connect on-premise network to GCP network.</p>
<ul>
<li><p>Implemented using IPSec VPN Tunnel</p>
</li>
<li><p>Traffic through internet(public)</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Cloud Interconnect</strong></p>
<ul>
<li><p>physical connection between on-premise and VPC networks</p>
<ul>
<li>Highly available and high throughput****</li>
</ul>
</li>
</ul>
</li>
<li><p>Subnets IP range can be expanded: <strong>gcloud compute networks subnets expand-ip-range</strong></p>
</li>
<li><p>Auto mode can be changed to custom but custom can’t .</p>
</li>
<li><p>use service accounts to control access between the application servers and the database servers.</p>
</li>
</ul>
<hr />
<h3 id="heading-app-engine">App Engine</h3>
<ul>
<li><p>28 free instance hours per day.</p>
</li>
<li><p>Versions Limit: Free app: 5, Paid App: 105</p>
</li>
</ul>
<hr />
<h3 id="heading-big-query">Big Query</h3>
<ul>
<li><p>If need to analyze the billing data</p>
<ul>
<li>Export billing data to bigquery dataset.</li>
</ul>
</li>
<li><p><strong>External Tables</strong></p>
<ul>
<li><p>Query external data sources without storing data in bigquery</p>
<ul>
<li><p>Cloud Storage, Cloud SQL, BigTable, Google Drive</p>
</li>
<li><p>Use permanent or temporary external tables.</p>
</li>
</ul>
</li>
<li><p>Use case: Joining 2 external data sources tables for data analytics like BigTable and Cloud storage.</p>
<ul>
<li><p>create 2 external tables for bigtable and cloud storage</p>
</li>
<li><p>Join tables through bigquery console and apply appropriate filters.</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p>Data catalog</p>
<ul>
<li>If you need to find something across multiple projects or datasets.</li>
</ul>
</li>
<li><p>Query cost reduction?</p>
<ul>
<li><p>Apply user project-level custom query quota for Bigquery</p>
</li>
<li><p>Change your bigquery model from on-demand to flat rate.</p>
</li>
</ul>
</li>
<li><p>If data is broken, first step to debug or finding out the issue</p>
<ul>
<li>Go to bigquery and review the job to look for errors.</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-billing">Billing</h3>
<ul>
<li><p>Billing data can be exported(on schedule) to</p>
<ul>
<li><p>Big Query(for analyze, visualizing)</p>
</li>
<li><p>Cloud Storage(for archiving)</p>
</li>
</ul>
</li>
<li><p>Cost Details on billing dashboard gives you cost details for a specific invoice.</p>
</li>
<li><p>billing alert gets triggered on the project’s total cost and not just for specific service costs.</p>
</li>
<li><p>If need alerts for specific service costs, follow this approach</p>
<ul>
<li>exporting the billing data to bigquery and analyzing the charges incurred by service is the best option.</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-cloud-storage-related">Cloud Storage Related</h3>
<ul>
<li><p>Lifecycle Policy rules</p>
<pre><code class="lang-json">  {
      <span class="hljs-attr">"lifecycle"</span>:{
          <span class="hljs-attr">"rule"</span>: [
              {
                  <span class="hljs-attr">"action"</span>:{<span class="hljs-attr">"type"</span>: <span class="hljs-string">"Delete"</span>},
                  <span class="hljs-attr">"condition"</span>:{
                      <span class="hljs-attr">"age"</span>: <span class="hljs-number">30</span>,
                      <span class="hljs-attr">"isLive"</span>: <span class="hljs-literal">true</span>
                  }
              },
              {
                  <span class="hljs-attr">"action"</span>:{
                      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"SetStorageClass"</span>,
                      <span class="hljs-attr">"storageClass"</span>: <span class="hljs-string">"NEARLINE"</span>
                  },
                  <span class="hljs-attr">"condition"</span>:{
                      <span class="hljs-attr">"age"</span>: <span class="hljs-number">365</span>,
                      <span class="hljs-attr">"matchesStorageClass"</span>:[<span class="hljs-string">"MULTI_REGIONAL"</span>,<span class="hljs-string">"STANDARD"</span>,<span class="hljs-string">"DURABLE_REDUCED_AVAILABILITY"</span>]
                  }
              }
          ]
      }
  }
</code></pre>
</li>
<li><p><strong>Parallel composite uploads</strong></p>
<ul>
<li><p>Faster uploads</p>
</li>
<li><p>File divided up to 32 chunks and uploaded in parallel.</p>
</li>
</ul>
</li>
<li><p>Cloud Storage Classes</p>
<ul>
<li><p>Standard - Frequently accessed data</p>
<ul>
<li>pricing</li>
</ul>
</li>
<li><p>Nearline - Once a month</p>
<ul>
<li>pricing</li>
</ul>
</li>
<li><p>Coldline - Once a quarter</p>
<ul>
<li>pricing</li>
</ul>
</li>
<li><p>Archive - Once a year</p>
<ul>
<li>pricing</li>
</ul>
</li>
</ul>
</li>
<li><p>Sync files from on-premises to Cloud storage</p>
<ul>
<li>Use gsutil CLI to write a script</li>
</ul>
</li>
<li><p>Optimal for regional outages and also cost effective storage</p>
<ul>
<li><p>Dual regional</p>
</li>
<li><p>if cost-effective not mentioned: multi-regional</p>
</li>
</ul>
</li>
<li><p>For configuration from on-premises to Cloud storage</p>
<ul>
<li><p>Create a VPN tunnel</p>
</li>
<li><p>configure DNS to resolve *.<a target="_blank" href="http://googleapis.com">googleapis.com</a> as a CNAME to <a target="_blank" href="http://restricted.googleapis.com">restricted.googleapis.com</a>.</p>
</li>
</ul>
</li>
<li><p>To change the storage class:</p>
<pre><code class="lang-bash">  gsutil rewrite -s[Storage-class] object-url
</code></pre>
</li>
</ul>
<hr />
<h3 id="heading-deployment-manager">Deployment Manager</h3>
<ul>
<li><p>Use -preview option in deployment manager to observe the state of resource for the preview what is going to be created.</p>
</li>
<li><p>Type Provider</p>
<ul>
<li><p>A type provider exposes all of the resources of a third-party API to Deployment Manager as base types that you can use in your configurations. These types must be directly served by a RESTful API that supports Create, Read, Update, and Delete (CRUD).</p>
</li>
<li><p>If you want to use an API that is not automatically provided by Google with Deployment Manager, you must add the API as a type <a target="_blank" href="http://provider.Like">provide</a>r</p>
</li>
<li><p>Like for creating kubernetes API objects like Daemonsets, pods, deployments etc.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-iam">IAM</h3>
<ul>
<li><p>Service account roles</p>
<ul>
<li><p><code>roles/iam.serviceAccountUser</code></p>
<ul>
<li>only provides the user with the ability to use service accounts, but it does not grant permissions to manage or administer service accounts.</li>
</ul>
</li>
<li><p><code>roles/iam.serviceAccountAdmin</code></p>
<ul>
<li><p>if need to manage all service accounts in a project.</p>
</li>
<li><p>provides the minimum set of permissions required to manage all service accounts for Google Cloud Projects.</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p>Follow least privileges principle.</p>
</li>
<li><p>Custom Roles:</p>
<ul>
<li><p>Custom roles include a launch stage, which is stored in the stage property for the role. The launch stage is informational; it helps you keep track of whether each role is ready for widespread use.</p>
</li>
<li><p>ALPHA means the role is still being developed or tested, or it includes permissions for Google Cloud services or features that are not yet public. It is not ready for widespread use.</p>
</li>
</ul>
</li>
<li><p>First priority is: Primitive and Predefined roles not custom roles.</p>
</li>
<li><p>If user is not one, choose groups to provide the permission.</p>
</li>
<li><p>When que is about Compute VM to Cloud Storage Access</p>
<ul>
<li>Choose creating service account, provide access to cloud storage and assign custom sa to compute VM.(Even if between 2 projects)</li>
</ul>
</li>
</ul>
<p><strong>BigQuery</strong></p>
<ul>
<li><p>Billing Account Roles</p>
<ul>
<li>billing.accounts.update” : to update something in billing account</li>
</ul>
</li>
<li><p>BigQuery Roles</p>
<ul>
<li><p><strong>BigQuery Job User</strong></p>
<ul>
<li><a target="_blank" href="http://bigquery.jobs"><code>bigquery.jobs</code></a><code>.create</code>****</li>
</ul>
</li>
</ul>
</li>
<li><p>If question is about an IAM role for bigquery access datasets, not to delete then choose</p>
<ul>
<li><code>custom role</code></li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-identity">Identity</h3>
<ul>
<li>Setup SSO with third-party identity provider in Cloud Identity with Google as a service provider. When using any other idenity accounts like active directory.</li>
</ul>
<hr />
<h3 id="heading-logging-and-monitoring">Logging and Monitoring</h3>
<ul>
<li><p>Audit logs:</p>
<ul>
<li><p><strong>Access Transparency Log</strong></p>
</li>
<li><p><strong>Cloud Audit Logs</strong></p>
<ul>
<li><p>Admin Activity logs</p>
</li>
<li><p>data access logs</p>
</li>
<li><p>System Event logs</p>
</li>
<li><p>Policy denied logs</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p>Logs can be exported to</p>
<ul>
<li><p>BigQuery</p>
</li>
<li><p>Cloud Storage</p>
</li>
<li><p>Pub/Sub(from pub/sub we can send logs anywhere)</p>
</li>
</ul>
</li>
<li><p>How to export logs?</p>
<ul>
<li>Create sinks to the destinations using Log Router(filters can be added)</li>
</ul>
</li>
<li><p>Disable logging if there’s higher cost</p>
<ul>
<li>For GKE: Go to the logs ingestion window in logging and disable the log source for the GKE container resource.</li>
</ul>
</li>
<li><p>If need to check creation time of a resource: use activity logs to view configuration category.</p>
</li>
<li><p>alert notifications for CPU utilization</p>
<ul>
<li><p>create cloud monitoring alert policy to that uses threshold as trigger condition.</p>
</li>
<li><p>configure email address in notification channel.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-gke-andamp-kubernetes-related">GKE &amp; Kubernetes Related</h3>
<ul>
<li><p>If something needs to be run on each node</p>
<ul>
<li>Use daemonsets</li>
</ul>
</li>
<li><p><em>Node auto-upgrades</em> help you keep the <a target="_blank" href="https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-architecture#nodes">nodes</a> in your <a target="_blank" href="https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-architecture">cluster</a> up-to-date with the cluster control plane version when your control plane is <a target="_blank" href="https://cloud.google.com/kubernetes-engine/upgrades#automatic_cp_upgrades">updated on your behalf</a>.</p>
</li>
<li><p>To Expose application using HTTPS on a public IP address</p>
<ul>
<li><p>Create a Kubernetes Service of type NodePort for your application, and a Kubernetes Ingress to expose this Service via a Cloud Load Balancer.</p>
</li>
<li><p>Use Load Balancer service of kubernetes</p>
</li>
</ul>
</li>
<li><p>Need different configurations in nodes like GPU?</p>
<ul>
<li>Add a new node pool with required configuration.</li>
</ul>
</li>
<li><p>Auto provisioning Feature in GKE</p>
<ul>
<li>Node auto-provisioning is a mechanism of the cluster autoscaler, which scales on a per-node pool basis. With node auto-provisioning enabled, the cluster autoscaler can extend node pools automatically based on the specifications of unschedulable Pods. Using the GKE cluster's node auto-provisioning feature allows for dynamically provisioning nodes with GPUs only when they are needed. This helps optimize cost as resources are only allocated as necessary.</li>
</ul>
</li>
<li><p>Auto Scaling Cluster</p>
<ul>
<li><p>Creating a GKE cluster with autoscaling enabled on the node pool allows for automated scaling of the cluster itself based on the workload.</p>
</li>
<li><p>By configuring a minimum and maximum size for the node pool, the cluster can automatically scale up or down the number of nodes based on the demand.</p>
</li>
</ul>
</li>
<li><p>Limits per cluster</p>
</li>
</ul>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Limits</td><td>GKE Standard cluster</td><td>GKE Autopilot cluster</td></tr>
</thead>
<tbody>
<tr>
<td>Pods per node 2</td><td>256 Note: For GKE versions earlier than 1.23.5-gke.1300, the limit is 110 Pods.</td><td>32</td></tr>
<tr>
<td>Pods per cluster 1</td><td>200,000 2</td><td>25,000</td></tr>
<tr>
<td>Containers per cluster</td><td>400,000</td><td>25,000</td></tr>
</tbody>
</table>
</div><hr />
<h3 id="heading-load-balancing">Load Balancing</h3>
<ul>
<li><p>If question is about to replicate a VM from a single zone to multiple zones, for high availability setup a load balancer which balance traffic between multiple zones VM instances.</p>
</li>
<li><p>HTTP(S) Load Balancer</p>
<ul>
<li><p>If application used to server over HTTPS.</p>
</li>
<li><p>From Internet to VMs</p>
</li>
<li><p>External and Internal</p>
</li>
</ul>
</li>
<li><p>HTTPS on 443 port : HTTPS Load balancer</p>
</li>
<li><p>SSL Proxy load balancer</p>
<ul>
<li><p>reverse proxy load balancer that distributes SSL traffic coming from the internet to virtual machine (VM) instances in your Google Cloud VPC network.</p>
</li>
<li><p>ports supported: 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 3389, 5222, 5432, 5671, 5672, 5900, 5901, 6379, 8085, 8099, 9092, 9200, and 9300.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-managed-instance-groups">Managed Instance Groups</h3>
<ul>
<li><p>Cool Down Period(Initial Delay)</p>
<ul>
<li>Always choose increase the cool down period, if question is related to instances autoscales rapidly or more than expected.</li>
</ul>
</li>
<li><p>Rolling Update</p>
<ul>
<li><p>Gradual update of instances in an instance group to the new instance template.</p>
</li>
<li><p>How should the update happen?</p>
<ul>
<li><p><strong>Maximum surge</strong>: How many instances are added at any point in time?</p>
</li>
<li><p><strong>Maximum unavailable</strong>: How many instances can be offline during the update?</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-cloud-functions">Cloud Functions</h3>
<ul>
<li>The default invocation limit is 1000/s.</li>
</ul>
<hr />
<h3 id="heading-cloud-sql">Cloud SQL</h3>
<ul>
<li><p>Binary logging</p>
</li>
<li><p>Only support MySQL and PostgreSQL</p>
</li>
</ul>
<h3 id="heading-cloud-spanner">Cloud Spanner</h3>
<ul>
<li>ensuring that the primary key does not have monotonically increasing values can help in resolving the read latency-related performance issues.</li>
</ul>
<hr />
<h3 id="heading-gcloud-cli">Gcloud CLI</h3>
<ul>
<li><p>In Ubuntu, When you install SDK using apt Cloud SDK Component Manager is disabled and you need to install extra packages again using apt.</p>
</li>
<li><p>Make separate configurations for multiple projects</p>
<ul>
<li>activate the appropriate configuration for project to use.</li>
</ul>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Having problems working with the primary and another GitHub account on the same machine.]]></title><description><![CDATA[Sometimes when we are working with multiple accounts on the same machine with GitHub we get errors where we are authorized to push and pull from a remote…]]></description><link>https://blog.kubekode.io/having-problems-working-with-the-primary-and-another-github-account-on-the-same-machine</link><guid isPermaLink="true">https://blog.kubekode.io/having-problems-working-with-the-primary-and-another-github-account-on-the-same-machine</guid><category><![CDATA[GitHub]]></category><category><![CDATA[ssh-keys]]></category><category><![CDATA[ssh-keygen]]></category><category><![CDATA[SSH Git]]></category><category><![CDATA[error handling]]></category><dc:creator><![CDATA[kuwar pratap singh]]></dc:creator><pubDate>Tue, 01 Aug 2023 18:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/HLQDfaJUTVI/upload/075d433a7a6b6e7f830af59da56dd353.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Sometimes when we are working with multiple accounts on the same machine with GitHub we get errors where we are authorized to push and pull from a remote repository and are stuck with notifications like:</p>
<h3 id="heading-you-are-not-the-authorized-author-of-this-repository-please-create-a-fork-from-the-github-branch"><mark>You are not the authorized author of this repository please create a fork from the GitHub branch.</mark></h3>
<hr />
<p>Let's make it easy in just 5-6 simple and easy steps, follow each step one by one.</p>
<p>Suppose you are logged in with your primary account, and also have a client GitHub account from which you need to work with them. You don't need to signOut your primary account simply open your command palette like cmd, bash, and any editor.</p>
<ul>
<li><p><strong>Step 1: Generate and setup SSH Key :</strong></p>
<p>  Please ensure that first you have SSH keys for both accounts, if you don't have an SSH key for the client account, first we need to generate.</p>
<pre><code class="lang-bash">  ssh-keygen -t rsa -b 4096 -C <span class="hljs-string">"client@example.com"</span>
</code></pre>
<p>  Describe given above bash command line:</p>
<p>  <strong>ssh-keygen:</strong> used to generate SSH (Secure Shell) key pairs, which consist of a public key and a private key. These keys are used for secure authentication and communication between your computer and remote servers.</p>
<p>  <strong>-t rsa:</strong> This option specifies the type of key to <strong>be</strong> <strong>created.</strong> <strong>The</strong> <strong>commonly</strong> used asymmetric encryption <strong>algorithm</strong> <strong>in</strong> <strong>this</strong> <strong>case</strong> <strong>is</strong> <strong>RSA</strong> <strong>(Rivest-Shamir-Adleman).</strong></p>
<p>  <strong>-b 4096:</strong> This option sets the number of bits within the key. A longer key gives more prominent security but may take longer to create <strong>(a</strong> 4096-bit key is very secure and is commonly used for SSH).</p>
<p>  <strong>-c "</strong><a target="_blank" href="mailto:your-email@example.com"><strong>client@example.com</strong></a><strong>":</strong> It's typically used to associate the key with an email address. In this case, you're associating the key with the email address "<a target="_blank" href="mailto:your-email@example.com"><strong>client@example.com</strong></a>."</p>
</li>
<li><p><strong>Step 2: Adding SSH Key to SSH Agent:</strong></p>
<p>  Firstly, we need to start the SSH agent</p>
<pre><code class="lang-bash">  <span class="hljs-built_in">eval</span> <span class="hljs-string">"<span class="hljs-subst">$(ssh-agent -s)</span>"</span>
</code></pre>
<p>  Describe given above bash command line:</p>
<p>  <strong>eval:</strong> command is used to evaluate the commands produced by <code>ssh-agent -s.</code></p>
<p>  <strong>ssh-agent:</strong> responsible for managing SSH keys and facilitating secure SSH connections.</p>
<p>  <strong>-s:</strong> that need to be evaluated by the shell to set up the agent environment.</p>
<p>  After starting SSH we need to add the client key to the agent:</p>
<pre><code class="lang-bash">  ssh-add ~/.ssh/your-client-ssh-key
</code></pre>
</li>
<li><p><strong>Step 3: configure ssh key to Github :</strong></p>
<p>  We can use any of them like Vim, nano any other bash editor. Open the editor and create a plaintext file -</p>
<pre><code class="lang-bash">  nano ~/.ssh/config
</code></pre>
<p>  Describe given above bash command line:</p>
<p>  <strong>nano:</strong> It is a text Editor.</p>
<p>  <strong>~:</strong> Symbol represents your home directory.</p>
<p>  <strong>.ssh/config:</strong> Path of sub-directory where key is stored.</p>
<pre><code class="lang-plaintext">  Host github.com-client
    HostName github.com
    User git
    IdentityFile ~/.ssh/your-client-ssh-key
</code></pre>
</li>
<li><p><strong>Step 4: Configuration of Git</strong></p>
<p>  Open the bash editor and run these commands for the configuration your SSH key to GitHub</p>
<pre><code class="lang-bash">  git config --global user.name <span class="hljs-string">"Your Client's Username"</span>
  git config --global user.email <span class="hljs-string">"client@example.com"</span>
  git config --global --replace-all url.<span class="hljs-string">"git@github.com:"</span>.insteadOf <span class="hljs-string">"https://github.com/"</span>
</code></pre>
</li>
<li><p><strong>Step 5: Work with Repositories</strong>:</p>
<p>  clone or create a new Git repository, always <strong>remember</strong> to use <strong>a</strong> custom <strong>name</strong> when specifying the repository URL.</p>
<pre><code class="lang-scss">  git<span class="hljs-keyword">@github</span>.com-client:client-username/client-repo.git
</code></pre>
</li>
</ul>
<p>If you want to test your configuration use this command.</p>
<pre><code class="lang-bash">ssh -T git@github.com-client
</code></pre>
<hr />
<p>I hope this blog finds something knowledgeable for you.</p>
<center>🙌🙌🙌🙌Thank You for reading. 🙌🙌🙌🙌</center>]]></content:encoded></item><item><title><![CDATA[How did I pass terraform associate exam?]]></title><description><![CDATA[The Terraform Associate certification is for Cloud Engineers specializing in operations, IT, or developers who know the basic concepts and skills…]]></description><link>https://blog.kubekode.io/how-did-i-pass-terraform-associate-exam</link><guid isPermaLink="true">https://blog.kubekode.io/how-did-i-pass-terraform-associate-exam</guid><category><![CDATA[Terraform]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Kubernetes]]></category><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Sat, 29 Jul 2023 19:53:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1690656338590/fe0c3548-4267-4e46-97bc-c1190d698f08.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690659105333/be53074d-b6e3-4a9b-8d16-053b1da649a8.png" alt class="image--center mx-auto" /></p>
<p>The Terraform Associate certification is for Cloud Engineers specializing in operations, IT, or developers who know the basic concepts and skills associated with open-source HashiCorp Terraform. Candidates will be best prepared for this exam if they have professional experience using Terraform in production, but performing the exam objectives in a personal demo environment may also be sufficient.</p>
<h2 id="heading-background">Background</h2>
<p>Before I dive into the specifics, let me give you some context. I joined my first Tech Organization early in March 2021 and as part of my project I got introduced to terraform for the first time as a DevOps Engineer.</p>
<p>I'm working with Terraform in a production environment for around 2 years. And I decided to upskill myself in terraform with having a validation of my skill. So I started preparing for the Terraform Associate Exam.</p>
<p>I dedicated around 10-20 days to preparing for the exam and was able to pass it successfully.</p>
<h2 id="heading-resources-that-helped-me"><strong>Resources That Helped Me</strong></h2>
<h3 id="heading-official-terraform-documentation">Official Terraform Documentation</h3>
<p>As I was working with Terraform already so I was well familiar with the documentation and other resources. Whenever I stuck in some error I used documentation to solve that.</p>
<p><a target="_blank" href="https://developer.hashicorp.com/terraform?product_intent=terraform">Terraform Official Documentation</a></p>
<h3 id="heading-video-based-resources">Video based resources</h3>
<ul>
<li><p>For the first time, to get started with terraform I used a youtube video by kodekloud. That video almost cleared my all doubts about terraform.</p>
</li>
<li><p>But when I started preparing for the certification, I took <a target="_blank" href="https://www.udemy.com/course/terraform-beginner-to-advanced/">Terraform Associate udemy course by Zeal Vora</a> for the preparation.</p>
</li>
<li><p>You can also use other free resources from youtube as well.</p>
</li>
</ul>
<h3 id="heading-practice-exams"><strong>Practice Exams</strong></h3>
<p>I didn't try any practice exams for my certification as I was confident enough to pass the certification and also in the course itself there's a practice exam which gives enough idea of questions asked in the exam.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>In conclusion, these were the resources that I relied on for my preparation. The entire process took me around 20 days. Remember, each person's journey is unique, and what worked for me might not work for you. However, I hope that sharing my experience will provide you with some guidance and inspiration as you prepare for your Terraform Associate exam.</p>
]]></content:encoded></item><item><title><![CDATA[Terratest: Streamline Your Infrastructure Testing]]></title><description><![CDATA[Terratest is an open-source testing framework developed by Gruntwork, designed to facilitate infrastructure testing and validation. Whether you are…]]></description><link>https://blog.kubekode.io/terratest-streamline-your-infrastructure-testing</link><guid isPermaLink="true">https://blog.kubekode.io/terratest-streamline-your-infrastructure-testing</guid><category><![CDATA[Terraform]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Kubernetes]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Infrastructure as code]]></category><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Wed, 12 Jul 2023 00:43:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1689122571845/9aaf58c5-7a16-4969-b361-baac6dd5b94b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Terratest is an open-source testing framework developed by Gruntwork, designed to facilitate infrastructure testing and validation. Whether you are managing infrastructure on cloud platforms like AWS, Azure, or Google Cloud, or using configuration management tools like Terraform or Ansible, Terratest can streamline and automate your testing process, giving you confidence in the reliability of your infrastructure.</p>
<h2 id="heading-getting-started-with-terratest">Getting Started with Terratest</h2>
<p>To get started with Terratest, you need to have Go installed on your machine. Once you have Go set up, you can initialize a new Go module and import the Terratest library. From there, you can begin writing your infrastructure tests using Terratest's expressive syntax.</p>
<p>Terratest has extensive documentation, including examples and best practices, which can guide you through the process of writing effective tests. The Gruntwork GitHub repository hosts various example projects and modules that demonstrate how to use Terratest in real-world scenarios.</p>
<h2 id="heading-testing-aws-ec2-resource">Testing AWS EC2 resource</h2>
<ul>
<li>Directory structure</li>
</ul>
<pre><code class="lang-bash">├── aws-ec2-test
│   ├── aws_ec2_test.go
│   ├── go.mod
│   └── go.sum
├── aws_ec2
│   ├── main.tf
│   ├── terraform.tfstate
│   └── terraform.tfstate.backup
</code></pre>
<h2 id="heading-steps">Steps</h2>
<ol>
<li><p>Create 2 directories</p>
<ol>
<li><p>For terraform code</p>
</li>
<li><p>For testing golang code</p>
</li>
</ol>
</li>
<li><p>Add terraform scripts for aws ec2 instance</p>
<pre><code class="lang-json"> provider <span class="hljs-string">"aws"</span> {
     region = <span class="hljs-attr">"eu-north-1"</span>

 }
 data <span class="hljs-string">"aws_ami"</span> <span class="hljs-string">"app_ami"</span> {
     most_recent = true
     owners = [<span class="hljs-attr">"amazon"</span>]
     filter{
         name = <span class="hljs-attr">"name"</span>
         values = [<span class="hljs-attr">"amzn2-ami-hvm*"</span>]
     }
 }
 resource <span class="hljs-string">"aws_instance"</span> <span class="hljs-string">"instance-dev"</span> {
   ami           = data.aws_ami.app_ami.id
   instance_type = <span class="hljs-attr">"t3.micro"</span>
 }
 output <span class="hljs-string">"instance_type"</span> {
     # value = aws_instance.instance-dev.public_ip
     value = aws_instance.instance-dev.instance_type
 }
</code></pre>
</li>
</ol>
<h2 id="heading-3-add-golang-testing-file-in-2nd-testing-directory">3. Add Golang testing file in 2nd testing directory.</h2>
<ul>
<li><p>Create a golang file in the test directory.</p>
<ul>
<li>NOTE: test file should be always in this syntax: <code>yourfilename_test.go</code>(<code>_test.go</code> should be in the last)</li>
</ul>
</li>
<li><p>First define modules to import</p>
</li>
</ul>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> test
<span class="hljs-keyword">import</span>(
    <span class="hljs-string">"testing"</span>
    <span class="hljs-string">"github.com/gruntwork-io/terratest/modules/terraform"</span>
    <span class="hljs-string">"github.com/stretchr/testify/assert"</span>
)
</code></pre>
<ul>
<li><p>Initialize go module and install required packages</p>
<pre><code class="lang-bash">  go mod init testmodule
  go mod tidy
</code></pre>
</li>
<li><p>Now define the function for the testing</p>
</li>
<li><p>Here's the complete test file</p>
</li>
</ul>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> test
<span class="hljs-keyword">import</span>(
    <span class="hljs-string">"testing"</span>
    <span class="hljs-string">"github.com/gruntwork-io/terratest/modules/terraform"</span>
    <span class="hljs-string">"github.com/stretchr/testify/assert"</span>
)
<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">TestAWSEC2Instance</span><span class="hljs-params">(t *testing.T)</span></span>{
    terraformOptions := terraform.WithDefaultRetryableErrors(t, &amp;terraform.Options{
        TerraformDir: <span class="hljs-string">"../aws_ec2"</span>,
    })
    <span class="hljs-keyword">defer</span> terraform.Destroy(t, terraformOptions)
    terraform.InitAndApply(t, terraformOptions)
    instanceType := terraform.Output(t, terraformOptions, <span class="hljs-string">"instance_type"</span>)
    assert.Equal(t, <span class="hljs-string">"t3.micro"</span>,instanceType)
}
</code></pre>
<ul>
<li><p>What testing will do?</p>
<ul>
<li><p>First it will do terraform init in the specified terraform directory</p>
</li>
<li><p>Then it will do terraform apply</p>
</li>
<li><p>Then it will check our defined terraform output is same as expected or not(using assert.Equal)</p>
<ul>
<li><p>If not it will fail the test.</p>
</li>
<li><p>If true, it will continue.</p>
</li>
</ul>
</li>
<li><p>If all tests passed, in the last it will destroy the infrastructure(define with defer)</p>
</li>
</ul>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Getting started with ArgoCD]]></title><description><![CDATA[Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. It follows gitOps principles to deploy your application. It works like an agent…]]></description><link>https://blog.kubekode.io/getting-started-with-argocd</link><guid isPermaLink="true">https://blog.kubekode.io/getting-started-with-argocd</guid><category><![CDATA[ArgoCD]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Docker]]></category><category><![CDATA[Kubernetes]]></category><category><![CDATA[Git]]></category><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Sat, 13 May 2023 17:36:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683997096293/108a4174-1fd2-47c7-be08-9b66cf06144d.avif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-argo-cd">What Is Argo CD?</h2>
<ul>
<li><p>Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.</p>
</li>
<li><p>It follows gitOps principles to deploy your application.</p>
</li>
<li><p>It works like an agent installed on your Kubernetes cluster.</p>
</li>
<li><p>It works on the pull deployment model.</p>
</li>
</ul>
<h2 id="heading-push-deployment-vs-pull-deployment">Push Deployment vs Pull Deployment</h2>
<ul>
<li><p>Push deployment is what you do in your CI/CD pipelines that you define using Jenkins/Github Actions/Gitlab CICD/Circle CI.</p>
</li>
<li><p>When you define your CICD pipeline using push deployment what you do is, you add steps to build, test your application and deploy it to Kubernetes.</p>
</li>
<li><p>You add your CD steps also in your CICD pipeline and you need to configure secrets and credentials for your k8s cluster, aws/GCP in your pipeline.</p>
</li>
<li><p>But if you use pull deployment, you don't need to add your CD steps in your pipeline instead you can use ArgoCD.</p>
</li>
<li><p>You just need to install argocd on your kubernetes cluster and create an application using argocd and map it to your github repository(Where you have your kubernetes configuration files).</p>
</li>
<li><p>ArgoCD works like an agent installed on your k8s cluster that works on pull deployment, checks your configuration files from your git repo and always match your desired state with actual state.</p>
</li>
<li><p>If it finds any difference, it makes changes required to match your desired state with actual state.</p>
</li>
<li><p>It provides an amazing UI where you can create, monitor your k8s deployments and configurations.</p>
</li>
</ul>
<h2 id="heading-why-argocd">Why ArgoCD?</h2>
<p>Application definitions, configurations, and environments should be declarative and version controlled. Application deployment and lifecycle management should be automated, auditable, and easy to understand.</p>
<h2 id="heading-steps-to-get-started-with-argocd">Steps to get started with ArgoCD</h2>
<h3 id="heading-1-install-argocd-on-your-kubernetes-cluster">1. Install argocd on your kubernetes cluster.</h3>
<ul>
<li><p>For cluster, you can use minikube cluster for getting started.</p>
</li>
<li><pre><code class="lang-bash">    kubectl create namespace argocd
    kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
</code></pre>
</li>
<li><p>Now if you check services in argocd namespace, you will see a service (ClusterIP) named argocd-server.</p>
</li>
<li><p>To access argocd-server you port-forward your clusterIP service to 8080 port</p>
</li>
<li><pre><code class="lang-bash">    kubectl port-forward svc/argocd-server -n argocd 8080:443
</code></pre>
</li>
<li><p>Now you access your argocd server on localhost:8080</p>
</li>
<li><p>To login into your argocd server you can use credentials from your kubernetes namespace.</p>
<ul>
<li><p>Username: admin</p>
</li>
<li><p>Password: You can get from a secret in your k8s cluster.</p>
</li>
<li><pre><code class="lang-bash">    kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath=<span class="hljs-string">"{.data.password}"</span> | base64 -d
</code></pre>
</li>
</ul>
</li>
</ul>
<h3 id="heading-2-create-application-on-argocd-and-map-to-git-repo">2. Create application on argocd and map to Git repo</h3>
<ul>
<li><p>Create a application yaml file for argocd application</p>
</li>
<li><pre><code class="lang-yaml">    <span class="hljs-attr">apiVersion:</span> <span class="hljs-string">argoproj.io/v1alpha1</span>
    <span class="hljs-attr">kind:</span> <span class="hljs-string">Application</span>
    <span class="hljs-attr">metadata:</span>
      <span class="hljs-attr">name:</span> <span class="hljs-string">myapp-argo-application</span>
      <span class="hljs-attr">namespace:</span> <span class="hljs-string">argocd</span>
    <span class="hljs-attr">spec:</span>
      <span class="hljs-attr">destination:</span>
        <span class="hljs-attr">server:</span> <span class="hljs-string">https://kubernetes.default.svc</span>
        <span class="hljs-attr">namespace:</span> <span class="hljs-string">myapp</span>
      <span class="hljs-attr">source:</span>
        <span class="hljs-attr">repoURL:</span> <span class="hljs-string">https://github.com/KubeKode/youtube</span>
        <span class="hljs-attr">targetRevision:</span> <span class="hljs-string">HEAD</span>
        <span class="hljs-attr">path:</span> <span class="hljs-string">k8s</span>
      <span class="hljs-attr">project:</span> <span class="hljs-string">default</span>
      <span class="hljs-attr">syncPolicy:</span>
        <span class="hljs-attr">syncOptions:</span>
          <span class="hljs-bullet">-</span> <span class="hljs-string">CreateNamespace=true</span>
        <span class="hljs-attr">automated:</span>
          <span class="hljs-attr">selfHeal:</span> <span class="hljs-literal">true</span>
          <span class="hljs-attr">prune:</span> <span class="hljs-literal">true</span>
</code></pre>
</li>
<li><p>Apply the config file using kubectl</p>
</li>
<li><pre><code class="lang-yaml">    <span class="hljs-string">kubectl</span> <span class="hljs-string">apply</span> <span class="hljs-string">-f</span> <span class="hljs-string">application.yml</span>
</code></pre>
</li>
</ul>
<h3 id="heading-3-check-application-deployment">3. Check application deployment</h3>
<ul>
<li>Now just access your argocd server and you can see your application and deployments.</li>
</ul>
<hr />
]]></content:encoded></item><item><title><![CDATA[Setup and Install Jenkins on GCP VM]]></title><description><![CDATA[On the VM instances creation page, Make sure you select the CentoOS Image and check the checkbox to allow HTTP traffic under the firewall section as below.]]></description><link>https://blog.kubekode.io/setup-and-install-jenkins-on-gcp-vm</link><guid isPermaLink="true">https://blog.kubekode.io/setup-and-install-jenkins-on-gcp-vm</guid><category><![CDATA[Jenkins]]></category><category><![CDATA[Devops]]></category><category><![CDATA[ci-cd]]></category><category><![CDATA[GCP]]></category><category><![CDATA[AWS]]></category><dc:creator><![CDATA[Tushar Rajpoot]]></dc:creator><pubDate>Sun, 07 May 2023 16:05:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683474802057/6777b6c9-a33f-4e48-8fd3-ea4fc89cb84a.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-configure-default-vpc-firewall-rules">Configure Default VPC Firewall rules</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683475436020/4ab1edcc-f5af-4cfd-8e0d-261cc9dfbfbc.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-create-a-gcp-vm">Create a GCP VM</h2>
<p><img src="https://miro.medium.com/v2/resize:fit:700/1*ukrI9Xbv5-rznIRZpqly7w.png" alt /></p>
<p>On the VM instances creation page, Make sure you select the CentoOS Image and check the checkbox to allow HTTP traffic under the firewall section as below.</p>
<p><img src="https://miro.medium.com/v2/resize:fit:700/1*np1qJB2Yq7x8lrUJkrxuHQ.png" alt /></p>
<p>In the advanced section</p>
<ul>
<li><p>Add this script in the startup script of the VM</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683475063972/8fe6c80d-4c4d-4870-b9b7-ccb3142aaa42.png" alt class="image--center mx-auto" /></p>
</li>
<li><pre><code class="lang-bash">  sudo apt update
  sudo apt install openjdk-11-jre -y
  curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
    /usr/share/keyrings/jenkins-keyring.asc &gt; /dev/null
  <span class="hljs-built_in">echo</span> deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
    https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
    /etc/apt/sources.list.d/jenkins.list &gt; /dev/null
  sudo apt-get update
  sudo apt-get install jenkins -y
</code></pre>
</li>
</ul>
<hr />
<h2 id="heading-using-gcloud-command">Using gcloud command</h2>
<pre><code class="lang-bash">gcloud compute instances create jenkins-server-template-1 --project=<span class="hljs-variable">$GCP_PROJECT_ID</span> --zone=us-central1<span class="hljs-_">-a</span> --machine-type=e2-medium --network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=default --metadata=startup-script=sudo\ apt\ update$<span class="hljs-string">'\n'</span>sudo\ apt\ install\ git\ -y$<span class="hljs-string">'\n'</span>sudo\ apt\ install\ openjdk-11-jre\ -y$<span class="hljs-string">'\n'</span>curl\ -fsSL\ https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key\ \|\ sudo\ tee\ \\$<span class="hljs-string">'\n'</span>\ \ /usr/share/keyrings/jenkins-keyring.asc\ \&gt;\ /dev/null$<span class="hljs-string">'\n'</span><span class="hljs-built_in">echo</span>\ deb\ \[signed-by=/usr/share/keyrings/jenkins-keyring.asc\]\ \\$<span class="hljs-string">'\n'</span>\ \ https://pkg.jenkins.io/debian-stable\ binary/\ \|\ sudo\ tee\ \\$<span class="hljs-string">'\n'</span>\ \ /etc/apt/sources.list.d/jenkins.list\ \&gt;\ /dev/null$<span class="hljs-string">'\n'</span>sudo\ apt-get\ update$<span class="hljs-string">'\n'</span>sudo\ apt-get\ install\ jenkins\ -y --maintenance-policy=MIGRATE --provisioning-model=STANDARD --service-account=1008566890267-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append --tags=jenkins,http-server,https-server --create-disk=auto-delete=yes,boot=yes,device-name=instance-template-1,image=projects/debian-cloud/global/images/debian-11-bullseye-v20230411,mode=rw,size=10,<span class="hljs-built_in">type</span>=projects/<span class="hljs-variable">$GCP_PROJECT_ID</span>/zones/us-central1<span class="hljs-_">-a</span>/diskTypes/pd-balanced --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --labels=ec-src=vm_add-gcloud --reservation-affinity=any
</code></pre>
<hr />
<h2 id="heading-using-terraform">Using Terraform</h2>
<pre><code class="lang-json"># This code is compatible with Terraform <span class="hljs-number">4.25</span><span class="hljs-number">.0</span> and versions that are backward compatible to <span class="hljs-number">4.25</span><span class="hljs-number">.0</span>.
# For information about validating this Terraform code, see https:<span class="hljs-comment">//developer.hashicorp.com/terraform/tutorials/gcp-get-started/google-cloud-platform-build#format-and-validate-the-configuration</span>

resource <span class="hljs-string">"google_compute_instance"</span> <span class="hljs-string">"jenkins-server-1"</span> {
  boot_disk {
    auto_delete = true
    device_name = <span class="hljs-attr">"instance-template-1"</span>

    initialize_params {
      image = <span class="hljs-attr">"projects/debian-cloud/global/images/debian-11-bullseye-v20230411"</span>
      size  = 10
      type  = <span class="hljs-attr">"pd-balanced"</span>
    }

    mode = <span class="hljs-string">"READ_WRITE"</span>
  }

  can_ip_forward      = <span class="hljs-literal">false</span>
  deletion_protection = <span class="hljs-literal">false</span>
  enable_display      = <span class="hljs-literal">false</span>

  labels = {
    ec-src = <span class="hljs-attr">"vm_add-tf"</span>
  }

  machine_type = <span class="hljs-string">"e2-medium"</span>

  metadata = {
    startup-script = <span class="hljs-attr">"sudo apt update\nsudo apt install git -y\nsudo apt install openjdk-11-jre -y\ncurl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \\\n  /usr/share/keyrings/jenkins-keyring.asc &gt; /dev/null\necho deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \\\n  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \\\n  /etc/apt/sources.list.d/jenkins.list &gt; /dev/null\nsudo apt-get update\nsudo apt-get install jenkins -y"</span>
  }

  name = <span class="hljs-string">"jenkins-server-1"</span>

  network_interface {
    access_config {
      network_tier = <span class="hljs-attr">"PREMIUM"</span>
    }

    subnetwork = <span class="hljs-string">"projects/${var.project_id}/regions/us-central1/subnetworks/default"</span>
  }

  scheduling {
    automatic_restart   = true
    on_host_maintenance = <span class="hljs-attr">"MIGRATE"</span>
    preemptible         = false
    provisioning_model  = <span class="hljs-attr">"STANDARD"</span>
  }

  service_account {
    email  = <span class="hljs-attr">"1008566890267-compute@developer.gserviceaccount.com"</span>
    scopes = [<span class="hljs-attr">"https://www.googleapis.com/auth/devstorage.read_only"</span>, <span class="hljs-attr">"https://www.googleapis.com/auth/logging.write"</span>, <span class="hljs-attr">"https://www.googleapis.com/auth/monitoring.write"</span>, <span class="hljs-attr">"https://www.googleapis.com/auth/service.management.readonly"</span>, <span class="hljs-attr">"https://www.googleapis.com/auth/servicecontrol"</span>, <span class="hljs-attr">"https://www.googleapis.com/auth/trace.append"</span>]
  }

  shielded_instance_config {
    enable_integrity_monitoring = true
    enable_secure_boot          = false
    enable_vtpm                 = true
  }

  tags = [<span class="hljs-string">"http-server"</span>, <span class="hljs-string">"https-server"</span>, <span class="hljs-string">"jenkins"</span>]
  zone = <span class="hljs-string">"us-central1-a"</span>
}
</code></pre>
<hr />
]]></content:encoded></item></channel></rss>