<?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 Rama Hammer on Medium]]></title>
        <description><![CDATA[Stories by Rama Hammer on Medium]]></description>
        <link>https://medium.com/@ramahammer?source=rss-1785b8751b68------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eDeRgA2yG5KScJvAXnvZaw.png</url>
            <title>Stories by Rama Hammer on Medium</title>
            <link>https://medium.com/@ramahammer?source=rss-1785b8751b68------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 06:00:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ramahammer/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[DevOps Hands On : Prometheus & Grafana]]></title>
            <link>https://medium.com/@ramahammer/devops-hands-on-prometheus-grafana-1f0a23a9abf1?source=rss-1785b8751b68------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f0a23a9abf1</guid>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[pormetheus]]></category>
            <dc:creator><![CDATA[Rama Hammer]]></dc:creator>
            <pubDate>Wed, 03 Apr 2024 19:23:53 GMT</pubDate>
            <atom:updated>2024-04-03T19:23:53.261Z</atom:updated>
            <content:encoded><![CDATA[<h3>DevOps Hands On : Prometheus &amp; Grafana</h3><p><a href="https://prometheus.io/docs/introduction/overview/">https://prometheus.io/docs/introduction/overview/</a><a href="https://prometheus.io/docs/prometheus/latest/getting_started/">https://prometheus.io/docs/prometheus/latest/getting_started/</a><a href="https://prometheus.io/docs/guides/node-exporter/">https://prometheus.io/docs/guides/node-exporter/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FVvTvGgeDqVdbuluL7mxdA.png" /></figure><h3>Part 1: EC2, Docker &amp; Docker-Compose</h3><h4>Create [EC2] Instance and install Docker, Docker-Compose and Stress</h4><ul><li>Amazon Linux</li><li>Name: <strong>monitoring-srv</strong></li><li>SSH Key: <strong>cw-ssh-key</strong></li><li>User data (while creating EC2):</li><li>#!/bin/bash<br>yum update -y<br>yum install docker -y<br>service docker start<br>usermod -aG docker ec2-user<br>curl -L <a href="https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname">https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname</a> -s)-$(uname -m) -o /usr/local/bin/docker-compose<br>chmod +x /usr/local/bin/docker-compose<br>yum install stress -y<br>systemctl restart docker</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*lnu79K4xWn28fNMekUTEQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cS3yixU3F_mVcxF7QehyXQ.png" /></figure><h4>Validate:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*dTbBiNL1wFCZBngrBpo5yg.png" /></figure><h4>Create 2 yml files:</h4><p><strong>monitoring/prometheu/sprometheus.yml:</strong></p><p>global:<br> scrape_interval: 5s<br> scrape_timeout: 5s<br>scrape_configs:<br> — job_name: ‘prometheus’<br> static_configs:<br> — targets: [‘prometheus:9090’]<br> — job_name: ‘node-exporter’<br> static_configs:<br> — targets: [‘node-exporter:9100’]</p><p><strong>monitoring/docker-compose.yml</strong></p><p>version: ‘3’</p><p>services:</p><p>portainer:<br> container_name: portainer<br> hostname: portainer<br> image: portainer/portainer-ce:latest<br> ports:<br> — “9000:9000”<br> — “8000:8000”<br> volumes:<br> — portainer_data:/data<br> — /var/run/docker.sock:/var/run/docker.sock<br> restart: always</p><p>prometheus:<br> container_name: prometheus<br> hostname: prometheus<br> image: prom/prometheus:latest<br> ports:<br> — 9090:9090<br> volumes:<br> — ./prometheus:/etc/prometheus<br> restart: unless-stopped<br> command: — web.enable-lifecycle — config.file=/etc/prometheus/prometheus.yml<br> <br> node-exporter:<br> container_name: node-exporter<br> hostname: node-exporter<br> image: prom/node-exporter:latest<br> volumes:<br> — /proc:/host/proc:ro<br> — /sys:/host/sys:ro<br> — /:/rootfs:ro<br> command: <br> — ‘ — path.procfs=/host/proc’ <br> — ‘ — path.sysfs=/host/sys’<br> — — collector.filesystem.ignored-mount-points<br> — “^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)”<br> ports:<br> — 9100:9100<br> restart: unless-stopped</p><p>grafana:<br> container_name: grafana<br> hostname: grafana<br> image: grafana/grafana:latest<br> ports:<br> — 3000:3000<br> volumes:<br> — grafana-storage:/var/lib/grafana<br> restart: unless-stopped<br> <br> <br>volumes:<br> portainer_data:<br> grafana-storage:</p><p>Run this to create the containers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*ELq1ymbd2PVvp3e2nwFqhg.png" /></figure><p>Validate all containers were created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LwWjZ43VEYZm1MYPAU4tzg.png" /></figure><p>Update Security Group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47JsYy7VLEkoFhTFBseUFw.png" /></figure><p>Validate:</p><p>Open Portainer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xcXzA-lOxc7oB3mYiLwSBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GPlZwr6J4XDDB41NoyUc-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HKonMS_4oNKlxDQY5GmqCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VGQdY85CGyfxM1T2dnpo4w.png" /><figcaption>s</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V2yk6jc9k7BxxhLxkECy8Q.png" /></figure><p>Open Prometheus:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r981KTYRgdxf65PQ32Ce0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oXp6lPfpjSECzxWfTAa5dw.png" /></figure><p>Check Grafana:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6QPwI2q5MET4aBnwN9-dA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*01ooAUOiEf4hy5s50q9k-g.png" /></figure><h3>Setting Up Data Source</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y4YJv6G9lAx1fcB6Vy5SEA.png" /></figure><h3>Create a dashboard:</h3><p>Get the container ID:</p><p><a href="https://grafana.com/grafana/dashboards">Dashboards | Grafana Labs</a></p><p><a href="https://grafana.com/grafana/dashboards/1860-node-exporter-full/">Node Exporter Full | Grafana Labs</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hn9GQPIg-AEcwd2OI3Rm9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pcSBgFX9qQIRUrfhprGYjg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m0M_n454uQU_14RLKYQ2Vw.png" /></figure><h3>Increase Disk Usage and Stress memory</h3><p>sudo dd if=/dev/urandom of=random_file.txt bs=1M count=4096</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*wun9cQwRehVDO7zhuUSXzA.png" /></figure><p>Update metrics:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXRwpAxc3wEOlQ-2oEVi6Q.png" /></figure><h3>Set Stress:</h3><p>stress — vm 1 — vm-bytes 500M — timeout 300s</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BPgcAo2_M__ll90qrb-FIw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f0a23a9abf1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HumanGov: Implementing AWS Cloud Watch Synthetics for Real-Time Application URL Monitoring…]]></title>
            <link>https://medium.com/@ramahammer/humangov-implementing-aws-cloud-watch-synthetics-for-real-time-application-url-monitoring-c3a496ad29e8?source=rss-1785b8751b68------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3a496ad29e8</guid>
            <category><![CDATA[aws-cloudwatch]]></category>
            <category><![CDATA[multi-cloud]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Rama Hammer]]></dc:creator>
            <pubDate>Wed, 27 Mar 2024 04:30:17 GMT</pubDate>
            <atom:updated>2024-04-03T02:42:10.629Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>HumanGov: Implementing AWS Cloud Watch Synthetics for Real-Time Application URL Monitoring Integrated With CloudWatch Alarms, SNS, and AWS Chatbot to Send Real-Time Alerts on Slack.</em></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*smbtBYNtcMSAPEAOChx3LQ.png" /></figure><p>In this hands-on project, I engaged in the advanced aspects of AWS CloudWatch, focusing on implementing CloudWatch Synthetics for real-time application URL monitoring, integrated with CloudWatch Alarms, SNS, and AWS Chatbot for immediate alerts on Slack. The goal was to establish a robust monitoring system for the HumanGov application to ensure its high availability and performance.</p><p>To get started, I initiated the creation of CloudWatch Synthetic canaries. These canaries were designed to continuously monitor the HumanGov application URLs, simulating user interactions to check for availability and response times.</p><p>Following the canaries’ setup, I integrated CloudWatch Alarms. These alarms were configured to trigger based on specific metrics such as high response time or failure rates, ensuring immediate detection of any application issues.</p><p>The alarm thresholds were carefully set to balance sensitivity and practicality, avoiding false positives while ensuring no critical issues were missed.</p><p>To enhance the response to these alarms, I integrated AWS SNS (Simple Notification Service). This allowed for the creation of notification topics that would relay any alarm state changes to designated subscribers. It was crucial to have a seamless flow of information regarding the application’s health.</p><p>The pinnacle of this project was integrating AWS Chatbot with Slack. By linking the SNS topics to AWS Chatbot, I enabled real-time alerts to be sent directly to a designated Slack channel. This ensured that the development and operations SRE team were immediately informed about any application issues, allowing for prompt action.</p><p>The project culminated in a series of rigorous tests to validate the entire setup. By simulating various application issues, I confirmed that the canaries correctly detected problems, alarms triggered as expected, and notifications were promptly sent through AWS Chatbot to Slack.</p><p>This intensive project not only reinforced my understanding of AWS CloudWatch and its integrations but also highlighted the importance of proactive monitoring in maintaining application reliability and performance in the cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YvsoCFA9INVWx3k178kXvg.png" /></figure><p>Creating SNS Topic for Synthetics</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Dt_YeCMzpBY9t4F0zKJHA.png" /></figure><p>Creating a Heartbeat Canary for URL Monitoring</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*oyZ53aMi0RW7gYsde313Dw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*q-_3M_4S7pk36GVLCiQxRw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*TlpIklpfWT_NttZm8_D9lg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5I_9JsNk0dVFfMEsq26vDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_xUeO_2O8iLTq8G3NC8OJQ.png" /></figure><p>Create additional one for florida:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vkmFSyZ9ieInv_hdMqV1Ng.png" /></figure><p>Configure chatBot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*AiU1C_1pWnoQXznZIWI38Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hjAzXjXOeJ2TTwDhe6YKkA.png" /></figure><p>From chatbot -&gt; slack, allow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*prrIVvR3jmi42SN0W-t1IQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eVPSGOY9bQXjq6o3P9cHRw.png" /></figure><p>Add notification:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*tcYbeDNOpr93Giy1DbMwaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iBwk5x036DZlM9deiaHAPw.png" /></figure><p>Press send test message and you can see it in slack:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0lxRY8Rwi49iwubdgjSq2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*-A3CkXrMMHmaumrYpfLwPQ.png" /></figure><p>Simulate that nginx is down:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*4VU_f8ep39h2CcnN0paykg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vuq79aji1ki-7YkYTvZBOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VMMN1g9azYsEJIQEIk8XvA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OH_PgBGfAbbOtepz2ty8Sg.png" /></figure><p>In slack:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NcXGb3791ITm1G5LuCzQyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*25j6WCFFmfE3H4M-JjvtAw.png" /></figure><p>Fixed the error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*Czmh7ayaYy8VeBTDFjVcHg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w0z5clzFy2Gt0pgSNyCDrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nIU3gRZhYsdmsCkvw6-Maw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3a496ad29e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HumanGov: Developing an Event-Driven and Serverless Python Microservice Triggered by DynamoDB…]]></title>
            <link>https://medium.com/@ramahammer/humangov-developing-an-event-driven-and-serverless-python-microservice-triggered-by-dynamodb-6cb19a4312b3?source=rss-1785b8751b68------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cb19a4312b3</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Rama Hammer]]></dc:creator>
            <pubDate>Wed, 27 Mar 2024 04:18:04 GMT</pubDate>
            <atom:updated>2024-04-03T03:23:24.533Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>HumanGov: Developing an Event-Driven and Serverless Python Microservice Triggered by DynamoDB Streams Using AWS Lambda Function and AWS SDK Python Boto3.</em></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uFZQBH6M4wOVKu2wLOvOyw.png" /></figure><p>This hands-on project was a deep dive into the world of serverless architectures and event-driven microservices using AWS technologies. The central task was to develop “HumanGov,” a Python-based serverless microservice, triggered by data modifications in a DynamoDB table and executed by AWS Lambda functions.</p><p>The initial phase involved setting up the AWS environment, which included configuring IAM roles for secure access and initializing the Lambda functions with the necessary permissions. The DynamoDB table was designed to hold governmental data, which, upon being updated, would emit streams that trigger our Lambda functions.</p><p>With the DynamoDB and Lambda setup, I proceeded to implement the microservice logic in Python using the AWS SDK, Boto3. This SDK facilitated the interaction with AWS services and allowed the Lambda function to process the DynamoDB streams effectively. The microservice was architected to be scalable and responsive to the data flow in real-time, ensuring immediate processing of changes in the database.</p><p>To ensure smooth operation, I incorporated logging and monitoring through AWS CloudWatch, which provided insights into the performance and health of the microservice.</p><p>The deployment process involved writing the Lambda function, deploying it to AWS, and linking it to the DynamoDB stream. This required a keen understanding of event source mappings and the execution role’s policies.</p><p>The end result was a fully operational, event-driven microservice that could efficiently process data changes and scale on demand. The serverless design meant reduced operational costs and a focus on code rather than infrastructure management.</p><p>From this project, my key learnings were the intricacies of serverless architectures, the power of AWS Lambda functions in real-time data processing, and the utility of Boto3 in crafting event-driven microservices. It honed my skills in cloud infrastructure, Python programming, and the effective use of AWS services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lb77ftrKfza1s7iHCIkJBg.png" /></figure><p>DynamoDB Streams must be enabled on California table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*yV0mRIj4dc_s7F9FzHfGRQ.png" /></figure><p>Add a new entry:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eG64NzX0J343vma2XYv28A.png" /></figure><p>Delete the new record:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKss5nhWXoG51j6LO-XjEA.png" /></figure><p>Currently there is a bug, and the pdf file is not deleted from the S3 bucket:</p><p>After the delete:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6mLMNW9EhU-UU2F_6VzARQ.png" /></figure><p>Step 1: Setting up AWS Lambda</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NDIItblk6rDTYv_akUwThA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*HoYSYI-JT9_uYlh59xeVqg.png" /></figure><p>Step 2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2LG3K0El7fvZJpGQHanB_w.png" /></figure><p>Step 3: Add Trigger</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*WwwMytbIQclmeL7POL2b8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xT2Ejm4NPjbwm2SCjulSqQ.png" /></figure><p>Step 4: Create the CloudWatch Log group: /aws/lambda/HumanGovDeleteFile</p><p>Metrics -&gt; View CloudWatch Logs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Fn31E8D6LlJiCbHdyLvog.png" /></figure><p>Need to add the Log Group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*3ebpZx5-PveEwRRpIZ8nTg.png" /></figure><p>Step 5: Test the lamda Function:</p><p>Add new entry then remove it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V2TDlYilhnqk79jizAazqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HK_pCzOixhDE-j7w87XxxA.png" /></figure><p>Check S3 Bucket:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vBTuoJeUkTIBietsLGUnIg.png" /></figure><p>Check Lamda Logs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*xETY0YaKCLaBhwObKu0hyQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cb19a4312b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Textract — The Paperless Challenge]]></title>
            <link>https://medium.com/@ramahammer/aws-textract-the-paperless-challenge-576289ad8818?source=rss-1785b8751b68------2</link>
            <guid isPermaLink="false">https://medium.com/p/576289ad8818</guid>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws-dynamodb]]></category>
            <category><![CDATA[aws-textract]]></category>
            <dc:creator><![CDATA[Rama Hammer]]></dc:creator>
            <pubDate>Fri, 15 Mar 2024 00:16:40 GMT</pubDate>
            <atom:updated>2024-03-15T00:16:40.070Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS Textract — The Paperless Challenge</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*a10WtqFN4KpYsImReFTldQ.jpeg" /></figure><h3>Introduction</h3><p>AWS Textract is a machine learning service from Amazon Web Services (AWS) that automatically extracts textual content, forms, and tables from scanned documents. It can recognize a wide range of document formats, including PDFs and JPEGs, among others. Textract goes beyond traditional optical character recognition (OCR) to not only identify the text in the document but also understand its structure, such as fields in forms or data in tables.</p><h3>Key Features:</h3><ol><li><strong>Text Extraction</strong>: Identifies and extracts textual content from documents.</li><li><strong>Form Recognition</strong>: Detects key-value pairs and checkboxes within forms.</li><li><strong>Table Recognition</strong>: Identifies tables, and extracts the rows and columns into a usable format.</li><li><strong>Document Analysis</strong>: Can understand the layout and the relationships between different pieces of text.</li><li><strong>Batch Operations</strong>: Ability to process a large collection of documents asynchronously.</li><li><strong>Integration</strong>: Seamlessly integrates with other AWS services like S3, Lambda, DynamoDB, and more.</li></ol><h3>Common Use-Cases</h3><ol><li><strong>Invoice Processing</strong>: Extracts key details like invoice numbers, line items, and totals.</li><li><strong>Document Archival</strong>: Automates the digitization of paper-based records for better search and retrieval.</li><li><strong>Compliance Monitoring</strong>: Automates the extraction of crucial information to ensure regulatory compliance.</li><li><strong>Content Management</strong>: Helps in organizing, tagging, and searching text in a large set of documents.</li></ol><p>AWS Textract provides both an API and a console interface, making it suitable for a wide range of applications.</p><h3>Challenge Scenario: The Story of “Paperless Logistics Inc.”</h3><p>Imagine that Paperless Logistics Inc. is a fast-growing logistics company that manages a vast network of suppliers, contractors, and clients. With the rapid expansion of their services, they have found themselves drowning in paperwork — freight bills, invoices, delivery orders, and compliance documents, to name a few.</p><p>Efficiency is taking a hit; manual data entry errors are leading to invoice disputes, and crucial contract renewals are being missed. To reclaim their competitive edge, the company has decided to digitize and automate its document processing pipeline. Their focus is on scanning and extracting key information from various kinds of documents, which they aim to achieve using AWS Textract.</p><h3>The Challenge</h3><p>Your mission is to build a solution that automates the extraction of information from different types of logistics documents. This will allow Paperless Logistics Inc. to reduce manual errors, improve efficiency, and streamline their operations.</p><h3>Objectives</h3><ol><li><strong>Set Up Your AWS Environment</strong>: Make sure you have an AWS account and configure your AWS CLI.</li><li><strong>Upload Sample Documents to an S3 Bucket</strong>: You’ll need different types of logistics documents.</li><li><strong>Configure AWS Textract</strong>: Implement Textract to scan documents and identify crucial data fields such as “Invoice Number,” “Supplier Name,” “Delivery Date,” and so forth.</li><li><strong>Data Storage</strong>: Store the extracted information in a structured format into a database (you could use AWS DynamoDB).</li></ol><h3>Requirements</h3><ul><li>AWS Account</li><li>Basic understanding of Python</li><li>Familiarity with Amazon S3, Textract, DynamoDB</li></ul><h3>Step 1: Create an S3 bucket and upload a sample document.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPtV4W-LDxxsXhEzSEhbjg.png" /></figure><h3>Step 2: Create a DynamoDB table to store the extracted text (provide document_name as id column)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wA4GvgyUCuqWErEajNGa6A.png" /></figure><h3>Step 3: Create a new Cloud9 Instance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UnoTU9QvrXTYFORHTAWAUA.png" /></figure><h3>Step 4: Run the Python script below to read the document from code</h3><p>mkdir paperless-challenge</p><p>cd paperless-challenge</p><p>pip install virtualenv</p><p>virtualenv -p python3 venv</p><p>source venv/bin/activate</p><p>pip install boto3</p><h3>Step 5: Create a new main.py file with the below content</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*jmOZJx-vtlZgSWD1CWP8LA.png" /></figure><h3>Step 6: Run the file:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*bQZc40fhvRZq-pMtuMIj8A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*Dk8HdLLGoP4sgcxNxioUkQ.png" /></figure><h3>Step 7: Verify entry in DynamoDB table:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tXzpFYCTGyxDDjNF8Xc6_g.png" /></figure><h3>References</h3><ul><li><a href="https://aws.amazon.com/textract/">https://aws.amazon.com/textract/</a></li><li><a href="https://docs.aws.amazon.com/code-library/latest/ug/python_3_textract_code_examples.html">https://docs.aws.amazon.com/code-library/latest/ug/python_3_textract_code_examples.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=576289ad8818" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS CI/CD With Docker]]></title>
            <link>https://medium.com/@ramahammer/aws-ci-cd-with-docker-5c994d7251aa?source=rss-1785b8751b68------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c994d7251aa</guid>
            <category><![CDATA[aws-codepipeline]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-codebuild]]></category>
            <category><![CDATA[aws-codecommit]]></category>
            <dc:creator><![CDATA[Rama Hammer]]></dc:creator>
            <pubDate>Fri, 16 Feb 2024 02:12:45 GMT</pubDate>
            <atom:updated>2024-02-16T02:22:49.481Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OpoQaMYal6rjthU6VMhOlA.png" /></figure><ul><li><a href="https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html">https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html</a></li><li><a href="https://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html">https://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html</a></li><li><a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html">https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html</a></li></ul><h3>Challenge Scenario</h3><p>Let’s consider a scenario where <strong>InnovateTech</strong>, a tech startup, is developing a new web application aimed at providing innovative solutions to common business problems. They have decided to use AWS for their infrastructure needs, specifically focusing on implementing a CI/CD pipeline to automate their deployment process using Docker, AWS CodeCommit, AWS CodeBuild, and Amazon ECS.</p><p><strong>Problem Statement:</strong> InnovateTech’s development team is spending too much time on deployment processes, which is slowing down their ability to deliver new features. They need a streamlined process that automates builds, tests, and deployments, allowing them to focus more on development and less on operational tasks.</p><p><strong>My Mission:</strong> Create a CI/CD pipeline using AWS CodeCommit, AWS CodeBuild, and Amazon ECS to automate the process of building, testing, and deploying a Dockerized web application.</p><h3>Challenge: Automating Web Application Deployment with Docker on AWS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OPVjGCaSIGitY-uY7GiVOA.png" /></figure><h4>Step 1: Create a new Cloud 9 instance:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQdf71_R4a6QBSM7Jy3k9Q.png" /></figure><h4>Step 2: Creating the ECS Cluster</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*aWkBP_dSniqqLkG9ymdhIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9K3zh2_zWusih9Hmb9CxCg.png" /></figure><h4>Step 3: Create AWS CodeCommit</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P0KOH0iwqEtaNmIGGEicIg.png" /></figure><h4>Step 4: Create ECR:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*ZEVV9gtOz36hu45cr7RHfQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zi2bX_CZxzWGlVIKtXrcFw.png" /></figure><h4>Step 5: <strong>Setting up the environment on Cloud9</strong></h4><ol><li>Ensure that AWS CLI, Git, and Docker are installed by running the following commands:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*Ir23KIos33Voo2Ze_2ybUg.png" /></figure><p>2. Create and Push Application Files to AWS CodeCommit</p><p>Get the URL of the codeCommit and clone:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*W7nEt34rZFLVeglCPqQ_uQ.png" /></figure><p>3. <strong>Containerizing the application</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*0qJa23BX3X57Mh_BxOyRfQ.png" /></figure><p>5. Create a new Task Definition:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*c89R7ZbKALjRM2l4M5UeTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*NeDHsMlJKUQ98nA-5c_1PA.png" /></figure><p>6. Create new Service:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*uBXqJAtizSGJkD2RWzf3Jg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*rJEGoYm6JLF8EHjg9K9tGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sFzlPXt-OMostAEiAT_44w.png" /></figure><p>Update the security group to allow trafic to port 80:</p><p><strong>Step 6: Creating the CI/CD pipeline on Code Pipeline</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*UpYElJdp8FZ14r64_dF4Yg.png" /></figure><p>All default except:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*jkGHeo5rDrTAiWdjD8gBMg.png" /></figure><p>Create code build:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*J8fBUqjuuPYq-4yTV54q9A.png" /></figure><p>version: 0.2</p><p>phases:<br> pre_build:<br> commands:<br> — echo Logging in to Amazon ECR…<br> — REPOSITORY_NAME=$ECR_REPO_NAME<br> — REPOSITORY_URI=$ECR_REPO_URI<br> — docker logout<br> — aws ecr-public get-login-password — region us-east-1 | docker login — username AWS — password-stdin public.ecr.aws/n9j8h0s5<br> build:<br> commands:<br> — echo Build started on `date`<br> — echo Building the Docker image… <br> — docker build -t $REPOSITORY_NAME .<br> — docker tag $REPOSITORY_NAME:latest $REPOSITORY_URI:latest<br> post_build:<br> commands:<br> — echo Build completed on `date`<br> — echo Pushing the Docker image…<br> — docker push $REPOSITORY_URI:latest <br> — printf ‘[{\”name\”:\”InnovateTechWebApp\”,\”imageUri\”:\”%s\”}]’ $REPOSITORY_URI:latest &gt; imagedefinitions.json<br> — cat imagedefinitions.json<br>artifacts:<br> files: <br> — imagedefinitions.json</p><p>update authentication from the ECR push command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*ZVAlBKBgzwrKMJC9xx1jfg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*gwDn17ReIQcWjcM8OBPizg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*MG9hvyjBH2-rb6KjSxiVsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*MmW__IEv56em-cZ5QkONqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*LNXx0e_ebAq7k5J3sBhNHw.png" /></figure><p><strong>Adding permission to IAM roles</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PFMBICLeFj9NZR4vDDIkow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wa0w9VZLLKerTR40xTpZVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*xNe7a85QGVB05B6pMc120g.png" /></figure><h4>Step 7: Test the application:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*7UKHfZvPbjVWNpawODGsSQ.png" /></figure><h4>Step 8: Testing the Build and Deploy process</h4><p>Click in “Release changed” to start the pipeline</p><p>Make a change in the application file and commit the changes.</p><p>git add .<br>git commit -m “updated file app.py line 6”<br>git push</p><p>Then check that the pipeline has restarted and the changes have been deployed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*mjhsB0-ztnPXXn8-X_o1Lw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*g7jSmyoIaNwP4VckbHQLxg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c994d7251aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DevOps — AWS CloudWatch Hands On]]></title>
            <link>https://medium.com/@ramahammer/devops-aws-cloudwatch-hands-on-6f27adf1db02?source=rss-1785b8751b68------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f27adf1db02</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-cloudwatch]]></category>
            <dc:creator><![CDATA[Rama Hammer]]></dc:creator>
            <pubDate>Fri, 16 Feb 2024 00:09:16 GMT</pubDate>
            <atom:updated>2024-03-08T16:30:05.653Z</atom:updated>
            <content:encoded><![CDATA[<h3>DevOps — AWS CloudWatch Hands On</h3><p><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-cloudwatch.html">Monitor your instances using CloudWatch</a></p><p><strong>Hands On 1: CloudWatch (Metrics, Dashboards and Alarms)</strong></p><p>Step 1: Create a key pair for EC2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*H987JObx0fxCCoOB4qoE-Q.png" /></figure><h4>Step 2: Create credentials for cloud9 user:</h4><p>export AWS_ACCESS_KEY_ID=”AKIATOHFUNNEBHZJEKN5&quot;<br>export AWS_SECRET_ACCESS_KEY=”WQ7pLmRtJbjFF9J/qf082H+vTqMOKAcHTbcTFlQl”</p><p>Set the key:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*JtJaM86vloFV42WRnm2mqA.png" /></figure><h4>Step 3: Create 2 EC2 instances using CLI:</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f27adf1db02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins on AWS]]></title>
            <link>https://medium.com/@ramahammer/jenkins-on-aws-0149998c005c?source=rss-1785b8751b68------2</link>
            <guid isPermaLink="false">https://medium.com/p/0149998c005c</guid>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[aws-ecr]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Rama Hammer]]></dc:creator>
            <pubDate>Fri, 09 Feb 2024 20:55:09 GMT</pubDate>
            <atom:updated>2024-02-09T20:55:09.283Z</atom:updated>
            <content:encoded><![CDATA[<p>Mare sure git and docker install.</p><h4>Install AWS CLI</h4><p>curl “&lt;<a href="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip">https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip</a>&gt;&quot; -o “awscliv2.zip”<br>sudo apt install unzip<br>unzip awscliv2.zip<br>sudo ./aws/install<br>aws — version</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*6R5Q5ElpZ8T57dgPkn2Ghw.png" /></figure><p>Install AWS credentials in Jenkins:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*qH-wwsI_2c45IP4RxW2wag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VjNDkS012FMaf_5GN8RxdA.png" /></figure><p>Create a new Jenkins pipeline to configure to AWS:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*9SpdaF2E4B8ttQICFtqwpQ.png" /></figure><h4>Testing to list AWS Resources</h4><p>Add a stage to the Jenkins pipeline to list AWS resources</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*c3_D-UCPGvyPiw81hbnrQA.png" /></figure><p>We will get an error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*333R6PfxqXtrVXNl0KZGBw.png" /></figure><p>AWS IAM: Create Credentials for Jenkins User</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NpVHsrMuY-7mS3WJbY-nQw.png" /><figcaption>Get</figcaption></figure><p>Add AWS credentials in Jenkins,</p><p>First — get access key for the jk-user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*KowTinNKLXy-Hv7O1mKAdw.png" /></figure><p>Fix the pipeline to use the credentials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*TQOl9C25xL_2mA_BCmNKYQ.png" /></figure><p>Better way to to handle credentials by adding env variable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*pR9gqQ-AaiQzxJ0ZJd9z1g.png" /></figure><h3>AWS: CodeCommit</h3><p>Create new repository:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5lkv7N-ZVGutFqMJWJgZA.png" /></figure><p>Add the 3 files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S35zV3HquP5q0HYFsJR_yg.png" /></figure><p>Add <strong>HTTPS Git credentials for AWS CodeCommit to jk_user:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*du9TYeTqhyLYyJdVYNmCkA.png" /></figure><p>Update Jenkins:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*gm9FLq-nygVotcO7TqtKmQ.png" /></figure><p>Add Credentials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*OaPaoW_uWV8-fiEWX5dMXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x6CEvq2sgsHquHrUMEjTQw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*UnFFthjRDOMVF-nss-8L3g.png" /></figure><h3>Part 02: AWS ECR &amp; ECS</h3><p>Creating a private ECR repository jk-webapp — for docker images</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vHWT3o09TvGIuwdh-0n3Qg.png" /></figure><p>Building and Pushing docker Image to ECR</p><p>Get the commands and update Jenkins:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*f1tUzesZf4GkDgdl_ZuZVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AlII3VeTH4s1tGCmnmy4MA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MNHjr6uJxJfStRgh0zyWaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*Mf5mPEYEbJe473sIVdlMQw.png" /></figure><h3>Creating ECS of EC2 Cluster to deploy application image — <strong>jk-webapp-cluster (use the same key we got earlier)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*ZMLOvJhG0HAqJCXIPy0-pA.png" /></figure><p>Use default VPC, turn on IP:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*Cs6S9xKZZsR9VJU_8RV3CA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ogsziaGxRka8KOm0YjW7jQ.png" /></figure><p>Two instances got created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jYxYB5NETclC-texpRvHWg.png" /></figure><p>Create new task definition <strong>jk-webapp-td</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*9TqCug0Gi73X5h4ixMHWoQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*fRXE6P9QfNhuzYiAodb-Eg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*itmUNCivixcsSxv59ZrBUA.png" /></figure><p>Create a service to deploy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*gfFJpzffTA7SWTgQW6lB-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*0VU59LBWezWF9QFRlc4n4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*RCV9bsnB1jG9O7N3Tj7Jyw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mM9HY48fGjHiwI7MZBBbOQ.png" /></figure><p>Open the load balancer DNS:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*DG1TiJwVchYzGqQhfDydww.png" /></figure><h3>Deploying Webapp Application on AWS ECS</h3><ul><li><strong>Stage:</strong> <strong>Deploying Webapp Application on AWS ECS</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*7mMg0RGztiz1Zonf5as9cw.png" /></figure><p>Add Env variables:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*00gIcecV3DTTH5RAPJBy4w.png" /></figure><p>Fix the Docker file in codecommit:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zexcyVczAzMNr3aks2qUQw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vcjWvqicR_6kJSS3me9MTw.png" /></figure><p>Application was deployed and updated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IaKpJpWkUgoBAuNgJ2G0KQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0149998c005c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins Hands On]]></title>
            <link>https://medium.com/@ramahammer/jenkins-hands-on-be61297f092e?source=rss-1785b8751b68------2</link>
            <guid isPermaLink="false">https://medium.com/p/be61297f092e</guid>
            <dc:creator><![CDATA[Rama Hammer]]></dc:creator>
            <pubDate>Thu, 08 Feb 2024 20:19:57 GMT</pubDate>
            <atom:updated>2024-02-08T20:21:11.468Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/112/1*zvCzQQ-x3TwW6oQ24UlCSA.png" /></figure><h3><strong>Hands On 1: Install and Configure Jenkins on AWS</strong></h3><p><a href="https://www.jenkins.io/doc/book/installing/linux">https://www.jenkins.io/doc/book/installing/linux</a></p><h4>Create a new ECR Instance:</h4><p>- EC2 Name: jk-server | Ubuntu 22.04 LTS | t2.micro</p><p>- SSH Key Pair: jk-ssh-key</p><p>- VPC Default</p><p>- SG: Allow SSH</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wg217m4R2kcJvrcQTHCkRw.png" /></figure><h4>Install Java:</h4><p>ssh connection to: ubuntu@34.228.233.215</p><p>sudo apt update -y</p><p>java -version</p><p>sudo apt install openjdk-11-jre -y</p><p>java -version</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*2MIU5nelT7H4tFDjGGqRUQ.png" /></figure><h4>Install Jenkins:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*IF2LqBGbOeNWygzGzV7GxQ.png" /></figure><p>First download a key for the jenkins command to work:</p><p>curl -fsSL <a href="https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key">https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key</a> | sudo tee /usr/share/keyrings/jenkins-keyring.asc &gt; /dev/null</p><p>echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] <a href="https://pkg.jenkins.io/debian-stable">https://pkg.jenkins.io/debian-stable</a> binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list &gt; /dev/null</p><p>sudo apt update -y</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gbaAVIBvABiHv9-BcH591Q.png" /></figure><p>sudo apt install jenkins -y</p><p>Verify commands:</p><p>jenkins — version<br>systemctl is-enabled jenkins<br>sudo systemctl enable jenkins<br>systemctl status jenkins<br>‘q’ to exit<br>ps -ef | grep jenkins # See it running on port 8080</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*owHCmLYrV1xOq6tNLtCw4w.png" /></figure><h4>Testing Jenkins on Default Port 8080</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-uIa5-tw9oKcfNEQ-EmxQ.png" /></figure><p>sudo cat /var/lib/jenkins/secrets/initialAdminPassword to get the password:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*63tMPv_lu2HtURhMv-1I_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*Iv0YEcElT7JdwEKitGefew.png" /></figure><p>Install suggested plugins</p><p><strong>Create First Admin User</strong></p><ul><li>Username: admin</li><li>Password: 654321</li><li>Full name: Admin</li><li>E-mail address: <a href="/service/mailto:admin@tcb.com">admin@tcb.com</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yLb3GLBtbwPsjU7285rewA.png" /></figure><p>Save Jenkins URL: <a href="http://34.228.233.215:8080/">http://34.228.233.215:8080/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h22Y0z7CWoMEDL0GVGqPQw.png" /></figure><h3>Hands On 2: Creating a ‘Freestyle’ Project</h3><h4>Install docker:</h4><p>follow: <a href="https://docs.docker.com/engine/install/ubuntu/">Install Docker Engine on Ubuntu | Docker Docs</a></p><p># Add Docker’s official GPG key:<br>sudo apt-get update<br>sudo apt-get install ca-certificates curl<br>sudo install -m 0755 -d /etc/apt/keyrings<br>sudo curl -fsSL <a href="https://download.docker.com/linux/ubuntu/gpg">https://download.docker.com/linux/ubuntu/gpg</a> -o /etc/apt/keyrings/docker.asc<br>sudo chmod a+r /etc/apt/keyrings/docker.asc</p><p># Add the repository to Apt sources:<br>echo \<br> “deb [arch=$(dpkg — print-architecture) signed-by=/etc/apt/keyrings/docker.asc] <a href="https://download.docker.com/linux/ubuntu">https://download.docker.com/linux/ubuntu</a> \<br> $(. /etc/os-release &amp;&amp; echo “$VERSION_CODENAME”) stable” | \<br> sudo tee /etc/apt/sources.list.d/docker.list &gt; /dev/null<br>sudo apt-get update</p><p>#Install latest version:</p><p>sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin</p><p>Easy way to install docker:</p><p>curl -fsSL &lt;<a href="https://get.docker.com/">https://get.docker.com</a>&gt; -o get-docker.sh<br>sudo sh get-docker.sh</p><p>docker -v<br>docker ps | <a href="http://twitter.com/error">@error</a></p><p>sudo usermod -aG docker $USER &amp;&amp; sudo systemctl restart docker<br>^d<br>ssh -i jk-ssh-key.pem ubuntu@ec2-public-ip</p><h4>Create a new GitHub repository:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*Yg_npnzTwu4yDlmU0KzYYQ.png" /></figure><p>Upload files directly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zl8IY-dVtaWMhVgm1lMK5g.png" /></figure><h4><strong>Create a Freestyle Project for Building and Running a Single Container:</strong></h4><ul><li>Jenkins dashboard and click on ‘<strong>New Item</strong>’</li><li>Enter a name for your project: <strong>jk-freestyle-public-gh</strong></li><li>Select ‘<strong>Freestyle project</strong>’, click ‘<strong>OK</strong>’</li><li>You can add some description for your project if you want.</li><li>Under Source Code Management: ‘<strong>Git</strong>’ and enter <strong>your repository URL</strong>:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LOe4SI7bRJ1psYFJP3KHYw.png" /></figure><h4>Step 01: “Building Image”</h4><p>Using a BUILD_NUMBER env variable to set up the version</p><p>docker build -t webapp:${BUILD_NUMBER}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*AqFDqYSmCT7DpW1OWWTgXw.png" /></figure><h4>Step 02: “Deploying Container”</h4><p>docker run — rm -d -p 3000:3000 — name webapp_ctr webapp:${BUILD_NUMBER}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*NbSgtIFdK7ijGYfjPP6IUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wihq0hDe3vCAD8QyCtQ_Lg.png" /></figure><p><a href="https://www.jenkins.io/doc/book/blueocean/dashboard/#pipeline-health">Dashboard</a></p><p>Try to build now, it will fail. Run these commands:</p><p>less /etc/passwd | grep jenkins</p><p>sudo usermod -aG docker jenkins</p><p>grep docker /etc/group</p><p>sudo systemctl restart jenkins</p><p>systemctl status jenkins</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YZwAhi0YGbVtHP4p6FE8Ag.png" /></figure><p>Run build now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BRdIlcigxtXu4-gikSDBMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*Te2AdD7d0-NqzK-2xElCNw.png" /></figure><p>Add access to port 3000:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*orbqXpPyrjiATiTB5h04BQ.png" /></figure><p>Test the application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*i7TdYh4j6canDDlT30wLOg.png" /></figure><p>Need to fix the docker file to use the style as well:</p><p>FROM python:2.7<br>WORKDIR /html<br>COPY . .<br>EXPOSE 3000<br>CMD python -m SimpleHTTPServer 3000</p><p>Once we try to build again it fails on container name cannot be reused. We will need to update the pipeline configuration (press name-&gt;configure):</p><p>Need to add a step:</p><p>docker stop webapp_ctr</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*kNGcvF6XeJOoCTPwiU9UAg.png" /></figure><p>Test the application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J-cE9kpiI8snKjnFq7Mb9w.png" /></figure><h3>Hands On 3: Creating a Jenkins Pipeline using ‘Pipeline Script Definition’</h3><p># First, let’s clean up all Image and Container created</p><p>docker stop webapp_ctr</p><p>docker system prune -a -f — volumes</p><p>docker ps -a</p><p>docker images</p><p># Create a “Pipeline” Project for Building and Running a Single Container</p><ol><li>Go to Jenkins dashboard and click on ‘New Item’</li><li>Enter a name for your project: jk-pipeline_script-public-gh</li><li>Select ‘Pipeline’ click ‘OK’</li><li>You can add some description for your project if you want. — Definition: Pipeline script — Try sample pipeline: Hello World</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*qbGtcQPp6v1X4AkZkcw5SQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vT66IiK__nWH35fduFFWzQ.png" /></figure><p>Build now, it will show build stage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*G39HWoh9dRnIAAasC1Li8g.png" /></figure><p>### Stage 02: “Building Image” — steps:</p><p>`sh ‘docker build -t webapp:${BUILD_NUMBER} .’`</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*HPqKLBezQPzGCKCvm4sOag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*yLVQSLyoTW85jUEB4VxX-Q.png" /></figure><p>### Stage 03: “Deploying Application” —</p><p>steps:</p><p>- `sh ‘docker stop webapp_ctr’`</p><p>`sh ‘docker run — rm -d -p 3000:3000 — name webapp_ctr webapp:${BUILD_NUMBER}’`</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*UphvwOXx3BKC08a3NOqWaw.png" /></figure><h3>Hands On 4: Creating a Jenkins Pipeline using ‘Pipeline Script from SCM’</h3><p>Create a new Pipeline from SCM:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*rpQAiAq_AWHwEva3a23Cvw.png" /></figure><p>Create a new jenkinsfile inside GitHub:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*doS0eMiKmFfGNo8raU_SJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*6nDhdqQHnFAwLZo3RHcSzg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0-S18n52969m1QikDAs6Eg.png" /></figure><h3>Hands On 5: Creating a Jenkins Pipeline to Build, Push and Deploy process using ‘private’ GitHub repository, and Docker Hub</h3><p>step 1: Create a docker hub token:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mz-bWK-eQrudlc7Dc2SOfQ.png" /></figure><p>Add credentials in Jenkins:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*P9OAtgeEQEfIvxYkyaNqcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vzzN6jb_NX-N202f8Aq_jQ.png" /></figure><p>Create a private repository in GitHub</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N7ZUTYMR3pawSR_rY4WMVw.png" /></figure><p>Create credentials in GitHub (only permissioin to content):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7m1TyJ7oUDpXP10Ir1omLw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5PETxVT17R-ONN33_PmhDQ.png" /></figure><p>Create a new SCM pipeline for the private GH repository:</p><p>Add the dockers credentials and add a new one for GitHub:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*TfEl_k7E_Qy6QZFBjSN8zQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*oJZX-xUG2xVJXchYBimfgA.png" /></figure><p>Stage 01: ‘SCM Checkout’</p><p>Create initial Jenkins file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*WGCsUdSSfeVbCVhQCz66Kw.png" /></figure><p>Build check connectivity to private repository:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*NvIBszD6AAX2dmxmmJQP3A.png" /></figure><p>Stage 02: Build Docker image</p><p>stage(‘Build Docker Image’) {<br> steps {<br> sh ‘docker build -t devopscloudbootcamp/webapp:$BUILD_NUMBER .’<br> }<br>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*W0vllMd7SKgcK827fbOSrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*sPKQ-yJLhCx2mH6OJbh9YQ.png" /></figure><p>Stage 03: Login to Docker Hub</p><p>Add new block and env variable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*QaxjZJ6_8dI_SESKv8XG5A.png" /></figure><p>Stage 04: Push Image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*BOb6btHJ4Nilf1Y6NtLrHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ALh7-sRM6j-HZRYEmXZCbA.png" /></figure><p>Stage 05: Deploy the application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*oEz7UXARRWTOLM8II5wHyg.png" /></figure><h3>Hands On 6: Jenkins Build Triggers</h3><p>Set up build triggers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*zGziXshGjmWfVVAtVOZyxA.png" /></figure><p>Set webhook in GitHub private repository:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*E3hYnCNjnpJQ_rjVWUWDig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*jn90xZZ7h1IJmt9MpsO3HQ.png" /></figure><p>Lets make a change in the Dockerfile and see the build run automatically:</p><p>This build started automatically:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*LqBod68JIHa7k_NzMzCF7w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be61297f092e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HumanGov: Automating HumanGov SaaS Application Build and Deployment Process on Kubernetes with…]]></title>
            <link>https://medium.com/@ramahammer/humangov-automating-humangov-saas-application-build-and-deployment-process-on-kubernetes-with-a1656ab10289?source=rss-1785b8751b68------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1656ab10289</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Rama Hammer]]></dc:creator>
            <pubDate>Tue, 30 Jan 2024 23:52:38 GMT</pubDate>
            <atom:updated>2024-04-02T22:31:17.402Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>HumanGov: Automating HumanGov SaaS Application Build and Deployment Process on Kubernetes with CI/CD Pipelines using the AWS Code Commit, AWS Code Pipeline and AWS Code Build</em></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dVTP4c9qi-09jKtngdt99Q.png" /></figure><p>In this hands-on project, I ventured into the automation of cloud-based services, focusing on the HumanGov SaaS application. The objective was to streamline the build and deployment processes using Kubernetes and implement continuous integration and delivery with AWS services.</p><p>The project kicked off with the configuration of the AWS CodeCommit repository to manage and store source code, ensuring version control best practices. Following this, I orchestrated the continuous integration (CI) process using AWS CodeBuild, setting up automated builds that compile and package the HumanGov application into a deployable format.</p><p>The central piece of the automation was the creation of Kubernetes configurations to define the deployment, including services, pods, and other necessary resources. I defined a continuous delivery (CD) pipeline with AWS CodePipeline, linking the source code repository, build service, and Kubernetes clusters to enable a seamless flow from code commit to deployment.</p><p>For the application’s containerization, Docker came into play. I created Dockerfiles to build images of the HumanGov application, which were then pushed to the AWS Elastic Container Registry (ECR). These images were pulled during the deployment phase on the Kubernetes cluster, ensuring an efficient and reproducible deployment process.</p><p>With the CI/CD pipeline in place, any change made in the source code automatically triggered a build process, followed by a deployment to the Kubernetes cluster. This allowed for high agility in feature development and deployment, with minimal human intervention.</p><p>The automation process concluded with rigorous testing of the deployment, ensuring that the application was performing as expected in the AWS cloud environment. This project not only automated the application deployment but also provided valuable insights into cloud services, Kubernetes orchestration, and the power of CI/CD in maintaining a robust development workflow.</p><p>Key takeaways from this project included the intricacies of AWS services, the advantages of Kubernetes in managing containerized applications, and the efficiency gains from automating the build and deployment pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8zaBaWzLlE7I-g-miPMbBQ.png" /></figure><h3>The main steps for this project are:</h3><ol><li>Set up AWS CodeCommit — commit all application files.</li><li>Implement AWS CodeBuild to build and test the application.</li><li>Configure the kubernetes cluster.</li><li>Create a CI/CD pipleline using AWS CodePipeline.</li><li>Utilize docker to package the HumanGov application.</li><li>Push the docker images into the AWS ECR.</li><li>Automate the deployment in the Kubernetes cluster.</li></ol><h3>Part 1: CI/CD pipeline setup</h3><h3>Step 1: Push HumanGov application source code changes to AWS CodeCommit</h3><p># Config for DevOps Engineer<br>git config — global user.name “Rama Hammer — DevOps Engineer”<br>git config — global user.email <a href="/service/mailto:ramahammer@humangov.com">ramahammer@humangov.com</a></p><p>git config — global credential.helper ‘!aws codecommit credential-helper $@’<br>git config — global credential.UseHttpPath true</p><p>export AWS_ACCESS_KEY_ID=AKIATOHFUNNEAAR4GAFP<br>export AWS_SECRET_ACCESS_KEY=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</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*NL346WDFEiCLjsFRYEfYSw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*FzDdaVETPFfMwEVEOH36Vg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*DOa4QY73tU86ur1-RupITw.png" /></figure><h3>step 2: Set Up AWS CodePipeline</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*JRLiUDr-BLTCN6gGWDFv0w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*37aXNmKPRRSDrMT797FHHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*-gcvQyiN3u1nNvU_iAM11w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*Mqq5d0eOGRi99xlRSc-M3A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*HDgBOZD3DUR1dnWPgKbE-g.png" /></figure><p>Build yaml file content:</p><p>version: 0.2<br>phases:<br> install:<br> runtime-versions:<br> docker: 20<br> pre_build:<br> commands:<br> — echo Logging in to Amazon ECR…<br> — aws — version<br> — REPOSITORY_URI=$ECR_REPO<br> — aws ecr-public get-login-password — region $AWS_DEFAULT_REGION | docker login — username AWS — password-stdin public.ecr.aws/l4c0j8h9 <br> build:<br> commands:<br> — echo Build started on `date`<br> — echo Building the Docker image…<br> — cd src<br> — docker build -t $REPOSITORY_URI:latest .<br> — docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$CODEBUILD_RESOLVED_SOURCE_VERSION<br> post_build:<br> commands:<br> — echo Build completed on `date` <br> — echo Pushing the Docker image…<br> — docker push $REPOSITORY_URI:latest<br> — docker push $REPOSITORY_URI:$CODEBUILD_RESOLVED_SOURCE_VERSION<br> — export imageTag=$CODEBUILD_RESOLVED_SOURCE_VERSION<br> — printf ‘[{\”name\”:\”humangov-app\”,\”imageUri\”:\”%s\”}]’ $REPOSITORY_URI:$imageTag &gt; imagedefinitions.json<br> — cat imagedefinitions.json<br> — ls -l</p><p>env:<br> exported-variables: [“imageTag”]<br> <br>artifacts:<br> files: <br> — src/imagedefinitions.json<br> — src/humangov-california.yaml<br> — src/humangov-florida.yaml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*4FLTAfU835dVVYmAhM8N9A.png" /></figure><p>Update authentication from the ECR Push command:</p><p>aws ecr-public get-login-password — region us-east-1 | docker login — username AWS — password-stdin public.ecr.aws/n9j8h0s5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*Kn5LUh084g0a5-EN9gKYVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*7mlDXXgBU6G0XGId19jh-g.png" /></figure><ol><li><strong>Add AmazonElasticContainerRegistryPublicFullAccess permission to ECR on service role</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jtxnp1Ax-G1CtAIQRURdjg.png" /></figure><ol><li>Rerun the build:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*3viq8HO-BEkvTY7Je2L35g.png" /></figure><p><strong>Set Up AWS CodeBuild for Deploying the Application</strong></p><p>Add a new stage after build, create new action:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ruAEYmL8MUOK1mxz71weDw.png" /></figure><p>Select create new project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*HlSIM7fzLnyzk_-LfmoPUw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*t6HfydiBDPZbDHienT0OGg.png" /></figure><p>Use this for the build:</p><p>version: 0.2</p><p>phases:<br> install:<br> runtime-versions:<br> docker: 20<br> commands:<br> — curl -o kubectl <a href="https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.9/2020-11-02/bin/linux/amd64/kubectl">https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.9/2020-11-02/bin/linux/amd64/kubectl</a><br> — chmod +x ./kubectl<br> — mv ./kubectl /usr/local/bin<br> — kubectl version — short — client<br> post_build:<br> commands:<br> — aws eks update-kubeconfig — region $AWS_DEFAULT_REGION — name humangov-cluster<br> — kubectl get nodes<br> — ls<br> — cd src<br> — IMAGE_URI=$(jq -r ‘.[0].imageUri’ imagedefinitions.json)<br> — echo $IMAGE_URI<br> — sed -i “s|CONTAINER_IMAGE|$IMAGE_URI|g” humangov-california.yaml<br> — sed -i “s|CONTAINER_IMAGE|$IMAGE_URI|g” humangov-florida.yaml<br> — kubectl apply -f humangov-california.yaml<br> — kubectl apply -f humangov-florida.yaml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*LV8Lr2K_bpNJwPP2Pk4SQA.png" /></figure><p>Update the state files, replace the image by the parameter:<br> containers:<br> — name: humangov-python-app-florida<br> image: CONTAINER_IMAGE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*op1rpKY6IWIKjq4fnIp9HA.png" /></figure><p>Make a change in home.html file, commit the changes, build again and watch the change:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtFpiJQfCf4l81lPHuzRIw.png" /></figure><p>Step 7: Add Test phase</p><p>Create a new directoy tests: create 2 files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*_3kt5JkAFvKpq8xRTpvyuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*K568qu9hINFAh8Q3QAJQxg.png" /></figure><p>Add stage after build:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*CYFArqrQwUY6S3A2m7olNA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*8kmdMsnrLVYnXNvWWjSU6g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*RuJ5n4B2nN0zFQBAQovLpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*5BOJDE6Li-3rzbpvzdWETw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*cqnMBv7LIlJ4rCLuZ_OlzQ.png" /></figure><p>Add permission:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UJaxOHOms5MqrAzVjDK52Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*kxUHOon-cWmeF71zi8hPWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*0ts6hVcSh5ZHCEXGqPEuVQ.png" /></figure><p>Make a change in the test file to fail the test:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zhoa3Fre_p_9dZ-yq--f-Q.png" /></figure><h3>Part 3: Simulate Continuous Delivery by adding Manual Approval step before going to Production instead of Continuous Deployment</h3><p><em>“Continuous Delivery vs Continuous Deployment: Key Differences. Simply put, Continuous Delivery focuses on ensuring software is always release-ready with manual approval, while Continuous Deployment automates the release process, deploying changes to production automatically once tests pass.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nQcjPXf3LGpDgAuE" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JmNSj8UA4b0OIRr7" /></figure><p>Add a new tenant staging to the HumanGov application to serve as our “staging” environment.</p><p>Update variables file:</p><p>variable “states” {<br> description = “The list of state names”<br> default = [“california”,”florida”, “staging”]<br>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*G25NID_Co42H0HFlTqDZ0w.png" /></figure><p>Create the deployment files:</p><p>humangov-staging.yaml</p><p>apply the changes:</p><p>Upodage ingress file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*KP-WO2uLHIN6TGbcIDJaBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JwcKXEdLiK0K8Scog1vKVA.png" /></figure><p>Update Route 53:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBCQzNHLkDHlNuTfCZG32w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-2TTfAR5xKFhEDmHizukYA.png" /></figure><p>Add staging</p><p>Add ManualApplication:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GGY85oANpKq_Ue-iRf-QPA.png" /></figure><p>Update HumanGovBuild:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*pqmkfq_V1E3iURZf-2_vcw.png" /></figure><p>Waiting for approval:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*RLsVo8Lza2IngaHEge2P6g.png" /></figure><p>Validate that the change was made:<br>In staging env — change was made:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zzz0MB4NJABpCdSuoV2LRg.png" /></figure><p>In production not yet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fWE9SaTjO95We_fKaVmtXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*aXPRxELBNbh6hMjl-zhxIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*GwIGRYgcnu4oScAMwX7lgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*odMKkLTmbXonAlbYvWrrWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ALK2b-GcgAd7b2BqnoPbdw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qzAwf_I2NFTja1vhXvkfw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1656ab10289" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HumanGov: Deployment Of HumanGov SaaS Application on AWS Elastic Kubernetes Service (EKS) Using a…]]></title>
            <link>https://medium.com/@ramahammer/humangov-deployment-of-humangov-saas-application-on-aws-elastic-kubernetes-service-eks-using-a-acb7d8bca160?source=rss-1785b8751b68------2</link>
            <guid isPermaLink="false">https://medium.com/p/acb7d8bca160</guid>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[multi-cloud]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-kubernetes-cluster]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Rama Hammer]]></dc:creator>
            <pubDate>Fri, 19 Jan 2024 01:54:08 GMT</pubDate>
            <atom:updated>2024-01-30T23:05:26.448Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>HumanGov: Deployment Of HumanGov SaaS Application on AWS Elastic Kubernetes Service (EKS) Using a Route 53 Domain, ALB Ingress, and SSL Endpoint Powered by AWS Certificate Manager.</em></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gls6j2ItPwZ8wrQ3kWW5bA.png" /></figure><p>In this comprehensive project, I tackled the challenge of deploying the HumanGov SaaS application using the Amazon Web Services (AWS) platform, specifically focusing on Elastic Kubernetes Service (EKS) for orchestration, along with Route 53 for domain management, Application Load Balancer (ALB) for ingress, and AWS Certificate Manager for SSL endpoint encryption.</p><p>My journey commenced with the foundational work of setting up the AWS VPC and EKS cluster. I proceeded with the installation of kubectl and eksctl on Cloud 9, leveraging these tools to interact with the EKS cluster.</p><p>The application was containerized using Docker, which involved writing Dockerfiles and optimizing the build process for the HumanGov app. Once containerized, the images were pushed to the Amazon Elastic Container Registry (ECR), ensuring they were ready for deployment.</p><p>With the ECR set, I crafted Kubernetes deployment and service manifests. This allowed me to define the desired state of the application, including the number of pods, resource limits, and the necessary environment variables.</p><p>For domain management and traffic routing, I configured a Route 53 hosted zone and records. This was integral for domain name resolution and providing a user-friendly URL for the application.</p><p>To manage incoming traffic, I set up an ALB and configured ingress resources. This step was crucial for directing traffic to the correct services within the EKS cluster and for enabling SSL termination at the ALB level.</p><p>I utilized AWS Certificate Manager to provision and manage the SSL certificate, ensuring encrypted and secure communication to and from the application.</p><p>The outcome was a highly available, secure, and scalable HumanGov SaaS application on AWS EKS, accessible via a secure domain. This deployment not only showcased the efficiency of Kubernetes on AWS but also the robustness of AWS’s networking and security services.</p><p>Key takeaways from this project include a deepened understanding of Kubernetes on AWS, domain and traffic management, SSL encryption, containerization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MgKaVdNUDvrIf00MAofz8Q.png" /></figure><h3>Part 1: EKS Cluster Setup</h3><ol><li>Have AWS Version 2 or up:</li></ol><p>aws — version</p><p>If need to reinstall:</p><p>curl “<a href="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip">https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip</a>&quot; -o “awscliv2.zip”<br>unzip awscliv2.zip<br>sudo ./aws/install — bin-dir /usr/local/bin — install-dir /usr/local/aws-cli — update</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*hH_cBl7VRZd-jHd7JUSxPw.png" /></figure><p>2. Install eksctl CLI tool</p><p>curl — silent — location “<a href="https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname">https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname</a> -s)_amd64.tar.gz” | tar xz -C /tmp<br>sudo cp /tmp/eksctl /usr/bin<br>eksctl version</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1xkatVRJOMvXxHu4b1Akrw.png" /></figure><p>3. Install kubectl CLI tool</p><p>curl -o kubectl <a href="https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.9/2020-11-02/bin/linux/amd64/kubectl">https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.9/2020-11-02/bin/linux/amd64/kubectl</a><br>chmod +x ./kubectl<br>mkdir -p $HOME/bin &amp;&amp; cp ./kubectl $HOME/bin/kubectl &amp;&amp; export PATH=$PATH:$HOME/bin<br>echo ‘export PATH=$PATH:$HOME/bin’ &gt;&gt; ~/.bashrc<br>kubectl version — short — client</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*Rv55JsLVPd5RwtPq1_-3eQ.png" /></figure><p>4. Install helm CLI tool</p><p>curl -fsSL -o get_helm.sh <a href="https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3">https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3</a><br>chmod 700 get_helm.sh<br>./get_helm.sh<br>helm version</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*g54-Y3OvPLOE-9hmiZwTVw.png" /></figure><p>5. Create an IAM User eks-user with AdministratorAccess policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k3hsK9rCH7KHumif4xkFtw.png" /></figure><p>6. Create an Access Key for the eks-userand authenticate with eks-user access key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*LTsKquQ-37lqsmo0SXqKwg.png" /></figure><p>AKIATOHFUNNEAAR4GAFP<br>opUxUxLPbMX2Cws70xhF2M58f6SJjojo5kx2Brp4</p><p><strong>7. </strong>Disable Managed Credentials on Cloud9 (Very Important — DO NOT SKIP)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*Q47I2KcWoIdp13HX7fMUoA.png" /></figure><p>8. Using Terraform, provision the S3 and DynamoDB table to be used by the HumanGov Application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*_HykIIDDRB58dB7XuiyT7g.png" /></figure><p>9. Create an EKS Cluster</p><p>eksctl create cluster — name humangov-cluster — region us-east-1 — nodegroup-name standard-workers — node-type t3.medium — nodes 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n2REe_yyYos1D3ZvWj8jRQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H4eMgAM5RgF_WWcfAjHn4w.png" /></figure><p>10. Connect to the EKS Cluster using kubectl Config</p><p>aws eks update-kubeconfig — name humangov-cluster</p><p>11. Verify Cluster Connectivity</p><p>kubectl get svc<br>kubectl get nodes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*taPt4Vm-yzyrh5ZssXQF2Q.png" /></figure><h3><strong>Part 2: Installing Ingress Controller and ALB</strong></h3><h4><strong>1. Create an IAM policy.</strong></h4><p>a. Download an IAM policy for the AWS Load Balancer Controller that allows it to make calls to AWS APIs on your behalf.</p><p>cd ../..<br>curl -O <a href="https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy.json">https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy.json</a></p><p>b. Create an IAM policy using the policy downloaded in the previous step.</p><p>aws iam create-policy \<br> — policy-name AWSLoadBalancerControllerIAMPolicy \<br> — policy-document file://iam_policy.json</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*HaPbph4WLc8X6F6VX6yqUA.png" /></figure><h4>2. Create an IAM OIDC identity provider for your cluster with eksctl</h4><p>eksctl utils associate-iam-oidc-provider — cluster humangov-cluster — approve</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*B0SYEcuLGvyTpZFtpfCXaA.png" /></figure><h4>3. Create an IAM role and a Kubernetes service account named aws-load-balancer-controller in the kube-system namespace for the AWS Load Balancer Controller and annotate the Kubernetes service account with the name of the IAM role.</h4><p>eksctl create iamserviceaccount \<br> — cluster=humangov-cluster \<br> — namespace=kube-system \<br> — name=aws-load-balancer-controller \<br> — role-name AmazonEKSLoadBalancerControllerRole \<br> — attach-policy-arn=arn:aws:iam::236704787272:policy/AWSLoadBalancerControllerIAMPolicy \<br> — approve</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*geiaypO-bxdhbFRg3XtGug.png" /></figure><h4>4. Install the AWS Load Balancer Controller using <a href="https://docs.aws.amazon.com/eks/latest/userguide/helm.html">Helm V3</a> or later or by applying a Kubernetes manifest.</h4><p>a. Add the eks-charts repository.</p><p>helm repo add eks <a href="https://aws.github.io/eks-charts">https://aws.github.io/eks-charts</a></p><p>b. Update your local repo to make sure that you have the most recent charts.</p><p>helm repo update eks</p><p>c. Install the AWS Load Balancer Controller.</p><p>helm install aws-load-balancer-controller eks/aws-load-balancer-controller \<br> -n kube-system \<br> — set clusterName=humangov-cluster \<br> — set serviceAccount.create=false \<br> — set serviceAccount.name=aws-load-balancer-controller</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*A-RY1Oq8laTYYkyFc81SnQ.png" /></figure><h4>5. Verify that the controller is installed.</h4><p>kubectl get deployment -n kube-system aws-load-balancer-controller</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*KYyyQM0LqV7S5JSXsPhhDw.png" /></figure><h3><strong>Part 3: Deploying the HumanGov Application</strong></h3><h4><strong>1. Create Role &amp; Service Account to provide pods access to S3 and DynamoDB tables</strong></h4><p>eksctl create iamserviceaccount \<br> — cluster=humangov-cluster \<br> — name=humangov-pod-execution-role \<br> — role-name HumanGovPodExecutionRole \<br> — attach-policy-arn=arn:aws:iam::aws:policy/AmazonS3FullAccess \<br> — attach-policy-arn=arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess \<br> — region us-east-1 \<br> — approve</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*bYQyn6j9Vgl4oh9leillew.png" /></figure><h4>2. Containerize the HumanGov application</h4><ol><li><strong>Create ECR Repository</strong></li></ol><p>cd human-gov-application/src</p><p>Create a new public ECR repository named humangov-app, build and push the Docker Image to the ECR repository created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*BaQt8pikHwzqnsLhr42Cqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*739w99J8kVE0f8coag8e6A.png" /></figure><p><strong>3. Deploy the Application for Each State</strong></p><p>Use your application deployment YAML files to deploy your service. Create the file humangov-california.yaml under the human-gov-application/src directory.</p><p><strong>Replace the ECR image path and AWS Bucket name</strong> with your resource names as shown in red below:</p><p>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br> name: humangov-python-app-california<br>spec:<br> replicas: 1<br> selector:<br> matchLabels:<br> app: humangov-python-app-california<br> template:<br> metadata:<br> labels:<br> app: humangov-python-app-california<br> spec:<br> serviceAccountName: humangov-pod-execution-role<br> containers:<br> — name: humangov-python-app-california<br> image: <a href="https://medium.com/public.ecr.aws/n9j8h0s5/humangov-app:latest">public.ecr.aws/l4c0j8h9/humangov-app:latest</a><br> env:<br> — name: AWS_BUCKET<br> value: “humangov-california-s3-nlj7”<br> — name: AWS_DYNAMODB_TABLE<br> value: “humangov-california-dynamodb”<br> — name: AWS_REGION<br> value: “us-east-1”<br> — name: US_STATE<br> value: “california”</p><p>— -</p><p>apiVersion: v1<br>kind: Service<br>metadata:<br> name: humangov-python-app-service-california<br>spec:<br> type: ClusterIP<br> selector:<br> app: humangov-python-app-california<br> ports:<br> — protocol: TCP<br> port: 8000<br> targetPort: 8000</p><p>— -</p><p>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br> name: humangov-nginx-reverse-proxy-california<br>spec:<br> replicas: 1<br> selector:<br> matchLabels:<br> app: humangov-nginx-reverse-proxy-california<br> template:<br> metadata:<br> labels:<br> app: humangov-nginx-reverse-proxy-california<br> spec:<br> containers:<br> — name: humangov-nginx-reverse-proxy-california<br> image: nginx:alpine<br> ports:<br> — containerPort: 80<br> volumeMounts:<br> — name: humangov-nginx-config-california-vol<br> mountPath: /etc/nginx/<br> volumes:<br> — name: humangov-nginx-config-california-vol<br> configMap:<br> name: humangov-nginx-config-california</p><p>— -</p><p>apiVersion: v1<br>kind: Service<br>metadata:<br> name: humangov-nginx-service-california<br>spec:<br> selector:<br> app: humangov-nginx-reverse-proxy-california<br> ports:<br> — protocol: TCP<br> port: 80<br> targetPort: 80</p><p>— -</p><p>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br> name: humangov-nginx-config-california<br>data:<br> nginx.conf: |</p><p>events {<br> worker_connections 1024;<br> }</p><p>http {</p><p>server {<br> listen 80;</p><p>location / {<br> proxy_set_header Host $host;<br> proxy_set_header X-Real-IP $remote_addr;<br> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br> proxy_pass <a href="http://humangov-python-app-service-california:8000/">http://humangov-python-app-service-california:8000</a>; # App container<br> }<br> }<br> }<br> <br> proxy_params: |<br> proxy_set_header Host $host;<br> proxy_set_header X-Real-IP $remote_addr;<br> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</p><p>Apply:</p><p>kubectl apply -f humangov-california.yaml</p><p>kubectl apply -f humangov-florida.yaml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*l4WRpDr6iu-wkxmzkQVrHg.png" /></figure><h3>Part 4: Ingress and ALB Setup with SSL</h3><ol><li><strong>Create a new Route 53 domain (use suffix click for cheapest domain)</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ss8eWJ4Yjhfl7MgFTdu6Nw.png" /></figure><p><strong>2. Create a Certificate for the ALB</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yE0dyO9pfvDNrFO_Ndr_nw.png" /></figure><p><strong>3. Validate the domain</strong></p><p>create records in Route 53:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SdDIUNuo2CXiVLGQYt-vZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aIqTPNS1LaYBCafKVtx8_A.png" /></figure><p>4. <strong>Deploy the Ingress Rules</strong></p><p>Create a yaml file: humangov-ingress-all.yaml</p><p>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br> name: humangov-python-app-ingress<br> annotations:<br> alb.ingress.kubernetes.io/scheme: internet-facing<br> alb.ingress.kubernetes.io/target-type: ip<br> alb.ingress.kubernetes.io/group.name: frontend<br> alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-east-1:xxxxxxxxxxx:certificate/xxxxxxxxxxx<br> alb.ingress.kubernetes.io/listen-ports: ‘[{“HTTP”: 80}, {“HTTPS”:443}]’<br> alb.ingress.kubernetes.io/ssl-redirect: ‘443’<br> labels:<br> app: humangov-python-app-ingress<br>spec:<br> ingressClassName: alb<br> rules:<br> — host: california.humangov.click<br> http:<br> paths:<br> — path: /<br> pathType: Prefix<br> backend:<br> service:<br> name: humangov-nginx-service-california<br> port:<br> number: 80</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*7vNw3qaPKmO07yezPbUNIA.png" /></figure><p><strong>5. Apply the ingress:</strong></p><p>kubectl apply -f humangov-ingress-all.yaml</p><p>Verify the ingress: kubectl get ingress</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*HM0metkjhNfEEFna5U9CAA.png" /></figure><p>Load balancer created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yBJFJDmiASwafCMr42mQKg.png" /></figure><p>6.<strong> Create an alias entry</strong> (Record Type: A) on Route 53 point the subdomain to the ALB domain. Example: california.humangovrh.click → dualstack.k8s-frontend-ded5adda2e-875432214.us-east-1.elb.amazonaws.com</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T3CiBJawYjXB1sj7Td9D7g.png" /></figure><p>7. Test the application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GrDNw7qjG2_0Wtcl7ltJ4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0jUKrEQrKejjmg9EAlPRQg.png" /></figure><h3>Part 5: Deploy the application for HumanGov Florida in the same cluster.</h3><ol><li><strong>Update terraform file — add florida:</strong></li></ol><p>human-gov-infrastructure/terraform/variables.tf</p><p>variable “states” {<br> description = “The list of state names”<br> default = [“california”,”florida”]<br>}</p><p>Apply the Terraform configuration</p><p>cd /home/ec2-user/environment/human-gov-infrastructure/terraform<br>terraform plan<br>terraform apply</p><p><strong>2. Create a Kubernetes deployment file for florida — </strong>humangov-florida.yaml</p><p>Deploy the HumanGov Florida application</p><p>kubectl apply -f humangov-florida.yaml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*WUNsP5HAVM5yg4vrpIbTOg.png" /></figure><p><strong>3. Update in ingress file — add rule for Florida:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*MqckUpDOApBYzGd056FNVg.png" /></figure><p>Apply the ingress changes:</p><p>kubectl apply -f humangov-ingress-all.yaml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P6bvD4u3OJH2N868DlP4xw.png" /></figure><p><strong>4. Add the Route 53 DNS entry for the Florida state</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AAHLlBlNOtfPRYeb1uDsUQ.png" /></figure><p><strong>5. Test the application for Florida</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BqadBrBGjdgxxvPbWr-1pA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acb7d8bca160" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>