<?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 Mohammed Saad on Medium]]></title>
        <description><![CDATA[Stories by Mohammed Saad on Medium]]></description>
        <link>https://medium.com/@msaad_86696?source=rss-cc428ab18c9a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*b4y1SmPae03Svjn5wZxCcg.png</url>
            <title>Stories by Mohammed Saad on Medium</title>
            <link>https://medium.com/@msaad_86696?source=rss-cc428ab18c9a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 14:43:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@msaad_86696/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[Guardrails before apply: what my IaC starter kit caught that code review wouldn’t]]></title>
            <link>https://medium.com/@msaad_86696/guardrails-before-apply-what-my-iac-starter-kit-caught-that-code-review-wouldnt-edc8a9877dd2?source=rss-cc428ab18c9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/edc8a9877dd2</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[site-reliability-engineer]]></category>
            <category><![CDATA[ai-infrastructure]]></category>
            <dc:creator><![CDATA[Mohammed Saad]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 02:05:40 GMT</pubDate>
            <atom:updated>2026-11-13T02:05:40.451Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQe5-61wJY0CJfcFpU82_Q.png" /></figure><p>Most teams don’t start infrastructure as code on a blank page. Some have nothing yet. Others have years of resources clicked together in the console. Either way, the expensive mistakes are the quiet ones: a GPU instance with no cost-centre tag, a bucket that’s one setting away from public, a second NAT gateway in dev that nobody needed.</p><p>I built an open-source starter kit for AWS that tries to catch those mistakes <strong>before </strong><strong>apply</strong>, for both kinds of team. It runs entirely on a laptop against a local AWS mock, so you can try all of it with no AWS account and no API key. CI runs the same way.</p><p>This article is about the guardrails, and the real bugs they caught while I was building the kit.</p><h3>The shape of the kit</h3><ul><li><strong>Five Terraform modules:</strong> tags, s3-bucket, network, budget and gpu-inference. They come with 23 terraform test cases that use mock providers, so the tests need no credentials.</li><li><strong>A Terragrunt live layout</strong> for dev and prod. The provider, default tags and state are defined once. Each unit only states what differs per environment. For example, the dev GPU group scales to zero outside 08:00–19:00 on weekdays, while prod keeps one on-demand instance always on.</li><li><strong>Policy as code on the plan.</strong> Five Kyverno policies read terraform show -json, so they check what will actually change, not what the HCL looks like:</li></ul><p>1) FinOps tags on every taggable resource;</p><p>2) S3 public access block;</p><p>3) IMDSv2 on launch templates and instances;</p><p>4) GPU spend limits;</p><p>5) at most one NAT gateway outside prod.</p><ul><li><strong>A brownfield path.</strong> Discover hand-made resources, import them with zero changes, then adopt them into the standard modules.</li></ul><h3>Guardrail 1: test the policies in both directions</h3><p>A policy that never fires looks exactly like a policy that passes. So CI checks both ways:</p><ul><li>all 8 dev and prod plans must pass every policy;</li><li>a deliberately bad plan must make <strong>every</strong> policy fail.</li></ul><p>That second check earned its place. At one point kyverno apply &lt;dir&gt; loaded <strong>zero</strong> policies, because the directory also held test fixtures, and the run still looked clean. The check script now passes the policy files explicitly, and it fails unless the number of passes equals the number of policies.</p><h3>Guardrail 2: policies catch what modules forget</h3><p>The require-finops-tags policy failed my own dev and prod plans. The reason: the provider&#39;s default_tags don&#39;t reach Auto Scaling group tags or launch template tag_specifications. Every GPU instance would have launched with no cost-center, which is exactly the spend you most want to attribute.</p><p>The module now merges data.aws_default_tags into both. No reviewer reading the HCL would have spotted this. The plan JSON showed it.</p><h3>Guardrail 3: module tests catch silent string bugs</h3><p>In the budget module, &quot;user:cost-center$${var.cost_center}&quot; escapes the interpolation. The Cost Explorer filter would have been the literal text ${var.cost_center}: a budget that never matches anything and never alerts. A terraform test assertion caught it, and the module now uses format().</p><h3>Brownfield, measured</h3><p>scripts/brownfield-demo.sh seeds the mock with a small &quot;ClickOps&quot; estate: a bucket, a VPC, a subnet, and a security group with port 443 open to the world. Then:</p><ol><li>A discovery script writes <strong>4 import blocks</strong>, skipping the default VPC and the default security groups.</li><li>Terraform’s generated config is reviewed and planned: <strong>4 to import, 0 to add, 0 to change, 0 to destroy</strong>. Adoption that changes nothing is the whole point.</li><li>The bucket is adopted into the hardened s3-bucket module: <strong>1 to import, 6 to add, 1 to change, 0 to destroy</strong>. The 6 additions are the hardening it was missing, and the change is the FinOps tags.</li></ol><p>The script fails if either summary changes, and CI runs it on every push.</p><p>Two lessons from this part:</p><ul><li><strong>Terraform rejected its own generated config.</strong> -generate-config-out produced a file that failed to plan with five errors. Generated config needs a human review step, so the kit keeps the raw file next to the reviewed one.</li><li><strong>Bulk export is noisy.</strong> Terraformer, run on the same estate, exported 14 resources instead of 4: the default VPC, its 6 subnets and 2 default security groups came along, with names like tfer--subnet-1bf5f134aebbf7561.</li></ul><h3>The mock tried to call real AWS</h3><p>This is my favourite failure, because it’s the one that matters most for a “safe to try locally” kit. AWS provider 6.x reads bucket tags through <strong>S3 Control</strong>, which had no endpoint override. One apply against the mock sent requests with fake keys to the real service. They got a 403 and nothing was created, but it should never have happened.</p><p>The fix is defence in depth:</p><ul><li>override s3control too;</li><li>set AWS_ENDPOINT_URL as a catch-all;</li><li>make the brownfield seed script refuse to run against any endpoint that isn’t local.</li></ul><h3>Moto vs the new AWS Emulator</h3><p>In November 2026 AWS released AWS Emulator, a free local emulator. I trialled it as a second target on the same machine, the same day:</p><ul><li><strong>CI steps:</strong> every step the kit runs in CI passed on both (plans, policy checks, brownfield demo).</li><li><strong>Apply round trip:</strong> the emulator was cleaner. It showed <strong>no drift</strong> on the 30 resources it created; Moto drifted on 2. The budget unit created in 10 s, where Moto hung for over 8 minutes on a call it doesn’t implement.</li><li><strong>Missing calls:</strong> the emulator didn’t yet implement Auto Scaling scheduled actions or Cost Explorer tag reads, so the dev GPU schedules and the prod budget with anomaly detection failed.</li></ul><p>My decision: keep Moto as the CI default, add the emulator as an optional local target, and re-check on each release. Measure before you switch.</p><h3>What I’d tell a team adopting IaC</h3><ol><li><strong>Check the plan, not the code.</strong> Plan JSON shows what will really change, including what defaults and providers quietly leave out.</li><li><strong>Test that your policies can fail.</strong> A guardrail that never fires gives you false confidence.</li><li><strong>Import first, improve second.</strong> Zero-change adoption builds trust. Hardening then shows up as a small, reviewable diff.</li><li><strong>Make “local” truly local.</strong> Mocks are great until one SDK call slips past your endpoint overrides.</li></ol><h3>Limitations</h3><ul><li>It’s AWS only.</li><li>There are no cost estimates in pull requests: Infracost needs an account, and the kit runs with none.</li><li>Plans and the brownfield demo run against local mocks, which aren’t AWS. Apply in a sandbox account before trusting a module in production.</li></ul><p>Code, tests and docs: <a href="https://github.com/msaad7777/iac-starter-kit">github.com/msaad7777/iac-starter-kit</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edc8a9877dd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Master DevOps Project 4 : Effortless Database Migrations in Production with Cloud Run Jobs and…]]></title>
            <link>https://medium.com/@msaad_86696/master-devops-project-4-effortless-database-migrations-in-production-with-cloud-run-jobs-and-061d13d374a7?source=rss-cc428ab18c9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/061d13d374a7</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[database-migration]]></category>
            <dc:creator><![CDATA[Mohammed Saad]]></dc:creator>
            <pubDate>Thu, 24 Apr 2025 21:40:25 GMT</pubDate>
            <atom:updated>2025-04-28T14:15:03.511Z</atom:updated>
            <content:encoded><![CDATA[<h3>Master DevOps Project 4 : Database Migrations in Production with Cloud Run Jobs and Alembic</h3><p><strong>Introduction</strong></p><p>Database schema migrations are a critical part of modern application development. However, running these migrations safely in production without manual overhead or local access can be challenging. In this guide, we’ll explore how to use <strong>Cloud Run Jobs</strong> to execute <strong>Alembic</strong> migrations automatically as part of a CI/CD pipeline in <strong>Google Cloud Platform (GCP)</strong>. This method ensures secure, repeatable, and infrastructure-compliant migrations that align with the <strong>12-Factor App methodology</strong>.</p><h3>Why Use Cloud Run Jobs for Database Migrations?</h3><p>Previously, GCP users relied on local execution or embedding migrations into deployment flows, which posed risks and limitations. With <strong>Cloud Run Jobs</strong>, we can:</p><ul><li>Run one-off admin tasks (Factor 12: Admin Processes)</li><li>Reuse the same container image from Cloud Run Services</li><li>Access secrets securely through Secret Manager</li><li>Use private IPs for secure database connections</li><li>Avoid long-running processes on services intended for web traffic</li></ul><p><strong>Reference:</strong> Cloud Run and the Twelve-Factor App</p><h3>Step-by-Step Guide</h3><h3>1. Prepare Alembic Setup</h3><p>Ensure your project has the following:</p><ul><li>alembic.ini</li><li>alembic/ directory with migration scripts</li><li>migrate.sh with retry logic:</li></ul><pre>#!/bin/bash<br>set -e<br><br>echo &quot;🔄 Starting Alembic migrations...&quot;<br>cd /code || exit 1<br>ls -al<br><br>for i in {1..5}; do<br>  alembic upgrade head &amp;&amp; echo &quot;✅ Migrations complete.&quot; &amp;&amp; exit 0 || echo &quot;⏳ Retry $i/5...&quot; &amp;&amp; sleep 5<br>done<br><br>echo &quot;❌ Migration failed.&quot; &amp;&amp; exit 1</pre><h3>2. Dockerfile Changes</h3><p>Ensure your Dockerfile includes:</p><pre>COPY alembic.ini .<br>COPY ./alembic ./alembic<br>COPY migrate.sh /app/migrate.sh<br>RUN chmod +x /app/migrate.sh</pre><h3>3. Cloud Build Integration</h3><p>In your cloudbuild.yaml, add steps:</p><pre># Deploy service<br>- name: &#39;gcr.io/google.com/cloudsdktool/cloud-sdk&#39;<br>  args: [..., &#39;--set-secrets&#39;, &#39;ENVIRONMENT=ENVIRONMENT:latest,...&#39;]<br><br># Update job<br>- name: &#39;gcr.io/google.com/cloudsdktool/cloud-sdk&#39;<br>  args:<br>    - &#39;beta&#39;<br>    - &#39;run&#39;<br>    - &#39;jobs&#39;<br>    - &#39;update&#39;<br>    - &#39;migrate-database&#39;<br>    - &#39;--image=us-central1-docker.pkg.dev/...:latest&#39;<br>    - &#39;--region=us-central1&#39;<br>    - &#39;--vpc-connector=cloudbuild-vpc&#39;<br>    - &#39;--set-cloudsql-instances=$PROJECT_ID:us-central1:your-db&#39;<br>    - &#39;--set-secrets=...&#39;<br><br># Execute job<br>- name: &#39;gcr.io/google.com/cloudsdktool/cloud-sdk&#39;<br>  args:<br>    - &#39;beta&#39;<br>    - &#39;run&#39;<br>    - &#39;jobs&#39;<br>    - &#39;execute&#39;<br>    - &#39;migrate-database&#39;<br>    - &#39;--region=us-central1&#39;<br>    - &#39;--wait&#39;</pre><h3>4. Firewall Rules for Private IP Access</h3><p>Create required ingress rules:</p><pre>gcloud compute firewall-rules create allow-google-serverless-to-vpc-connector \<br>  --direction=INGRESS \<br>  --priority=1000 \<br>  --network=default \<br>  --action=ALLOW \<br>  --rules=tcp,udp,icmp \<br>  --source-ranges=35.199.224.0/19,35.191.0.0/16,... \<br>  --target-tags=cloudbuild-vpc</pre><h3>5. IAM Permissions</h3><p>Ensure your Cloud Run job’s service account has:</p><ul><li>Artifact Registry Reader</li><li>Secret Manager Secret Accessor</li><li>Cloud SQL Client</li></ul><p>Use this to check:</p><pre>gcloud beta run jobs describe migrate-database --region=us-central1 --format=&quot;value(spec.template.spec.serviceAccountName)&quot;</pre><h3>Conclusion</h3><p>Cloud Run Jobs provide a secure and reliable way to handle database migrations in production. By decoupling migrations from deployments, you gain better control and repeatability, aligning with best DevOps and 12-Factor App practices.</p><p><strong>References:</strong></p><ul><li><a href="https://cloud.google.com/blog/topics/developers-practitioners/running-database-migrations-cloud-run-jobs/">Running database migrations with Cloud Run Jobs | Google Cloud Blog</a></li><li><a href="https://cloud.google.com/run/docs/create-jobs">Create jobs | Cloud Run Documentation | Google Cloud</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=061d13d374a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Database Migrations with CI/CD: Flyway, Cloud Build, and Cloud SQL]]></title>
            <link>https://medium.com/@msaad_86696/automating-database-migrations-with-ci-cd-flyway-cloud-build-and-cloud-sql-877492088690?source=rss-cc428ab18c9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/877492088690</guid>
            <category><![CDATA[database-migration]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[database-administration]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Mohammed Saad]]></dc:creator>
            <pubDate>Fri, 28 Feb 2025 15:11:12 GMT</pubDate>
            <atom:updated>2025-02-28T15:12:02.212Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering DevOps: Project 3 — CI/CD Pipeline for Database Migrations: Flyway, Cloud Build, and Cloud SQL</h3><h3>Introduction</h3><p>Continuous Integration and Continuous Deployment (CI/CD) isn’t just for application code — it’s also critical for managing database changes. In this guide, we’ll explore how to automate <strong>database migrations</strong> using <strong>Flyway, Cloud Build, and Cloud SQL</strong> in Google Cloud Platform (GCP).</p><p>By implementing an automated database migration pipeline, you ensure:</p><ul><li><strong>Version control</strong> for database schema changes.</li><li><strong>Seamless deployments</strong> without manual intervention.</li><li><strong>Consistency across environments</strong> (dev, staging, production).</li></ul><p>Let’s walk through the step-by-step process of setting up a <strong>CI/CD pipeline</strong> for database schema migrations.</p><h3>Why Use Flyway for Database Migrations?</h3><p>Flyway is an open-source database migration tool that allows developers to:</p><ul><li>Version control SQL scripts.</li><li>Apply schema changes in a predictable manner.</li><li>Rollback changes if necessary.</li></ul><p>With Flyway, we can manage database changes as code, ensuring an <strong>audit trail</strong> and repeatable deployments.</p><h3>Architecture Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*dsQtiQdblK4PKAR9-vchlQ.png" /><figcaption>Ref: <a href="https://www.youtube.com/watch?v=spCUBaRsQP4">https://www.youtube.com/watch?v=spCUBaRsQP4</a></figcaption></figure><p>Our CI/CD pipeline will consist of:</p><ol><li><strong>Cloud Build</strong>: The CI/CD engine that will execute Flyway migrations.</li><li><strong>Flyway</strong>: The database migration tool to apply schema changes.</li><li><strong>Cloud SQL</strong>: Our managed relational database (MySQL or PostgreSQL).</li><li><strong>Secret Manager</strong>: Securely storing database credentials.</li><li><strong>Cloud Storage (Optional)</strong>: Storing migration scripts externally.</li></ol><p><strong>Pipeline Workflow:</strong></p><ol><li>Developer pushes new migration scripts to a <strong>Git repository</strong>.</li><li>A <strong>Cloud Build trigger</strong> starts the pipeline.</li><li>Flyway runs migration scripts against the <strong>Cloud SQL database</strong>.</li><li>The updated schema is applied, ensuring database consistency.</li></ol><h3>Step 1: Setting Up Cloud SQL</h3><p>Before automating database migrations, we need a <strong>Cloud SQL instance</strong>.</p><h3>Create a Cloud SQL Instance</h3><p>Run the following command to create a MySQL instance:</p><pre>gcloud sql instances create my-database-instance \<br>  --database-version=MYSQL_8_0 \<br>  --tier=db-f1-micro \<br>  --region=us-central1</pre><h3>Create a Database in Cloud SQL</h3><pre>gcloud sql databases create my_database --instance=my-database-instance</pre><h3>Step 2: Store Credentials Securely in Secret Manager</h3><p>We don’t want to hardcode database passwords. Instead, we store them securely</p><pre>gcloud secrets create db_password --replication-policy=&quot;automatic&quot;<br>echo &quot;my_secure_password&quot; | gcloud secrets versions add db_password --data-file=-</pre><p>Grant Cloud Build access to read secrets:</p><pre>gcloud secrets add-iam-policy-binding db_password \<br>  --member=&quot;serviceAccount:$(gcloud projects describe $(gcloud config get-value project) --format=&#39;value(projectNumber)&#39;)@cloudbuild.gserviceaccount.com&quot; \<br>  --role=&quot;roles/secretmanager.secretAccessor&quot;</pre><h3>Step 3: Writing Migration Scripts</h3><p>Flyway migration scripts follow a naming convention:</p><pre>V&lt;version&gt;__&lt;description&gt;.sql</pre><p>Example:</p><pre>V1__create_users_table.sql<br>CREATE TABLE users (<br>    id INT PRIMARY KEY AUTO_INCREMENT,<br>    name VARCHAR(255) NOT NULL,<br>    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP<br>);</pre><p>Store these scripts in a migrations/ directory in your Git repository.</p><h3>Step 4: Configuring Cloud Build</h3><h3>Create a Cloud Build Configuration File (cloudbuild.yaml)</h3><pre>steps:<br>  - name: &#39;alpine&#39;<br>    id: &#39;Install Flyway&#39;<br>    entrypoint: &#39;sh&#39;<br>    args:<br>      - &#39;-c&#39;<br>      - |<br>        apk add --no-cache openjdk11 curl &amp;&amp; \<br>        curl -L https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/9.8.1/flyway-commandline-9.8.1-linux-x64.tar.gz -o flyway.tar.gz &amp;&amp; \<br>        tar -xzf flyway.tar.gz &amp;&amp; \<br>        mv flyway-9.8.1 /flyway<br><br>  - name: &#39;/flyway/flyway&#39;<br>    id: &#39;Run Flyway Migrations&#39;<br>    args:<br>      - &#39;-url=jdbc:mysql://${_DB_HOST}:3306/my_database&#39;<br>      - &#39;-user=flyway&#39;<br>      - &#39;-password=${_DB_PASSWORD}&#39;<br>      - &#39;-locations=filesystem:/workspace/migrations&#39;<br>      - &#39;migrate&#39;<br>    secretEnv: [&#39;_DB_PASSWORD&#39;]<br><br>availableSecrets:<br>  secretManager:<br>    - versionName: projects/YOUR_PROJECT_ID/secrets/db_password/versions/latest<br>      env: &#39;_DB_PASSWORD&#39;<br><br>options:<br>  logging: CLOUD_LOGGING_ONLY<br><br>substitutions:<br>  _DB_HOST: &quot;your_cloud_sql_public_ip&quot;</pre><h3>Step 5: Creating a Cloud Build Trigger</h3><p>A Cloud Build trigger will <strong>automate migrations</strong> when new scripts are pushed.</p><p>Run:</p><pre>gcloud builds triggers create github \<br>  --name=db-migration-trigger \<br>  --repo-name=your-repo-name \<br>  --branch-pattern=main \<br>  --build-config=cloudbuild.yaml</pre><h3>Step 6: Deploying and Testing</h3><p>To manually trigger a migration:</p><pre>gcloud builds submit --config=cloudbuild.yaml</pre><p>Check logs in <strong>Cloud Build → Build History</strong> to verify execution.</p><h3>Conclusion</h3><p>By integrating <strong>Flyway, Cloud Build, and Cloud SQL</strong>, we have created an automated CI/CD pipeline for database migrations.</p><p>This approach:</p><p>✔ Ensures <strong>schema consistency</strong> across environments.</p><p>✔ Eliminates <strong>manual migration errors</strong>.</p><p>✔ Provides <strong>auditability and version control</strong> for database changes.</p><p>This setup can be extended further by adding <strong>rollback mechanisms, scheduled migrations, or automated testing</strong> before applying changes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=877492088690" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Mastering DevOps: Project 2— Multi-Cluster Ingress Deployment in GKE with CI/CD”]]></title>
            <link>https://medium.com/@msaad_86696/mastering-multi-cluster-ingress-deployment-in-gke-with-ci-cd-a-complete-gcp-project-a6ae56ba09a5?source=rss-cc428ab18c9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6ae56ba09a5</guid>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Mohammed Saad]]></dc:creator>
            <pubDate>Wed, 03 Jul 2024 17:18:18 GMT</pubDate>
            <atom:updated>2024-10-14T17:21:58.341Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong> In today’s cloud-native landscape, orchestrating deployments across multiple Kubernetes clusters poses unique challenges for development teams. Google Kubernetes Engine (GKE) offers a robust solution for managing containerized workloads, while Cloud Build simplifies the CI/CD process.</p><p>In this comprehensive guide, we’ll delve into setting up a seamless CI/CD pipeline for multi-cluster deployment in GKE, optimizing your workflow for efficiency and reliability. Throughout this guide, we’ll cover key aspects of multi-cluster deployment, including setting up GKE clusters in different regions, configuring Cloud Build for automated builds and deployments, and addressing common challenges such as setting up Google Certificate Manager for secure communication across clusters. Whether you’re a seasoned DevOps engineer or new to cloud-native development, this guide will provide valuable insights and practical tips for mastering multi-cluster deployment with GKE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lh2mYK0qVIojelyW23Rnaw.png" /></figure><p><strong>Project Description:</strong></p><p>Our project aims to establish a robust CI/CD pipeline for orchestrating deployments across multiple Kubernetes clusters using Google Kubernetes Engine (GKE), while leveraging the power of Cloud Build, Artifact Registry, and GitHub. The primary objective is to streamline the software delivery process, enabling rapid, reliable, and automated deployments of cloud-native applications.</p><p><strong>Overview of the technology stack:</strong></p><ul><li><strong>Google Kubernetes Engine (GKE):</strong> GKE provides a managed Kubernetes service that simplifies the deployment, management, and scaling of containerized applications. With GKE, we can create and manage Kubernetes clusters in various regions to distribute workloads geographically and improve application availability.</li><li><strong>Cloud Build:</strong> Cloud Build is Google Cloud Platform’s native CI/CD platform that automates the build, test, and deployment process. It integrates seamlessly with other Google Cloud services, allowing us to define build configurations, trigger builds based on code changes, and deploy applications to GKE clusters.</li><li><strong>Artifact Registry:</strong> Artifact Registry is a managed service for storing, managing, and securing artifacts such as Docker container images and Maven/Gradle packages. By using Artifact Registry, we can store our Docker images securely and efficiently, ensuring reliable access during the deployment process.</li><li><strong>GitHub: </strong>GitHub is a widely-used platform for hosting Git repositories and collaborating on software development projects. We’ll leverage GitHub to host our application code, manage version control, and trigger CI/CD pipelines using webhooks or GitHub Actions.</li></ul><p>Importance of efficient deployment strategies in modern software development: Efficient deployment strategies are crucial in modern software development for several reasons:</p><ol><li><strong>Speed: </strong>Rapid deployment enables faster time-to-market, allowing organizations to respond quickly to customer needs and market demands.</li><li><strong>Reliability: </strong>Automated deployments reduce the risk of human error and ensure consistent deployment practices, leading to greater reliability and stability of applications.</li><li><strong>Scalability: </strong>CI/CD pipelines facilitate the scaling of infrastructure and applications, enabling organizations to handle increasing workloads and user demand without manual intervention.</li><li><strong>Security: </strong>Automated testing and deployment processes help identify and address security vulnerabilities early in the development cycle, improving overall application security.</li><li><strong>Cost-effectiveness: B</strong>y automating repetitive tasks and optimizing resource utilization, efficient deployment strategies can reduce operational costs and increase resource efficiency.</li></ol><p>In summary, our project aims to leverage GKE, Cloud Build, Artifact Registry, and GitHub to establish a comprehensive CI/CD pipeline that addresses the challenges of multi-cluster deployment in a cloud-native environment. By adopting efficient deployment strategies, we can enhance the speed, reliability, scalability, security, and cost-effectiveness of our software delivery process.</p><p><strong>Before creating clusters, enable following APIs:</strong></p><p>To enable standalone pricing, perform the following steps:</p><ol><li>Confirm that the GKE Enterprise API is disabled in your project:</li></ol><pre>gcloud services list --project=PROJECT_ID | grep anthos.googleapis.co</pre><ol><li>Replace PROJECT_ID with the project ID where your GKE clusters are running.</li><li>If the output is an empty response, the GKE Enterprise API is disabled in your project and any Multi Cluster Ingress resources are billed using standalone pricing.</li><li>Enable the required APIs in your project:</li></ol><pre>gcloud services enable \<br>    multiclusteringress.googleapis.com \<br>    gkehub.googleapis.com \<br>    container.googleapis.com \<br>    multiclusterservicediscovery.googleapis.com \<br>    --project=PROJECT_ID</pre><h3><strong>Setting Up GKE Clusters with Multi cluster Ingress:</strong></h3><p>Setting up Google Kubernetes Engine (GKE) clusters is the first step in our multi-cluster deployment project. Here’s a detailed guide on how to create GKE clusters in different regions (US, Europe, Asia), configure settings, allocate resources, and establish context in Cloud Shell for seamless interaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BiAtHQQ0-QVJx0rTxwzB8A.png" /></figure><p>select standard cluster, for having more control over configuration management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aRkXjLEKuEixaRrB-Y0xsg.png" /></figure><p>select regional as the cluster type and register cluster to the same feet for all three clusters.</p><p>make sure to select the disk type we want to setup in configuration, I chose standard disk type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zzQqxrERwA2ZyQL2RhQRPw.png" /></figure><p>Now specify the max number of pods in each node :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z705TAmm-8byx14ig0JhOA.png" /></figure><p>I have created a separate service account for GKE :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oSP4bJoOlQes52bYElVH8A.png" /></figure><p>use the same VPC network were other servies like cloud sql, redis or any other service used by the application is registered in :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vRv8Ky-9TsfzwvSLPeWdVQ.png" /></figure><p>and repeat the same for other regions :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQKmsSRRl3doErTec_Nzog.png" /></figure><p>register all the clusters to same fleet.</p><p>Also you might have to request qouta to be increased in each region, to get high vCPUs and memory. I have chosen random zones in each region.</p><p><strong>Establishing Context in Cloud Shell:</strong></p><ul><li>Once the clusters are created, establish context in Cloud Shell to interact with each cluster seamlessly.</li><li>Use the gcloud container clusters get-credentials command to set the context for each cluster, specifying the cluster name and region.</li><li>For example:</li></ul><pre>gcloud container clusters get-credentials us-cluster --region=us-central1 <br>gcloud container clusters get-credentials europe-cluster --region=europe-west2 <br>gcloud container clusters get-credentials asia-cluster --region=asia-southeast1</pre><ul><li>This allows you to switch between clusters easily using kubectl commands without the need for repeated authentication.</li></ul><p><strong>Rename the cluster contexts:</strong> This allows us to switch between clusters directly from cloudshell.</p><pre>kubectl config rename-context gke_PROJECT_ID_us-central1_gke-us gke-us<br>kubectl config rename-context gke_PROJECT_ID_europe-west1_gke-eu gke-eu<br>kubectl config rename-context gke_PROJECT_ID_asia-southest1_gke-asia gke-asia</pre><p>If you haven’t already registers clusters to a fleet, you can do so now by following these steps:</p><p><strong>Note:</strong> If you have chosen to enable the entire GKE Enterprise platform, you can also register clusters from the GKE Enterprise pages in the Google Cloud console. Learn more in <a href="https://cloud.google.com/anthos/fleet-management/docs/register/gke#console">Register a GKE cluster to your fleet</a>.</p><p><strong>Register your clusters:</strong></p><pre>gcloud container fleet memberships register gke-us \<br>    --gke-cluster us-central1/gke-us \<br>    --enable-workload-identity \<br>    --project=PROJECT_ID</pre><pre>gcloud container fleet memberships register gke-eu \<br>    --gke-cluster europe-west1/gke-eu \<br>    --enable-workload-identity \<br>    --project=PROJECT_ID</pre><pre>gcloud container fleet memberships register gke-asia \<br>    --gke-cluster asia-southeast1/gke-asia \<br>    --enable-workload-identity \<br>    --project=PROJECT_ID</pre><p>Confirm that your clusters have successfully been registered to the fleet:</p><pre>gcloud container fleet memberships list --project=PROJECT_ID</pre><p>The output is similar to the following:</p><pre>NAME                                  EXTERNAL_ID <br>gke-us                                0115c158-11af-141a-gfe9-42sdsadss141 <br>gke-eu                                d1274b54-11ad-141a-gf6-42sdsadsds11<br>gke-asia                              e1324b14-11ad-141a-gf6-42dsdsdsds24</pre><p><strong>Specify a config cluster:</strong></p><p>The config cluster is a GKE cluster you choose to be the central point of control for Ingress across the member clusters. This cluster must already be registered to the fleet. For more information, see <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/multi-cluster-ingress#config_cluster_design">Config cluster design</a>.</p><p>Enable Multi Cluster Ingress and select gke-us as the config cluster, you choose any cluster as config cluster.</p><pre>gcloud container fleet ingress enable \<br>    --config-membership=gke-us \<br>    --location=us-central1 \<br>    --project=PROJECT_ID</pre><p>The config cluster takes up to 15 minutes to register. Successful output is similar to the following:</p><pre>Waiting for Feature to be created...done.<br>Waiting for controller to start...done.</pre><h3><strong>Deploying Ingress across clusters:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*95RY3QBdYpGjmEATvMU07g.png" /></figure><p>Before we deploy ingress we need to have deployments in each cluster already deployed. This sample deployment uses following services:</p><ol><li>Nodejs app</li><li>python monitroing app</li><li>redis</li><li>postgres</li><li>External Postgres — Cloud SQL</li><li>AWS S3</li></ol><p>Before we start setting up front end config, backend config, and certificates for the domain, deployment files should be ready to deploy and should be deployed in each cluster already.</p><p>Also before applying the deployments, we should have dockerfiles ready for nodejs app and python script seperately. Following are the list of files needed prior to applying any manifests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*x-Q2i4MOR7d0RIfVCZ6uAg.png" /></figure><p>I assume local testing with minikube and docker-desktop is already done, to make sure the deployment files, and docker images are building up correctly and the application is running the way it should.</p><p>I wanted my aisa cluster to have an application that will respond differently just based on env files, so for better ineratcion and smooth deployments, i have created three seperate deployment files, and seperate secret files in each case, as below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*I8M3Wu15los8oiXxIDIGpg.png" /></figure><p>These are the files that are generally required, we are using google managed certificates, to allow both http and https traffic for the domain configured through Cloud Domains in GCP.</p><p>Lets look into deployment file for our main nodejs app:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: app-name<br>  namespace: namespace-name<br>spec:<br>  replicas: 30<br>  selector:<br>    matchLabels:<br>      app: app-name<br>  template:<br>    metadata:<br>      labels:<br>        app: app-name<br>    spec:<br>      containers:<br>        - name: app-name<br>          image: asia.gcr.io/&lt;project-ID&gt;/&lt;app-name&gt;:latest<br>          imagePullPolicy: IfNotPresent<br>          ports:<br>            - containerPort: 3000<br>          resources:<br>            requests:<br>              cpu: 350m<br>              memory: 250Mi<br>            limits:<br>              cpu: 700m<br>              memory: 1600Mi<br>          envFrom:<br>            - secretRef:<br>                name: all-secrets<br>          env:<br>            - name: Key<br>              value: &#39;value&#39;<br>---<br>apiVersion: autoscaling/v2<br>kind: HorizontalPodAutoscaler<br>metadata:<br>  name: app-name<br>  namespace: namespace-name<br>spec:<br>  scaleTargetRef:<br>    apiVersion: apps/v1<br>    kind: Deployment<br>    name: app-name<br>  minReplicas: 30<br>  maxReplicas: 35<br>  metrics:<br>    - type: Resource<br>      resource:<br>        name: cpu<br>        target:<br>          type: Utilization<br>          averageUtilization: 85</pre><p>here env variables, application name and other variables can be adjusted based on needs.</p><p>Similar to this, one can have redis, python app and postgres service and deployment files.</p><p>Now lets me move to the most important files for setting up multi-cluster ingress and multi-cluster service</p><p><strong>multi-cluster service</strong> file should be setup in the config cluster, which in my case is us , service configures the backend for GKE deployment and ingress configures frontend.</p><pre>apiVersion: networking.gke.io/v1<br>kind: MultiClusterService<br>metadata:<br>  name: app-name<br>  namespace: namespace-name<br>  annotations:<br>    networking.gke.io/app-protocols: &#39;{&quot;https&quot;:&quot;HTTPS&quot;}&#39;<br>    cloud.google.com/backend-config: &#39;{&quot;ports&quot;: {&quot;3000&quot;:&quot;backend-health-check&quot;}}&#39;<br>spec:<br>  template:<br>    spec:<br>      selector:<br>        app: app-name<br>      ports:<br>        - name: http<br>          protocol: TCP<br>          port: 3000<br>          targetPort: 3000</pre><p><strong>multi-cluster-ingress:</strong></p><pre>apiVersion: networking.gke.io/v1<br>kind: MultiClusterIngress<br>metadata:<br>  name: app-name<br>  namespace: namespace-name<br>  annotations:<br>    networking.gke.io/static-ip: &lt;static-Ip-address&gt;<br>    kubernetes.io/ingress.class: &#39;gce&#39;<br>    kubernetes.io/ingress.allow-http: &#39;true&#39;<br>    networking.gke.io/pre-shared-certs: &#39;certificate-name&#39;<br>spec:<br>  template:<br>    spec:<br>      backend:<br>        serviceName: app-name<br>        servicePort: 3000<br>      rules:<br>        - host: &lt;domain-name&gt;<br>          http:<br>            paths:<br>              - path: /*<br>                backend:<br>                  serviceName: app-name<br>                  servicePort: 3000</pre><p>here replace static-ip address with the already provisioned ip from cloud dns, and also assign certificate name, this will be tricky, and might need few trials, as one want to use existing certificate or a new google managed certificate based on preference, last replace domain-name with existing domain or subdomain name from cloud domains if present in gcp.</p><p>Other yaml files that can be added here backendconfig, frontendconfig, network policy, pvc, and storage-class. But as it will increase the post content, i recommend to use standard taml file from kubernetes documentation if required.</p><p>I am using ENV variables and env files to provide AWS service account information, and gcp cloud sql user name and password , etc., which is straightforward.</p><p><strong>Following is the article which will talk about CI/CD:</strong></p><p>Will be updating this story , with more data shortly.</p><p><strong>Reference :</strong></p><p><strong>Setting up Multi-cluster Ingress:</strong></p><p><a href="https://cloud.google.com/kubernetes-engine/docs/how-to/multi-cluster-ingress-setup">Setting up Multi Cluster Ingress | Google Kubernetes Engine (GKE) | Google Cloud</a></p><p><strong>Using Managed certificate:</strong></p><p><a href="https://cloud.google.com/kubernetes-engine/docs/how-to/managed-certs">Using Google-managed SSL certificates | Google Kubernetes Engine (GKE) | Google Cloud</a></p><p><strong>Kuberenets Ingress:</strong></p><p><a href="https://kubernetes.io/docs/concepts/services-networking/ingress/">Ingress</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6ae56ba09a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform to AutoScale and Load Balance Compute Engine instances in GCP]]></title>
            <link>https://awstip.com/terraform-to-autoscale-and-load-balance-compute-engine-instances-in-gcp-4b5d6f1bb4ff?source=rss-cc428ab18c9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b5d6f1bb4ff</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[compute-engine]]></category>
            <category><![CDATA[autoscaling]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Mohammed Saad]]></dc:creator>
            <pubDate>Sat, 30 Mar 2024 04:58:40 GMT</pubDate>
            <atom:updated>2024-04-01T17:21:08.296Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong></p><p>In today’s dynamic cloud environments, the ability to automatically scale resources based on demand and efficiently distribute incoming traffic is essential for ensuring optimal performance and cost-effectiveness. Google Cloud Platform (GCP) offers powerful tools for achieving this, and Terraform provides a convenient way to automate the configuration of infrastructure resources. In this article, we’ll explore how to leverage Terraform to set up autoscaling and load balancing for Compute Engine instances in GCP.</p><p><strong>1. Understanding Autoscaling and Load Balancing:</strong></p><p>Autoscaling allows your infrastructure to automatically adjust the number of Compute Engine instances based on criteria such as CPU utilization or request rate. This ensures that your applications can handle varying workloads efficiently without over-provisioning resources.</p><p>Load balancing distributes incoming traffic across multiple instances to ensure high availability and prevent any single instance from becoming a bottleneck. This improves the performance and reliability of your applications by evenly distributing the workload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XikgBUgAWcgqTbh6d2Jfng.png" /></figure><p>2. Setting Up Autoscaling and Load Balancing with Terraform:</p><p><strong>a. </strong>Create a Service Account:</p><ul><li>Navigate to IAM &amp; Admin &gt; Service Accounts in the Google Cloud Console.</li><li>Create a new service account with the necessary permissions, such as Project Owner.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*L1eYTJiwZ4lqV_K1nrFUeA.png" /></figure><p>and copy the account email created :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zinj7Uyj314dxDJELv-oJg.png" /></figure><p>then ssh into the terraform instance.</p><pre>Log in to the Host Instance and Ensure Terraform Is Installed<br><br>From Google Cloud navigation, choose Compute Engine &gt; VM instances.<br><br>Click SSH next to terraform-instance.<br><br>Use root privileges:<br><br>sudo -i<br>Change into the root directory:<br><br>cd /<br>Input the path to communicate with Terraform into the /etc/profile file:<br><br>echo &quot;PATH=&#39;$PATH:/downloads/&#39;&quot; &gt;&gt; /etc/profile<br>Run the following in order to be able to call Terraform:<br><br>source /etc/profile<br>Call Terraform:<br><br>terraform</pre><p>b. Install Terraform and Configure Environment:</p><ul><li>Access the host instance via Compute Engine.</li><li>Ensure Terraform is installed and configured correctly to interact with GCP.</li></ul><p>c. Generate Service Account Key:</p><ul><li>Use the Google Cloud SDK to authenticate with GCP and generate a service account key if not created as shown previously.</li></ul><pre>Create a Service Account Key within the Instance<br><br>Allow the SDK to communicate with GCP:<br><br>gcloud auth login<br>Enter Y at the prompt.<br><br>Click on the link in the output.<br><br>Select the Cloud Student account.<br><br>Click Allow.<br><br>Copy the code provided.<br><br>Paste the code into the terminal</pre><pre>gcloud iam service-accounts keys create /downloads/auto-scaling.json --iam-account &lt;SERVICE_ACCOUNT_EMAIL&gt;</pre><p><em>d. Write Terraform Configuration:</em></p><ul><li>Create a main.tf file containing the Terraform configuration for autoscaling and load balancing.</li><li>Paste in the following, replacing all instances of &lt;PROJECT_NAME&gt; with your project name, which can be found in the top navigation bar of the Google Cloud console:</li></ul><pre>provider &quot;google&quot; {<br>  version = &quot;3.20.0&quot;<br><br>  credentials = file(&quot;/downloads/auto-scaling.json&quot;)<br><br>  project = &quot;&lt;PROJECT_NAME&gt;&quot;<br>  region  = &quot;us-central1&quot;<br>  zone    = &quot;us-central1-c&quot;<br>}<br><br>resource &quot;google_compute_network&quot; &quot;vpc_network&quot; {<br>  name = &quot;new-terraform-network&quot;<br>}<br>resource &quot;google_compute_autoscaler&quot; &quot;foobar&quot; {<br>  name   = &quot;my-autoscaler&quot;<br>  project = &quot;&lt;PROJECT_NAME&gt;&quot;<br>  zone   = &quot;us-central1-c&quot;<br>  target = google_compute_instance_group_manager.foobar.self_link<br><br>  autoscaling_policy {<br>    max_replicas    = 5<br>    min_replicas    = 2<br>    cooldown_period = 60<br><br>    cpu_utilization {<br>      target = 0.5<br>    }<br>  }<br>}<br><br>resource &quot;google_compute_instance_template&quot; &quot;foobar&quot; {<br>  name           = &quot;my-instance-template&quot;<br>  machine_type   = &quot;n1-standard-1&quot;<br>  can_ip_forward = false<br>  project = &quot;&lt;PROJECT_NAME&gt;&quot;<br>  tags = [&quot;foo&quot;, &quot;bar&quot;, &quot;allow-lb-service&quot;]<br><br>  disk {<br>    source_image = data.google_compute_image.centos_7.self_link<br>  }<br><br>  network_interface {<br>    network = google_compute_network.vpc_network.name<br>  }<br><br>  metadata = {<br>    foo = &quot;bar&quot;<br>  }<br><br>  service_account {<br>    scopes = [&quot;userinfo-email&quot;, &quot;compute-ro&quot;, &quot;storage-ro&quot;]<br>  }<br>}<br><br>resource &quot;google_compute_target_pool&quot; &quot;foobar&quot; {<br>  name = &quot;my-target-pool&quot;<br>  project = &quot;&lt;PROJECT_NAME&gt;&quot;<br>  region = &quot;us-central1&quot;<br>}<br><br>resource &quot;google_compute_instance_group_manager&quot; &quot;foobar&quot; {<br>  name = &quot;my-igm&quot;<br>  zone = &quot;us-central1-c&quot;<br>  project = &quot;&lt;PROJECT_NAME&gt;&quot;<br>  version {<br>    instance_template  = google_compute_instance_template.foobar.self_link<br>    name               = &quot;primary&quot;<br>  }<br><br>  target_pools       = [google_compute_target_pool.foobar.self_link]<br>  base_instance_name = &quot;terraform&quot;<br>}<br><br>data &quot;google_compute_image&quot; &quot;centos_7&quot; {<br>  family  = &quot;centos-7&quot;<br>  project = &quot;centos-cloud&quot;<br>}<br><br>module &quot;lb&quot; {<br>  source  = &quot;GoogleCloudPlatform/lb/google&quot;<br>  version = &quot;2.2.0&quot;<br>  region       = &quot;us-central1&quot;<br>  name         = &quot;load-balancer&quot;<br>  service_port = 80<br>  target_tags  = [&quot;my-target-pool&quot;]<br>  network      = google_compute_network.vpc_network.name<br>}</pre><ul><li>Define resources such as network, autoscaler, instance template, target pool, instance group manager, and load balancer.</li></ul><p>e. Apply Terraform Configuration:</p><ul><li>Run terraform init to initialize Terraform.</li><li>Run terraform plan to review the proposed changes.</li><li>Run terraform apply to apply the configuration and create the resources in GCP.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u7Sj5jnzXuTaeGeOQsnhPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vfcSJARLvfgHmbGEaxPQhw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*8ZRiSpSP2_Pz4H0B4n1bbQ.png" /></figure><p><strong>3. Conclusion:</strong></p><p>By automating autoscaling and load balancing with Terraform, you can ensure that your infrastructure is responsive to changes in demand and efficiently distributes incoming traffic. This not only improves the performance and reliability of your applications but also helps optimize costs by scaling resources as needed. Leveraging Terraform’s infrastructure as code approach streamlines the provisioning and management of GCP resources, enabling you to focus on building and scaling your applications with confidence in the cloud.</p><p>In summary, Terraform empowers you to harness the full potential of autoscaling and load balancing capabilities offered by Google Cloud Platform, making it easier than ever to build resilient and scalable cloud-native applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b5d6f1bb4ff" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/terraform-to-autoscale-and-load-balance-compute-engine-instances-in-gcp-4b5d6f1bb4ff">Terraform to AutoScale and Load Balance Compute Engine instances in GCP</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Mastering DevOps: Project 1 — Setting Up a Multi-Tier Web Application, Manually and Automatically”]]></title>
            <link>https://medium.com/@msaad_86696/mastering-devops-project-1-setting-up-a-multi-tier-web-application-manually-and-automatically-1a9587a6b476?source=rss-cc428ab18c9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a9587a6b476</guid>
            <category><![CDATA[vagrant]]></category>
            <category><![CDATA[devops-tool]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[devops-practice]]></category>
            <dc:creator><![CDATA[Mohammed Saad]]></dc:creator>
            <pubDate>Sun, 21 May 2023 20:09:00 GMT</pubDate>
            <atom:updated>2023-05-22T02:09:48.249Z</atom:updated>
            <content:encoded><![CDATA[<h3>“Mastering DevOps: Project 1 — Setting Up a Multi-Tier Web Application, Manually and Automatically”</h3><p><strong>Introduction:</strong><br>In the world of software development, deploying applications to different environments can be a challenging task. DevOps practices aim to bridge the gap between development and operations teams, enabling seamless collaboration and efficient delivery of software. In this DevOps Project Series, we will explore various projects that demonstrate the implementation of DevOps principles. Our first project focuses on setting up a multi-tier web application stack consisting of five services: Nginx, Apache Tomcat, RabbitMQ, Memcached, and MySQL. We will discuss both manual and automatic setup approaches to provide a comprehensive understanding.</p><p>The given text describes two architectures for setting up a multi-tier web application, one manual and one automated.</p><p><strong>Setting up a web application stack locally:</strong><br>This section explains that the project helps in setting up the mentioned components locally, allowing developers to work on projects without making changes directly on real servers. It acknowledges that setting up a local environment can be complex, time-consuming, and not easily repeatable.</p><p><strong>Manual Architecture:</strong><br>In the manual architecture, the following components are used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ywA8YTQZQt0aY1FHxGdwWA.png" /></figure><p>1. <strong>Nginx:</strong> It is used for creating a load balancing experience. Nginx acts as a reverse proxy and distributes incoming network traffic across multiple servers to improve performance and reliability.</p><p>2.<strong> Apache Tomcat</strong>: It is a Java web application service used to host the web application. Apache Tomcat provides an environment for running Java-based web applications.</p><p>3<strong>. RabbitMQ:</strong> It is a message broker/queueing agent. RabbitMQ enables different components of the application to communicate asynchronously by passing messages between them. It acts as an intermediary between various services.</p><p>4. <strong>Memcached:</strong> It is a database caching service. Memcached stores data in memory to reduce the load on the database server and improve the performance of the web application.</p><p>5.<strong> MySQL: </strong>It is used to store login details. MySQL is a popular open-source relational database management system.</p><p>Each service requires careful configuration to ensure they work together seamlessly. Manual setup allows for greater control and customization, but it can be time-consuming and error-prone.</p><p><strong>Setting up a web application stack locally:</strong></p><p><strong>Real-World Scenario:</strong><br>Imagine you are working on a project that requires multiple services to power its runtime. These services may include popular components like Wordpress, MySQL, PHP, and jQuery. Managing these services individually and ensuring their smooth integration can be complex. This project aims to simplify the setup process, making it easier to develop and test your applications locally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*8--lsdST_QH4kX1sJ62Ldw.png" /></figure><p><strong>Solution:</strong><br>The suggested solution is to have an automated, repeatable, infrastructure-as-code (IaC) local setup. It proposes using tools and techniques that allow for setting up and managing the project locally, mimicking the real-world environment. This approach enables efficient R&amp;D (research and development) on the local machine.</p><p><strong>Tools needed:</strong><br>The mentioned tools required for the local setup include:</p><p>1. <strong>Hypervisor (e.g., Oracle VM VirtualBox):</strong> It allows running multiple virtual machines (VMs) on a single physical machine.</p><p>2. <strong>Automation tool (e.g., Vagrant):</strong> Vagrant is used to automate the creation and configuration of virtual environments. It helps in setting up VMs with the desired configurations.</p><p>3.<strong> Command-line interface (CLI) tool (e.g., Git Bash):</strong> Git Bash provides a Unix-like command-line environment on Windows, allowing developers to execute commands and scripts.</p><p>4. <strong>Integrated Development Environment (IDE) (e.g., Sublime Text, Notepad++): </strong>IDEs are text editors with additional features for coding and development, making it easier to work on the project source code.</p><p><strong>Objective:</strong><br>The objective of the second part of the project is to automate the setup of virtual machines locally. It is considered a good first project because it provides hands-on experience in setting up real-world projects locally. It allows for research and development activities without directly impacting production environments.</p><p><strong>Automated Architecture:</strong><br>The automated architecture involves the following components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*oWlD0UcIkR_xxkV26XZPQQ.png" /></figure><p><strong>1. Vagrant: </strong>Vagrant is used for setting up virtual machines (VMs). It provides a command-line interface to define and manage VM configurations, making it easier to create consistent development environments.</p><p>2. <strong>VirtualBox: </strong>VirtualBox is a virtualization platform that allows the running of multiple operating systems on a single physical machine. It is used by Vagrant to create and manage VMs.</p><p>3. <strong>Git Bash:</strong> Git Bash is a command-line interface that provides a Unix-like shell environment on Windows. It is used to execute commands and scripts related to the setup process.</p><p>Setting up a social networking web application written in java.</p><p><strong>Flow of Execution:</strong></p><ol><li>Setup Tools</li><li>Clone Source code</li><li>cd into the vagrant dir</li><li>Bring up Vm’s</li><li>Validate</li><li>Setup All the services</li></ol><ul><li>Mysql</li><li>Memcached</li><li>Rabbit MQ</li><li>TomCat</li><li>nginx</li><li>App Build and Deploy</li></ul><p>7. Verify from Browser</p><p><strong>Pre-requisites :</strong></p><p><strong>Windows:</strong> Open PowerShell as administrator and Install chocolatey from the instructions given in the link below.</p><p><a href="https://chocolatey.org/docs/installation">https://chocolatey.org/docs/installation </a>and then run following commands</p><pre>choco install virtualbox --version=7.0.8 -y<br>choco install vagrant --version=2.3.4 -y<br>choco install git -y<br>choco install corretto11jdk -y<br>choco install maven -y<br>choco install awscli -y<br>choco install intellijidea-community -y<br>choco install vscode -y<br>choco install sublimetext3.app -y</pre><p><strong>Prerequisites:</strong><br>1. Oracle VM Virtualbox<br>2. Vagrant<br>3. Vagrant plugins<br>a. vagrant plugin install vagrant-hostmanager<br>b. vagrant plugin install vagrant-vbguest<br>4. Git bash or equivalent editor</p><p><strong>VM SETUP</strong><br>1. Clone source code. (git clone <a href="https://github.com/devopshydclub/vprofile-project.git)">https://github.com/devopshydclub/vprofile-project.git)</a><br>2. Cd into the repository.<br>3. Switch to the local-setup branch.<br>4. cd into vagrant/Manual_provisioning.</p><pre>Bring up vm’s<br>$ vagrant up</pre><p><strong>NOTE: </strong>Bringing up all the vm’s may take a long time based on various factors. If vm setup stops in the middle run <strong>“vagrant up”</strong> command again.<br><strong>INFO:</strong> All the vm’s hostname and /etc/hosts file entries will be automatically updated.<br><strong>PROVISIONING: </strong>Setup should be done in below mentioned order:<br>1. MySQL (Database SVC)<br>2. Memcache (DB Caching SVC)<br>3. RabbitMQ (Broker/Queue SVC)<br>4. Tomcat (Application SVC)<br>5. Nginx (Web SVC)</p><p><strong>MYSQL Setup:</strong></p><pre><br>Login to the db vm<br>$ vagrant ssh db01<br>Verify Hosts entry, if entries missing update the it with IP and hostnames<br># cat /etc/hosts<br>Update OS with latest patches<br># yum update -y<br>Set Repository<br># yum install epel-release -y<br>Install Maria DB Package<br># yum install git mariadb-server -y<br>Starting &amp; enabling mariadb-server<br># systemctl start mariadb<br># systemctl enable mariadb<br>RUN mysql secure installation script.<br># mysql_secure_installation</pre><p><strong>NOTE:</strong> Set db root password, example, I will be using admin123 as password<br><strong>Set root password? [Y/n] Y</strong><br>New password:<br>Re-enter new password:<br>Password updated successfully!<br>Reloading privilege tables..<br>… Success!<br>By default, a MariaDB installation has an anonymous user, allowing anyone<br>to log into MariaDB without having to have a user account created for<br>them. This is intended only for testing, and to make the installation<br>go a bit smoother. You should remove them before moving into a<br>production environment.<br><strong>Remove anonymous users? [Y/n] Y</strong><br>… Success!<br>Normally, root should only be allowed to connect from ‘localhost’. This<br>ensures that someone cannot guess at the root password from the network.<br><strong>Disallow root login remotely? [Y/n] n</strong><br>… skipping.<br>By default, MariaDB comes with a database named ‘test’ that anyone can<br>access. This is also intended only for testing, and should be removed<br>before moving into a production environment.<br><strong>Remove test database and access to it? [Y/n] Y</strong><br>- Dropping test database…<br>… Success!<br>- Removing privileges on test database…<br>… Success!<br>Reloading the privilege tables will ensure that all changes made so far<br>will take effect immediately.<br><strong>Reload privilege tables now? [Y/n] Y</strong><br>… Success!</p><pre>Set DB name and users.<br># mysql -u root -padmin123<br>mysql&gt; create database accounts;<br>mysql&gt; grant all privileges on accounts.* TO &#39;admin&#39;@’%’ identified by &#39;admin123&#39; ;<br>mysql&gt; FLUSH PRIVILEGES;<br>mysql&gt; exit;<br>Download Source code &amp; Initialize Database.<br># git clone -b local-setup https://github.com/devopshydclub/vprofile-project.git<br># cd vprofile-project<br># mysql -u root -padmin123 accounts &lt; src/main/resources/db_backup.sql<br># mysql -u root -padmin123 accounts<br>mysql&gt; show tables;<br>Restart mariadb-server<br># systemctl restart mariadb<br>Starting the firewall and allowing the mariadb to access from port no. 3306<br># systemctl start firewalld<br># systemctl enable firewalld<br># firewall-cmd --get-active-zones<br># firewall-cmd --zone=public --add-port=3306/tcp --permanent<br># firewall-cmd --reload<br># systemctl restart mariadb</pre><p><strong>MEMCACHE SETUP:</strong></p><pre><br>Install, start &amp; enable memcache on port 11211<br>#yum install epel-release -y<br>#yum install memcached -y<br>#systemctl start memcached<br>#systemctl enable memcached<br>#systemctl status memcached<br>#memcached -p 11211 -U 11111 -u memcached -d<br>Starting the firewall and allowing the port 11211 to access memcache<br># systemctl enable firewalld<br># systemctl start firewalld<br># systemctl status firewalld<br># firewall-cmd --add-port=11211/tcp --permanent<br># firewall-cmd --reload<br># memcached -p 11211 -U 11111 -u memcache -d</pre><p><strong>RABBITMQ SETUP:</strong></p><pre>Login to the RabbitMQ vm<br>$ vagrant ssh rmq01<br>Verify Hosts entry, if entries missing update the it with IP and hostnames<br># cat /etc/hosts<br>Update OS with latest patches<br># yum update -y<br>Set EPEL Repository<br># yum install epel-release -y<br>Install Dependencies<br>#sudo yum install wget -y<br>#cd /tmp/<br>#wget http://packages.erlang-solutions.com/erlang-solutions-2.0-1.noarch.rpm<br>#sudo rpm -Uvh erlang-solutions-2.0-1.noarch.rpm<br>#sudo yum -y install erlang socat<br>Install Rabbitmq Server<br>#curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash<br>#sudo yum install rabbitmq-server -y<br>Start &amp; Enable RabbitMQ<br>#sudo systemctl start rabbitmq-server<br>#sudo systemctl enable rabbitmq-server<br>#sudo systemctl status rabbitmq-server<br>Config Change<br>#sudo sh -c &#39;echo &quot;[{rabbit, [{loopback_users, []}]}].&quot; &gt; /etc/rabbitmq/rabbitmq.config&#39;<br>#sudo rabbitmqctl add_user test test<br>#sudo rabbitmqctl set_user_tags test administrator<br>Restart RabbitMQ service<br># systemctl restart rabbitmq-server<br>Enabling the firewall and allowing port 25672 to access the rabbitmq permanently<br># systemctl start firewalld<br># systemctl enable firewalld<br># firewall-cmd --get-active-zones<br># firewall-cmd --zone=public --add-port=25672/tcp --permanent<br># firewall-cmd --reload</pre><p><strong>TOMCAT SETUP:</strong></p><pre>Login to the tomcat vm<br>$ vagrant ssh app01<br>Verify Hosts entry, if entries missing update the it with IP and hostnames<br># cat /etc/hosts<br>Update OS with latest patches<br># yum update -y<br>Set Repository<br># yum install epel-release -y<br>Install Dependencies<br># yum install java-1.8.0-openjdk -y<br># yum install git maven wget -y<br>Change dir to /tmp<br># cd /tmp/<br>Download &amp; Tomcat Package<br># wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.37/bin/apache-tomcat-8.5.37.tar.gz<br># tar xzvf apache-tomcat-8.5.37.tar.gz<br>Add tomcat user<br># useradd --home-dir /usr/local/tomcat8 --shell /sbin/nologin tomcat<br>Copy data to tomcat home dir<br># cp -r /tmp/apache-tomcat-8.5.37/* /usr/local/tomcat8/<br>Make tomcat user owner of tomcat home dir<br># chown -R tomcat.tomcat /usr/local/tomcat8<br>Setup systemd for tomcat<br>Update file with following content.<br>vi /etc/systemd/system/tomcat.service<br>[Unit]<br>Description=Tomcat<br>After=network.target<br>[Service]<br>User=tomcat<br>WorkingDirectory=/usr/local/tomcat8<br>Environment=JRE_HOME=/usr/lib/jvm/jre<br>Environment=JAVA_HOME=/usr/lib/jvm/jre<br>Environment=CATALINA_HOME=/usr/local/tomcat8<br>Environment=CATALINE_BASE=/usr/local/tomcat8<br>ExecStart=/usr/local/tomcat8/bin/catalina.sh run<br>ExecStop=/usr/local/tomcat8/bin/shutdown.sh<br>SyslogIdentifier=tomcat-%i<br>[Install]<br>WantedBy=multi-user.target<br># systemctl daemon-reload<br># systemctl start tomcat<br># systemctl enable tomcat<br>Enabling the firewall and allowing port 8080 to access the tomcat<br># systemctl start firewalld<br># systemctl enable firewalld<br># firewall-cmd --get-active-zones<br># firewall-cmd --zone=public --add-port=8080/tcp --permanent<br># firewall-cmd --reload</pre><p>CODE BUILD &amp; DEPLOY (app01):</p><pre>Download Source code<br># git clone -b local-setup https://github.com/devopshydclub/vprofile-project.git<br>Update configuration<br># cd vprofile-project<br># vim src/main/resources/application.properties<br># Update file with backend server details<br>Build code<br>Run below command inside the repository (vprofile-project)<br># mvn install<br>Deploy artifact<br># systemctl stop tomcat<br># sleep 120<br># rm -rf /usr/local/tomcat8/webapps/ROOT*<br># cp target/vprofile-v2.war /usr/local/tomcat8/webapps/ROOT.war<br># systemctl start tomcat<br># sleep 300<br># chown tomcat.tomcat usr/local/tomcat8/webapps -R<br># systemctl restart tomcat</pre><p>NGINX SETUP:</p><pre>Login to the Nginx vm<br>$ vagrant ssh web01<br>Verify Hosts entry, if entries missing update the it with IP and hostnames<br># cat /etc/hosts<br>Update OS with latest patches<br># apt update<br># apt upgrade<br>Install nginx<br># apt install nginx -y<br>Create Nginx conf file with below content<br># vi /etc/nginx/sites-available/vproapp<br>upstream vproapp {<br>server app01:8080;<br>}<br>server {<br>listen 80;<br>location / {<br>proxy_pass http://vproapp;<br>}<br>}<br>Remove default nginx conf<br># rm -rf /etc/nginx/sites-enabled/default<br>Create link to activate website<br># ln -s /etc/nginx/sites-available/vproapp /etc/nginx/sites-enabled/vproapp<br>Restart Nginx<br># systemctl restart nginx</pre><p><strong>Manual Provisioning :</strong></p><p>Use the public IP to verify :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*75FhvTSxULn8TL23sWrP6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m33Uz4__FUnL4qxBUHyNFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*1h1CXYJruzyNAu9C7DbRiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cm9KfScPY4PQaZnutn74iw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZ7I6EkFQuJC9379hldiXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PEqjQsKVLEiqOenGFkvwHA.png" /></figure><p><strong>Deleting all vms:</strong></p><p>vagrant destroy</p><p>yes to all vms</p><p><strong>Automatic Setup:</strong></p><p>Automatic provisioning refers to the process of setting up and configuring a software stack or infrastructure with minimal human intervention. It involves using tools or scripts to automate the provisioning tasks, reducing the manual effort and potential for errors.</p><p>One popular tool for automatic provisioning is Vagrant. Vagrant allows developers to define and manage virtual environments in a simple and reproducible manner. With Vagrant, a developer can describe the desired software stack using a configuration file, specifying things like operating system, software packages, and network settings.</p><p>clone the repository if not done already in step1 :</p><pre>git clone https://github.com/devopshydclub/vprofile-project.git</pre><p>use sublime text and open automated provisioning folder and navigate through all scripts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eqQtoa1MAU_XRr9S8RS1AA.png" /></figure><p>cd into automated provision directory and use <strong>vagrant up</strong> command</p><p>It will take 20–25 mins to provision all vms :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z9sqQMDIKwaiRhFk6n4xRw.png" /></figure><p>Once done :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rlx_oC5QaG5H23_vAggCbg.png" /></figure><p><strong>username : admin_vp</strong></p><p><strong>password: admin_vp</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pe5HA5SkS87AWsBdG44b1A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cEvoUP1Z6fkVQ_-_cCLUzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhJNueUd4tXpbIfR9gQUQw.png" /></figure><p>In the case of automatic provisioning with Vagrant, the process becomes even more streamlined. By using a single command, “<strong>vagrant up</strong>,” the entire software stack defined in the Vagrantfile is provisioned. This means that the virtual environment, along with the necessary operating system, libraries, and applications, is automatically created and configured. The process takes care of downloading and setting up the required dependencies, ensuring that the environment is ready for development or testing.</p><p>This approach offers several benefits. Firstly, it saves time and effort by eliminating the need for manual installation and configuration of each component in the stack. It also ensures consistency across different development environments, making it easier to collaborate and share projects. Additionally, automatic provisioning reduces the chances of errors or inconsistencies that may arise from manual setup, thereby enhancing the reliability and reproducibility of the development environment.</p><p>Overall, automatic provisioning, exemplified by the ease and efficiency of Vagrant’s “vagrant up” command, simplifies the process of creating and managing software stacks, enabling developers to focus more on their core tasks and improving productivity.</p><p>Finally, vagrant halt can be used to shut down all vms:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*Zc598c7oSEZk6gvzyFkw7Q.png" /></figure><p><strong>Conclusion:</strong><br>Setting up a multi-tier web application stack can be a complex task, but with the right approach, it becomes manageable. In this project, we explored both manual and automatic setup methods for a multi-tier web application stack consisting of Nginx, Apache Tomcat, RabbitMQ, Memcached, and MySQL. While manual setup provides greater control and customization, automation using tools like Vagrant can save time and reduce the potential for errors.</p><p>DevOps practices aim to streamline software development and deployment processes, enabling teams to deliver high-quality software at a faster pace. By understanding and implementing projects like these, developers and operations teams can work together more effectively, leading to improved productivity and better software outcomes.</p><p><strong>References :</strong></p><p><a href="https://www.udemy.com/share/104Tz63@slyPHpUQ--DbfCUCp4U5M8FRBT4N7CyVHV9PVteC4M7uTteqtR9KAZyCiiHbTuFRgQ==/">https://www.udemy.com/share/104Tz63@slyPHpUQ--DbfCUCp4U5M8FRBT4N7CyVHV9PVteC4M7uTteqtR9KAZyCiiHbTuFRgQ==/</a></p><p><a href="https://www.udemy.com/share/103WIY3@WvBQVRNj5NnZcMrIMpCGfsoC1NXLK9crJ5kvVtM50mRH8_arjc2LUJH5qL_db8jjNw==/">https://www.udemy.com/share/103WIY3@WvBQVRNj5NnZcMrIMpCGfsoC1NXLK9crJ5kvVtM50mRH8_arjc2LUJH5qL_db8jjNw==/</a></p><ul><li><a href="https://community.chocolatey.org/packages">Packages</a></li><li><a href="https://developer.hashicorp.com/vagrant/tutorials/getting-started">Quick Start | Vagrant | HashiCorp Developer</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a9587a6b476" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Paraphrasing: How to Generate High-Quality Text That is Indistinguishable from Human Writing]]></title>
            <link>https://medium.com/@msaad_86696/ai-paraphrasing-how-to-generate-high-quality-text-that-is-indistinguishable-from-human-writing-1540944ebfb?source=rss-cc428ab18c9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1540944ebfb</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[paraphrasing-tool]]></category>
            <dc:creator><![CDATA[Mohammed Saad]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 03:00:00 GMT</pubDate>
            <atom:updated>2023-02-27T04:51:57.203Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*KfT-MC4LErK9NLCK11UAUA.jpeg" /></figure><h4>Step 1: Gather a dataset of paraphrased sentences</h4><p>The first stage in developing an AI paraphraser is to collect a training set of paraphrased sentences. You can utilise an existing dataset or generate a new one. There are a number of publicly accessible datasets including paraphrased sentences, such as the <a href="https://www.microsoft.com/en-us/download/details.aspx?id=52398">Microsoft Research Paraphrase Corpus</a> and the <a href="https://data.quora.com/First-Quora-Dataset-Release-Question-Pairs">Quora Question Pairs</a> collection, some more are given at the end of this article. You can also generate your own dataset by manually or automatically rewriting texts.<br>After collecting your dataset, you must preprocess the data before training your model. This entails cleaning the text, deleting stop words, and translating it to numerical format.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb69ae848be4b85727e210d5ea329dfc/href">https://medium.com/media/bb69ae848be4b85727e210d5ea329dfc/href</a></iframe><h4>Step 2: Preprocess the dataset</h4><p>Before you can train your model, you will need to preprocess the dataset to clean the text and convert it to numerical form. This involves several steps:</p><ol><li>Tokenize the text — split the text into individual words.</li><li>Remove stop words and punctuation — remove common words that do not carry much meaning, and remove punctuation.</li><li>Convert the text to numerical form — convert each word to a unique integer.</li></ol><p>You can use the Natural Language Toolkit (NLTK) library in Python to perform these steps. Once you have preprocessed your dataset, you can save it to a CSV file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/100e99d7c0a57859bda72f75375e0bb7/href">https://medium.com/media/100e99d7c0a57859bda72f75375e0bb7/href</a></iframe><h4>Step 3: Split the dataset into training and validation sets</h4><p>In order to train your model, you must split your dataset into training and validation sets. The training set is used to train the model, whereas the validation set is used to verify the model’s performance and prevent overfitting.<br>Python’s scikit-learn package can be used to divide a dataset into training and validation sets. Once you have separated your data, you can save the split data to separate CSV files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab152fb2321bc3a863c0fb8c809f29fa/href">https://medium.com/media/ab152fb2321bc3a863c0fb8c809f29fa/href</a></iframe><h4>Step 4: Train a deep learning model</h4><p>The next step is to train a deep learning model on the training set. There are several deep learning architectures that can be used for sequence-to-sequence learning, such as the encoder-decoder architecture and the attention mechanism. You can use a pre-trained language model such as GPT-2, T5 or train your own model.</p><p>Once you have defined your model architecture, you can compile the model and train it on the training set. You can use the TensorFlow library in Python to define and train your model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83c4c40913aea1e8d8c06dfe5e09b175/href">https://medium.com/media/83c4c40913aea1e8d8c06dfe5e09b175/href</a></iframe><h4>Step 5: Evaluate the model</h4><p>After training your model, you will need to evaluate its performance on the validation set. This step is important to ensure that your model is not overfitting to the training data and can generalize to new data.</p><p>You can use the trained model to generate paraphrased text for the validation set and compare it to the actual paraphrases. You can also calculate the loss and accuracy of the model on the validation set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/753820fb5a649c4a292cd4304d53dfa6/href">https://medium.com/media/753820fb5a649c4a292cd4304d53dfa6/href</a></iframe><h4>Step 6: Test the model on new text</h4><p>Once your model has been trained and evaluated, it may be used to generate paraphrased text from new text inputs. To generate paraphrased text, you can utilize an existing API like OpenAI or the trained model.<br>In order to generate paraphrased text with the OpenAI API, you must create an account and enter your API key. Then, using the OpenAI API, you can generate paraphrased text for any amount of words and produce sentences as if you were a human.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5f60dcdabc8ed31858f3358ab62d698/href">https://medium.com/media/c5f60dcdabc8ed31858f3358ab62d698/href</a></iframe><p>This code defines a function to generate paraphrased text using the OpenAI API. It takes in a text input and uses the API to generate a new text output. This function can be used to generate paraphrased text for any number of words and produce texts as humans.</p><p>Following are some publicly available datasets that you can use to gather paraphrased sentences for training an AI paraphraser:</p><ol><li>Microsoft Research Paraphrase Corpus: This dataset consists of sentence pairs extracted from online news sources, where each pair is labeled as either a paraphrase or not a paraphrase. The dataset contains over 5,800 sentence pairs, and is available for download from the Microsoft Research website: <a href="https://www.microsoft.com/en-us/download/details.aspx?id=52398">https://www.microsoft.com/en-us/download/details.aspx?id=52398</a></li></ol><p>2. Quora Question Pairs: This dataset contains over 400,000 pairs of question sentences from the question-and-answer website Quora. Each pair is labeled as either a paraphrase or not a paraphrase. The dataset is available for download from the Quora website: <a href="https://data.quora.com/First-Quora-Dataset-Release-Question-Pairs">https://data.quora.com/First-Quora-Dataset-Release-Question-Pairs</a></p><p>3. ParaNMT-50M: This dataset contains over 50 million parallel sentence pairs in 11 languages, including English, French, German, and Chinese. The dataset is available for download from the ParaCrawl website: <a href="https://paracrawl.eu/releases.html">https://paracrawl.eu/releases.html</a></p><p>4. STS Benchmark: This dataset consists of sentence pairs extracted from various sources, where each pair is labeled with a semantic similarity score between 0 and 5. The dataset contains over 8,000 sentence pairs, and is available for download from the STS Benchmark website: <a href="http://ixa2.si.ehu.es/stswiki/index.php/STSbenchmark">http://ixa2.si.ehu.es/stswiki/index.php/STSbenchmark</a></p><p>These datasets can be used to train and assess an AI paraphraser’s performance. However, it is crucial to keep in mind that these datasets may have relevance and variety constraints, and it is always a good idea to examine different datasets and methodologies while developing a high-quality paraphraser.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1540944ebfb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build an AI Code Writer App with ChatGPT: A Step-by-Step Beginners Guide]]></title>
            <link>https://medium.com/@msaad_86696/build-an-ai-code-writer-app-with-chatgpt-a-step-by-step-beginners-guide-14f2782c8f84?source=rss-cc428ab18c9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/14f2782c8f84</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Mohammed Saad]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 01:41:40 GMT</pubDate>
            <atom:updated>2023-02-27T16:24:16.333Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*xe3V1iEBIvWTm2id373fIA.jpeg" /></figure><h3>Prerequisites</h3><p>Before we begin, you’ll need to have the following:</p><ul><li>Python 3.6 or higher</li><li>Django 3.2 or higher</li><li>The openai Python package (you can install it with pip install openai)</li><li>An API key for the ChatGPT API (you can get one at <a href="https://beta.openai.com/docs/quickstart">https://beta.openai.com/docs/quickstart</a>)</li><li><a href="https://www.sublimetext.com/3">Sublime Text</a></li><li><a href="https://www.sublimetext.com/3">Git Bash</a></li></ul><h3>Step 1: Set up a Django project</h3><p>First, we’ll create a new Django project and app: In Git Bash , move to the directory were you want to save all the files and run the following commands.</p><pre>django-admin startproject code_writer_project<br>cd code_writer_project<br>python manage.py startapp code_writer_app</pre><h3>Step 2: Create a view</h3><p>Next, Open sublime text and then open your project folder, here we’ll create a view that will handle the chatbot conversation. In code_writer_app/views.py, add the following code: change ‘YOUR_API_KEY’ with your chatgpt api key. You can create a new file to hide this key.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1f13d795e403a0e84fa074ea0383d2e/href">https://medium.com/media/b1f13d795e403a0e84fa074ea0383d2e/href</a></iframe><p>This function uses the openai package to call the OpenAI Codex API and generate code based on the user&#39;s prompt. It then returns the generated code as JSON.</p><h3>Step 3: Create a template</h3><p>In code_writer_app/templates/code_writer.html, create a form that will allow the user to enter a code prompt and see the generated code. Here&#39;s an example:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Code Writer&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/themes/prism.min.css&quot; /&gt;<br>    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;{% static &#39;code_writer.css&#39; %}&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Code Writer&lt;/h1&gt;<br>    &lt;div id=&quot;code-prompt-container&quot;&gt;<br>        &lt;form id=&quot;code-prompt-form&quot;&gt;<br>            &lt;textarea id=&quot;code-prompt&quot; placeholder=&quot;Enter your code prompt here...&quot;&gt;&lt;/textarea&gt;<br>            &lt;button type=&quot;submit&quot;&gt;Generate Code&lt;/button&gt;<br>        &lt;/form&gt;<br>    &lt;/div&gt;<br>    &lt;div id=&quot;code-container&quot;&gt;<br>        &lt;pre&gt;&lt;code id=&quot;generated-code&quot; class=&quot;language-python&quot;&gt;&lt;/code&gt;&lt;/pre&gt;<br>    &lt;/div&gt;<br>    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/prism.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/components/prism-python.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;script src=&quot;{% static &#39;code_writer.js&#39; %}&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>This template includes a form with a textarea for the user to enter their code prompt, and a div to display the generated code. We’ll be using JavaScript to handle the form submission and display the generated code.</p><h3>Step 4: Create static files</h3><p>In code_writer_app/static, create two files: code_writer.css and code_writer.js. Here&#39;s an example:</p><p>code_writer.css:</p><pre>/* Code prompt form */<br>#code-prompt-container {<br>    max-width: 800px;<br>    margin: 0 auto;<br>    padding: 20px;<br>    border: 1px solid #ddd;<br>    border-radius: 10px;<br>}<br><br>#code-prompt-form {<br>    display: flex;<br>    flex-direction: column;<br>    margin: 20px;<br>}<br><br>#code-prompt {<br>    height: 200px;<br>    margin-bottom: 10px;<br>    padding: 5px;<br>    border-radius: 5px;<br>    border: 1px solid #ddd;<br>}<br><br>#code-prompt-container button {<br>    padding: 5px 10px;<br>    border-radius: 5px;<br>    border: none;<br>    background-color: #007bff;<br>    color: white;<br>    cursor: pointer;<br>}<br><br>#code-prompt-container button:hover {<br>    background-color: #0062cc;<br>}<br><br>/* Generated code */<br>#code-container {<br>    max-width: 800px;<br>    margin: 0 auto;<br>    padding: 20px;<br>    border: 1px solid #ddd;<br>    border-radius: 10px;<br>}<br><br>pre {<br>    margin: 0;<br>}</pre><pre><br>document.addEventListener(&#39;DOMContentLoaded&#39;, function() {<br>    const codePromptForm = document.getElementById(&#39;code-prompt-form&#39;);<br>    const codePrompt = document.getElementById(&#39;code-prompt&#39;);<br>    const generatedCode = document.getElementById(&#39;generated-code&#39;);<br><br>    codePromptForm.addEventListener(&#39;submit&#39;, function(event) {<br>        event.preventDefault();<br><br>        // Get the code prompt<br>        const codePromptText = codePrompt.value;<br><br>        // Clear the input field<br>        codePrompt.value = &#39;&#39;;<br><br>        // Call the server to generate code<br>        fetch(&#39;/code_writer&#39;, {<br>            method: &#39;POST&#39;,<br>            headers: {<br>                &#39;Content-Type&#39;: &#39;application/x-www-form-urlencoded;charset=UTF-8&#39;<br>            },<br>            body: &#39;code_prompt=&#39; + encodeURIComponent(codePromptText)<br>        })<br>        .then(response =&gt; response.json())<br>        .then(data =&gt; {<br>            // Display the generated code<br>            generatedCode.textContent = data.code;<br>            Prism.highlightElement(generatedCode);<br>        });<br>    });<br>});</pre><p>This JavaScript code listens for the form submission event, sends the user input to the server using the fetch function, and displays the generated code in the generated-code element using Prism for syntax highlighting.</p><h3>Step 5: Add URLs to code_writer_app/urls.py</h3><p>In code_writer_app/urls.py, add a URL pattern for the code_writer view:</p><pre>from django.urls import path<br>from . import views<br><br>urlpatterns = [<br>    path(&#39;code_writer&#39;, views.code_writer, name=&#39;code_writer&#39;),<br>]</pre><h3>Step 6: Hide the API key</h3><p>To hide the API key, we’ll use environment variables. Create a new file called .env in the root directory of the project, and add the following line:</p><pre>OPENAI_API_KEY=YOUR_API_KEY</pre><p>Then, in code_writer_app/views.py, replace the line that sets the API key with the following:</p><pre>import os<br><br>openai.api_key = os.environ.get(&#39;OPENAI_API_KEY&#39;)</pre><p>This will load the API key from the environment variable instead of hard-coding it in the code.</p><h3>Step 7: Deploy the app</h3><p>To deploy the app, you can use a hosting service like Heroku. Here’s how to deploy the app to Heroku:</p><ol><li>Create a new Heroku app with heroku create.</li><li>Add the Heroku git remote with heroku git:remote -a YOUR_APP_NAME.</li><li>Commit your code and push it to the Heroku remote with git push heroku main.</li><li>Run the database migrations with `heroku run python manage.py</li></ol><p>That’s it! You should now have a simple code writer app integrated into your Django app, powered by ChatGPT. With a bit of customization, you can adapt this chatbot to suit your specific needs.</p><p>Your <a href="https://rocky-reaches-38356.herokuapp.com/">Final- Result</a> can look something like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*acVAaX74e1o_CMI2fsWiIA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-PnNCZCZAr9bYF8XQfP7Vg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14f2782c8f84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Chatbot with ChatGPT: A Beginner’s Guide to Building Your Own AI-Powered Chatbot]]></title>
            <link>https://medium.com/@msaad_86696/create-a-chatbot-with-chatgpt-and-python-and-django-a-step-by-step-guide-for-beginners-9906b18b401c?source=rss-cc428ab18c9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9906b18b401c</guid>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[portfolio-website]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Mohammed Saad]]></dc:creator>
            <pubDate>Sat, 25 Feb 2023 21:37:25 GMT</pubDate>
            <atom:updated>2023-02-27T06:15:36.906Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*6IsLjN6K787QZ0Pj_t0REA.jpeg" /></figure><p>Chatbots have become increasingly popular in recent years. They can be used for a wide range of applications, from customer support to language learning. In this tutorial, we’ll be creating a simple chatbot using ChatGPT, an AI-powered language model developed by OpenAI.</p><h3>Prerequisites</h3><p>Before we begin, you’ll need to have the following:</p><ul><li>Python 3.6 or higher</li><li>Django 3.2 or higher</li><li>The openai Python package (you can install it with pip install openai)</li><li>An API key for the ChatGPT API (you can get one at <a href="https://beta.openai.com/docs/quickstart">https://beta.openai.com/docs/quickstart</a>)</li><li><a href="https://www.sublimetext.com/3">Sublime Text</a></li><li><a href="https://www.sublimetext.com/3">Git Bash</a></li></ul><h3>Step 1: Set up a Django project</h3><p>First, we’ll create a new Django project and app: In Git Bash , move to the directory were you want to save all the files and run the following commands.</p><pre>django-admin startproject chatbot_project<br>cd chatbot_project<br>python manage.py startapp chatbot_app</pre><h3>Step 2: Create a view</h3><p>Next, Open sublime text and then open your project folder, here we’ll create a view that will handle the chatbot conversation. In chatbot_app/views.py, add the following code: change ‘YOUR_API_KEY’ with your chatgpt api key. You can create a new file to hide this key.</p><pre>import openai<br>from django.shortcuts import render<br>from django.http import JsonResponse<br><br>openai.api_key = &#39;YOUR_API_KEY&#39;<br><br>def chatbot(request):<br>    if request.method == &#39;POST&#39;:<br>        # Get user input<br>        user_input = request.POST[&#39;user_input&#39;]<br><br>        # Call the ChatGPT API to get a response<br>        response = openai.Completion.create(<br>            engine=&#39;davinci&#39;,<br>            prompt=f&quot;Conversation with a user:\nUser: {user_input}\nAI:&quot;,<br>            max_tokens=60,<br>            n=1,<br>            stop=None,<br>            temperature=0.7,<br>        )<br><br>        # Extract the response text from the API result<br>        bot_response = response.choices[0].text.strip()<br><br>        # Return the response as JSON<br>        return JsonResponse({&#39;bot_response&#39;: bot_response})<br><br>    # If the request is not a POST, render the chatbot template<br>    return render(request, &#39;chatbot.html&#39;)</pre><p>This function uses the openai package to call the ChatGPT API and generate a response to the user input. It then returns the response as JSON.</p><h3>Step 3: Create a template</h3><p>In chatbot_app/templates/chatbot.html, create a form that will allow the user to input their message and see the chatbot&#39;s response. Here&#39;s an example:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Chatbot&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;{% static &#39;chatbot.css&#39; %}&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Chatbot&lt;/h1&gt;<br>    &lt;div id=&quot;chatbot-container&quot;&gt;<br>        &lt;div id=&quot;chatlog&quot;&gt;&lt;/div&gt;<br>        &lt;form id=&quot;chat-form&quot;&gt;<br>            &lt;input type=&quot;text&quot; id=&quot;user-input&quot; placeholder=&quot;Say something...&quot;&gt;<br>            &lt;button type=&quot;submit&quot;&gt;Send&lt;/button&gt;<br>        &lt;/form&gt;<br>    &lt;/div&gt;<br>    &lt;script src=&quot;{% static &#39;chatbot.js&#39; %}&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>This template includes a form with an input field for the user to enter their message, and a div to display the chatbot’s responses. We’ll be using JavaScript to handle the form submission and display the chatbot’s responses.</p><h3>Step 4: Create static files</h3><p>In chatbot_app/static, create two files: chatbot.css and chatbot.js. example:</p><p>chatbot.css</p><pre>#chatbot-container {<br>    max-width: 500px;<br>    margin: 0 auto;<br>    padding: 20px;<br>    border: 1px solid #ddd;<br>    border-radius: 10px;<br>}<br><br>#chatlog {<br>    height: 300px;<br>    overflow-y: scroll;<br>    margin-bottom: 10px;<br>}<br><br>#chatlog p {<br>    margin: 0;<br>}<br><br>#chat-form {<br>    display: flex;<br>    margin-top: 10px;<br>}<br><br>#user-input {<br>    flex-grow: 1;<br>    margin-right: 10px;<br>    padding: 5px;<br>    border-radius: 5px;<br>    border: 1px solid #ddd;<br>}<br><br>#chatbot-container button {<br>    padding: 5px 10px;<br>    border-radius: 5px;<br>    border: none;<br>    background-color: #007bff;<br>    color: white;<br>    cursor: pointer;<br>}<br><br>#chatbot-container button:hover {<br>    background-color: #0062cc;<br>}</pre><p>chatbot.js:</p><pre>document.addEventListener(&#39;DOMContentLoaded&#39;, function() {<br>    const chatlog = document.getElementById(&#39;chatlog&#39;);<br>    const chatForm = document.getElementById(&#39;chat-form&#39;);<br>    const userInput = document.getElementById(&#39;user-input&#39;);<br><br>    chatForm.addEventListener(&#39;submit&#39;, function(event) {<br>        event.preventDefault();<br><br>        // Get user input<br>        const userMessage = userInput.value;<br><br>        // Clear the input field<br>        userInput.value = &#39;&#39;;<br><br>        // Add the user message to the chat log<br>        chatlog.innerHTML += &#39;&lt;p class=&quot;user-message&quot;&gt;&#39; + userMessage + &#39;&lt;/p&gt;&#39;;<br><br>        // Send the user message to the server and get the response<br>        fetch(&#39;/chatbot&#39;, {<br>            method: &#39;POST&#39;,<br>            headers: {<br>                &#39;Content-Type&#39;: &#39;application/x-www-form-urlencoded;charset=UTF-8&#39;<br>            },<br>            body: &#39;user_input=&#39; + encodeURIComponent(userMessage)<br>        })<br>        .then(response =&gt; response.json())<br>        .then(data =&gt; {<br>            // Add the bot response to the chat log<br>            chatlog.innerHTML += &#39;&lt;p class=&quot;bot-message&quot;&gt;&#39; + data.bot_response + &#39;&lt;/p&gt;&#39;;<br>            // Scroll to the bottom of the chat log<br>            chatlog.scrollTop = chatlog.scrollHeight;<br>        });<br>    });<br>});</pre><p>This JavaScript code listens for the form submission event, sends the user input to the server using the fetch function, and displays the bot response in the chat log.</p><h3>Step 5: Add URLs to chatbot_app/urls.py</h3><p>In chatbot_app/urls.py, add a URL pattern for the chatbot view:</p><pre>from django.urls import path<br>from . import views<br><br>urlpatterns = [<br>    path(&#39;chatbot&#39;, views.chatbot, name=&#39;chatbot&#39;),<br>]</pre><p>Use following commands to start virtual environment in Git Bash and use localhost:8000 to check all changes to app before migrating to heroku.</p><pre>python -m virtualenv venv<br>source venv/Scripts/activate<br>python manage.py migrate<br>python manage.py runserver</pre><h3>Step 6: Deploy the app</h3><p>To deploy the app, you can use a hosting service like Heroku. Here’s how to deploy the app to Heroku:</p><ol><li>Create a new Heroku app with heroku create.</li><li>Add the Heroku git remote with heroku git:remote -a YOUR_APP_NAME.</li><li>Commit your code and push it to the Heroku remote with git push heroku main.</li><li>Run the database migrations with heroku run python manage.py migrate.</li><li>Open the app in your browser with heroku open.</li></ol><p>That’s it! You should now have a simple chatbot integrated into your Django app, powered by ChatGPT. With a bit of customization, you can adapt this chatbot to suit your specific needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9906b18b401c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Data Engineering: A Technical Guide to Essential Skills and Tools]]></title>
            <link>https://medium.com/@msaad_86696/mastering-data-engineering-a-technical-guide-to-essential-skills-and-tools-d70b64472963?source=rss-cc428ab18c9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d70b64472963</guid>
            <category><![CDATA[data-engineer-skills]]></category>
            <category><![CDATA[data-engineering-101]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mohammed Saad]]></dc:creator>
            <pubDate>Wed, 15 Feb 2023 04:17:26 GMT</pubDate>
            <atom:updated>2023-02-27T19:04:49.662Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s88ctj2z6JF_qKzM_Bf3tA.jpeg" /></figure><h3>I. Introduction</h3><p>A. Explanation of Data Engineering</p><p>Data Engineering is the design, construction, and maintenance of the infrastructure required for the storage, processing, and analysis of data. This includes creating and managing data pipelines, integrating data from several sources, and assuring data integrity and security.</p><p>B. Importance of Data Engineering</p><p>Due to the rise of big data and the necessity of data-driven decision making, data engineering has become a crucial component of any organization’s data strategy. By constructing a comprehensive data infrastructure, businesses can maximize the value of their data and acquire important insights to enhance their operations, products, and services.</p><p>C. Overview of the Article</p><p>This technical reference will provide an exhaustive review of the skills and tools required to master data engineering. The essay will cover important data engineering concepts, skills, and best practice&#39;s, including Python, SQL, Spark, Hadoop, AWS, GCP, Azure, Docker, Elasticsearch, Snowflake, MongoDB, Databricks, Apache Airflow, and Kafka.</p><h3>II. Key Technical Skills for Data Engineering:</h3><p>In this section, the blog will focus on the essential technical skills required for <a href="https://ca.coursera.org/professional-certificates/ibm-data-engineer?"><strong><em>data engineering</em></strong></a>. It will highlight the key technologies, languages, and tools that are necessary for data engineers to master.</p><p>A. Databases: Databases are the backbone of data engineering, and data engineers should be well-versed in using them. SQL is a common language used for managing relational databases, while NoSQL databases like MongoDB are also widely used.</p><p>B. Programming languages: A data engineer should have proficiency in at least one programming language, with <a href="https://ca.coursera.org/specializations/python"><strong><em>Python</em></strong></a> being the most popular. Java is also a useful language for building scalable data pipelines.</p><p>C. Big data frameworks: Hadoop and Spark are popular big data frameworks that enable data engineers to process, store and analyze large amounts of data.</p><p>D. Cloud platforms: The cloud has revolutionized the way data engineering is done, and data engineers should have a good understanding of cloud platforms such as AWS, GCP, and Azure.</p><p>E. Containerization: Docker is a popular containerization technology that data engineers use to create portable, scalable, and reproducible data processing environments.</p><p>F. Data processing tools: Elasticsearch is a distributed search engine that data engineers can use to search and analyze large amounts of data. Snowflake is a cloud-based data warehouse that enables data engineers to store and process large amounts of data. Databricks is a unified data analytics platform that data engineers use to build data pipelines and perform machine learning tasks.</p><p>G. Workflow management tools: Apache Airflow is an open-source platform for creating, scheduling, and monitoring data pipelines.</p><p>H. Stream processing: Kafka is a distributed streaming platform that data engineers use to process and analyze real-time data streams.</p><p>Mastering these technical skills is crucial for becoming a successful data engineer. All future blogs will provide an in-depth analysis of each of these skills, including their importance and best practices for mastering them.</p><h3>III. Data Modeling and Architecture:</h3><p>In this section, we will focus on the key concepts of data modeling and architecture, which are fundamental skills for any data engineer. We will cover best practices for designing and implementing data models, as well as popular data modeling techniques and tools.</p><p>A. Introduction to data modeling and architecture</p><p>Data modeling is the process of creating a conceptual representation of data and the relationships between them. It involves identifying and defining the data elements and their attributes, as well as the relationships between them. Data architecture, on the other hand, is the design and organization of data in a way that optimizes its accessibility, security, and efficiency.</p><p>B. Best practices for designing and implementing data models.</p><p>When designing and implementing data models, it is essential to follow certain best practices to ensure the quality, reliability, and scalability of the data. These practices include:</p><p>• Starting with a clear understanding of the data requirements and business objectives.</p><p>• Normalizing the data to reduce redundancy and improve data integrity.</p><p>• Deformalizing the data when necessary for performance optimization.</p><p>• Defining clear and consistent naming conventions for data elements.</p><p>• Using data types that accurately reflect the nature of the data.</p><p>• Ensuring data consistency and integrity using constraints and validations.</p><p>C. Popular data modeling techniques and tools</p><p>There are various techniques and tools available for data modeling, each with its own strengths and weaknesses. Some of the popular techniques and tools include:</p><p>• Entity-relationship modeling (ERM): This is a technique for representing data in the form of entities, attributes, and relationships. It is useful for visualizing the relationships between different data elements.</p><p>• Unified Modeling Language (UML): This is a general-purpose modeling language used for software engineering and system design. It can be used to model data, as well as processes and systems.</p><p>•Data modeling tools: There are several data modeling tools available, such as ERwin, Oracle SQL Developer Data Modeler, and PowerDesigner. These tools provide a visual interface for designing and implementing data models.</p><h3>IV. Data Integration and Transformation</h3><p>Data integration and transformation are crucial components of data engineering. This section will cover the basics of data integration and transformation, including the various techniques and tools used.</p><p>A. Introduction to data integration and transformation:</p><ul><li>Overview of data integration and transformation</li><li>Importance of data integration and transformation in data engineering</li></ul><p>B. Techniques for data ingestion and extraction:</p><ul><li>Introduction to data ingestion and extraction</li><li>Best practices for data ingestion and extraction</li><li>Techniques for data extraction, including batch processing and real-time processing.</li><li>Tools for data ingestion and extraction, including Apache Nifi and Apache Kafka</li></ul><p>C. Methods for cleaning and transforming data:</p><ul><li>Introduction to data cleaning and transformation</li><li>Best practices for data cleaning and transformation</li><li>Techniques for data cleaning and transformation, including data normalization and data denormalization.</li><li>Tools for data cleaning and transformation, including Apache Spark and Pandas</li></ul><p>D. Tools for data integration and transformation:</p><p>Overview of popular tools for data integration and transformation, including Talend, Apache NiFi, and Apache Beam.</p><ul><li>Comparison of various data integration and transformation tools</li><li>Best practices for selecting the right tools for your data engineering project</li></ul><h3>V. Data Storage and Retrieval</h3><p>A. Introduction to data storage and retrieval:</p><p>Data storage and retrieval refer to the process of storing and retrieving data in a secure, reliable, and efficient manner. It is an essential aspect of data engineering and involves designing and implementing the right storage solutions to meet the data processing and analysis needs of an organization.</p><p>B. Relational and non-relational database systems:</p><p>One of the key considerations in data storage and retrieval is choosing the right type of database system. Relational databases, such as MySQL and PostgreSQL, are the traditional choice for structured data storage and retrieval, while non-relational databases, such as MongoDB and Cassandra, are suitable for unstructured and semi-structured data.</p><p>C. Techniques for data storage and retrieval:</p><p>Data storage and retrieval techniques include partitioning, replication, sharding, and caching. These techniques help ensure data availability, reliability, and scalability.</p><p>D. Popular storage and retrieval tools:</p><p>Some of the popular storage and retrieval tools used in data engineering include MySQL, PostgreSQL, Oracle, MongoDB, Cassandra, Amazon S3, Azure Blob Storage, and Google Cloud Storage. These tools offer a range of features and capabilities that can be tailored to the specific data storage and retrieval needs of an organization.</p><h3>VI. Ensuring Data Quality and Integrity</h3><p>A. Introduction to data quality and integrity.</p><p>• Explanation of data quality and integrity</p><p>• Importance of ensuring high data quality and integrity</p><p>B. Techniques for data quality assessment and improvement</p><p>• Data profiling techniques</p><p>• Data cleansing techniques</p><p>• Data validation techniques</p><p>• Data enrichment techniques</p><p>C. Best practices for data quality and integrity</p><p>• Implementing data quality policies and procedures</p><p>• Using automation and machine learning for data quality assessment and improvement</p><p>• Ensuring data privacy and security</p><p>• Regularly reviewing and updating data quality measures</p><p>In this section, we discuss the importance of ensuring high data quality and integrity in data engineering. We cover various techniques for data quality assessment and improvement, including data profiling, cleansing, validation, and enrichment. We also discuss best practices for data quality and integrity, such as implementing data quality policies and procedures, using automation and machine learning, ensuring data privacy and security, and regularly reviewing and updating data quality measures. By following these best practices, data engineers can ensure that the data they are working with is of high quality and integrity, which is critical for making informed business decisions.</p><h3>VII. Building and Managing Data Pipelines</h3><p>A. Introduction to data pipelines:</p><p>A data pipeline is a series of processes that collaborate to move and change data from one area to another. These procedures may comprise data extraction, purification, transformation, and storage, in addition to any other processing that may be necessary. The objective of a data pipeline is to move data from its source to its destination while maintaining its quality and integrity. Data pipelines are a crucial component of modern data architecture, allowing enterprises to utilise data for analytics, machine learning, and other data-driven applications.</p><p>B. Techniques for building and managing data pipelines: Building and managing data pipelines require careful planning, design, and execution. Here are some techniques for building and managing data pipelines:</p><ol><li>Identify and understand data sources: Before designing a pipeline, it is essential to identify the sources of data and understand their formats and structure.</li></ol><p>2. Use the right tools and technologies: There are many tools and technologies available for building and managing data pipelines. Choosing the right tool and technology is critical to building a scalable and robust data pipeline.</p><p>3. Design the pipeline architecture: Designing the pipeline architecture is critical to ensure that data is processed efficiently and accurately. The architecture should be designed based on the type of data source, data processing requirements, and the expected output.</p><p>4. Plan for error handling and data quality: It is crucial to plan for error handling and data quality to ensure that the pipeline works as expected. The pipeline should be able to detect errors and handle them appropriately.</p><p>5. Implement monitoring and testing: It is essential to monitor the pipeline and test it regularly to ensure that it is working correctly. Monitoring and testing can help detect errors and issues early, allowing you to fix them before they cause significant problems.</p><p>6. Automate pipeline execution: Automating the pipeline execution can help ensure that it runs consistently and reliably. This can be done using scheduling tools or other automation techniques.</p><p>Overall, building and managing data pipelines is a complex task that requires a combination of technical skills and careful planning. By following these techniques, you can design and implement a scalable and robust data pipeline that meets your data processing requirements.</p><p>C. Best practices for data pipeline development and management: We will provide best practices for developing and managing data pipelines, including tips for optimizing pipeline performance, ensuring data quality and reliability, and monitoring pipeline health. We will also discuss the importance of testing and version control in pipeline development.</p><p>By the end of this section, readers will have a solid understanding of the importance of data pipelines in data engineering, as well as the techniques and best practices for building and managing effective data pipelines.</p><h3>VIII. Real-World Examples of Data Engineering</h3><p>As you develop your technical skills in data engineering, it’s important to understand how these skills are applied in the real world. Case studies and real-world examples can provide valuable insights into the practical applications of data engineering.</p><p>A. Case studies on data engineering:</p><p>Case studies can provide a detailed examination of how data engineering was used to solve a particular problem or achieve a specific goal. By examining real-world scenarios, you can gain a better understanding of how different data engineering tools and techniques can be used to address common challenges.</p><p>1. Real-time data processing for a healthcare provider</p><p>2. Data pipeline for an e-commerce company</p><p>3. Big data platform for a financial institution</p><p>B. Real-world examples of data engineering in action</p><p>Real-world examples of data engineering in action can provide a more general overview of how data engineering is used across different industries and use cases. By examining these examples, you can gain a better understanding of how data engineering fits into the larger context of data management and analysis.</p><p>1. Building a recommendation engine using collaborative filtering</p><p>2. Creating a sentiment analysis model using natural language processing</p><p>3. Developing a fraud detection system using machine learning techniques</p><p>4. Implementing machine learning algorithms to improve customer recommendations for a popular streaming service.</p><p>5. Developing a cloud-based data storage and processing infrastructure for a global financial services company</p><p>6. Designing and implementing a data lake for a large healthcare provider to centralize and analyze disparate data sources.</p><p>By studying these real-world examples, you can gain a deeper appreciation for the complexity and diversity of data engineering, as well as the skills and tools needed to be successful in this field. I will provide hyperlinks to these projects and other useful topics in future.</p><h3>IX. Conclusion</h3><p>A. Recap of key points:</p><p>B. In this article, we discussed the importance of data engineering and the key technical skills required to excel in this field. We covered various aspects of data engineering, including data modeling and architecture, data integration and transformation, data storage and retrieval, ensuring data quality and integrity, building, and managing data pipelines, and real-world examples of data engineering.</p><p>C. Future outlook for data engineering:</p><p>Data engineering is a rapidly evolving field, and the demand for skilled professionals is expected to continue to grow in the coming years. Advancements in cloud computing, big data processing, and machine learning are expected to play a key role in shaping the future of data engineering.</p><p>C. Final thoughts and recommendations for mastering data engineering:</p><p>To become a successful data engineer, it is important to have a strong foundation in the key technical skills and concepts discussed in this article. Additionally, it is important to stay up to date with the latest tools, technologies, and best practices in the field. Pursuing a degree or certification in data engineering, participating in online communities and forums, attending industry events, and continuously learning and experimenting with new tools and techniques can all help in mastering data engineering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d70b64472963" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>