<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rhegisan Jebas on Medium]]></title>
        <description><![CDATA[Stories by Rhegisan Jebas on Medium]]></description>
        <link>https://medium.com/@rhegisanjebas?source=rss-5bece31519------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fx7n8JI3nlX48gYPNEAgvw@2x.jpeg</url>
            <title>Stories by Rhegisan Jebas on Medium</title>
            <link>https://medium.com/@rhegisanjebas?source=rss-5bece31519------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 12:59:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rhegisanjebas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Your First Ethereum DApp: Complete Step-by-Step Guide]]></title>
            <link>https://rhegisanjebas.medium.com/building-your-first-ethereum-dapp-complete-step-by-step-guide-a6323d8f0abb?source=rss-5bece31519------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6323d8f0abb</guid>
            <dc:creator><![CDATA[Rhegisan Jebas]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 00:56:20 GMT</pubDate>
            <atom:updated>2025-11-17T00:56:20.701Z</atom:updated>
            <content:encoded><![CDATA[<h3>From Zero to DApp on Sepolia Testnet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*spJdWp0ulxI1MzpF0Uq4bg.png" /><figcaption>DApp interface</figcaption></figure><p>When I started my Web3 development journey, I found plenty of theoretical explanations but struggled to find a complete, practical guide for building a decentralized application from scratch. After successfully building and deploying my first DApp, I decided to create the guide I wish I had when I started.</p><p>In this tutorial, I’ll walk you through every step of building a Transaction DApp that can send real ETH transactions on Ethereum’s Sepolia testnet. By the end, you’ll have a fully functional DApp and understand the complete development lifecycle.</p><h3>What We’re Building</h3><p>We’re creating a Transaction DApp that allows users to:</p><ul><li>Connect their MetaMask wallet</li><li>Send ETH between accounts</li><li>View real-time balances</li><li>See transaction history</li><li>Interact with deployed smart contracts</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*Md7n2uEyjKE9qywA8I1GZA.png" /></figure><h3>Prerequisites</h3><p>Before we begin, make sure you have:</p><ul><li>Basic HTML, CSS, JavaScript and Solidity knowledge</li><li>Node.js installed on your machine</li><li>MetaMask wallet browser extension</li><li>A code editor (VS Code recommended)</li><li>Basic understanding of blockchain concepts</li></ul><h3>Step 1: Project Setup and Environment Configuration</h3><p>Installing Required Tools</p><p>Open your terminal and run these commands:</p><pre># Install Truffle globally<br>npm install -g truffle<br><br># Verify installation<br>truffle version<br><br># Create project directory<br>mkdir transaction-dapp<br>cd transaction-dapp<br><br># Initialize Truffle project<br>truffle init<br><br># Install dependencies<br>npm init -y<br>npm install web3 @truffle/contract<br>npm install lite-server --save-dev</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*q3YJDa2kgleDgBfT1IdeBw.png" /></figure><p>Project Structure Explained, After running these commands, you’ll have this structure:</p><pre>transaction-dapp/<br>├── contracts/               # Smart contracts (.sol files)<br>├── migrations/              # Deployment scripts<br>├── test/                    # Test files<br>├── src/                     # Frontend files<br>│   ├── index.html<br>│   ├── app.js<br>│   └── style.css<br>├── truffle-config.js        # Truffle configuration<br>└── package.json            # Project dependencies</pre><h3>Step 2: Smart Contract Development</h3><p>Creating the Transaction Contract</p><p>Create a new file contracts/Transaction.sol:</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>/**<br> * @title SimpleTransaction<br> * @dev Allows ETH transfers and tracks transaction history<br> */<br>contract SimpleTransaction {<br>    // Events for tracking transactions<br>    event Transfer(<br>        address indexed from,<br>        address indexed to,<br>        uint256 amount,<br>        uint256 timestamp<br>    );<br>    <br>    // Store transaction count per user<br>    mapping(address =&gt; uint256) public transactionCount;<br>    <br>    // Struct to represent a transaction<br>    struct Transaction {<br>        address sender;<br>        address receiver;<br>        uint256 amount;<br>        uint256 timestamp;<br>    }<br>    <br>    // Store all transactions per user<br>    mapping(address =&gt; Transaction[]) public transactionHistory;<br>    <br>    /**<br>     * @dev Send ETH to another address<br>     * @param _to Recipient address<br>     */<br>    function sendETH(address payable _to) public payable {<br>        require(msg.value &gt; 0, &quot;Amount must be greater than 0&quot;);<br>        require(_to != address(0), &quot;Invalid recipient address&quot;);<br>        require(_to != msg.sender, &quot;Cannot send to yourself&quot;);<br>        <br>        // Transfer ETH<br>        (bool success, ) = _to.call{value: msg.value}(&quot;&quot;);<br>        require(success, &quot;Transfer failed&quot;);<br>        <br>        // Update transaction count<br>        transactionCount[msg.sender]++;<br>        transactionCount[_to]++;<br>        <br>        // Add to transaction history<br>        transactionHistory[msg.sender].push(Transaction({<br>            sender: msg.sender,<br>            receiver: _to,<br>            amount: msg.value,<br>            timestamp: block.timestamp<br>        }));<br>        <br>        transactionHistory[_to].push(Transaction({<br>            sender: msg.sender,<br>            receiver: _to,<br>            amount: msg.value,<br>            timestamp: block.timestamp<br>        }));<br>        <br>        // Emit event<br>        emit Transfer(msg.sender, _to, msg.value, block.timestamp);<br>    }<br>    <br>    /**<br>     * @dev Get user&#39;s transaction count<br>     * @param _user User address<br>     * @return count Number of transactions<br>     */<br>    function getTransactionCount(address _user) public view returns (uint256) {<br>        return transactionCount[_user];<br>    }<br>    <br>    /**<br>     * @dev Get user&#39;s transaction history<br>     * @param _user User address<br>     * @return Array of transactions<br>     */<br>    function getTransactionHistory(address _user) <br>        public <br>        view <br>        returns (Transaction[] memory) <br>    {<br>        return transactionHistory[_user];<br>    }<br>    <br>    /**<br>     * @dev Get contract balance<br>     * @return Contract&#39;s ETH balance<br>     */<br>    function getContractBalance() public view returns (uint256) {<br>        return address(this).balance;<br>    }<br>    <br>    /**<br>     * @dev Get user&#39;s balance<br>     * @param _user User address<br>     * @return User&#39;s ETH balance<br>     */<br>    function getUserBalance(address _user) public view returns (uint256) {<br>        return _user.balance;<br>    }<br>}</pre><p>Create a new file contracts/Migrations.sol:</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract Migrations {<br>  address public owner = msg.sender;<br>  uint public last_completed_migration;<br><br>  modifier restricted() {<br>    require(<br>      msg.sender == owner,<br>      &quot;This function is restricted to the contract&#39;s owner&quot;<br>    );<br>    _;<br>  }<br><br>  function setCompleted(uint completed) public restricted {<br>    last_completed_migration = completed;<br>  }<br>}</pre><h3>Step 3: Creating Migration Files</h3><p>Migration files tell Truffle how to deploy your contracts in the correct order.</p><p>Create a new file migrations/1_initial_migration.js: (cross check if auto-created)</p><pre>const Migrations = artifacts.require(&quot;Migrations&quot;);<br><br>module.exports = function(deployer) {<br>  deployer.deploy(Migrations);<br>};</pre><p>Create a new file migrations/2_deploy_transaction.js:</p><pre>const SimpleTransaction = artifacts.require(&quot;SimpleTransaction&quot;);<br><br>module.exports = function (deployer) {<br>  deployer.deploy(SimpleTransaction);<br>};</pre><h3>Step 4: Local Development with Ganache</h3><p><strong>Setting Up Ganache</strong></p><p>Ganache provides a local blockchain for development and testing:</p><ol><li>Download Ganache from <a href="https://trufflesuite.com/ganache/">trufflesuite.com/ganache</a></li><li>Create a new workspace or use Quickstart</li><li>Note the RPC server URL (usually <a href="http://127.0.0.1:7545/">http://127.0.0.1:7545</a>)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vm3X2W_0cOAW5yEReZVwTw.png" /><figcaption>Ganache UI</figcaption></figure><p><strong>Configuring Truffle</strong></p><p>Update truffle-config.js for Ganache:</p><pre>module.exports = {<br>  networks: {<br>    development: {<br>      host: &quot;127.0.0.1&quot;,     // Ganache default host<br>      port: 7545,            // Ganache default port<br>      network_id: &quot;*&quot;,       // Match any network id<br>      gas: 6721975,          // Gas limit<br>      gasPrice: 20000000000, // 20 gwei<br>    }<br>  },<br>  compilers: {<br>    solc: {<br>      version: &quot;0.8.0&quot;,      // Match your pragma statement<br>      settings: {<br>        optimizer: {<br>          enabled: true,<br>          runs: 200<br>        }<br>      }<br>    }<br>  }<br>};</pre><p><strong>Compiling and Deploying Locally</strong></p><pre># Compile the smart contracts<br>truffle compile<br><br># Deploy to local Ganache blockchain<br>truffle migrate --network development</pre><h3>Step 5: Building the Frontend Interface</h3><p><strong>HTML Structure</strong></p><p>Create src/index.html:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;ETH Transaction DApp&lt;/title&gt;<br>    &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;div class=&quot;container mt-5&quot;&gt;<br>        &lt;h1 class=&quot;text-center mb-4&quot;&gt;ETH Transaction DApp&lt;/h1&gt;<br>        <br>        &lt;!-- Connection Section --&gt;<br>        &lt;div class=&quot;card mb-4&quot;&gt;<br>            &lt;div class=&quot;card-header&quot;&gt;<br>                &lt;h5&gt;Wallet Connection&lt;/h5&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;card-body&quot;&gt;<br>                &lt;button id=&quot;connectButton&quot; class=&quot;btn btn-primary&quot;&gt;Connect MetaMask&lt;/button&gt;<br>                &lt;div id=&quot;accountInfo&quot; class=&quot;mt-2&quot;&gt;&lt;/div&gt;<br>                &lt;div id=&quot;networkInfo&quot; class=&quot;mt-2&quot;&gt;&lt;/div&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br><br>        &lt;!-- Balance Section --&gt;<br>        &lt;div class=&quot;card mb-4&quot;&gt;<br>            &lt;div class=&quot;card-header&quot;&gt;<br>                &lt;h5&gt;Account Balances&lt;/h5&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;card-body&quot;&gt;<br>                &lt;div class=&quot;row&quot;&gt;<br>                    &lt;div class=&quot;col-md-6&quot;&gt;<br>                        &lt;h6&gt;Your Balance&lt;/h6&gt;<br>                        &lt;p id=&quot;userBalance&quot;&gt;-&lt;/p&gt;<br>                    &lt;/div&gt;<br>                    &lt;div class=&quot;col-md-6&quot;&gt;<br>                        &lt;h6&gt;Contract Balance&lt;/h6&gt;<br>                        &lt;p id=&quot;contractBalance&quot;&gt;-&lt;/p&gt;<br>                    &lt;/div&gt;<br>                &lt;/div&gt;<br>                &lt;button id=&quot;refreshBalance&quot; class=&quot;btn btn-outline-secondary btn-sm&quot;&gt;Refresh Balances&lt;/button&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br><br>        &lt;!-- Transaction Section --&gt;<br>        &lt;div class=&quot;card mb-4&quot;&gt;<br>            &lt;div class=&quot;card-header&quot;&gt;<br>                &lt;h5&gt;Send ETH&lt;/h5&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;card-body&quot;&gt;<br>                &lt;form id=&quot;transactionForm&quot;&gt;<br>                    &lt;div class=&quot;mb-3&quot;&gt;<br>                        &lt;label for=&quot;recipient&quot; class=&quot;form-label&quot;&gt;Recipient Address&lt;/label&gt;<br>                        &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;recipient&quot; placeholder=&quot;0x...&quot;&gt;<br>                    &lt;/div&gt;<br>                    &lt;div class=&quot;mb-3&quot;&gt;<br>                        &lt;label for=&quot;amount&quot; class=&quot;form-label&quot;&gt;Amount (ETH)&lt;/label&gt;<br>                        &lt;input type=&quot;number&quot; class=&quot;form-control&quot; id=&quot;amount&quot; step=&quot;0.001&quot; placeholder=&quot;0.1&quot;&gt;<br>                    &lt;/div&gt;<br>                    &lt;button type=&quot;submit&quot; class=&quot;btn btn-success&quot; id=&quot;sendButton&quot;&gt;Send ETH&lt;/button&gt;<br>                &lt;/form&gt;<br>                &lt;div id=&quot;transactionStatus&quot; class=&quot;mt-3&quot;&gt;&lt;/div&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br><br>        &lt;!-- Transaction History --&gt;<br>        &lt;div class=&quot;card&quot;&gt;<br>            &lt;div class=&quot;card-header&quot;&gt;<br>                &lt;h5&gt;Transaction History&lt;/h5&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;card-body&quot;&gt;<br>                &lt;button id=&quot;loadHistory&quot; class=&quot;btn btn-outline-primary mb-3&quot;&gt;Load History&lt;/button&gt;<br>                &lt;div id=&quot;transactionHistory&quot;&gt;&lt;/div&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br><br>    &lt;!-- Web3 and JavaScript --&gt;<br>    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/@truffle/contract@latest/dist/truffle-contract.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;script src=&quot;app.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>JavaScript DApp Logic</strong></p><pre>class TransactionDApp {<br>    constructor() {<br>        this.web3 = null;<br>        this.accounts = [];<br>        this.contract = null;<br>        this.contractAddress = &#39;0xfdF87E1567Bbe8387dE7fCF7058A82D49387eae5&#39;; // Sepolia contract address<br>        this.currentAccount = null;<br>        <br>        this.init();<br>    }<br><br>    async init() {<br>        try {<br>            await this.initWeb3();<br>            await this.initContract();<br>            this.setupEventListeners();<br>            console.log(&#39;DApp initialized successfully&#39;);<br>        } catch (error) {<br>            console.error(&#39;Error initializing DApp:&#39;, error);<br>            this.showMessage(&#39;Error initializing application&#39;, &#39;error&#39;);<br>        }<br>    }<br><br>    // 1. WEB3 INITIALIZATION<br>    async initWeb3() {<br>        // Modern dapp browsers (MetaMask etc.)<br>        if (window.ethereum) {<br>            this.web3 = new Web3(window.ethereum);<br>            console.log(&#39;Using modern dapp browser&#39;);<br>        } <br>        // Legacy dapp browsers<br>        else if (window.web3) {<br>            this.web3 = new Web3(window.web3.currentProvider);<br>            console.log(&#39;Using legacy dapp browser&#39;);<br>        } <br>        // Fallback to Ganache<br>        else {<br>            this.web3 = new Web3(new Web3.providers.HttpProvider(&#39;http://localhost:7545&#39;));<br>            console.log(&#39;Using Ganache local provider&#39;);<br>        }<br>    }<br><br>    // 2. CONTRACT INITIALIZATION - UPDATED<br>    async initContract() {<br>        try {<br>            // Try to load the actual ABI from the deployed contract JSON file<br>            const response = await fetch(&#39;/Transaction.json&#39;);<br>            const contractData = await response.json();<br>            const contractABI = contractData.abi;<br>            <br>            this.contract = new this.web3.eth.Contract(contractABI, this.contractAddress);<br>            console.log(&#39;Contract initialized with deployed ABI from JSON file&#39;);<br>        } catch (error) {<br>            console.error(&#39;Error loading contract ABI from JSON file, using fallback ABI:&#39;, error);<br>            <br>            // Fallback to hardcoded ABI if the JSON file is not available<br>            const contractABI = [<br>                {<br>                    &quot;inputs&quot;: [<br>                        {<br>                            &quot;internalType&quot;: &quot;address payable&quot;,<br>                            &quot;name&quot;: &quot;_to&quot;,<br>                            &quot;type&quot;: &quot;address&quot;<br>                        }<br>                    ],<br>                    &quot;name&quot;: &quot;sendETH&quot;,<br>                    &quot;outputs&quot;: [],<br>                    &quot;stateMutability&quot;: &quot;payable&quot;,<br>                    &quot;type&quot;: &quot;function&quot;<br>                },<br>                {<br>                    &quot;inputs&quot;: [],<br>                    &quot;name&quot;: &quot;getContractBalance&quot;,<br>                    &quot;outputs&quot;: [<br>                        {<br>                            &quot;internalType&quot;: &quot;uint256&quot;,<br>                            &quot;name&quot;: &quot;&quot;,<br>                            &quot;type&quot;: &quot;uint256&quot;<br>                        }<br>                    ],<br>                    &quot;stateMutability&quot;: &quot;view&quot;,<br>                    &quot;type&quot;: &quot;function&quot;<br>                },<br>                {<br>                    &quot;inputs&quot;: [<br>                        {<br>                            &quot;internalType&quot;: &quot;address&quot;,<br>                            &quot;name&quot;: &quot;_user&quot;,<br>                            &quot;type&quot;: &quot;address&quot;<br>                        }<br>                    ],<br>                    &quot;name&quot;: &quot;getTransactionCount&quot;,<br>                    &quot;outputs&quot;: [<br>                        {<br>                            &quot;internalType&quot;: &quot;uint256&quot;,<br>                            &quot;name&quot;: &quot;&quot;,<br>                            &quot;type&quot;: &quot;uint256&quot;<br>                        }<br>                    ],<br>                    &quot;stateMutability&quot;: &quot;view&quot;,<br>                    &quot;type&quot;: &quot;function&quot;<br>                },<br>                {<br>                    &quot;inputs&quot;: [<br>                        {<br>                            &quot;internalType&quot;: &quot;address&quot;,<br>                            &quot;name&quot;: &quot;_user&quot;,<br>                            &quot;type&quot;: &quot;address&quot;<br>                        }<br>                    ],<br>                    &quot;name&quot;: &quot;getUserBalance&quot;,<br>                    &quot;outputs&quot;: [<br>                        {<br>                            &quot;internalType&quot;: &quot;uint256&quot;,<br>                            &quot;name&quot;: &quot;&quot;,<br>                            &quot;type&quot;: &quot;uint256&quot;<br>                        }<br>                    ],<br>                    &quot;stateMutability&quot;: &quot;view&quot;,<br>                    &quot;type&quot;: &quot;function&quot;<br>                },<br>                {<br>                    &quot;anonymous&quot;: false,<br>                    &quot;inputs&quot;: [<br>                        {<br>                            &quot;indexed&quot;: true,<br>                            &quot;internalType&quot;: &quot;address&quot;,<br>                            &quot;name&quot;: &quot;from&quot;,<br>                            &quot;type&quot;: &quot;address&quot;<br>                        },<br>                        {<br>                            &quot;indexed&quot;: true,<br>                            &quot;internalType&quot;: &quot;address&quot;,<br>                            &quot;name&quot;: &quot;to&quot;,<br>                            &quot;type&quot;: &quot;address&quot;<br>                        },<br>                        {<br>                            &quot;indexed&quot;: false,<br>                            &quot;internalType&quot;: &quot;uint256&quot;,<br>                            &quot;name&quot;: &quot;amount&quot;,<br>                            &quot;type&quot;: &quot;uint256&quot;<br>                        },<br>                        {<br>                            &quot;indexed&quot;: false,<br>                            &quot;internalType&quot;: &quot;uint256&quot;,<br>                            &quot;name&quot;: &quot;timestamp&quot;,<br>                            &quot;type&quot;: &quot;uint256&quot;<br>                        }<br>                    ],<br>                    &quot;name&quot;: &quot;Transfer&quot;,<br>                    &quot;type&quot;: &quot;event&quot;<br>                }<br>            ];<br><br>            this.contract = new this.web3.eth.Contract(contractABI, this.contractAddress);<br>            console.log(&#39;Contract initialized with fallback ABI&#39;);<br>        }<br>    }<br><br>    // 3. EVENT LISTENERS SETUP<br>    setupEventListeners() {<br>        // Connect MetaMask button<br>        document.getElementById(&#39;connectButton&#39;).addEventListener(&#39;click&#39;, () =&gt; {<br>            this.connectMetaMask();<br>        });<br><br>        // Send transaction form<br>        document.getElementById(&#39;transactionForm&#39;).addEventListener(&#39;submit&#39;, (e) =&gt; {<br>            e.preventDefault();<br>            this.sendTransaction();<br>        });<br><br>        // Refresh balances<br>        document.getElementById(&#39;refreshBalance&#39;).addEventListener(&#39;click&#39;, () =&gt; {<br>            this.loadBalances();<br>        });<br><br>        // Load transaction history<br>        document.getElementById(&#39;loadHistory&#39;).addEventListener(&#39;click&#39;, () =&gt; {<br>            this.loadTransactionHistory();<br>        });<br><br>        // Listen for account changes<br>        if (window.ethereum) {<br>            window.ethereum.on(&#39;accountsChanged&#39;, (accounts) =&gt; {<br>                this.accountsChanged(accounts);<br>            });<br><br>            window.ethereum.on(&#39;chainChanged&#39;, (chainId) =&gt; {<br>                window.location.reload();<br>            });<br>        }<br>    }<br><br>    // 4. METAMASK CONNECTION<br>    async connectMetaMask() {<br>        try {<br>            if (!window.ethereum) {<br>                this.showMessage(&#39;Please install MetaMask!&#39;, &#39;error&#39;);<br>                return;<br>            }<br><br>            // Request account access<br>            this.accounts = await window.ethereum.request({ <br>                method: &#39;eth_requestAccounts&#39; <br>            });<br>            <br>            this.currentAccount = this.accounts[0];<br>            this.updateAccountInfo();<br>            await this.loadBalances();<br>            <br>            this.showMessage(&#39;MetaMask connected successfully!&#39;, &#39;success&#39;);<br>            console.log(&#39;Connected account:&#39;, this.currentAccount);<br>            <br>        } catch (error) {<br>            if (error.code === 4001) {<br>                this.showMessage(&#39;User rejected connection request&#39;, &#39;error&#39;);<br>            } else {<br>                console.error(&#39;Error connecting MetaMask:&#39;, error);<br>                this.showMessage(&#39;Error connecting to MetaMask&#39;, &#39;error&#39;);<br>            }<br>        }<br>    }<br><br>    // 5. ACCOUNT MANAGEMENT<br>    accountsChanged(accounts) {<br>        if (accounts.length === 0) {<br>            this.showMessage(&#39;Please connect to MetaMask&#39;, &#39;error&#39;);<br>        } else {<br>            this.currentAccount = accounts[0];<br>            this.updateAccountInfo();<br>            this.loadBalances();<br>        }<br>    }<br><br>    updateAccountInfo() {<br>        const accountInfo = document.getElementById(&#39;accountInfo&#39;);<br>        const networkInfo = document.getElementById(&#39;networkInfo&#39;);<br>        <br>        if (this.currentAccount) {<br>            const shortAddress = `${this.currentAccount.substring(0, 6)}...${this.currentAccount.substring(38)}`;<br>            accountInfo.innerHTML = `&lt;span class=&quot;status-success&quot;&gt;Connected: ${shortAddress}&lt;/span&gt;`;<br>            <br>            // Get network info<br>            this.web3.eth.getChainId().then(chainId =&gt; {<br>                const networkName = this.getNetworkName(chainId);<br>                networkInfo.innerHTML = `Network: ${networkName} (Chain ID: ${chainId})`;<br>            });<br>        }<br>    }<br><br>    getNetworkName(chainId) {<br>        const networks = {<br>            1: &#39;Ethereum Mainnet&#39;,<br>            3: &#39;Ropsten Testnet&#39;,<br>            4: &#39;Rinkeby Testnet&#39;,<br>            5: &#39;Goerli Testnet&#39;,<br>            11155111: &#39;Sepolia Testnet&#39;,<br>            1337: &#39;Ganache Local&#39;,<br>            5777: &#39;Ganache&#39;<br>        };<br>        return networks[chainId] || `Unknown Network (${chainId})`;<br>    }<br><br>    // 6. BALANCE MANAGEMENT<br>    async loadBalances() {<br>        if (!this.currentAccount || !this.contract) return;<br><br>        try {<br>            // Get user balance<br>            const userBalanceWei = await this.web3.eth.getBalance(this.currentAccount);<br>            const userBalanceETH = this.web3.utils.fromWei(userBalanceWei, &#39;ether&#39;);<br>            document.getElementById(&#39;userBalance&#39;).textContent = `${parseFloat(userBalanceETH).toFixed(4)} ETH`;<br><br>            // Get contract balance<br>            const contractBalanceWei = await this.contract.methods.getContractBalance().call();<br>            const contractBalanceETH = this.web3.utils.fromWei(contractBalanceWei, &#39;ether&#39;);<br>            document.getElementById(&#39;contractBalance&#39;).textContent = `${parseFloat(contractBalanceETH).toFixed(4)} ETH`;<br><br>        } catch (error) {<br>            console.error(&#39;Error loading balances:&#39;, error);<br>            this.showMessage(&#39;Error loading balances&#39;, &#39;error&#39;);<br>        }<br>    }<br><br>    // 7. TRANSACTION HANDLING<br>    async sendTransaction() {<br>        if (!this.currentAccount) {<br>            this.showMessage(&#39;Please connect MetaMask first&#39;, &#39;error&#39;);<br>            return;<br>        }<br><br>        const recipient = document.getElementById(&#39;recipient&#39;).value;<br>        const amountETH = document.getElementById(&#39;amount&#39;).value;<br><br>        // Validation<br>        if (!this.web3.utils.isAddress(recipient)) {<br>            this.showMessage(&#39;Invalid recipient address&#39;, &#39;error&#39;);<br>            return;<br>        }<br><br>        if (!amountETH || parseFloat(amountETH) &lt;= 0) {<br>            this.showMessage(&#39;Please enter a valid amount&#39;, &#39;error&#39;);<br>            return;<br>        }<br><br>        try {<br>            this.showMessage(&#39;Processing transaction...&#39;, &#39;pending&#39;);<br><br>            const amountWei = this.web3.utils.toWei(amountETH, &#39;ether&#39;);<br>            <br>            // Estimate gas<br>            const gasEstimate = await this.contract.methods.sendETH(recipient).estimateGas({<br>                from: this.currentAccount,<br>                value: amountWei<br>            });<br><br>            // Send transaction<br>            const transaction = await this.contract.methods.sendETH(recipient).send({<br>                from: this.currentAccount,<br>                value: amountWei,<br>                gas: gasEstimate<br>            });<br><br>            this.showMessage(`Transaction successful! Hash: ${transaction.transactionHash}`, &#39;success&#39;);<br>            console.log(&#39;Transaction details:&#39;, transaction);<br><br>            // Clear form<br>            document.getElementById(&#39;transactionForm&#39;).reset();<br>            <br>            // Update balances<br>            await this.loadBalances();<br>            <br>            // Reload transaction history<br>            await this.loadTransactionHistory();<br><br>        } catch (error) {<br>            console.error(&#39;Transaction error:&#39;, error);<br>            <br>            if (error.code === 4001) {<br>                this.showMessage(&#39;User rejected transaction&#39;, &#39;error&#39;);<br>            } else if (error.message.includes(&#39;insufficient funds&#39;)) {<br>                this.showMessage(&#39;Insufficient funds for transaction&#39;, &#39;error&#39;);<br>            } else {<br>                this.showMessage(`Transaction failed: ${error.message}`, &#39;error&#39;);<br>            }<br>        }<br>    }<br><br>    // 8. TRANSACTION HISTORY<br>    async loadTransactionHistory() {<br>        if (!this.currentAccount) {<br>            this.showMessage(&#39;Please connect MetaMask first&#39;, &#39;error&#39;);<br>            return;<br>        }<br><br>        try {<br>            // Get transaction count<br>            const txCount = await this.web3.eth.getTransactionCount(this.currentAccount, &#39;latest&#39;);<br>            <br>            const historyDiv = document.getElementById(&#39;transactionHistory&#39;);<br>            historyDiv.innerHTML = `&lt;p&gt;Total transactions from your account: ${txCount}&lt;/p&gt;`;<br>            <br>            // Note: For full transaction history, you&#39;d need to query the blockchain<br>            // or use a service like Etherscan API<br>            this.showMessage(&#39;Transaction count loaded&#39;, &#39;success&#39;);<br>            <br>        } catch (error) {<br>            console.error(&#39;Error loading transaction history:&#39;, error);<br>            this.showMessage(&#39;Error loading transaction history&#39;, &#39;error&#39;);<br>        }<br>    }<br><br>    // 9. UTILITY FUNCTIONS<br>    showMessage(message, type = &#39;info&#39;) {<br>        const statusDiv = document.getElementById(&#39;transactionStatus&#39;);<br>        statusDiv.innerHTML = `&lt;div class=&quot;status-${type}&quot;&gt;${message}&lt;/div&gt;`;<br>        <br>        // Auto-clear success messages after 5 seconds<br>        if (type === &#39;success&#39;) {<br>            setTimeout(() =&gt; {<br>                statusDiv.innerHTML = &#39;&#39;;<br>            }, 5000);<br>        }<br>    }<br>}<br><br>// Initialize the DApp when page loads<br>window.addEventListener(&#39;load&#39;, () =&gt; {<br>    window.transactionDApp = new TransactionDApp();<br>});<br><br></pre><h3>Step 6: Local Testing</h3><p><strong>Configure Lite-Server</strong></p><p>Create bs-config.json</p><pre>{<br>  &quot;server&quot;: {<br>    &quot;baseDir&quot;: [&quot;./src&quot;, &quot;./build/contracts&quot;]<br>  },<br>  &quot;port&quot;: 3000,<br>  &quot;open&quot;: false<br>}</pre><p>Update package.json scripts:</p><pre>{<br>  &quot;name&quot;: &quot;transaction-dapp&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;dev&quot;: &quot;lite-server --config bs-config.json&quot;,<br>    &quot;compile&quot;: &quot;truffle compile&quot;,<br>    &quot;migrate:dev&quot;: &quot;truffle migrate --network development&quot;,<br>    &quot;migrate:sepolia&quot;: &quot;truffle migrate --network sepolia&quot;,<br>    &quot;test&quot;: &quot;truffle test&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;@truffle/contract&quot;: &quot;^4.4.0&quot;,<br>    &quot;@truffle/hdwallet-provider&quot;: &quot;^2.0.8&quot;,<br>    &quot;web3&quot;: &quot;^1.10.0&quot;<br>  },<br>  &quot;devDependencies&quot;: {<br>    &quot;dotenv&quot;: &quot;^17.2.3&quot;,<br>    &quot;lite-server&quot;: &quot;^2.6.1&quot;<br>  }<br>}</pre><p><strong>Test Locally</strong></p><pre># Start development server<br>npm run dev<br><br># Open http://localhost:3000 in your browser</pre><h3>Step 7: Deploying to Sepolia Testnet</h3><p><strong>Setting Up Alchemy</strong></p><ol><li>Create a free account at <a href="https://www.alchemy.com/">Alchemy.com</a></li><li>Create new app → Select “Ethereum” → “Sepolia”</li><li>Copy your API Key</li></ol><p><strong>Update Truffle Configuration</strong></p><p>Install additional dependencies:</p><pre>npm install @truffle/hdwallet-provider dotenv --save-dev</pre><p>Update truffle-config.js:</p><pre>require(&#39;dotenv&#39;).config();<br>const HDWalletProvider = require(&#39;@truffle/hdwallet-provider&#39;);<br><br>module.exports = {<br>  networks: {<br>    development: {<br>      host: &quot;127.0.0.1&quot;,<br>      port: 7545,<br>      network_id: &quot;*&quot;,<br>    },<br>    sepolia: {<br>      provider: () =&gt; {<br>        if (!process.env.MNEMONIC || !process.env.ALCHEMY_API_KEY) {<br>          throw new Error(&#39;Missing MNEMONIC or ALCHEMY_API_KEY in .env file&#39;);<br>        }<br>        <br>        return new HDWalletProvider(<br>          process.env.MNEMONIC,<br>          `https://eth-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`<br>        );<br>      },<br>      network_id: 11155111,<br>      gas: 5500000,<br>      gasPrice: 20000000000,<br>      confirmations: 2,<br>      timeoutBlocks: 200,<br>      skipDryRun: true<br>    }<br>  },<br>  compilers: {<br>    solc: {<br>      version: &quot;0.8.0&quot;,<br>    }<br>  }<br>};</pre><p><strong>Create .env file:</strong></p><pre>MNEMONIC=&quot;your_metamask_seed_phrase_here&quot;<br>ALCHEMY_API_KEY=&quot;your_alchemy_api_key_here&quot;</pre><p><strong>Get Sepolia Test ETH (optional if you dont have enough ETH)</strong></p><ol><li>Go to <a href="https://cloud.google.com/application/web3/faucet/ethereum/sepolia">https://cloud.google.com/application/web3/faucet/ethereum/sepolia</a></li><li>Select network “Ethereum Sepolia”</li><li>Enter Wallet address and get 0.05 Sepolia ETH</li></ol><p><strong>Deploy to Sepolia</strong></p><pre># Compile contracts<br>truffle compile<br><br># Deploy to Sepolia<br>truffle migrate --network sepolia</pre><h3>Step 8: Update Frontend with Live Contract</h3><p>After deployment, get your contract address from the migration output and update app.js:</p><pre>this.contractAddress = &#39;0xfdF87E1567Bbe8387dE7fCF7058A82D49387eae5&#39;; // Your actual contract address</pre><h3>Step 9: Testing the Live DApp</h3><ol><li>Switch MetaMask to Sepolia network</li><li>Refresh your DApp (<a href="http://localhost:3000/">http://localhost:3000</a>)</li><li>Connect MetaMask</li><li>Send test transactions between accounts</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6SLpqR5hmkjBpIPpYNClkA.png" /><figcaption>MetaMask wallet ETH Transactions</figcaption></figure><h3>Viewing Transactions on Etherscan</h3><p>One of the most rewarding parts is seeing your transactions on a block explorer:</p><ul><li>My deployed contract: <a href="https://sepolia.etherscan.io/address/0xfdF87E1567Bbe8387dE7fCF7058A82D49387eae5">https://sepolia.etherscan.io/address/0xfdF87E1567Bbe8387dE7fCF7058A82D49387eae5</a></li><li>Transaction example: <a href="https://sepolia.etherscan.io/tx/0xb3d3a595f68bcffd4c61e5fa25d14be5bb0ddbf7adf040cdb6c369b5d0c7f267">https://sepolia.etherscan.io/tx/0xb3d3a595f68bcffd4c61e5fa25d14be5bb0ddbf7adf040cdb6c369b5d0c7f267</a></li></ul><h3>Common Issues and Solutions</h3><p><strong>1. MetaMask Connection Issues</strong></p><ul><li>Ensure you’re on the correct network</li><li>Check if the site has connection permissions</li><li>Reset MetaMask account if needed</li></ul><p><strong>2. Gas Estimation Errors</strong></p><ul><li>Make sure you have enough ETH for gas fees</li><li>Verify recipient address format</li><li>Check contract deployment status</li></ul><p><strong>3. Contract Deployment Failures</strong></p><ul><li>Double-check your Alchemy API key</li><li>Ensure your MNEMONIC has test ETH</li><li>Verify network configuration in truffle-config.js</li></ul><h3>What I Learned</h3><p>Building this DApp taught me invaluable lessons:</p><ol><li>Smart contract development is more accessible than expected</li><li>Web3 integration follows similar patterns to traditional web apps</li><li>Testing on testnets is crucial before mainnet deployment</li><li>Error handling in Web3 requires special attention</li><li>The Ethereum ecosystem has amazing developer tools</li></ol><h3>Next Steps</h3><ul><li>Add transaction history with timestamps</li><li>Implement ERC-20 token transfers</li><li>Add multi-signature functionality</li><li>Deploy to Ethereum mainnet</li><li>Implement advanced DeFi features</li></ul><h3>Resources</h3><ul><li><a href="https://github.com/rhegisan/ethereum-transaction-dapp">GitHub Repository</a></li><li><a href="https://dashboard.alchemy.com/">Alchemy Dashboard</a></li><li><a href="https://sepolia.etherscan.io/">Sepolia Etherscan</a></li><li><a href="https://trufflesuite.com/docs/">Truffle Suite Documentation</a></li><li><a href="https://web3js.readthedocs.io/">Web3.js Documentation</a></li><li><a href="https://docs.soliditylang.org/en/v0.8.30/">Solidity — Solidity 0.8.30 documentation</a></li></ul><p>Building this DApp was an incredible learning experience that transformed my understanding of Web3 development. The satisfaction of seeing real transactions on a live blockchain is unmatched!</p><p>If you have any questions or want to share your own DApp building experience, feel free to reach out. Happy coding!</p><p><em>Connect with me on </em><a href="http://www.linkedin.com/in/rhegisan"><em>LinkedIn </em></a><em>for more Web3 content and development insights.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6323d8f0abb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond Containers: How WebAssembly (WASM) is Redefining Cloud-Native Development]]></title>
            <link>https://rhegisanjebas.medium.com/beyond-containers-how-webassembly-wasm-is-redefining-cloud-native-development-33776f184d7c?source=rss-5bece31519------2</link>
            <guid isPermaLink="false">https://medium.com/p/33776f184d7c</guid>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[wasm]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[webassembly]]></category>
            <dc:creator><![CDATA[Rhegisan Jebas]]></dc:creator>
            <pubDate>Sat, 22 Mar 2025 02:38:07 GMT</pubDate>
            <atom:updated>2025-03-22T02:38:07.167Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="WASM IS AWESOME" src="https://cdn-images-1.medium.com/max/1024/1*PngciRoEGVlTvD0EO3S2bA.jpeg" /><figcaption>WASM IS AWESOME</figcaption></figure><h3>Introduction: The “Aha!” Moment</h3><p><em>As a developer who’s spent years wrestling with containers, I’ve seen firsthand how they revolutionized deployment — until I hit a wall. Picture this: a client needed a serverless function to process real-time sensor data. My Docker container? 150MB, taking 3 seconds to cold-start. Then I discovered </em><strong><em>WebAssembly (WASM)</em></strong><em>. The same logic, compiled to WASM, weighed </em><strong><em>2MB</em></strong><em> and started in </em><strong><em>20 milliseconds</em></strong><em>.</em></p><p><em>This isn’t just about speed. WASM is redefining how we build software — for the browser, the cloud, and beyond. Let’s unpack why.</em></p><h3>What Is WebAssembly?</h3><p>WebAssembly (WASM) is a <strong>binary instruction format</strong> for a stack-based virtual machine. Unlike JavaScript, which is interpreted at runtime, WASM is a low-level, compact bytecode that runs at near-native speed. Here’s why it’s groundbreaking:</p><ul><li><strong>Language Agnostic</strong>: Write code in C, C++, Rust, Go, or even Python (via tools like Pyodide), then compile it to WASM.</li><li><strong>Portable</strong>: Runs anywhere — browsers, servers, edge devices, and even blockchain nodes.</li><li><strong>Secure</strong>: Executes in a memory-safe, sandboxed environment with no direct OS access.</li></ul><p><strong>Example</strong>: Figma, the collaborative design tool, uses WASM to run its C++ graphics engine directly in the browser. No plugins, no downloads — just instant performance.</p><h3>WASM vs. Containers: A Pragmatic Comparison</h3><p>Containers and WASM solve different problems. Let’s break it down:</p><pre>╔════════════╦════════════════════════════════╦════════════════════════════════════════════════╗<br>║ Aspect     ║ Containers                     ║ WebAssembly                                    ║<br>╠════════════╬════════════════════════════════╬════════════════════════════════════════════════╣<br>║ Isolation  ║ OS-level (namespaces, cgroups) ║ Code-level (sandboxed runtime)                 ║<br>╠════════════╬════════════════════════════════╬════════════════════════════════════════════════╣<br>║ Size       ║ 50MB–1GB+ (OS, libraries, app) ║ 1KB–10MB (only your code + minimal runtime)    ║<br>╠════════════╬════════════════════════════════╬════════════════════════════════════════════════╣<br>║ Cold Start ║ Seconds                        ║ Milliseconds                                   ║<br>╠════════════╬════════════════════════════════╬════════════════════════════════════════════════╣<br>║ Use Case   ║ Full-stack apps, microservices ║ Performance-critical code, plugins, serverless ║<br>╚════════════╩════════════════════════════════╩════════════════════════════════════════════════╝</pre><h3>Problems WASM Solves (That Containers Can’t)</h3><h4>Browser-Based Compute Heft</h4><p>JavaScript struggles with tasks like 3D rendering, video editing, or scientific simulations. WASM fills this gap: <strong>Example</strong>: Google Earth compiles its C++ codebase to WASM, enabling smooth 3D navigation in Chrome.</p><h4>Edge Computing’s Hunger for Efficiency</h4><p>Containers are too bulky for edge devices with limited resources. WASM shines here: <strong>Example</strong>: Shopify uses WASM to run third-party payment processors securely at the edge, reducing latency by 50%.</p><h4>Secure Multi-Tenancy</h4><p>Running untrusted code (e.g., user plugins) in containers is risky. WASM’s sandboxing is bulletproof: <strong>Example</strong>: Cloudflare Workers uses WASM to isolate customer code across 200+ data centers.</p><h4>Cross-Platform Consistency</h4><p>Compile once, run anywhere — no more “works on my machine” headaches: <strong>Example</strong>: The game <em>Doom 3</em> runs identically in browsers (via WASM) and native PCs.</p><h3>WASM’s Secret Sauce: What Makes It Unique</h3><h4>The Browser’s Performance Power-Up</h4><ul><li><strong>No DOM Access</strong>: WASM can’t manipulate HTML directly — it offloads heavy math/processing to WASM, while JavaScript handles the UI.</li><li><strong>Parallelism</strong>: Threads (via Web Workers) and SIMD (Single Instruction, Multiple Data) support enable near-native multithreading.</li></ul><h4>Beyond the Browser: WASI</h4><p>The <strong>WebAssembly System Interface (WASI)</strong> lets WASM interact with files, networks, and systems outside the browser: <strong>Example</strong>: Fermyon Spin builds serverless apps with WASM + WASI, starting in 1ms vs. Docker’s 2+ seconds.</p><h4>The Ecosystem Boom</h4><ul><li><strong>Languages</strong>: Rust’s wasm-pack, Go’s TinyGo, and .NET’s Blazor compile to WASM.</li><li><strong>Frameworks</strong>: WASM runs in Kubernetes (Krustlet), blockchain (CosmWasm), and even ESP32 microcontrollers.</li></ul><h3>The Future: Where WASM Is Headed</h3><h4>Serverless 2.0</h4><ul><li><strong>Cold Starts</strong>: Near-zero latency makes WASM ideal for ephemeral functions (e.g., Vercel’s Edge Functions).</li><li><strong>Cost</strong>: Smaller binaries = cheaper cloud bills.</li></ul><h4>The Edge Revolution</h4><ul><li><strong>Example</strong>: Fastly’s edge network processes 100M+ requests/sec using WASM.</li></ul><h4>Blurring the Lines Between Native and Web</h4><ul><li><strong>Example</strong>: AutoCAD’s WASM port lets engineers edit CAD files directly in browsers.</li></ul><h3>Conclusion: Why You Should Care</h3><p>WASM isn’t a container killer — it’s a <strong><em>new layer in your toolkit</em></strong>. Use it when:</p><ul><li>You need <strong>millisecond cold starts</strong>.</li><li>Security is non-negotiable (e.g., third-party code).</li><li>Your app demands <strong>browser-based compute muscle</strong>.</li></ul><p><strong>The bottom line: </strong>Containers rule monolithic deployments. WASM owns the edge, the browser, and the micro-task. Ignore it, and you’ll miss the next wave of software innovation.</p><p><em>Thanks for reading! I hope you found it helpful and informative.</em></p><p><em>If you have any questions or comments, please don’t hesitate to leave them in the comments section below. I’ll do my best to respond to each one.</em></p><p><em>If you’d like to stay up to date on WASM related content, be sure to follow me on Medium and </em><a href="http://www.linkedin.com/in/rhegisan"><em>LinkedIn</em></a><em>. I’d love to connect with you and hear your thoughts.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33776f184d7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Kubernetes: Your Roadmap to CKAD Certification]]></title>
            <link>https://rhegisanjebas.medium.com/mastering-kubernetes-your-roadmap-to-ckad-certification-1156539b23a?source=rss-5bece31519------2</link>
            <guid isPermaLink="false">https://medium.com/p/1156539b23a</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ckad-exam]]></category>
            <category><![CDATA[cncf]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux-foundation]]></category>
            <dc:creator><![CDATA[Rhegisan Jebas]]></dc:creator>
            <pubDate>Tue, 15 Aug 2023 07:34:36 GMT</pubDate>
            <atom:updated>2023-08-15T07:34:36.793Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*n2ZDFeA1ai6qxASAZKvFnA.png" /></figure><h4>INTRODUCTION:</h4><p>Mastering Kubernetes and earning your Certified Kubernetes Application Developer (CKAD) certification is an exciting journey. This roadmap is designed to guide you through the process, whether you’re new to Kubernetes or have some experience. By following these steps and staying consistent, you can confidently conquer the CKAD exam.</p><h4>UNDERSTANDING CKAD:</h4><p>The CKAD certification validates your ability to work with Kubernetes clusters, containers, and application deployment. It’s a sought-after credential that showcases your expertise in designing, building, configuring, and exposing cloud-native applications using Kubernetes.</p><h4>MY EXPERIENCE AND TIME MANAGEMENT:</h4><p>Drawing from my own journey, I had around 2 years of experience with Kubernetes. My preparation for the CKAD exam took approximately 2 months, balancing it with my office work. On weekdays, I dedicated 1-2 hours daily, and on weekends, I allocated 2–3 hours. Despite a busy schedule, consistency was key to my success.</p><h4>ROADMAP TO CKAD SUCCESS:</h4><p>Whether you’re a complete beginner or already familiar with Kubernetes, this roadmap is tailored for you. Consistency is vital — 1-2 hours every day is more effective than cramming in 6 hours on one day.</p><p><strong>For Beginners:</strong><br>If you’re new to Kubernetes, start with the <em>‘Kubernetes for the Absolute Beginners — Hands-on Tutorial’</em> course available at <a href="https://kodekloud.com/courses/kubernetes-for-the-absolute-beginners-hands-on"><em>https://kodekloud.com/courses/kubernetes-for-the-absolute-beginners-hands-on/</em></a>. This foundational course will give you a head start before diving into CKAD preparation.</p><p><strong>For Those with Experience:</strong><br>Skip the beginner course if you’re already comfortable with Kubernetes and proceed directly to the ‘<strong><em>Certified Kubernetes Application Developer (CKAD)</em></strong>’ course at <a href="https://kodekloud.com/courses/certified-kubernetes-application-developer-ckad/"><em>https://kodekloud.com/courses/certified-kubernetes-application-developer-ckad/</em></a>. This comprehensive course covers all topics in the CKAD exam syllabus.</p><p>During your learning process, create your own notes while watching course lectures. Dive into the <strong><em>Kubernetes official documentation </em></strong><a href="https://kubernetes.io/docs/home/">https://kubernetes.io/docs/home/</a><strong><em> </em></strong>— it’s a valuable resource that you can use during the exam. Ensure you thoroughly understand all topics covered in the lectures. Don’t hesitate to revisit challenging concepts multiple times. Also this course has hands on labs which is performed on their environment, so you don’t need to setup your own cluster in your machine.</p><p>With your learning completed, assess your knowledge by taking the ‘<strong><em>Ultimate Certified Kubernetes Application Developer (CKAD) Mock Exam Series</em></strong>’ at <a href="https://kodekloud.com/courses/ultimate-certified-kubernetes-application-developer-ckad-mock-exam-series/"><em>https://kodekloud.com/courses/ultimate-certified-kubernetes-application-developer-ckad-mock-exam-series/</em></a>. After submitting each test, review the explanations and solutions to gain insights and save time. This tests has random questions and covers all the topics from certification point of view.</p><p>Once you started consistently scoring above 80% in the above mock tests, you’re ready to book your CKAD exam via the<strong> Linux Foundation</strong> at <a href="https://training.linuxfoundation.org/certification/certified-kubernetes-application-developer-ckad/"><em>https://training.linuxfoundation.org/certification/certified-kubernetes-application-developer-ckad/</em></a>. Upon booking, you’ll receive two free mock tests from killer.sh (Give the first killer.sh mock test 1 week prior to the exam and the second mock test on the day of exam). These tests are more complex than the actual exam, so don’t be discouraged by lower scores on the first attempt. Study solutions thoroughly and focus on weak areas and try to score good on the second mock test (Questions are same for both the tests).</p><h4>NAVIGATING THE EXAM DAY AND PRACTICAL GUIDELINES:</h4><p>Approaching the exam day strategically is crucial. Allocate a dedicated period, roughly 3–4 hours before your scheduled exam time, to revisit the killer.sh mock test. This will immerse you in a problem-solving mindset, enhancing your exam readiness and workflow. Additionally, take the time to re-run all system checks, even if you’ve completed them before. This precaution ensures that your technical environment remains optimal and minimizes any unforeseen challenges during the exam.</p><p>Remember that the CKAD exam is conducted through the PSI browser. While it offers a seamless experience, occasional lag might arise. Effective time management is paramount — allocate your time judiciously across the tasks. If you encounter a question that stumps you, avoid the temptation to answer everything out of ego. Instead, prioritize wisely and consider skipping the question.</p><p>For an enhanced exam experience, opt for a larger screen as the browser isn’t responsive. To further streamline your workflow, utilizing time-saving aliases and shortcuts can significantly enhance your efficiency during the exam.<br><strong><em>export dry=’ — dry-run=client -o yaml’<br>export fo=’ — force — grace-period=0&#39;</em></strong></p><h4>POST-EXAM REFLECTIONS:</h4><p>Reflecting on your exam experience is invaluable. Regardless of the outcome, acknowledge that the journey itself is an enriching learning opportunity. Embrace the progress you’ve made, celebrate the effort you’ve invested, and recognize the wealth of knowledge you’ve gained along the way. You will get the results after 24hrs of the exam.</p><h4>NEXT STEPS AND CONCLUSION:</h4><p>After achieving success with the CKAD certification, consider setting your sights on the Certified Kubernetes Administrator (CKA) certification. This step further deepens your skills in cluster management and administration.</p><p>Ready to embark on your CKAD journey? Share your thoughts, experiences, and queries in the comments below. Let’s cultivate a supportive community of Kubernetes enthusiasts dedicated to achieving excellence.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1156539b23a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform Taint vs. Replace: Why Replace is the Better Option for Your Infrastructure]]></title>
            <link>https://rhegisanjebas.medium.com/terraform-taint-vs-replace-why-replace-is-the-better-option-for-your-infrastructure-e59c1193e6db?source=rss-5bece31519------2</link>
            <guid isPermaLink="false">https://medium.com/p/e59c1193e6db</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[iaac]]></category>
            <dc:creator><![CDATA[Rhegisan Jebas]]></dc:creator>
            <pubDate>Thu, 13 Apr 2023 22:49:04 GMT</pubDate>
            <atom:updated>2023-04-13T22:49:04.603Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AHROIu99UqoCAFamUfGnXw.png" /><figcaption>TERRAFORM TAINT VS TERRAFROM REPLACE</figcaption></figure><h3>INTRODUCTION</h3><p>When working with Terraform, you may find that resources are modified outside of Terraform’s control. This can cause issues with Terraform’s state management, making it difficult to know what resources are under Terraform’s control and what changes have been made. To address this issue, terraform provides two commands: terraform taint and terraform replace.</p><h3>TERRAFORM TAINT</h3><p>The terraform taint command marks a resource as “tainted”, which means that terraform will destroy and recreate the resource the next time it runs. This allows you to bring the resource back under Terraform’s management, even though it has been manually modified.</p><p>For example, if you manually modify an EC2 instance outside of Terraform, you can use terraform taint to mark the instance as tainted and terraform will recreate it the next time you run terraform apply.</p><p>Here’s an example of how to use terraform taint:</p><pre>$ terraform taint aws_instance.web_server<br>Resource instance aws_instance.web_server has been marked as tainted.</pre><p>In this example, terraform taint aws_instance.web_server marks the aws_instance resource named web_server as tainted.</p><p>However, it’s worth noting that taint is considered a deprecated command in Terraform, and it’s not recommended for use in new code.</p><h3>TERRAFORM REPLACE</h3><p>The terraform replace command is similar to taint, but it provides more fine-grained control over how resources are replaced. Specifically, replace allows you to replace a resource with a new resource of a different type or with a different set of attributes.</p><p>For example, if you need to change an EC2 instance from a t2.micro to a t2.small instance type, you can use terraform replace to create a new instance of the desired type, and then destroy the old instance.</p><p>Here’s an example of how to use terraform replace:</p><pre>$ terraform replace aws_instance.web_server<br>aws_instance.new_web_server: Creating...<br>  ami:                      &quot;ami-0c55b159cbfafe1f0&quot;<br>  instance_type:            &quot;t2.small&quot;<br>  subnet_id:                &quot;subnet-0123456789abcdef0&quot;<br>  vpc_security_group_ids.#: &quot;1&quot;<br>  vpc_security_group_ids.0: &quot;sg-0123456789abcdef0&quot;<br>aws_instance.web_server: Destroying... [id=i-0123456789abcdef0]<br>aws_instance.web_server: Destruction complete after 1m5s<br>aws_instance.new_web_server: Creation complete after 1m10s<br><br>Apply complete! Resources: 1 added, 1 destroyed.</pre><p>In this example, terraform replace aws_instance.web_server creates a new aws_instance resource with the desired attributes, and destroys the old aws_instance resource.</p><h3>COMPARISON</h3><p>While terraform taint and terraform replace are similar commands, they work in slightly different ways.</p><p>The main difference between taint and replace is how they handle resource modifications. Taint simply marks a resource as tainted, and Terraform destroys and recreates it the next time it runs. This can be useful for bringing a resource back under Terraform’s management, but it doesn’t provide any control over how the resource is recreated.</p><p>Replace, on the other hand, creates a new resource with the desired attributes, and then destroys the old resource. This provides more control over how resources are replaced, and can be especially useful when you need to change a resource’s type or attributes.</p><p>Additionally, because replace creates a new resource instead of simply marking the old one as tainted, it’s safer and less prone to unintended consequences. By creating a new resource and destroying the old one, you can ensure that your changes are safe and predictable.</p><h3>CONCLUSION</h3><p>While both terraform taint and terraform replace are useful tools for managing resources that have been modified outside of Terraform’s control, terraform replace is generally considered to be a better option because it provides more control and is safer to use.</p><p>It’s also worth noting that taint is considered a deprecated command in Terraform, and it’s not recommended for use in new code. Instead, you should use replace or other techniques, such as using an external data source or importing an existing resource, to bring modified resources back under Terraform’s control.</p><p><em>Thanks for reading! I hope you found it helpful and informative.</em></p><p><em>If you have any questions or comments, please don’t hesitate to leave them in the comments section below. I’ll do my best to respond to each one.</em></p><p><em>If you’d like to stay up to date on terraform related content, be sure to follow me on Medium and </em><a href="http://www.linkedin.com/in/rhegisan"><em>LinkedIn</em></a><em>. I’d love to connect with you and hear your thoughts.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e59c1193e6db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding CMD vs ENTRYPOINT Commands in Docker File]]></title>
            <link>https://rhegisanjebas.medium.com/understanding-cmd-vs-entrypoint-commands-in-docker-file-e9c9f9cd2061?source=rss-5bece31519------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9c9f9cd2061</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Rhegisan Jebas]]></dc:creator>
            <pubDate>Tue, 04 Apr 2023 19:40:31 GMT</pubDate>
            <atom:updated>2023-04-04T19:40:31.668Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uW80dVtTVpln4H6VGqJFbA.png" /></figure><h3><strong>INTRODUCTION</strong></h3><p>Docker is a popular containerization platform that allows developers to package their applications and run them in a consistent and portable environment. One of the key features of Docker is the ability to use CMD and ENTRYPOINT commands to define how the container should be run.</p><p>In this blog post, we’ll explore the difference between CMD and ENTRYPOINT commands in Docker, using the echo command as an example. We’ll also explain how to use these commands together to create more flexible Docker images.</p><h3><strong>CMD Command</strong></h3><p>The CMD command is used to provide default arguments to the command specified in the ENTRYPOINT command. The default argument can be overridden at runtime by providing additional arguments to the docker run command.</p><p>Let’s take a look at an example Docker file using the echo command:</p><pre>FROM ubuntu:latest<br>CMD [&quot;echo&quot;, &quot;Hey Rhegi&quot;]</pre><p>In this example, we’re using the ubuntu:latest image as our base image. We’re then using the CMD command to provide a default command of echo Hey Rhegi. This means that when a container is started from this image, the message “Hey Rhegi” will be printed to the console.</p><p>To build and run this Docker image, use the following commands:</p><pre>$ docker build -t cmdimage .<br>$ docker run cmdimage</pre><p>This will start a container from the cmdimage image and print the message “Hey Rhegi” to the console.</p><p>If you want to provide a different argument to the echo command, you can do so by passing it as an argument to the docker run command. For example:</p><pre>$ docker run cmdimage &quot;Hey Shawn&quot;</pre><p>This will start a container from the cmdimage image and print the message “Hey Shawn” to the console.</p><h3><strong>ENTRYPOINT COMMAND</strong></h3><p>The ENTRYPOINT command is used to specify the command that should be run when the container starts. This command is the main command of the container and cannot be overridden at runtime.</p><p>Let’s take a look at an example Dockerfile using the echo command:</p><pre>FROM ubuntu:latest<br>ENTRYPOINT [&quot;echo&quot;, &quot;Hey&quot;]</pre><p>In this example, we’re using the ubuntu:latest image as our base image. We’re then using the ENTRYPOINT command to set the default command to echo Hey. This means that when a container is started from this image, the message “Hey” will be printed to the console.</p><p>To build and run this Docker image, use the following commands:</p><pre>$ docker build -t entrypointimage .<br>$ docker run entrypointimage</pre><p>This will start a container from the entrypointimage image and print the message “Hey” to the console.</p><p>If you want to provide a different argument to the echo command, you cannot do so by passing it as an argument to the docker run command because the ENTRYPOINT command specifies the main command of the container. However, you can provide additional arguments to the main command using the CMD command.</p><h3><strong>USING CMD AND ENTRYPOINT TOGETHER</strong></h3><p>Now, let’s say we want to use both the CMD and ENTRYPOINT commands together to provide a default command with default arguments, while still allowing users to specify additional arguments.</p><p>Here’s an example Dockerfile using both the CMD and ENTRYPOINT commands:</p><pre>FROM ubuntu:latest<br>ENTRYPOINT [&quot;echo&quot;, &quot;Hey&quot;]<br>CMD [&quot;Rhegi&quot;]</pre><p>In this example, we’re using the same Dockerfile as before. The ENTRYPOINT command is still set to echo Hey, and the CMD command is still set to Rhegi.</p><p>To build and run this Docker image, use the following commands:</p><pre>$ docker build -t combinedimage .<br>$ docker run combinedimage</pre><p>This will start a container from the combinedimage image and print the message “Hey Rhegi” to the console.</p><p>If you want to provide a different argument to the echo command, you can do so by passing it as an argument to the docker run command. For example:</p><pre>$ docker run combinedimage &quot;Shawn&quot;</pre><p>This will start a container from the combinedimage image and print the message “Hey Shawn” to the console.</p><p>Notice how the default argument provided by the CMD command is overridden by the argument provided at runtime.</p><h3><strong>Conclusion</strong></h3><p>In conclusion, CMD and ENTRYPOINT commands are important tools for defining how your Docker container should be run. While the CMD command provides default arguments that can be overridden at runtime, the ENTRYPOINT command sets the main command of the container and cannot be overridden.</p><p>By using both commands together, you can create more flexible Docker images that provide default arguments while still allowing users to specify additional arguments at runtime.</p><p>Hopefully, this blog post has helped you understand the difference between CMD and ENTRYPOINT commands in Docker, and how to use them effectively in your Dockerfiles.</p><p><em>If you have any questions or comments, please don’t hesitate to leave them in the comments section below. I’ll do my best to respond to each one.</em></p><p><em>If you’d like to stay up to date on my latest automation-related content, be sure to follow me on </em><a href="http://www.linkedin.com/in/rhegisan"><em>LinkedIn</em></a><em>. I’d love to connect with you and hear your thoughts on automation in the workplace.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9c9f9cd2061" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Best Practices to Control Terraform Destroy and Prevent Accidental Infrastructure Deletion]]></title>
            <link>https://rhegisanjebas.medium.com/5-best-practices-to-control-terraform-destroy-and-prevent-accidental-infrastructure-deletion-9452c6cd464b?source=rss-5bece31519------2</link>
            <guid isPermaLink="false">https://medium.com/p/9452c6cd464b</guid>
            <category><![CDATA[infrastructure-protection]]></category>
            <category><![CDATA[infrastructure-management]]></category>
            <category><![CDATA[iaac]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Rhegisan Jebas]]></dc:creator>
            <pubDate>Thu, 09 Mar 2023 19:12:51 GMT</pubDate>
            <atom:updated>2023-03-09T19:12:51.783Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*7h6_KIHLjh8tBHTki6WwjQ.png" /><figcaption>Terraform destroy command!</figcaption></figure><p>Terraform is a popular infrastructure-as-code tool used to provision and manage cloud infrastructure. It provides a powerful way to create and manage resources in a declarative way. However, Terraform is also a double-edged sword that can cause significant damage if not used properly. One of the most dangerous Terraform commands is terraform destroy, which deletes all the resources created by Terraform. If executed accidentally, it can cause data loss and system downtime, leading to costly outages. In this blog, we will discuss some best practices to control Terraform destroy and prevent accidental infrastructure deletion.</p><h3>1. USE TERRAFORM WORKSPACES</h3><p>Terraform workspaces enable you to have multiple instances of your infrastructure. This way, you can isolate and manage different environments, such as development, staging, and production. Each workspace has its own state file, which tracks the resources created by Terraform. By using workspaces, you can prevent accidental deletion of resources in a specific environment. For example, if you’re working on the production environment, you can switch to the production workspace and then execute terraform destroy only for that environment.</p><h3>2. DO NOT SKIP TERRAFORM PLANNING STEP</h3><p>Before running the terraform destroy command, it’s essential to have a clear understanding of the resources that will be destroyed. Review the Terraform plan to confirm that you’re only destroying the resources you intend to delete. You can use the terraform plan command to see the resources that will be created, updated, or destroyed. This step helps prevent unintended deletion of resources and ensures that you’re aware of the changes that will be made.</p><h3>3. MAKE USE OF -target OPTION</h3><p>If you only want to destroy a specific resource or set of resources, use the -target option to specify them. This will limit the scope of the destroy operation to only the targeted resources, reducing the risk of accidental deletion. You can use the <strong><em>-target</em></strong> option with the terraform destroy command to specify the resources you want to delete. For example, terraform destroy <strong><em>-target=aws_instance.example</em></strong> will only delete the <strong><em>aws_instance.example</em></strong> resource.</p><h3>4. ENABLE STATE FILE BACKUPS</h3><p>Ensure that you have state file backups enabled to protect against data loss in case of accidental deletion. The Terraform state file contains the current state of your infrastructure, and losing it can result in data loss and downtime. State file backups allow you to quickly recover from a disaster by restoring a previous version of the state file. You can configure a backend that supports backups, such as Amazon S3 or Google Cloud Storage, and enable versioning for the backup bucket.</p><h3><strong>5. LIMIT USER ACCESS</strong></h3><p>Limit access to the <strong><em>terraform destroy</em></strong> command to only those who need it and ensure that they understand the risks involved. Restricting access to destructive actions helps prevent accidental deletion of critical resources and reduces the risk of data loss. By limiting user access, you can ensure that only authorized users can perform destructive actions and that they’re aware of the risks involved.</p><p>In conclusion, the <strong><em>terraform destroy</em></strong> command is a powerful tool that should be used with caution. By taking these precautions, you can control Terraform destroy and prevent costly infrastructure outages. These best practices can help you ensure the reliability, security, and stability of your infrastructure.</p><p><em>Thanks for reading! I hope you found it helpful and informative.</em></p><p><em>If you have any questions or comments, please don’t hesitate to leave them in the comments section below. I’ll do my best to respond to each one.</em></p><p><em>If you’d like to stay up to date on my latest automation-related content, be sure to follow me on </em><a href="http://www.linkedin.com/in/rhegisan"><em>LinkedIn</em></a><em>. I’d love to connect with you and hear your thoughts on automation in the workplace.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9452c6cd464b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automated Server Monitoring and Recovery with Bash Scripting — Prevent Downtime!]]></title>
            <link>https://rhegisanjebas.medium.com/automated-server-monitoring-and-recovery-with-bash-scripting-prevent-downtime-c51aaac3b549?source=rss-5bece31519------2</link>
            <guid isPermaLink="false">https://medium.com/p/c51aaac3b549</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[bash-script]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[monitoring]]></category>
            <dc:creator><![CDATA[Rhegisan Jebas]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 23:01:24 GMT</pubDate>
            <atom:updated>2023-03-07T23:01:24.779Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automated Server Monitoring and Recovery with Bash Scripting — Prevent Downtime!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZmXakVlKu-q5-ictfmhE6Q.png" /></figure><blockquote><strong>INTRODUCTION:</strong></blockquote><p>In this blog post, we will discuss a Bash script that can be used to monitor the status of an HTTP server and automatically restart it if it’s down. The script checks the status of the server by checking if its process ID (PID) is currently running, and if it’s not, it will start the server and send an email notification to the administrator.</p><blockquote><strong>SCRIPT:</strong></blockquote><pre>#!/bin/bash<br>service_name=httpd<br>server_status=$(pidof $service | wc -l ) <br>if [ $server_status -gt 0 ]<br>then<br>echo &quot;$service_name is up and running&quot;<br>else<br>echo &quot;$service_name is down/dead&quot;<br>systemctl start $service_name<br>echo &quot;$service_name service is up and running now&quot; | mail -s &quot;$service_name service is down and restarted it now On $(hostname)&quot; &lt;your_email_id&gt;@gmail.com<br>fi</pre><blockquote><strong>SCRIPT EXPLANATION:</strong></blockquote><p>Let’s take a closer look at the code and explain how it works:</p><pre>#!/bin/bash</pre><p>This line tells the system to use the Bash shell to execute this script.</p><pre>service_name=httpd</pre><p>Here, we set the name of the service we want to monitor to “httpd”. You can change this to the name of the service you want to monitor.</p><pre>server_status=$(pidof $service | wc -l )</pre><p>This line runs the command pidof $service, which looks for the process ID (PID) of the process with the name specified in the $service variable. The output of pidof is a list of PIDs separated by whitespace. The output is then piped to wc -l, which counts the number of lines in the output (which should be the number of PIDs). The result is stored in the service_status variable.</p><p><em>when service is up the result is 1</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*uzT5g22jZij43J8NUoUODA.png" /><figcaption>httpd service is up and running.</figcaption></figure><p><em>when service is down/dead the </em>result is 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*nGv3Vk-icxP6KSSVzoG0ZQ.png" /><figcaption>httpd service is down/dead.</figcaption></figure><pre>if [ $server_status -gt 0 ]<br>then<br>echo &quot;$service_name is up and running&quot;<br>else<br>echo &quot;$service_name is down/dead&quot;</pre><p>This block of code checks the value of “server_status”. If it’s greater than zero, it means that the server is running, so we print a message saying that the server is up and running. If “server_status” is not greater than zero, it means that the server is down, so we print a message saying that the server is down/dead and proceed to restart it.</p><pre>systemctl start $service_name<br>echo &quot;$service_name service is up and running now&quot; | mail -s &quot;$service_name service is down and restarted it now On $(hostname)&quot; &lt;your_email_id&gt;@gmail.com<br>fi</pre><p>This block of code starts the service using the “systemctl” command and sends an email notification to the administrator to inform them that the service was down and has been restarted. Replace “&lt;your_email_id&gt;@gmail.com” with the email address where you want to receive the notification.</p><p><strong><em>NOTE :-</em></strong><em> </em>The script assumes that the systemctl command is available and that the user running the script has permission to start the server service. If you&#39;re running the script on a system that doesn&#39;t use systemctl, use service and if the system doesn’t use service, you&#39;ll need to modify the script accordingly.</p><pre>service $service_name start<br>echo &quot;$service_name service is up and running now&quot; | mail -s &quot;$service_name service is down and restarted it now On $(hostname)&quot; &lt;your_email_id&gt;@gmail.com<br>fi</pre><blockquote>AUTOMATING THE SERVICE MONITORING:</blockquote><p>Adding a cron job will allow this script to run automatically at set intervals to continuously monitor the HTTP server and take action if it’s down.</p><p>To add a cron job, follow these steps:</p><ol><li>Open your terminal and type crontab -e to edit your user&#39;s crontab file.</li><li>Add the following line to the crontab file to run the script every 5 minutes:</li></ol><pre>*/5 * * * * /path/to/your/script.sh</pre><p>This line tells cron to run the script every 5 minutes. Replace “/path/to/your/script.sh” with the actual path to your script file.</p><p>3. Save the crontab file and exit the editor.</p><p>Now, the script will run every 5 minutes and check the status of the HTTP server. If the server is down, the script will start it and send an email notification to the administrator. This automated monitoring and recovery process helps ensure that your HTTP server is always available and can help prevent downtime.</p><blockquote>CONCLUSION:</blockquote><p>In this blog post, we discussed a Bash script that can be used to monitor the status of an HTTP server and automatically restart it if it’s down. This script is useful for ensuring that critical services are always available and can help prevent downtime. By understanding how this script works, you can modify it to monitor other services and customize the email notification to suit your needs.</p><p><em>Thanks for reading! I hope you found it helpful and informative.</em></p><p><em>If you have any questions or comments, please don’t hesitate to leave them in the comments section below. I’ll do my best to respond to each one.</em></p><p><em>If you’d like to stay up to date on my latest automation-related content, be sure to follow me on </em><a href="http://www.linkedin.com/in/rhegisan"><em>LinkedIn</em></a><em>. I’d love to connect with you and hear your thoughts on automation in the workplace.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c51aaac3b549" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[9 Essential Linux Commands for DevOps Network Management: Level Up Your Skills]]></title>
            <link>https://rhegisanjebas.medium.com/9-essential-linux-commands-for-devops-network-management-level-up-your-skills-c096f17a48cb?source=rss-5bece31519------2</link>
            <guid isPermaLink="false">https://medium.com/p/c096f17a48cb</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Rhegisan Jebas]]></dc:creator>
            <pubDate>Fri, 03 Mar 2023 00:45:13 GMT</pubDate>
            <atom:updated>2023-03-03T00:45:13.755Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="One of the most valuable aspects of knowledge is that it can be gained for free through various means, including reading books and articles, watching videos, attending webinars, and engaging in conversations with experts in the field. Unlike physical goods that often require monetary exchange, gaining knowledge doesn’t cost a thing, and yet it can lead to significant personal and professional growth. By taking advantage of the many resources available online and offline, individuals can continuo" src="https://cdn-images-1.medium.com/max/940/1*YM3uoosL0HlhCvulD3jKdA.png" /></figure><p>To effectively manage and troubleshoot networking issues, it’s crucial for a DevOps engineer to possess knowledge of some essential networking commands as they work with various networking components. Therefore, below are nine networking commands that every DevOps engineer must know:</p><h3><strong>1. ping</strong></h3><p><em>Ping</em><strong><em> </em></strong><em>command sends an ICMP (Internet Control Message Protocol) echo request to a remote host and waits for a response. The time it takes to receive the response, or whether a response is received at all, can provide valuable information about the network performance and connectivity. Here are some ways the ping command helps in network management:<br></em><strong>Checking network connectivity:</strong><em> It checks whether a remote host is reachable over the network.<br></em><strong>Testing network performance:</strong> <em>It measures the round-trip time (RTT) and identifies high RTT values that may indicate network congestion or other performance issues.<br></em><strong>Troubleshooting network issues:</strong><em> It helps identify network issues by checking the connectivity and response times to various hosts along the network path.<br></em><strong>Diagnosing DNS issues:</strong> <em>By pinging a remote host using its hostname, it can diagnose DNS issues by detecting failures to resolve the hostname.</em></p><pre>#SYNTAX<br><strong>ping &lt;destination-ip&gt;</strong><br><br>#OUTPUT<br><strong>[DevOps@rhegi ~]$ ping google.com<br>PING google.com (142.251.42.14) 56(84) bytes of data.<br>64 bytes from bom12s19-in-f14.1e100.net (142.251.42.14): icmp_seq=1 ttl=113 time=26.8 ms<br>64 bytes from bom12s19-in-f14.1e100.net (142.251.42.14): icmp_seq=2 ttl=113 time=16.8 ms</strong><br></pre><h3>2. traceroute</h3><p><em>Traceroute command is a useful tool for network management in Linux that helps identify network issues by tracing the route that packets take from the source to the destination. It provides information about each hop along the path, including the IP address and response time of each router or device that the packet passes through. Here are some ways the traceroute command helps in network management:<br></em><strong>Identifying network connectivity issues:</strong><em> by showing the last successful hop and the first failed hop.<br></em><strong>Identifying network performance issues:</strong><em> by measuring response times or packet loss.<br></em><strong>Troubleshooting network issues:</strong><em> such as misconfigured routers, network congestion, or firewall issues.<br></em><strong>Optimizing network routing:</strong><em> by identifying the fastest route and improving network performance.</em></p><pre><em>#SYNTAX</em><br><strong>traceroute &lt;destination-ip&gt;</strong><br><br><em>#OUTPUT</em><br><strong>[DevOps@rhegi ~]$ traceroute google.com<br>traceroute to google.com (142.251.42.14), 30 hops max, 60 byte packets<br> 1  gateway (192.168.0.1)  19.713 ms  19.327 ms  19.209 ms<br> 2  192.168.1.1 (192.168.1.1)  19.099 ms  19.040 ms  18.971 ms<br> 3  10.230.0.1 (10.230.0.1)  18.909 ms  18.741 ms  18.655 ms<br> 4  125.99.88.133 (125.99.88.133)  23.212 ms  23.156 ms  23.056 ms<br> 5  203.212.193.26 (203.212.193.26)  18.239 ms  18.183 ms  18.068 ms<br> 6  192.168.221.14 (192.168.221.14)  9.182 ms  34.450 ms  34.246 ms<br> 7  125.99.55.169 (125.99.55.169)  34.347 ms  34.298 ms  34.219 ms</strong></pre><h3>3. netstat</h3><p><em>Netstat command is a tool that provides network statistics and helps in network management. It is used to display active network connections, open ports, and various other network statistics. Here are some ways the netstat command helps in network management:<br></em><strong>Identifying network connections:</strong><em> Identifying active network connections, both inbound and outbound, and displays information such as the IP address, port number, and the protocol used.<br></em><strong>Displaying open ports:</strong><em> Displays a list of all open ports on a system, which helps in identifying any unauthorized or unexpected network traffic.<br></em><strong>Monitoring network traffic:</strong><em> Used to monitor network traffic on a system, providing information about the amount of traffic, the type of traffic, and the endpoints involved.<br></em><strong>Troubleshooting network issues:</strong><em> To identify network issues by displaying network statistics such as the number of packets transmitted and received, the number of errors, and the status of network interfaces.<br></em><strong>Managing network services: </strong><em>Manages network services by displaying the status of network services and the ports they are listening on.</em></p><pre>#SYNTAX<br><strong>netstat</strong><br><br>#OUTPUT<br><strong>[DevOps@rhegi ~]$ netstat<br>Active Internet connections (w/o servers)<br>Proto Recv-Q Send-Q Local Address           Foreign Address         State      <br>tcp        0      0 RHEGI:33660             bom12s09-in-f5.1e:https ESTABLISHED<br>tcp        0      0 RHEGI:52874             bom12s17-in-f10.1:https ESTABLISHED<br>tcp        0      0 RHEGI:51430             bom07s33-in-f14.1:https ESTABLISHED<br>tcp        0      0 RHEGI:52876             bom12s17-in-f10.1:https ESTABLISHED<br>tcp        0      0 RHEGI:33200             bom12s15-in-f3.1e:https ESTABLISHED<br>tcp        0      0 RHEGI:39376             bom07s32-in-f14.1:https ESTABLISHED<br>Active UNIX domain sockets (w/o servers)<br>Proto RefCnt Flags       Type       State         I-Node   Path<br>unix  2      [ ]         DGRAM                    13328    /run/systemd/shutdownd<br>unix  3      [ ]         DGRAM                    7513     /run/systemd/notify<br>unix  2      [ ]         DGRAM                    7515     /run/systemd/cgroups-agent<br>unix  6      [ ]         DGRAM                    7530     /run/systemd/journal/socket<br>unix  27     [ ]         DGRAM                    7532     /dev/log<br>unix  2      [ ]         DGRAM                    19359    /var/run/chrony/chronyd.sock<br>unix  3      [ ]         STREAM     CONNECTED     32342    @/tmp/dbus-jwZn7FDQa3<br>unix  3      [ ]         STREAM     CONNECTED     33799    /run/systemd/journal/stdout<br>unix  3      [ ]         STREAM     CONNECTED     30286    <br>unix  3      [ ]         STREAM     CONNECTED     26094    /run/dbus/system_bus_socket<br>unix  3      [ ]         STREAM     CONNECTED     25076</strong></pre><h3>4. nslookup</h3><p><em>nslookupcommand is a tool used to query the Domain Name System (DNS) to obtain information about domain names, IP addresses, and other DNS records. Here are some ways the nslookup command helps in network management:<br></em><strong>Domain name resolution: </strong><em>It resolves domain names to IP addresses, helping to identify network issues caused by DNS misconfiguration.<br></em><strong>DNS record retrieval:</strong><em> It retrieves various DNS records, such as MX, TXT, and SRV records, for email servers, domain authentication, and service discovery.<br></em><strong>Debugging DNS issues:<em> </em></strong><em>It helps to debug DNS issues by allowing users to query specific DNS servers, test DNS zone transfers, and troubleshoot DNS configuration issues.<br></em><strong>Network troubleshooting:<em> </em></strong><em>It verifies that DNS is functioning correctly and provides information about the DNS resolution process, helping in network troubleshooting.<br></em><strong><em>Network security: </em></strong><em>It verifies the authenticity of DNS responses, ensuring that they originate from the expected DNS server and have not been tampered with, enhancing network security.</em></p><pre>#SYNTAX<br><strong>nslookup &lt;domain-name&gt;</strong><br><br>#OUTPUT<br><strong>[DevOps@rhegi ~]$ nslookup google.com<br>Server: 192.168.0.1<br>Address: 192.168.0.1#53<br><br>Non-authoritative answer:<br>Name: google.com<br>Address: 142.251.42.14<br>Name: google.com<br>Address: 2404:6800:4009:82f::200e</strong></pre><h3>5. ifconfig</h3><p><em>ifconfigcommand is used to configure and manage network interfaces. Here are some ways the ifconfig command helps in network management:</em><br><strong>Displaying network interface</strong> <strong>information </strong><em>for all interfaces</em>, <strong>Configuring network interfaces</strong> <em>by assigning IP addresses, netmasks, and other parameters</em>, <strong>Enabling and disabling </strong><em>network interfaces</em><strong>, Checking network connectivity</strong> <em>by pinging other hosts</em>, <strong>Troubleshooting network problems</strong> <em>by identifying issues like misconfigured IP addresses or dropped packets.</em></p><pre>#SYNTAX<br><strong>ifconfig</strong>  <br><br>#OUTPUT<br><strong>[DevOps@rhegi ~]$ ifconfig<br>enp0s3: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500<br>        inet 192.168.0.108  netmask 255.255.255.0  broadcast 192.168.0.255<br>        inet6 fe80::5bd4:ef6e:915f:fe9f  prefixlen 64  scopeid 0x20&lt;link&gt;<br>        ether 08:00:27:60:3a:5b  txqueuelen 1000  (Ethernet)<br>        RX packets 14083  bytes 14034045 (13.3 MiB)<br>        RX errors 0  dropped 0  overruns 0  frame 0<br>        TX packets 6375  bytes 2730684 (2.6 MiB)<br>        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0<br><br>lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  mtu 65536<br>        inet 127.0.0.1  netmask 255.0.0.0<br>        inet6 ::1  prefixlen 128  scopeid 0x10&lt;host&gt;<br>        loop  txqueuelen 1000  (Local Loopback)<br>        RX packets 1  bytes 49 (49.0 B)<br>        RX errors 0  dropped 0  overruns 0  frame 0<br>        TX packets 1  bytes 49 (49.0 B)<br>        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0<br><br>virbr0: flags=4099&lt;UP,BROADCAST,MULTICAST&gt;  mtu 1500<br>        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255<br>        ether 52:54:00:e7:63:59  txqueuelen 1000  (Ethernet)<br>        RX packets 0  bytes 0 (0.0 B)<br>        RX errors 0  dropped 0  overruns 0  frame 0<br>        TX packets 0  bytes 0 (0.0 B)<br>        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0</strong></pre><h3>6. top</h3><p><em>topcommand is used to monitor system processes and resource usage. Here are some ways the top command helps in network management:<br></em><strong>Monitors resource usage</strong><em> to identify resource-hungry applications, </em><strong>Allows viewing and managing</strong><em> of running processes, </em><strong>Provides real-time updates </strong><em>on system performance to identify bottlenecks, </em><strong>Helps identify potential security threats</strong><em> through monitoring of system activity.</em></p><pre>#SYNTAX<br><strong>top </strong> <br><br>#OUTPUT<br><strong>[DevOps@rhegi ~]$ top<br>top - 15:27:20 up  1:20,  2 users,  load average: 0.20, 0.16, 0.15<br>Tasks: 231 total,   1 running, 230 sleeping,   0 stopped,   0 zombie<br>%Cpu(s):  0.5 us,  1.1 sy,  0.0 ni, 98.1 id,  0.0 wa,  0.0 hi,  0.3 si,  0.0 st<br>KiB Mem :  7401484 total,  4970272 free,  1484008 used,   947204 buff/cache<br>KiB Swap:  8388604 total,  8388604 free,        0 used.  5630608 avail Mem<br><br>  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND            <br> 1128 root      20   0  358432  53812  30436 S   6.0  0.7   3:01.65 X                  <br> 2232 DevOps   20   0 3932740 181772  66800 S   4.0  2.5   2:59.84 gnome-shell        <br> 6411 DevOps   20   0  682692  32864  17468 S   1.3  0.4   0:09.38 gnome-terminal-    <br>  550 root      20   0       0      0      0 S   0.7  0.0   0:14.70 xfsaild/sda5      <br> 5940 DevOps   20   0 3384320 256872  98744 S   0.7  3.5   4:51.18 firefox            <br> 6160 DevOps   20   0 3352476 424132  90844 S   0.7  5.7   7:26.63 Web Content        <br> 7888 DevOps   20   0  162200   2372   1584 R   0.7  0.0   0:00.09 top                <br>    9 root      20   0       0      0      0 S   0.3  0.0   0:23.56 rcu_sched          <br>  306 root      20   0       0      0      0 S   0.3  0.0   0:07.64 xfsaild/sda2      <br>  659 root      20   0   90568   3184   2324 S   0.3  0.0   0:20.08 rngd              <br> 1022 root      20   0  222740   6252   3268 S   0.3  0.1   0:03.22 rsyslogd          <br> 7737 root      20   0       0      0      0 S   0.3  0.0   0:01.14 kworker/3:1        <br> 7769 root      20   0       0      0      0 S   0.3  0.0   0:00.05 kworker/1:2        <br>    1 root      20   0  193972   7080   4196 S   0.0  0.1   0:10.07 systemd            <br>    2 root      20   0       0      0      0 S   0.0  0.0   0:00.08 kthreadd          <br>    4 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H      <br>    6 root      20   0       0      0      0 S   0.0  0.0   0:06.48 ksoftirqd/0        <br>    7 root      rt   0       0      0      0 S   0.0  0.0   0:04.35 migration/0</strong></pre><h3>7. ARP</h3><p><em>arpThe Address Resolution Protocol command is used in computer networks to map a network address (such as an IP address) to a physical address (such as a MAC address). Here are some ways that ARP helps in network management:<br></em><strong>Enables communication </strong><em>between devices using physical addresses, </em><strong>Troubleshoots network issues </strong><em>by checking address mappings, </em><strong>Enhances security</strong><em> by detecting and preventing ARP spoofing attacks, </em><strong>Creates network maps </strong><em>for identifying unauthorized devices and diagnosing performance issues.</em></p><pre>#SYNTAX<br><strong>arp</strong><br><br>#OUTPUT<br><strong>[DevOps@rhegi ~]$ arp<br>Address                  HWtype  HWaddress           Flags Mask            Iface<br>gateway                  ether   84:d8:1b:26:ab:29   C                     enp0s3</strong><br></pre><h3>8. route</h3><p><em>In computer networking, a routing table is a database that stores information about the routes that network packets can take. The </em><em>route command is used to view and modify the routing table in Unix-based operating systems. Here are some ways that the route command helps in network management:<br></em><strong>Determines network connectivity</strong><em> by checking the routing table, </em><strong>Troubleshoots network issues </strong><em>by identifying errors or inconsistencies in the routing table, </em><strong>Optimizes network traffic</strong><em> by modifying the routing table to add or remove routes, change priority, or set up load balancing, </em><strong>Enhances security </strong><em>by setting up VPNs or firewall rules with the route command.</em></p><pre>#SYNTAX<br><strong>route</strong> <br><br>#OUTPUT<br>[DevOps@rhegi ~]$ route <br><strong>Kernel IP routing table<br>Destination     Gateway         Genmask         Flags Metric Ref    Use Iface<br>default         gateway         0.0.0.0         UG    100    0        0 enp0s3<br>192.168.0.0     0.0.0.0         255.255.255.0   U     100    0        0 enp0s3<br>192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0</strong><br></pre><h3>9. ip</h3><p><em>ip command is a powerful tool for managing network interfaces, IP addresses, routing tables, and other aspects of the network. It provides a wide range of functionalities that enable administrators to configure, monitor, and troubleshoot the network. </em>Here are some ways that the ip command helps in network management:<br><strong>Configuring network interfaces:</strong><em> Used to set up network interfaces with IP addresses, netmasks, and other network-related parameters.<br></em><strong>Managing routing tables:</strong><em> Manages routing tables, including adding, modifying, and deleting routing entries.<br></em><strong>Monitoring network traffic:</strong><em> Displays real-time statistics on network traffic, including packet counts, bytes transmitted and received, and errors.<br></em><strong>Troubleshooting network issues: </strong><em>To diagnose network issues by displaying information about network interfaces, routing tables, and network traffic.<br></em><strong>Configuring network namespaces:</strong><em> Creates and manages network namespaces, which can help isolate network traffic and simplify network management.</em></p><pre>#SYNTAX<br><strong>ip [OPTIONS] OBJECT {COMMAND | help}</strong><br><br>#OUTPUT<br># Display network interface information<br><strong>[DevOps@rhegi ~]$ ip link show<br>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000<br>    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00<br>2: enp0s3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000<br>    link/ether 08:00:27:60:3a:5b brd ff:ff:ff:ff:ff:ff<br>3: virbr0: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000<br>    link/ether 52:54:00:e7:63:59 brd ff:ff:ff:ff:ff:ff<br>4: virbr0-nic: &lt;BROADCAST,MULTICAST&gt; mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT group default qlen 1000<br>    link/ether 52:54:00:e7:63:59 brd ff:ff:ff:ff:ff:ff</strong><br><br><br># Display IP address information for a specific network interface<br><strong>[DevOps@rhegi ~]$ ip address show virbr0<br>3: virbr0: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc noqueue state DOWN group default qlen 1000<br>    link/ether 52:54:00:e7:63:59 brd ff:ff:ff:ff:ff:ff<br>    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0<br>       valid_lft forever preferred_lft forever</strong><br><br><br># Display routing table information<br><strong>[DevOps@rhegi ~]$ ip route show<br>default via 192.168.0.1 dev enp0s3 proto dhcp metric 100<br>192.168.0.0/24 dev enp0s3 proto kernel scope link src 192.168.0.108 metric 100<br>192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1</strong></pre><p><em>In conclusion, networking commands are essential tools for DevOps engineers in managing and troubleshooting networking issues. The nine commands we’ve discussed in this blog — including utilities for network monitoring, connectivity testing, and configuration management — are just a few examples of the many tools available to engineers. By mastering these commands and incorporating them into their workflows, DevOps engineers can more effectively manage their networks and ensure their systems are running smoothly and securely. However, it’s worth noting that these commands are just a starting point, and networking is a complex and constantly evolving field. As such, engineers should continually seek to expand their knowledge of networking and stay up to date with the latest tools and techniques. By doing so, they can stay ahead of the curve and provide the best possible service to their users.</em></p><p><strong>Stay up to date with the latest insights and trends in DevOps by following me on </strong><a href="http://www.linkedin.com/in/rhegisan"><strong>LinkedIn</strong></a><strong>, where I share valuable content and resources that can help you enhance your skills and knowledge in this field.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c096f17a48cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>