<?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 Dergham Lahcene on Medium]]></title>
        <description><![CDATA[Stories by Dergham Lahcene on Medium]]></description>
        <link>https://medium.com/@l.dergham?source=rss-cca3bc280239------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YuPgUUpv8RnFI4za</url>
            <title>Stories by Dergham Lahcene on Medium</title>
            <link>https://medium.com/@l.dergham?source=rss-cca3bc280239------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:30:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@l.dergham/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[Designing a Production-Grade Multi-Tenant SaaS on Azure: Isolation, Security, and Scale]]></title>
            <link>https://medium.com/@l.dergham/designing-a-production-grade-multi-tenant-saas-on-azure-isolation-security-and-scale-4292ef2161a1?source=rss-cca3bc280239------2</link>
            <guid isPermaLink="false">https://medium.com/p/4292ef2161a1</guid>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Dergham Lahcene]]></dc:creator>
            <pubDate>Thu, 04 Jun 2026 12:08:44 GMT</pubDate>
            <atom:updated>2026-06-04T12:08:44.503Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AjBtNNMcdODq0a1yYGWz3A.png" /></figure><h4>How to choose the right tenant isolation model and build a secure, scalable SaaS architecture on Azure</h4><p>Multi-tenancy is one of the most important architectural decisions in any SaaS platform.</p><p>It shapes everything: how you secure customer data, how you scale the system, how you manage operational complexity, and how efficiently you use cloud resources.</p><p>At first, multi-tenancy can seem straightforward. A shared application, a shared database, a TenantId column, and some filters in the data access layer. But as the platform grows, the real questions begin:</p><ul><li>How do you prevent cross-tenant data leakage?</li><li>How do you handle premium tenants that need stronger isolation?</li><li>How do you scale without letting one tenant degrade the experience for everyone else?</li><li>How do you stay secure without turning every tenant into a separate infrastructure stack?</li></ul><p>On Azure, there is no single correct answer. The right design depends on your product, your tenant profiles, your compliance requirements, and your operational maturity.</p><p>In this article, I’ll walk through a practical reference approach for designing a <strong>production-grade multi-tenant SaaS on Azure</strong>, with a focus on three pillars:</p><ul><li><strong>Isolation</strong></li><li><strong>Security</strong></li><li><strong>Scale</strong></li></ul><p>This is not about one exact implementation. It is about the architecture decisions and tradeoffs that matter when building SaaS platforms that need to serve many tenants safely and efficiently.</p><h3>Why Multi-Tenancy Is an Architectural Concern</h3><p>Multi-tenancy is often described too narrowly as “multiple customers using the same application.”</p><p>That definition is technically correct, but architecturally incomplete.</p><p>In practice, multi-tenancy is about deciding what should be <strong>shared</strong> and what should be <strong>isolated</strong>.</p><p>That includes:</p><ul><li>application runtime</li><li>identity boundaries</li><li>databases</li><li>storage</li><li>cache</li><li>networking</li><li>secrets</li><li>monitoring</li><li>deployment units</li></ul><p>The real question is not whether your system is multi-tenant.</p><p>The real question is:</p><p><strong>At which layers should tenant boundaries be logical, and at which layers should they be physical?</strong></p><p>That is the design decision that drives the architecture.</p><p>A lightweight internal SaaS serving many low-risk tenants may work well with a shared application and shared database. A platform serving enterprise or regulated customers may need separate databases, stricter network boundaries, or even tenant-dedicated deployment models.</p><p>The important point is this:</p><p><strong>Multi-tenancy is not one pattern. It is a spectrum.</strong></p><h3>A Practical Azure Reference Architecture</h3><p>A production-grade multi-tenant SaaS on Azure usually includes these core building blocks:</p><h3>Ingress and Edge</h3><ul><li>Azure Front Door or Application Gateway</li><li>optional WAF for public-facing applications</li><li>routing based on subdomain, custom domain, or request metadata</li></ul><h3>Application Layer</h3><ul><li>Azure App Service, Azure Kubernetes Service, or Azure Container Apps</li><li>stateless API and application services</li><li>background workers for asynchronous workloads</li><li>centralized tenant resolution and tenant context propagation</li></ul><h3>Identity and Access</h3><ul><li>Microsoft Entra ID for authentication</li><li>tenant-aware authorization model</li><li>Managed Identity for internal Azure service access</li></ul><h3>Data and Storage</h3><ul><li>Azure SQL Database, SQL Managed Instance, PostgreSQL, Cosmos DB, or a mixed data strategy</li><li>Azure Storage for documents and files</li><li>tenant-aware data access and storage design</li></ul><h3>Security and Governance</h3><ul><li>Azure Key Vault for secrets and certificates</li><li>private endpoints for sensitive services</li><li>Azure Monitor, Application Insights, and Log Analytics for observability</li><li>RBAC and least-privilege design</li></ul><p>At a high level, the architecture looks like this:</p><p><strong>Users → Identity → Web/API Tier → Tenant Resolution → Data/Storage Tier → Monitoring/Governance</strong></p><p>The exact implementation varies, but the core challenge remains the same: preserve strong tenant boundaries while keeping the platform scalable and operationally manageable.</p><h3>Tenant Isolation Models</h3><p>One of the first major architectural decisions in any SaaS platform is the tenant isolation model.</p><p>There are three common patterns.</p><h3>1. Shared Application, Shared Database</h3><p>This is the simplest and most cost-efficient model.</p><p>All tenants use the same application deployment and the same database. Data is logically separated using a tenant discriminator such as TenantId.</p><p>This model works well when:</p><ul><li>tenant workloads are similar</li><li>compliance requirements are moderate</li><li>cost efficiency matters</li><li>the platform is still growing</li></ul><p>Its main advantages are:</p><ul><li>simpler operations</li><li>lower infrastructure cost</li><li>easier deployment and scaling</li></ul><p>But it comes with strict engineering requirements:</p><ul><li>every query must enforce tenant scope</li><li>every cache entry must be tenant-aware</li><li>every background process must preserve tenant context</li><li>every admin action must respect tenant boundaries</li></ul><p>This model is operationally efficient, but it requires a high level of discipline in the application layer.</p><h3>2. Shared Application, Separate Database per Tenant</h3><p>In this model, the application tier is shared, but each tenant gets its own database.</p><p>This gives a much stronger form of data isolation and is often a very good middle ground for enterprise SaaS systems.</p><p>It is useful when:</p><ul><li>tenants vary significantly in size</li><li>restore and retention policies differ by tenant</li><li>some customers require stronger isolation</li><li>premium enterprise tenants need more control</li></ul><p>Benefits include:</p><ul><li>better data isolation</li><li>easier per-tenant backup and restore</li><li>better containment of tenant-specific issues</li><li>more flexibility in tenant lifecycle operations</li></ul><p>The tradeoff is operational complexity:</p><ul><li>more databases to provision and monitor</li><li>more connection management logic</li><li>more migration orchestration</li><li>more automation requirements</li></ul><p>This model is often the sweet spot for mature B2B SaaS products.</p><h3>3. Dedicated Tenant Stack</h3><p>In this model, selected tenants get isolated deployments, isolated databases, and sometimes isolated network boundaries.</p><p>This is the strongest isolation pattern.</p><p>It is usually reserved for:</p><ul><li>regulated tenants</li><li>high-value enterprise customers</li><li>customers with contractual isolation requirements</li><li>premium service tiers</li></ul><p>Benefits:</p><ul><li>strongest security posture</li><li>better performance isolation</li><li>easier support for tenant-specific requirements</li><li>clearer compliance story</li></ul><p>Tradeoffs:</p><ul><li>highest cost</li><li>more operational overhead</li><li>more deployment complexity</li><li>more risk of environment drift</li></ul><p>This is not the best default for every tenant. It is the best model for the tenants that justify it.</p><h3>The real lesson</h3><p>A good SaaS platform does not always force every tenant into the same architecture model.</p><p>A strong design often supports <strong>segmented isolation models</strong> based on tenant needs.</p><h3>Tenant Resolution Must Happen Early</h3><p>A multi-tenant platform is only as safe as its tenant resolution strategy.</p><p>Tenant resolution is the mechanism that determines which tenant a request belongs to.</p><p>Common patterns include:</p><ul><li>subdomain-based routing</li><li>custom domain mapping</li><li>tenant claim in authentication tokens</li><li>tenant header in internal APIs</li><li>explicit route-based identifiers</li></ul><p>Architecturally, tenant resolution should happen as early as possible in the request pipeline.</p><p>Why?</p><p>Because tenant context is not just useful metadata.<br> It is a security boundary.</p><p>Once the tenant is resolved, that context should flow consistently into:</p><ul><li>authorization</li><li>data access</li><li>storage paths</li><li>cache keys</li><li>logging and tracing</li><li>background jobs</li></ul><p>A common anti-pattern is resolving the tenant in the controller layer, while deeper services assume the same context implicitly. That creates weak guarantees and increases the risk of tenant leakage.</p><p>In production SaaS, tenant context should be treated as part of the execution model, not as a UI concern.</p><h3>Identity, Authentication, and Authorization</h3><p>Authentication is only part of the access control story.</p><p>A multi-tenant platform must answer two questions:</p><ol><li>Who is the user?</li><li>What is that identity allowed to do within a specific tenant?</li></ol><p>On Azure, Microsoft Entra ID provides a strong foundation for enterprise identity scenarios. Depending on your SaaS model, you may support:</p><ul><li>internal workforce users</li><li>customer organization users</li><li>B2B collaboration users</li><li>external identities</li><li>service principals and managed identities</li></ul><p>The key architectural point is this:</p><p><strong>Authorization must be tenant-aware.</strong></p><p>A user may be:</p><ul><li>a platform administrator</li><li>a tenant administrator in one tenant</li><li>a standard user in another tenant</li><li>completely unauthorized outside their assigned tenant</li></ul><p>This means you need an authorization model that combines:</p><ul><li>identity claims</li><li>tenant membership</li><li>role or policy scope</li><li>tenant ownership of resources</li></ul><p>For internal Azure services, Managed Identity should be the default for service-to-service access whenever possible. It simplifies secret handling and makes internal authentication cleaner for services accessing:</p><ul><li>Key Vault</li><li>Storage</li><li>SQL</li><li>Service Bus</li><li>monitoring services</li></ul><p>A mature SaaS system also separates:</p><ul><li>platform administration</li><li>tenant administration</li></ul><p>Mixing these concerns is one of the fastest ways to create privilege and security issues.</p><h3>Data Isolation and Storage Strategy</h3><p>The data layer is where architectural multi-tenancy becomes real.</p><p>This is not only about choosing Azure SQL or Cosmos DB.<br> It is about deciding how tenant boundaries are represented and enforced in the persistence model.</p><p>Common patterns include:</p><ul><li>shared tables with tenant discriminator</li><li>schema per tenant</li><li>database per tenant</li></ul><p>For distributed stores, the equivalents may be:</p><ul><li>partition keys</li><li>isolated collections or containers</li><li>dedicated accounts for sensitive tenants</li></ul><p>When designing the data layer, you need to think about:</p><ul><li>query isolation</li><li>indexing</li><li>backup and restore</li><li>provisioning automation</li><li>lifecycle operations</li><li>tenant migration</li><li>retention policies</li><li>encryption boundaries</li></ul><p>In shared-database systems, the main technical risk is accidental cross-tenant access due to:</p><ul><li>missing filters</li><li>bad joins</li><li>admin queries</li><li>reporting paths</li><li>reusable repository methods that are not tenant-safe</li></ul><p>In separate-database systems, the challenge shifts toward operations:</p><ul><li>how databases are created</li><li>how connection strings are managed</li><li>how migrations are coordinated</li><li>how health and cost are monitored at scale</li></ul><p>The best choice depends on what your platform needs to optimize:</p><ul><li>application-level isolation discipline</li><li>or infrastructure-level separation</li></ul><h3>Files and Storage Are Part of the Tenant Boundary</h3><p>It is common for teams to pay attention to database isolation and forget that documents, blobs, and file storage are also part of the tenant security model.</p><p>Tenant-aware storage should be explicit in:</p><ul><li>container or path structure</li><li>blob naming strategy</li><li>access policies</li><li>lifecycle rules</li><li>auditability</li></ul><p>Whether you use shared storage with tenant-scoped paths or stronger physical isolation, the principle is the same:</p><p><strong>Storage is not just storage. It is part of the tenant boundary.</strong></p><p>If application data is tenant-aware but file storage is not, the architecture is incomplete.</p><h3>Security Architecture on Azure</h3><p>A production-grade SaaS architecture on Azure should aim to reduce the blast radius of both attacks and mistakes.</p><p>That means relying on:</p><ul><li>Managed Identity</li><li>Azure Key Vault</li><li>RBAC</li><li>private endpoints where needed</li><li>network segmentation for sensitive workloads</li><li>least-privilege access patterns</li></ul><p>Secrets should not live in code or static configuration files. They should be managed through Key Vault or equivalent secure configuration mechanisms.</p><p>Service-to-service access should use managed identities where possible, especially for access to:</p><ul><li>Azure Storage</li><li>Azure SQL</li><li>Key Vault</li><li>Service Bus</li></ul><p>For sensitive or regulated tenants, you may also introduce:</p><ul><li>private endpoints</li><li>restricted public access</li><li>dedicated integration paths</li><li>stricter network boundaries between public ingress and internal services</li></ul><p>The most serious SaaS security incidents are often not caused by exotic attack chains. They are caused by architecture flaws:</p><ul><li>missing tenant filters</li><li>over-privileged admin access</li><li>shared cache collisions</li><li>unscoped storage paths</li><li>background jobs executing in the wrong tenant context</li></ul><p>A strong Azure architecture helps make those mistakes harder to make.</p><h3>Scaling Without Breaking Isolation</h3><p>Scaling a SaaS platform is not only about serving more traffic. It is about scaling while preserving tenant fairness and platform stability.</p><p>The main scaling risks include:</p><ul><li>noisy neighbors</li><li>shared cache pressure</li><li>hotspot tenants in shared databases</li><li>large background workloads affecting all tenants</li><li>reporting and batch operations impacting interactive workloads</li></ul><p>A production-oriented Azure design typically uses a combination of:</p><ul><li>stateless horizontal scaling in the app tier</li><li>queue-based asynchronous processing</li><li>tenant-aware caching</li><li>workload separation between user-facing and background execution</li><li>tenant segmentation in the data tier where needed</li></ul><p>Azure App Service, AKS, and Container Apps can all support horizontally scalable application tiers. The critical design question is not just which hosting model you pick, but whether your application remains tenant-safe and scalable when it runs across many nodes and workers.</p><p>Background processing deserves particular attention.</p><p>Many SaaS platforms first encounter scale-related tenant problems in:</p><ul><li>imports</li><li>exports</li><li>reporting</li><li>billing</li><li>notifications</li><li>document processing</li></ul><p>Queue-based designs using Service Bus or equivalent asynchronous patterns help isolate long-running work and improve fairness. For premium or sensitive tenants, you may even need separate worker pools or workload partitions.</p><p>True SaaS scale is not only throughput.<br> It is throughput with tenant boundaries preserved.</p><h3>Observability Must Be Tenant-Aware</h3><p>You cannot operate a multi-tenant SaaS platform effectively without tenant-aware observability.</p><p>You need visibility into:</p><ul><li>which tenant is affected by an incident</li><li>which tenant is generating abnormal load</li><li>which tenant sees degraded response times</li><li>which tenant is producing repeated errors</li><li>which tenant is consuming unusual cost</li></ul><p>On Azure, Application Insights, Azure Monitor, and Log Analytics provide a strong technical foundation. But the important part is how you structure telemetry.</p><p>In practice, your logs, traces, and metrics should carry tenant context whenever possible.</p><p>That applies to:</p><ul><li>request traces</li><li>dependency calls</li><li>background job execution</li><li>exception logs</li><li>business events</li><li>support diagnostics</li></ul><p>If your monitoring is only environment-aware and not tenant-aware, incident response becomes slower and less precise.</p><p>A useful rule is this:</p><p><strong>If you cannot observe the platform by tenant, you do not yet have full operational control over a multi-tenant system.</strong></p><h3>Deployment and Tenant Lifecycle Strategy</h3><p>A production-grade SaaS platform must think beyond runtime architecture.</p><p>It also needs a strong tenant lifecycle model.</p><p>That includes:</p><ul><li>onboarding</li><li>provisioning</li><li>configuration</li><li>migrations</li><li>scaling changes</li><li>feature rollout</li><li>offboarding</li></ul><p>This is where many platforms become operationally fragile. The system may be technically multi-tenant, but tenant operations remain manual, inconsistent, and hard to audit.</p><p>A mature Azure SaaS platform should automate:</p><ul><li>tenant provisioning</li><li>data store initialization</li><li>configuration setup</li><li>default permission and role assignment</li><li>schema rollout</li><li>environment-aware deployment steps</li></ul><p>Feature flags are particularly valuable in multi-tenant systems. They allow you to:</p><ul><li>enable capabilities by tenant</li><li>roll out features gradually</li><li>test premium capabilities</li><li>manage differentiated pricing tiers</li><li>avoid permanent platform forks</li></ul><p>The more tenant lifecycle operations are automated, the more sustainable the SaaS model becomes.</p><h3>Common Failure Modes in Multi-Tenant SaaS</h3><p>Many SaaS systems do not fail because the cloud platform is weak. They fail because the tenant boundary model is inconsistent.</p><p>Common failure modes include:</p><ul><li>relying on TenantId without enforcing it everywhere</li><li>mixing tenant admin and platform admin privileges</li><li>using shared caches without tenant-scoped keys</li><li>storing files in loosely scoped storage structures</li><li>logging without tenant context</li><li>building so many tenant-specific customizations that the shared platform becomes unmanageable</li><li>ignoring noisy neighbor behavior</li><li>managing tenant secrets and config unsafely</li><li>treating tenant onboarding as a manual process</li></ul><p>These are not edge cases. They are common architectural traps.</p><p>The consistent lesson is that multi-tenancy is not just a hosting pattern. It is a platform discipline.</p><h3>Cost vs Isolation: The Tradeoff That Matters</h3><p>The most isolated architecture is not automatically the best architecture.</p><p>A fully dedicated deployment for every tenant may be easy to defend from a security perspective, but it may also be too expensive and too operationally heavy.</p><p>A fully shared model may be efficient, but it can become difficult to defend for premium, regulated, or high-sensitivity customers.</p><p>That is why many successful SaaS platforms use tiered architecture strategies, such as:</p><ul><li>shared model for standard tenants</li><li>separate database model for enterprise tenants</li><li>dedicated stacks for premium or regulated customers</li></ul><p>That approach aligns isolation with business value and risk.</p><p>The goal is not maximum isolation at any cost.</p><p>The goal is <strong>the right level of isolation for the tenant segment and security posture</strong>.</p><p>That is the difference between overengineering and sound architecture.</p><h3>A Practical Azure Blueprint</h3><p>A strong production-grade multi-tenant SaaS architecture on Azure often looks like this:</p><ul><li>shared ingress through Azure Front Door or Application Gateway</li><li>shared application runtime on App Service, AKS, or Container Apps</li><li>early tenant resolution through domain, claims, or routing context</li><li>Microsoft Entra ID for authentication</li><li>tenant-aware authorization model</li><li>shared core platform services with strong tenant context propagation</li><li>Azure SQL or other data platform with the right tenant isolation model</li><li>Azure Storage with tenant-aware design</li><li>Managed Identity for internal service authentication</li><li>Key Vault for secrets and certificates</li><li>Service Bus for asynchronous workloads</li><li>Application Insights and Azure Monitor for tenant-aware observability</li><li>optional private endpoints and stronger network boundaries for sensitive tiers</li></ul><p>This is not one fixed deployment pattern.<br> It is a practical reference architecture that can evolve with product growth, tenant segmentation, and compliance demands.</p><h3>Final Thoughts</h3><p>Multi-tenant SaaS on Azure is not difficult because Azure lacks services.</p><p>It is difficult because SaaS architecture requires constant balance:</p><ul><li>isolation vs cost</li><li>flexibility vs operational simplicity</li><li>shared efficiency vs security boundaries</li><li>tenant growth vs platform stability</li></ul><p>The strongest multi-tenant systems are not the ones with the most complex diagrams. They are the ones where tenant boundaries are respected consistently across:</p><ul><li>identity</li><li>application logic</li><li>data</li><li>storage</li><li>telemetry</li><li>operations</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4292ef2161a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing a Medallion Data Architecture on Azure with Databricks, Data Lake, and Orchestration]]></title>
            <link>https://medium.com/@l.dergham/designing-a-medallion-data-architecture-on-azure-with-databricks-data-lake-and-orchestration-6725c5aa0be5?source=rss-cca3bc280239------2</link>
            <guid isPermaLink="false">https://medium.com/p/6725c5aa0be5</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[solution-architect]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[data-lake]]></category>
            <dc:creator><![CDATA[Dergham Lahcene]]></dc:creator>
            <pubDate>Wed, 03 Jun 2026 08:50:28 GMT</pubDate>
            <atom:updated>2026-06-03T08:50:28.264Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>How to move from raw data ingestion to trusted analytics using Bronze, Silver, and Gold layers on Azure</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*fqPoLJQEHhUKL1Y1ZBSBTQ.png" /></figure><h3>1. Introduction</h3><ul><li>Why modern cloud data platforms need more than a single data lake</li><li>The challenge of turning raw enterprise data into trusted, query-ready datasets</li><li>Why the medallion pattern works well in Azure environments</li><li>What the article covers:</li><li>architecture principles</li><li>Azure services involved</li><li>layer responsibilities</li><li>orchestration patterns</li><li>production considerations</li></ul><h3>2. Why Medallion Architecture Matters</h3><ul><li>The problem with storing everything in one “raw but queryable” layer</li><li>Common pain points:</li><li>poor data quality</li><li>lack of lineage</li><li>schema drift</li><li>repeated transformations</li><li>inconsistent business logic</li><li>The core promise of medallion architecture:</li><li><strong>Bronze</strong> for ingestion</li><li><strong>Silver</strong> for cleansing and standardization</li><li><strong>Gold</strong> for business-ready consumption</li></ul><h3>3. Reference Architecture on Azure</h3><h3>Explain the main Azure building blocks:</h3><ul><li><strong>Azure Data Lake Storage Gen2</strong> as the storage foundation</li><li><strong>Azure Databricks</strong> for transformation and engineering workflows</li><li><strong>Azure Data Factory</strong> or orchestration service for pipeline scheduling</li><li><strong>Azure Event Grid</strong> for event-driven ingestion patterns</li><li><strong>Azure Key Vault</strong> for secrets and connection security</li><li><strong>Azure Monitor / Log Analytics</strong> for observability</li></ul><p>Optional:</p><ul><li><strong>Azure Purview / Microsoft Purview</strong> for governance</li><li><strong>Azure SQL / Synapse / Power BI</strong> for consumption</li></ul><h3>Suggested architecture flow</h3><ul><li>source systems</li><li>landing zone</li><li>Bronze ingestion</li><li>Silver transformations</li><li>Gold serving layer</li><li>downstream reporting / analytics / AI workloads</li></ul><h3>4. Bronze Layer: Raw Ingestion Without Losing Fidelity</h3><h3>Main goal</h3><p>Capture source data with minimal transformation.</p><h3>Cover:</h3><ul><li>why Bronze should be append-first and immutable where possible</li><li>preserving raw source payloads</li><li>handling batch and streaming inputs</li><li>storing ingestion metadata:</li><li>source system</li><li>ingestion timestamp</li><li>file name</li><li>partition key</li><li>processing status</li></ul><h3>Azure angle</h3><ul><li>ADLS Gen2 raw containers</li><li>Databricks Auto Loader for scalable ingestion</li><li>Event-driven ingestion via Event Grid</li><li>folder and partition design in the lake</li></ul><h3>Key point</h3><p>Bronze is not the place for business logic.<br> It is the place for <strong>data preservation and traceability</strong>.</p><h3>5. Silver Layer: Standardization, Validation, and Enrichment</h3><h3>Main goal</h3><p>Convert raw data into reliable, cleaned, structured datasets.</p><h3>Cover:</h3><ul><li>schema enforcement</li><li>deduplication</li><li>null handling</li><li>standardizing formats</li><li>joining reference/master data</li><li>handling late-arriving data</li><li>data quality checks</li><li>enrichment and normalization</li></ul><h3>Technical topics to explain</h3><ul><li>incremental processing</li><li>schema evolution</li><li>surrogate keys vs business keys</li><li>slowly changing dimensions if relevant</li><li>quarantine/error tables for bad records</li></ul><h3>Azure/Databricks angle</h3><ul><li>Delta Lake tables in Databricks</li><li>MERGE operations</li><li>expectations/data quality rules</li><li>notebook/job-based transformation pipelines</li></ul><h3>Key point</h3><p>Silver is where data becomes <strong>trustworthy enough to reuse across domains</strong>.</p><h3>6. Gold Layer: Business-Ready Data Products</h3><h3>Main goal</h3><p>Deliver curated datasets optimized for analytics, reporting, and downstream applications.</p><h3>Cover:</h3><ul><li>dimensional models</li><li>aggregate tables</li><li>KPI-ready datasets</li><li>domain-specific marts</li><li>feature-ready datasets for AI/ML use cases</li></ul><h3>Explain:</h3><ul><li>why Gold should be consumption-oriented</li><li>why Gold models should reflect business definitions, not raw source structures</li><li>the difference between operational truth and business truth</li></ul><h3>Azure angle</h3><ul><li>Databricks SQL / Delta tables</li><li>Power BI consumption</li><li>Azure SQL or serving layers where needed</li><li>exposing Gold datasets to analytics and applications</li></ul><h3>7. Orchestration Patterns on Azure</h3><h3>Explain the role of orchestration</h3><ul><li>sequencing jobs</li><li>retries</li><li>dependency handling</li><li>scheduling</li><li>failure notifications</li></ul><h3>Cover common patterns</h3><ul><li>time-based orchestration with Azure Data Factory</li><li>event-driven orchestration with Event Grid</li><li>Databricks Jobs for transformation chains</li><li>metadata-driven pipelines</li></ul><h3>Compare approaches</h3><ul><li>when to use ADF for orchestration</li><li>when Databricks workflows are enough</li><li>when hybrid orchestration makes sense</li></ul><h3>Key point</h3><p>A good data platform is not only about transformations.<br> It is also about <strong>reliable operational control</strong>.</p><h3>8. Data Modeling and Storage Design Considerations</h3><h3>Cover:</h3><ul><li>file formats: why Parquet/Delta usually beat CSV/JSON for analytics layers</li><li>partitioning strategy</li><li>naming conventions</li><li>zone/container structure in ADLS</li><li>table lifecycle strategy</li><li>retention policies</li></ul><h3>Useful contrast</h3><ul><li>logical medallion layers vs physical storage layout</li><li>why poor folder/table design creates long-term operational pain</li></ul><h3>9. Governance, Security, and Access Control</h3><h3>Explain why production-grade platforms need governance from day one</h3><h3>Cover:</h3><ul><li>role-based access control</li><li>managed identities</li><li>secret handling with Key Vault</li><li>table/column-level access where applicable</li><li>lineage and cataloging</li><li>data classification</li><li>auditability</li></ul><h3>Azure angle</h3><ul><li>RBAC</li><li>managed identity</li><li>Key Vault</li><li>Purview</li><li>storage access control</li><li>workspace/service principal design</li></ul><h3>10. Observability and Operational Excellence</h3><h3>Cover:</h3><ul><li>pipeline monitoring</li><li>job metrics</li><li>ingestion latency</li><li>failed record counts</li><li>schema drift detection</li><li>freshness SLAs</li><li>cost tracking</li></ul><h3>Azure angle</h3><ul><li>Azure Monitor</li><li>Log Analytics</li><li>Databricks job monitoring</li><li>alerting patterns</li></ul><h3>Key point</h3><p>If you cannot observe the health of the platform, you do not really have a production data architecture.</p><h3>11. Common Failure Modes in Medallion Implementations</h3><p>This section will make the article much stronger.</p><h3>Good examples:</h3><ul><li>putting business logic in Bronze</li><li>turning Silver into another raw layer</li><li>overloading Gold with too many use cases</li><li>ignoring schema evolution</li><li>weak orchestration and retry design</li><li>poor partitioning strategy</li><li>no data quality gates</li><li>missing lineage and ownership</li><li>too many ad hoc notebooks with no platform discipline</li></ul><h3>12. Cost and Scalability Considerations</h3><h3>Cover:</h3><ul><li>storage vs compute separation</li><li>scaling Databricks jobs independently</li><li>choosing batch vs streaming carefully</li><li>minimizing unnecessary reprocessing</li><li>optimizing table layout and partitioning</li><li>when to materialize Gold tables vs compute on demand</li></ul><h3>Key point</h3><p>A good medallion architecture is not only clean — it is also <strong>economically sustainable</strong>.</p><h3>13. A Practical Design Blueprint</h3><p>This is a concise synthesis section.</p><h3>Example blueprint:</h3><ul><li>ADLS Gen2 for landing and lake zones</li><li>Auto Loader into Bronze Delta tables</li><li>Databricks transformations into validated Silver tables</li><li>domain-oriented Gold marts</li><li>ADF for orchestration and scheduling</li><li>Key Vault + Managed Identity for secure access</li><li>Azure Monitor + Log Analytics for operations</li><li>Purview for governance</li></ul><p>Keep this generic and reference-style.</p><h3>14. Conclusion</h3><h3>Wrap up with key message:</h3><ul><li>Medallion is not just a storage pattern</li><li>it is an operating model for trustworthy cloud data platforms</li><li>Azure provides a strong ecosystem for implementing it</li><li>success depends on:</li><li>clear layer responsibilities</li><li>strong orchestration</li><li>disciplined data modeling</li><li>governance and observability</li></ul><h3>closing</h3><p>A production-grade medallion architecture is less about Bronze, Silver, and Gold as labels, and more about building a platform where data moves from raw ingestion to trusted insight in a controlled, repeatable way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6725c5aa0be5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing and Configuring Alfresco Community Edition: A Comprehensive Guide — Parto 03]]></title>
            <link>https://medium.com/@l.dergham/installing-and-configuring-alfresco-community-edition-a-comprehensive-guide-parto-03-bcde44232f59?source=rss-cca3bc280239------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcde44232f59</guid>
            <category><![CDATA[alfresco]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[system-administration]]></category>
            <dc:creator><![CDATA[Dergham Lahcene]]></dc:creator>
            <pubDate>Fri, 31 May 2024 16:51:28 GMT</pubDate>
            <atom:updated>2024-05-31T17:08:27.642Z</atom:updated>
            <content:encoded><![CDATA[<h3>Installing and Configuring Alfresco Community Edition: A Comprehensive Guide — Parto 03</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*iarfpurOCQnW6_bmaAQ8zQ.png" /></figure><h3>HAProxy Load Balancer with Alfresco Session Persistence</h3><p>This document outlines the steps for installing, configuring, and managing HAProxy as a load balancer for your Alfresco servers, ensuring session persistence.</p><p><strong>1. Installation and Configuration of HAProxy</strong></p><p><strong>1.1. Install HAProxy</strong></p><ul><li><strong>Explanation:</strong> This command installs the HAProxy package using the yum package manager. Adjust the command based on your Linux distribution (e.g., apt install haproxy for Debian/Ubuntu).</li></ul><pre>yum -y install haproxy</pre><p><strong>1.2. Edit the Configuration File (/etc/haproxy/haproxy.cfg)</strong></p><ul><li><strong>Explanation:</strong> This step involves editing the HAProxy configuration file. Make sure to back up the original file before making changes.</li></ul><pre>sudo nano /etc/haproxy/haproxy.cfg</pre><ul><li><strong>Add the following lines at the end:</strong></li></ul><pre>frontend http-in<br>    bind *:80<br>    http-request redirect scheme https code 301  # Force HTTPS redirection</pre><pre>frontend https-in<br>    bind *:443 ssl crt /etc/haproxy/ssl force-tlsv12  # Secure HTTPS binding<br>    #mode http                                 # Uncomment for HTTP mode (optional)</pre><pre>    acl go_share hdr_beg(host) -i ecm.domain.com   # Allow traffic for ecm.domain.com host</pre><pre>    ### Access Control Lists (ACLs)<br>    acl robots           path_reg ^/robots.txt$<br>    acl alfresco_path    path_reg ^/alfresco/.*<br>    acl share_path       path_reg ^/share/.*/proxy/alfresco/api/solr/.*<br>    acl share_redirect   path_reg ^$|^/$<br>    acl cockpit_path     path_reg ^/cockpit/.*<br>    ###</pre><pre>    http-request deny if alfresco_path go_share  # Deny Alfresco requests for ecm.domain.com<br>    redirect location /share/ if share_redirect go_share  # Redirect root and empty paths to share<br>    use_backend share if share_redirect              # Use share backend for redirected paths<br>    use_backend cockpit if cockpit_path               # Use cockpit backend for cockpit paths<br>    default_backend share                            # Default backend for all other traffic</pre><pre>backend share<br>    stats enable<br>    stats hide-version<br>    stats uri /monitor<br>    stats refresh 2s<br>    balance roundrobin                                # Round-robin load balancing<br>    option httpchk GET /share                       # Health check for backend servers<br>    cookie JSESSIONID prefix                         # Maintain session IDs with prefix<br>    server ecm1.domain.com XXX.XXX.XXX.XXX:80 check cookie ecm1 check inter 5000  # Backend server definition<br>    server ecm2.domain.com XXX.XXX.XXX.XXX:80 check cookie ecm2 check inter 5000</pre><p><strong>Explanation of Configuration Options:</strong></p><ul><li>frontend http-in: Defines a frontend that listens on port 80 and redirects all traffic to HTTPS.</li><li>frontend https-in: Defines a frontend that listens on port 443 with SSL encryption using the certificate stored at /etc/haproxy/ssl. It enforces TLSv1.2 for secure communication (uncomment mode http for HTTP mode if necessary).</li><li>acl directives: Define access control lists (ACLs) to route traffic based on path or host header.</li><li>http-request deny if alfresco_path go_share: Prevents direct access to Alfresco paths on ecm.domain.com.</li><li>redirect location /share/ if share_redirect go_share: Redirects root and empty paths to /share/.</li><li>use_backend directives: Route traffic to specific backends based on ACL matches.</li><li>default_backend share: Sets the default backend for unmatched requests.</li><li>backend share: Defines a backend named &quot;share&quot; that uses round-robin load balancing, performs health checks using GET /share, and maintains session IDs with the JSESSIONID cookie prefix.</li><li>server directives: Define the Alfresco servers (ecm1.domain.com and ecm2.domain.com) with their IP addresses, ports, and health check options.</li></ul><p>Part 01 : <a href="https://medium.com/p/6ddd06416711">https://medium.com/p/6ddd06416711</a></p><p>Part 02 : <a href="https://medium.com/p/8a95c6fbf117">https://medium.com/p/8a95c6fbf117</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcde44232f59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing and Configuring Alfresco Community Edition: A Comprehensive Guide — Parto 02]]></title>
            <link>https://medium.com/@l.dergham/installing-and-configuring-alfresco-community-edition-a-comprehensive-guide-parto-02-8a95c6fbf117?source=rss-cca3bc280239------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a95c6fbf117</guid>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[alfresco]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Dergham Lahcene]]></dc:creator>
            <pubDate>Fri, 31 May 2024 16:50:46 GMT</pubDate>
            <atom:updated>2024-05-31T16:50:46.686Z</atom:updated>
            <content:encoded><![CDATA[<h3>Installing and Configuring Alfresco Community Edition: A Comprehensive Guide — Parto 02</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*iarfpurOCQnW6_bmaAQ8zQ.png" /></figure><h3>Alfresco Content Services Deployment Guide</h3><p>This document details the steps to deploy Alfresco Content Services (ACS) using the Ansible playbook available in the provided project repository.</p><h3>Getting Started</h3><p>To deploy ACS on a pristine host running a supported Linux distribution, follow this guide for a localhost deployment.</p><h3>Initial Setup</h3><p><strong>Clone the Repository</strong></p><p>Fetch the latest source or a specific release from the repository:</p><pre>git clone https://github.com/Alfresco/alfresco-ansible-deployment.git cd alfresco-ansible-deployment</pre><p><strong>Set Up Runtime Environment</strong></p><p>Ensure Python 3.9 or higher is installed:</p><pre>python3 --version</pre><p>Install pipenv to manage Python dependencies consistently:</p><pre>pip install --user pipenv</pre><p>Install Ansible and other required dependencies using pipenv:</p><pre>pipenv install --deploy pipenv run ansible-galaxy install -r requirements.yml</pre><h3>Minimal Configuration</h3><p>Before running the playbook, you must configure the domain name for Alfresco services.</p><ol><li><strong>Configure Known URLs</strong></li><li>Edit the group_vars/repository.yml file to include the domain name where Alfresco applications will be accessed:</li></ol><pre>known_urls:   <br>  - https://ecm.acme.com/share   <br>  - http://ecm.acme.com/sharey</pre><h3>Understanding the Inventory File</h3><p>Use inventory_local.yml to deploy all components on the local machine.</p><h3>Launching the Installation</h3><p>Execute the playbook with the following command:</p><pre>pipenv run ansible-playbook playbooks/acs.yml -i inventory_local.yml -e ecm_host=192.168.100.158 -e &quot;@community-extra-vars.yml&quot;</pre><h3>Post-Installation Configuration</h3><p>Once the installation is complete, configure the Alfresco Global Properties and other services.</p><h3>Alfresco Global Properties</h3><p>Edit the alfresco-global.properties file located at /etc/opt/alfresco/content-services/classpath:</p><p>For alfresco</p><pre>alfresco.host=local_domain_name # for ex alfresco.domain.xyz<br>alfresco.port=80<br>alfresco.protocol=http<br>alfresco.cluster.enabled=false<br>dir.root=/mnt/data/alfresco/content-services/content</pre><p>For share service</p><pre>share.host=alfresco.domain.xyz #the same as alfresco host<br>share.port=80<br>share.protocol=http</pre><p>Configure the database settings:</p><pre>db.url=jdbc:postgresql://db-host-ip:db-port/db-name<br>db.driver=org.postgresql.Driver<br>db.username=alfresco<br>db.password=alfresco</pre><p>Cors configuration</p><pre># CORS filter overrides<br>cors.enabled=true<br>cors.allowed.origins=https://{loadbalancer_host},https?://localhost # the load balancer host will configured later with haproxy<br>cors.allowed.methods=DELETE,GET,HEAD,OPTIONS,POST,PUT<br>cors.allowed.headers=Accept,Access-Control-Request-Headers,Access-Control-Request-Method,Authorization,Cache-Control,Content-Type,Origin,X-CSRF-Token,X-Requested-With<br>cors.exposed.headers=Access-Control-Allow-Origin,Access-Control-Allow-Credentials<br>cors.support.credentials=true<br>cors.preflight.maxage=10</pre><p>Set up Keycloak integration:</p><pre>identity-service.credentials.secret=&quot;client-secret&quot;<br>identity-service.auth-server-url=&quot;keycloak-host-address&quot;<br>identity-service.realm=&quot;keycloak-realm&quot;<br>identity-service.resource=&quot;keycloak-realm-client&quot;</pre><h3>Authenticate with Keycloak Server: update share-config-custom.xml</h3><p>Update the share-config-custom.xml file to configure authentication with the Keycloak server:</p><pre>vim /etc/opt/alfresco/content-services/classpath/alfresco/web-extension/share-config-custom.xml</pre><p>Add the following configuration at the end of the file:</p><pre>&lt;config evaluator=&quot;string-compare&quot; condition=&quot;AIMS&quot;&gt;<br>    &lt;enabled&gt;true&lt;/enabled&gt;<br>    &lt;realm&gt;your-realm&lt;/realm&gt;<br>    &lt;resource&gt;your-ressource&lt;/resource&gt;<br>    &lt;secret&gt;ressource secret&lt;/secret&gt;<br>    &lt;authServerUrl&gt;keycloak-host-url&lt;/authServerUrl&gt;<br>    &lt;publicClient&gt;false&lt;/publicClient&gt;<br>&lt;/config&gt;</pre><p>Uncomment this configuration for poduction environment:</p><pre>&lt;!-- Security warning --&gt;<br>   &lt;!-- For production environment set verify-hostname to true.--&gt;</pre><pre>   &lt;config evaluator=&quot;string-compare&quot; condition=&quot;Remote&quot;&gt;<br>           &lt;remote&gt;<br>         &lt;ssl-config&gt;<br>            &lt;keystore-path&gt;alfresco/web-extension/alfresco-system.p12&lt;/keystore-path&gt;<br>            &lt;keystore-type&gt;pkcs12&lt;/keystore-type&gt;<br>            &lt;keystore-password&gt;alfresco-system&lt;/keystore-password&gt;<br>            &lt;truststore-path&gt;alfresco/web-extension/ssl-truststore&lt;/truststore-path&gt;<br>            &lt;truststore-type&gt;JCEKS&lt;/truststore-type&gt;<br>            &lt;truststore-password&gt;password&lt;/truststore-password&gt;<br>            &lt;verify-hostname&gt;true&lt;/verify-hostname&gt;<br>         &lt;/ssl-config&gt;<br>         &lt;connector&gt;<br>            &lt;id&gt;alfrescoCookie&lt;/id&gt;<br>            &lt;name&gt;Alfresco Connector&lt;/name&gt;<br>            &lt;description&gt;Connects to an Alfresco instance using cookie-based authentication&lt;/description&gt;<br>            &lt;class&gt;org.alfresco.web.site.servlet.SlingshotAlfrescoConnector&lt;/class&gt;<br>         &lt;/connector&gt;<br>         &lt;connector&gt;<br>            &lt;id&gt;alfrescoHeader&lt;/id&gt;<br>            &lt;name&gt;Alfresco Connector&lt;/name&gt;<br>            &lt;description&gt;Connects to an Alfresco instance using header and cookie-based authentication&lt;/description&gt;<br>            &lt;class&gt;org.alfresco.web.site.servlet.SlingshotAlfrescoConnector&lt;/class&gt;<br>            &lt;userHeader&gt;SsoUserHeader&lt;/userHeader&gt;<br>         &lt;/connector&gt;<br>         &lt;endpoint&gt;<br>            &lt;id&gt;alfresco&lt;/id&gt;<br>            &lt;name&gt;Alfresco - user access&lt;/name&gt;<br>            &lt;description&gt;Access to Alfresco Repository WebScripts that require user authentication&lt;/description&gt;<br>            &lt;connector-id&gt;alfrescoCookie&lt;/connector-id&gt;<br>            &lt;endpoint-url&gt;http://localhost:8080/alfresco/wcs&lt;/endpoint-url&gt;<br>            &lt;identity&gt;user&lt;/identity&gt;<br>            &lt;external-auth&gt;true&lt;/external-auth&gt;<br>         &lt;/endpoint&gt;<br>         &lt;endpoint&gt;<br>            &lt;id&gt;alfresco-feed&lt;/id&gt;<br>            &lt;parent-id&gt;alfresco&lt;/parent-id&gt;<br>            &lt;name&gt;Alfresco Feed&lt;/name&gt;<br>            &lt;description&gt;Alfresco Feed - supports basic HTTP authentication via the EndPointProxyServlet&lt;/description&gt;<br>            &lt;connector-id&gt;alfrescoHeader&lt;/connector-id&gt;<br>            &lt;endpoint-url&gt;http://localhost:8080/alfresco/wcs&lt;/endpoint-url&gt;<br>            &lt;identity&gt;user&lt;/identity&gt;<br>            &lt;external-auth&gt;true&lt;/external-auth&gt;<br>         &lt;/endpoint&gt;<br>         &lt;endpoint&gt;<br>            &lt;id&gt;alfresco-api&lt;/id&gt;<br>            &lt;parent-id&gt;alfresco&lt;/parent-id&gt;<br>            &lt;name&gt;Alfresco Public API - user access&lt;/name&gt;<br>            &lt;description&gt;Access to Alfresco Repository Public API that require user authentication.<br>                         This makes use of the authentication that is provided by parent &#39;alfresco&#39; endpoint.&lt;/description&gt;<br>            &lt;connector-id&gt;alfrescoHeader&lt;/connector-id&gt;<br>            &lt;endpoint-url&gt;http://localhost:8080/alfresco/api&lt;/endpoint-url&gt;<br>            &lt;identity&gt;user&lt;/identity&gt;<br>            &lt;external-auth&gt;true&lt;/external-auth&gt;<br>         &lt;/endpoint&gt;<br>      &lt;/remote&gt;<br>   &lt;/config&gt;</pre><h3>Solr and CORS Settings</h3><p>Configure Solr and CORS filter overrides:</p><pre>solr.host=local_hostname_or_ip_addr<br>cors.allowed.origins=http://your-local-host-addr</pre><h3>Restart Alfresco Service</h3><p>Restart the Alfresco content service to apply the new configurations:</p><pre>systemctl restart alfresco-content.service</pre><h3>Import CA Certificate</h3><p>Add your CA certificate to the Java keystore:</p><pre>keytool -importcert -keystore /opt/openjdk-17.0.9/lib/security/cacerts -storepass changeit -file certificate.crt -alias &quot;keycloak&quot;</pre><p>This guide provides a structured approach to deploy ACS using Ansible, ensuring a consistent setup across different environments.</p><p>Part 01 : <a href="https://medium.com/p/6ddd06416711">https://medium.com/p/6ddd06416711</a></p><p>Part 03 : <a href="https://medium.com/p/bcde44232f59">https://medium.com/p/bcde44232f59</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a95c6fbf117" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing and Configuring Alfresco Community Edition: A Comprehensive Guide — Parto 01]]></title>
            <link>https://medium.com/@l.dergham/installing-and-configuring-alfresco-community-edition-a-comprehensive-guide-parto-01-6ddd06416711?source=rss-cca3bc280239------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ddd06416711</guid>
            <category><![CDATA[alfresco]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[system-administration]]></category>
            <dc:creator><![CDATA[Dergham Lahcene]]></dc:creator>
            <pubDate>Fri, 31 May 2024 16:48:54 GMT</pubDate>
            <atom:updated>2024-05-31T16:53:20.565Z</atom:updated>
            <content:encoded><![CDATA[<h3>Installing and Configuring Alfresco Community Edition: A Comprehensive Guide — Parto 01</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*iarfpurOCQnW6_bmaAQ8zQ.png" /></figure><p>Deploying Alfresco Community Edition can be a complex process, but with the right steps, you can have a fully functional content management system up and running. This guide walks you through the setup of Samba shared disks, deployment of Alfresco Content Services using Ansible, and configuration of HAProxy for load balancing and session persistence.</p><h3>ECM Storage Configuration</h3><ul><li><strong>Install Required Packages</strong></li></ul><pre>dnf install cifs-utils -y<br>dnf install samba -y</pre><ul><li><strong>Firewall Configuration</strong></li></ul><p>Add Samba service to the firewall (permanent) and reload firewall:</p><pre>firewall-cmd --permanent --zone=public --add-service=samba firewall-cmd --reload</pre><p><strong>LVM Partition and Group Creation</strong></p><p>Steps:</p><ul><li>Create a new Partition using fdisk /dev/sdb tool and select partition type LVM</li></ul><pre>Command: n<br>Select: p (primary)<br>Partition number: 1<br>First sector: use default value<br>Last sector: use default value<br>Command: t<br>Selected partition: 1<br>Hex code: 8e</pre><ul><li>Selected partition: 1</li><li>Hex code: 8e</li><li>Initialize the partition /dev/sdb1 as an LVM physical volume</li></ul><pre>pvcreate /dev/sdb1</pre><ul><li>Useful commands:</li></ul><blockquote>lvmdiskscan //Scanning for Block Devices</blockquote><blockquote>pvdisplay //Displaying Physical Volumes</blockquote><blockquote>pvscan //Scans all supported LVM block devices</blockquote><ul><li>Create volume group name vg_newlvm and add /dev/sdb1 partition into the group:</li></ul><pre>vgcreate vg_newlvm /dev/sdb1</pre><ul><li>Create a logical volume called centos7_newvol that uses all of the unallocated space in the volume group vg_newlvm:</li></ul><pre>lvcreate --name centos7_newvol -l 100%FREE vg_newlvm</pre><ul><li>Display the created logical volumes:</li></ul><pre>lvdisplay</pre><ul><li>Format a newly created LVM with mkfs command:</li></ul><pre>mkfs.ext4 /dev/vg_newlvm/centos7_newvol</pre><ul><li>Create the mount point and mount the new LVM:</li></ul><pre>mkdir -p /data<br>mount /dev/vg_newlvm/centos7_newvol /data</pre><p><strong>Samba Configuration</strong></p><ul><li>Create a directory on the server to hold your shared files and folders (data).</li></ul><p>* Create Samba user and system user:</p><pre>useradd smb-user<br>groupadd smb-grp<br>usermod -aG smb-grp smb-user<br>smbpasswd -a smb-user</pre><p>Change the folder permissions and owner:</p><pre>chmod 770 /data<br>chown smb-user.smb-grp /data</pre><p>Change the SELinux context to samba_share_t:</p><pre>semanage fcontext --add --type &quot;samba_share_t&quot; &quot;/data(/.*)?&quot;<br>restorecon -R /data</pre><blockquote>Note: Backup Samba config file before editing.</blockquote><p>Samba config:</p><pre>[shared] # samba_shared_config  <br>   path = /data # folder_path - mounted   <br>   read only = no     <br>   writable = yes  <br>   browseable = yes    <br>   guest ok = no     <br>   valid users = @smb-user # samba user</pre><p>Restart Samba service:</p><pre>systemctl restart smb</pre><h4>ECM Instance Configuration</h4><p><strong>Install Required Packages</strong></p><pre>dnf install -y cifs-utils</pre><p><strong>Create folder to be mounted with shared disk</strong></p><pre>mkdir /mnt/data</pre><p><strong>Auto mount the folder in fstab file</strong></p><p>Edit /etc/fstab to add:</p><pre>//ECM_STORAGE_IP_ADDR/shared  /mnt/data  cifs  user=ecm_storage,password=ecm_storage@,rw,uid=996,gid=992 0 0</pre><p><strong>Reboot System</strong></p><pre>reboot</pre><p>Part 02 : <a href="https://medium.com/@l.dergham/installing-and-configuring-alfresco-community-edition-a-comprehensive-guide-parto-02-8a95c6fbf117">https://medium.com/p/8a95c6fbf11</a></p><p>Part 03 : <a href="https://medium.com/p/bcde44232f59">https://medium.com/p/bcde44232f59</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ddd06416711" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robust Distributed System with Apache ZooKeeper and Kafka]]></title>
            <link>https://medium.com/@l.dergham/robust-distributed-system-with-apache-zookeeper-and-kafka-73fd4256a85a?source=rss-cca3bc280239------2</link>
            <guid isPermaLink="false">https://medium.com/p/73fd4256a85a</guid>
            <category><![CDATA[zookeeper]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Dergham Lahcene]]></dc:creator>
            <pubDate>Tue, 19 Dec 2023 21:40:49 GMT</pubDate>
            <atom:updated>2023-12-19T21:40:49.420Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*nlzD4aH0MaT_68ilfFAnEA.png" /></figure><h4>Introduction:</h4><p>In the fast-paced world of distributed computing, organizations seek robust solutions to ensure the scalability, reliability, and fault tolerance of their systems. Apache ZooKeeper and Apache Kafka, two powerful tools in the realm of cluster architecture, stand out as cornerstones for constructing resilient and scalable infrastructure.</p><p>In this comprehensive guide, we will build a resilient and scalable distributed infrastructure using Apache ZooKeeper and Apache Kafka, and we’ll repeat this setup on each virtual machine (VM) in your cluster. The architecture we aim to create will serve as a foundation for highly available, fault-tolerant, and efficient systems capable of handling distributed workloads. Let’s outline the key components and the structure of the infrastructure we are going to construct.</p><ul><li><strong>Prerequisites</strong>: 3 VMs with Centos 9 and at least 4 GB of RAM</li></ul><blockquote>Note: we’ll repeat this setup on each virtual machine (VM) in your cluster.</blockquote><p>First of all, we’ll start with :</p><h3>Apache ZooKeeper Configuration</h3><p>This guide provides step-by-step instructions for configuring Apache ZooKeeper on a Linux system.</p><ol><li>Install Java</li></ol><pre>sudo yum update -y<br>sudo yum install java-1.8.0-openjdk java-devel -y</pre><p>2. Create ZooKeeper User</p><pre>sudo useradd -m zookeeper</pre><p>3. Download ZooKeeper binaries:</p><p>Download and move ZooKeeper to the designated directory:</p><pre>wget https://downloads.apache.org/zookeeper/zookeeper-3.8.3/apache-zookeeper-3.8.3-bin.tar.gz<br>tar -xzvf apache-zookeeper-3.8.3-bin.tar.gz<br>mv apache-zookeeper-3.8.3 zookeeper<br>sudo mv zookeeper /opt/ </pre><p>4. Create zoo.cfg File ( new zookeeper config file)</p><p>Create a ZooKeeper configuration file named zoo.cfg with the following content:</p><pre># zoo.cfg<br>dataDir=/data/zookeeper<br>clientPort=2181<br>maxClientCnxns=0<br>tickTime=2000<br>initLimit=10<br>syncLimit=5<br><br># Zoo Servers<br>server.1=zookeeper-1:2888:3888<br>server.2=zookeeper-2:2888:3888<br>server.3=zookeeper-3:2888:3888</pre><p>5. Update /etc/hosts</p><p>Add the following entries to the /etc/hosts file:</p><pre>sudo nano /etc/hosts</pre><pre>192.168.100.151 kafka-1 zookeeper-1<br>192.168.100.152 kafka-2 zookeeper-2<br>192.168.100.153 kafka-3 zookeeper-3</pre><p>6. Create systemd Service</p><p>Create a systemd service file for ZooKeeper at /etc/systemd/system/zookeeper.service:</p><pre># zookeeper.service<br>[Unit]<br>Description=ZooKeeper Service<br>Documentation=http://zookeeper.apache.org<br>Requires=network.target<br>After=network.target<br><br>[Service]<br>Type=forking<br>User=zookeeper<br>Group=zookeeper<br>ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg<br>ExecStop=/opt/zookeeper/bin/zkServer.sh stop /opt/zookeeper/conf/zoo.cfg<br>ExecReload=/opt/zookeeper/bin/zkServer.sh restart /opt/zookeeper/conf/zoo.cfg<br>WorkingDirectory=/opt/zookeeper<br><br>[Install]<br>WantedBy=default.target</pre><p>7. Change ZooKeeper Folder Owner</p><pre>sudo chown -R zookeeper:root /opt/zookeeper</pre><p>8. Create Data Directory and change the owner</p><pre>mkdir -p /data/zookeeper &amp;&amp; sudo chown -R zookeeper:root /data/zookeeper</pre><p>9. Create myid File</p><p>Create a file named myid inside the /data/zookeeper directory and write the server ID:</p><p>for VM1</p><pre>echo &quot;1&quot; &gt; /data/zookeeper/myid</pre><p>for VM2</p><pre>echo &quot;2&quot; &gt; /data/zookeeper/myid</pre><p>for VM1</p><pre>echo &quot;3&quot; &gt; /data/zookeeper/myid</pre><p>10. Start ZooKeeper Service</p><pre>sudo systemctl start zookeeper</pre><p>11. Enable ZooKeeper Service</p><pre>sudo systemctl enable zookeeper</pre><h3>Install and Configure Apache Kafka</h3><ol><li>Download and Install Kafka</li></ol><p>Download, install, and configure Kafka:</p><pre>wget https://downloads.apache.org/kafka/3.6.1/kafka-3.6.1-src.tgz<br>tar -xzvf kafka-3.6.1-src.tgz<br>mv kafka-3.6.1-src kafka<br>sudo mv kafka /opt/</pre><p>2. Configure Kafka Server:</p><p>Edit the config/server.properties file:</p><pre>sudo vim /opt/kafka/config/server.properties</pre><p>Replace the content with the following configuration:</p><p>For VM1: broker.id=1 , advertised.listeners=PLAINTEXT://kafka-1:9092</p><p>For VM2: broker.id=2 , advertised.listeners=PLAINTEXT://kafka-2:9092</p><p>For VM1: broker.id=3 , advertised.listeners=PLAINTEXT://kafka-3:9092</p><pre>broker.id=1<br>delete.topic.enable=true<br>default.replication.factor=3<br>min.insync.replicas=2<br>auto.create.topics.enable=false<br><br>advertised.listeners=PLAINTEXT://kafka-1:9092<br><br>num.network.threads=3<br>num.io.threads=8<br>socket.send.buffer.bytes=102400<br>socket.receive.buffer.bytes=102400<br>socket.request.max.bytes=104857600<br><br>log.dirs=/data/kafka<br>num.partitions=8<br>num.recovery.threads.per.data.dir=1<br><br>offsets.topic.replication.factor=3<br>transaction.state.log.replication.factor=1<br>transaction.state.log.min.isr=1<br><br>log.retention.hours=168<br>log.segment.bytes=1073741824<br>log.retention.check.interval.ms=300000<br><br>zookeeper.connect=zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181<br>zookeeper.connection.timeout.ms=18000<br><br>group.initial.rebalance.delay.ms=0</pre><p>Create directories, users, build the Kafka project, and set up Kafka as a systemd service:</p><p>3. Create Directories and Users</p><pre># Create Kafka Data Directory<br>sudo mkdir /data/kafka<br><br># Create Kafka User<br>sudo useradd -m kafka</pre><p>4. Change Ownership of Directories</p><pre>sudo chown -R kafka:root /data/kafka<br>sudo chown -R kafka:root /opt/kafka</pre><p>5. Build the Kafka Project</p><pre># Navigate to Kafka Folder<br>cd /opt/kafka<br><br># Build the Project<br>sudo ./gradlew jar -PscalaVersion=2.13.11</pre><p>6. Create Kafka Systemd Service</p><pre>sudo vim /etc/systemd/system/kafka.service</pre><p>Add the following content:</p><pre>[Unit]<br>Description=Apache Kafka server (broker)<br>Documentation=http://kafka.apache.org/documentation.html<br>Requires=network.target remote-fs.target<br>After=network.target remote-fs.target kafka-zookeeper.service<br><br>[Service]<br>Type=simple<br>User=kafka<br>Group=kafka<br>Environment=JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk<br>ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties<br>ExecStop=/opt/kafka/bin/kafka-server-stop.sh<br><br>[Install]<br>WantedBy=multi-user.target</pre><p>7. Start and Enable Kafka Service</p><pre>sudo systemctl start kafka<br>sudo systemctl enable kafka</pre><p>Now, Kafka should be running as a systemd service on your system. You can monitor the service status using:</p><pre>sudo systemctl status kafka</pre><h3>Conclusion</h3><ul><li>Emphasize the importance of Apache ZooKeeper and Kafka in distributed systems.</li><li>Acknowledge the completion of the configuration process.</li></ul><p>By following this comprehensive guide, readers gain hands-on experience in setting up and configuring Apache ZooKeeper and Kafka. This knowledge paves the way for the development of resilient and scalable distributed systems, making it an invaluable resource for system administrators and developers alike.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73fd4256a85a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Architect and Build an End-to-End AWS Web Application from Scratch, Step by Step]]></title>
            <link>https://medium.com/@l.dergham/architect-and-build-an-end-to-end-aws-web-application-from-scratch-step-by-step-b43485aa4b9f?source=rss-cca3bc280239------2</link>
            <guid isPermaLink="false">https://medium.com/p/b43485aa4b9f</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Dergham Lahcene]]></dc:creator>
            <pubDate>Wed, 27 Sep 2023 21:02:55 GMT</pubDate>
            <atom:updated>2023-09-27T21:02:55.316Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PKhJEbaHfVEc3V47e62sqg.png" /></figure><h4>Introduction:</h4><p>In this comprehensive guide, we’ve walked you through the step-by-step process of architecting and building an end-to-end AWS web application from scratch. We began by understanding the scope and purpose of our project and then proceeded to meticulously plan and execute each stage. Here’s a brief summary of the key steps:</p><ol><li><strong>Overviewing the Services and Application</strong>: Defining the project’s scope and purpose.</li><li><strong>Architecting the Web Application</strong>: Planning the system’s architecture and selecting AWS services.</li><li><strong>Creating and Hosting a Web Page</strong>: Building the front-end with a custom HTML page.</li><li><strong>Deploying and Hosting with AWS Amplify</strong>: Hosting the web page using AWS Amplify.</li><li><strong>Implementing Math Calculations</strong>: Creating a Python Lambda function for math operations.</li><li><strong>Testing Our Lambda Function</strong>: Ensuring the Lambda function works as intended.</li><li><strong>Invoking Our Lambda Function</strong>: Setting up a mechanism to trigger the Lambda function.</li><li><strong>Creating a REST API with API Gateway</strong>: Making the Lambda function accessible via an API.</li><li><strong>Persisting Data to DynamoDB</strong>: Storing math results securely in DynamoDB.</li><li><strong>Managing Permissions</strong>: Granting permissions for the Lambda function to write to DynamoDB.</li><li><strong>Integrating DynamoDB</strong>: Updating the Lambda function code to interact with DynamoDB.</li><li><strong>Calling API Gateway from Web Page</strong>: Modifying the web page to interact with the API Gateway.</li><li><strong>Re-deploying with Amplify</strong>: Using AWS Amplify to redeploy changes to the web application.</li><li><strong>Admiring the Completed Web Application</strong>: Celebrating the successful creation of the fully functional web application.</li><li><strong>Deleting Resources (Important!)</strong>: Ensuring that AWS resources are properly cleaned up to avoid unexpected costs.</li></ol><p>Step 1: Overviewing the Services and Application Before diving into the technical details, it’s crucial to have a clear understanding of the services and the application we’ll be building. This step involves defining the scope and purpose of your web application.</p><p>Step 2: Architecting the Web Application In this step, we’ll plan the architecture of our web application. This includes designing the system’s components, defining how they interact, and choosing the AWS services that best fit our requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nS_fJfzuiQwsk20VCRvjJA.png" /></figure><blockquote>In this hands-on tutorial, I’ll walk you through how to design and build a simple web application from scratch. We’ll pick five different services — Amplify, Lambda, IAM, API Gateway and DynamoDB — and talk about why/where to use them, and how to get them to work with each other. As we go, we’ll build out each of the services, resulting in a fully-functional math web application.</blockquote><p>Step 3: Creating and Hosting a Web Page To create a web application, we’ll need a user interface. We’ll start by creating an HTML page from scratch using a text editor. This is the foundation of our web application’s front-end.</p><p>Step 4: Deploying and Hosting with AWS Amplify AWS Amplify is a service that simplifies the deployment of web applications. We’ll use it to host our HTML page, making our application accessible on the internet.</p><ul><li>Go to AWS Amplify service</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ySwNjtzPUIJiMAtmCno_4Q.png" /></figure><ul><li>Then, in Amplify Hosting section, click on “Get started”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SSXls9Szanoz9Dkl9GNybw.png" /></figure><ul><li>Create a new file “index.html” with this content:</li></ul><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;To the Power of Math!&lt;/title&gt;<br>&lt;/head&gt;<br><br>&lt;body&gt;<br>    To the Power of Math!<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>Create zip file for that file “index.html”, so you’ll have index.zip</li><li>You will forwarded to this page, fill the name and Env name then apload the zip file “index.zip”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_gmkgCLDo6dOnptvdtd2JQ.png" /></figure><ul><li>Click “Save and Deploy”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3WBGpeR-dskDrb_HgbktCw.png" /></figure><ul><li>Click on your app</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*18vEo8gCbK4OOZ5QKQ1cqA.png" /></figure><ul><li>Your app will deployed in a moment, you can check it by clicking on the link https://dev…</li></ul><p>Now, we just finished the first step and we got this architecture</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cdyi5OlCM-N6dpAS5wn3MA.png" /></figure><p>Step 5: Implementing Math Calculations Our web application will include math calculations. We’ll create a Python Lambda function to handle these calculations efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YDAWfmqN2o-wbagbH-_zJg.png" /></figure><ul><li>Go to Lambda service</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jzIItfSrzU0wKhgeZsKQrQ.png" /></figure><ul><li>Click on “Create a function”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iya9BZeh_nMbDHrdaO16Ig.png" /></figure><ul><li>Fill the name and choose the Runtime you want, I chose python3.11</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HuvB0YT8PqTJloFCHR0d-w.png" /></figure><ul><li>Your Lambda function is just created !!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*37a_1Vbhwvp8S38QidbkYw.png" /></figure><ul><li>Update the function by the following code:</li></ul><pre># import the JSON utility package<br>import json<br># import the Python math library<br>import math<br><br># define the handler function that the Lambda service will use an entry point<br>def lambda_handler(event, context):<br><br># extract the two numbers from the Lambda service&#39;s event object<br>    mathResult = math.pow(int(event[&#39;base&#39;]), int(event[&#39;exponent&#39;]))<br><br>    # return a properly formatted JSON object<br>    return {<br>    &#39;statusCode&#39;: 200,<br>    &#39;body&#39;: json.dumps(&#39;Your result is &#39; + str(mathResult))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JrYOzg9haa0HR-Q04ZxScA.png" /></figure><ul><li>Then click on “Deploy”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lmd7z8PgrNxnPU6qHe9KCA.png" /></figure><p>Step 6: Testing Our Lambda Function Before integrating the Lambda function into our application, we’ll thoroughly test it to ensure it functions as expected.</p><ul><li>To test our Lambda function, we have to create a test event first</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aHKEqYjgDWtcvk0aqRmpIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PzK65HRNDd9TDW5fC5SGKA.png" /></figure><ul><li>Click save the click Test</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ineYPJMoD1SXkkDWs4gHmA.png" /></figure><p>Step 7: Invoking Our Lambda Function To execute the Lambda function, we need a way to trigger it. We’ll set up a mechanism to invoke our Lambda function from within the web application.</p><p>Step 8: Creating a REST API with API Gateway To make our Lambda function accessible over the internet, we’ll create a RESTful API using AWS API Gateway.</p><ul><li>Go to AWS API Gateway servcice</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8rTpQlZ7Evy7awrPG8viow.png" /></figure><ul><li>Choose REST API and click “build”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*px4GqWUGMbSbCQVhZlk8yQ.png" /></figure><ul><li>Choose protocol REST, and new API then fill the name:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B85zt_PUSqcfhOC2VULFRg.png" /></figure><ul><li>After you forwarded to the new API you created, Create a POST Method:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lGou0FCzW6Z_irA5fQJtDA.png" /></figure><ul><li>Choose Lambda function and your Lambda function “PowerOfMathFunction” then click “save” after that click on “OK”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXcSAR5p17BlabEuGN8TKA.png" /></figure><ul><li>You will get:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fBrMs5f0OcZMEk90w3f1qA.png" /></figure><ul><li>Then enable CORS:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aD4uhxMDBbGST7e_eRtWhg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ew6gnKqT2kMQ_J21f0xjuQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MLSo-4ql3bLfZnUsAJkhkg.png" /></figure><ul><li>Finally, Deploy the API</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y3ae0zS4pmWJTCqOaa4YVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hIZ4buSfIOzxcjRWwRjWgg.png" /></figure><ul><li>click “Deploy”</li><li>Copy your API Endpoint, you will need it later</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_mL-sehJBnisy9yQGuH-XQ.png" /></figure><ul><li>Now …</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opXxUu9xNK_4bdYpSrGEXA.png" /></figure><ul><li>Next step …</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fn_n6v4qKtgAxHDaw-keKg.png" /></figure><p>Step 9: Persisting Data to DynamoDB Our web application needs to store math results. We’ll create a DynamoDB table to persist these results securely.</p><ul><li>Go to DynamoDB service</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3O1Rg4TeAVV-4Pc8SiynfA.png" /></figure><ul><li>Click on “Create Table”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ofUgxnbBYictWyhZ_zH_ng.png" /></figure><ul><li>Fill the Table name and Partition Key and click “Create”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nJ1zhJ4wBAJkpRHLRneCJg.png" /></figure><ul><li>Result !!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9JnRrhf5L07tvbolXWfeVw.png" /></figure><ul><li>Click on you Table and go to General information section, then copy the ARN, you will need it later</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9e-UxV03DU4rjW6nU5cJhg.png" /></figure><p>Step 10: Managing Permissions To ensure security and proper functionality, we’ll grant the Lambda function permission to write to the DynamoDB table.</p><ul><li>Return to you lambda function, click on Configuration tab, then choose Permission, lastly click on the Role name link</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1bbovtN85bERO3GhuX0Rmw.png" /></figure><ul><li>You will forwarded to AMI service, add new permision</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vi79yk5cTxYyL8l1ZCjfjw.png" /></figure><ul><li>Choose JSON Policy editor and paste this code</li></ul><pre>{<br>&quot;Version&quot;: &quot;2012-10-17&quot;,<br>&quot;Statement&quot;: [<br>    {<br>        &quot;Sid&quot;: &quot;VisualEditor0&quot;,<br>        &quot;Effect&quot;: &quot;Allow&quot;,<br>        &quot;Action&quot;: [<br>            &quot;dynamodb:PutItem&quot;,<br>            &quot;dynamodb:DeleteItem&quot;,<br>            &quot;dynamodb:GetItem&quot;,<br>            &quot;dynamodb:Scan&quot;,<br>            &quot;dynamodb:Query&quot;,<br>            &quot;dynamodb:UpdateItem&quot;<br>        ],<br>        &quot;Resource&quot;: &quot;YOUR-TABLE-ARN&quot;<br>    }<br>    ]<br>}</pre><ul><li>Replace “YOUR-TABLE-ARN” by you DynamoDB ARN then click “next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BB1-FYqnZHbAS9XAL6MGIw.png" /></figure><ul><li>Fill Policy name then click “Create policy”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*un66lnmXDOxeyFWFq35D5w.png" /></figure><p>Step 11: Integrating DynamoDB We’ll update the Lambda function code to write math results to the DynamoDB table, creating a seamless data flow.</p><ul><li>Return to you Lambda function and update it with this code:</li></ul><blockquote>— Make sure to write you DynamoDB database name correctly</blockquote><blockquote>“ table = dynamodb.Table(‘PowerOfMathDatabase’) “</blockquote><pre># import the JSON utility package<br>import json<br># import the Python math library<br>import math<br><br># import the AWS SDK (for Python the package name is boto3)<br>import boto3<br># import two packages to help us with dates and date formatting<br>from time import gmtime, strftime<br><br># create a DynamoDB object using the AWS SDK<br>dynamodb = boto3.resource(&#39;dynamodb&#39;)<br># use the DynamoDB object to select our table<br>table = dynamodb.Table(&#39;PowerOfMathDatabase&#39;)<br># store the current time in a human readable format in a variable<br>now = strftime(&quot;%a, %d %b %Y %H:%M:%S +0000&quot;, gmtime())<br><br># define the handler function that the Lambda service will use an entry point<br>def lambda_handler(event, context):<br><br># extract the two numbers from the Lambda service&#39;s event object<br>    mathResult = math.pow(int(event[&#39;base&#39;]), int(event[&#39;exponent&#39;]))<br><br># write result and time to the DynamoDB table using the object we instantiated and save response in a variable<br>    response = table.put_item(<br>        Item={<br>            &#39;ID&#39;: str(mathResult),<br>            &#39;LatestGreetingTime&#39;:now<br>            })<br><br># return a properly formatted JSON object<br>    return {<br>    &#39;statusCode&#39;: 200,<br>    &#39;body&#39;: json.dumps(&#39;Your result is &#39; + str(mathResult))</pre><ul><li>Your Lambda function should be, then click “Deploy” to update the function:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqFhaAEC-PdHb0seuQV7IA.png" /></figure><ul><li>Test you function by clicking on “Test” button:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ts6aHgAwBlq1A2lYykgrew.png" /></figure><ul><li>The result should be:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wGdS5VLWP-SLcIwKEjRpXg.png" /></figure><ul><li>You can check your DynamoDB database now, it’s likely that you will find your record added to your database</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t08vkSe3D17UjDgWhght4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_SdJyNA4XSbe52zXgtiS7w.png" /></figure><blockquote>Now, we are sure that our function is running correctly , that’s amazing !!!</blockquote><ul><li>If you notice that we called the API Gateway from our Lmabda function, but the purpose it to Call it from our Web Page, we will cover that in the next step</li></ul><p>Step 12: Calling API Gateway from Web Page To fetch and display results from our REST API, we’ll modify our web page to call the API Gateway.</p><ul><li>Until now, we have achieved this architecture</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sn9YktB5eEk16TAr6SMb_g.png" /></figure><p>Step 13: Re-deploying with Amplify Any changes to our web application should be reflected in the hosted version. We’ll use AWS Amplify to redeploy our updated web page.</p><p>Step 14: Admiring the Completed Web Application With all the components in place, we can now appreciate the fully functional web application we’ve built from scratch.</p><blockquote>In this step, we will update our Web Page, as previous step of building a Web Page with Amplify, just follow the instructions bellow:</blockquote><ul><li>Create a new index.html file then create a zip</li></ul><p>the code:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;To the Power of Math!&lt;/title&gt;<br>    &lt;!-- Styling for the client UI --&gt;<br>    &lt;style&gt;<br>    h1 {<br>        color: #FFFFFF;<br>        font-family: system-ui;<br>		margin-left: 20px;<br>        }<br>	body {<br>        background-color: #222629;<br>        }<br>    label {<br>        color: #86C232;<br>        font-family: system-ui;<br>        font-size: 20px;<br>        margin-left: 20px;<br>		margin-top: 20px;<br>        }<br>     button {<br>        background-color: #86C232;<br>		border-color: #86C232;<br>		color: #FFFFFF;<br>        font-family: system-ui;<br>        font-size: 20px;<br>		font-weight: bold;<br>        margin-left: 30px;<br>		margin-top: 20px;<br>		width: 140px;<br>        }<br>	 input {<br>        color: #222629;<br>        font-family: system-ui;<br>        font-size: 20px;<br>        margin-left: 10px;<br>		margin-top: 20px;<br>		width: 100px;<br>        }<br>    &lt;/style&gt;<br>    &lt;script&gt;<br>        // callAPI function that takes the base and exponent numbers as parameters<br>        var callAPI = (base,exponent)=&gt;{<br>            // instantiate a headers object<br>            var myHeaders = new Headers();<br>            // add content type header to object<br>            myHeaders.append(&quot;Content-Type&quot;, &quot;application/json&quot;);<br>            // using built in JSON utility package turn object to string and store in a variable<br>            var raw = JSON.stringify({&quot;base&quot;:base,&quot;exponent&quot;:exponent});<br>            // create a JSON object with parameters for API call and store in a variable<br>            var requestOptions = {<br>                method: &#39;POST&#39;,<br>                headers: myHeaders,<br>                body: raw,<br>                redirect: &#39;follow&#39;<br>            };<br>            // make API call with parameters and use promises to get response<br>            fetch(&quot;YOUR API GATEWAY ENDPOINT&quot;, requestOptions)<br>            .then(response =&gt; response.text())<br>            .then(result =&gt; alert(JSON.parse(result).body))<br>            .catch(error =&gt; console.log(&#39;error&#39;, error));<br>        }<br>    &lt;/script&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;TO THE POWER OF MATH!&lt;/h1&gt;<br>	&lt;form&gt;<br>        &lt;label&gt;Base number:&lt;/label&gt;<br>        &lt;input type=&quot;text&quot; id=&quot;base&quot;&gt;<br>        &lt;label&gt;...to the power of:&lt;/label&gt;<br>        &lt;input type=&quot;text&quot; id=&quot;exponent&quot;&gt;<br>        &lt;!-- set button onClick method to call function we defined passing input values as parameters --&gt;<br>        &lt;button type=&quot;button&quot; onclick=&quot;callAPI(document.getElementById(&#39;base&#39;).value,document.getElementById(&#39;exponent&#39;).value)&quot;&gt;CALCULATE&lt;/button&gt;<br>    &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>Update “YOUR API GATEWAY ENDPOINT” with your API Gateway Endpoint which you copied before</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*qJFH-pqYlDApQyDnt9cRew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*zJ7TNUZCVdukeOBIlEqXVw.png" /></figure><ul><li>Go to Amplify app and click “choose Files”, then choose your new index.zip</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2F-W71GnBBAmnkVKot2aQ.png" /></figure><ul><li>Wait until your app is deployed successfully, then click on the URL</li><li>Try a random numbers to test you app</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bkWYX7CFlo2fuyI2CiKfmA.png" /></figure><p>Congratulations !!!!!</p><ul><li>To confirm, you can check you database</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6jgLyerb4IgX1X9TGrQSiQ.png" /></figure><p>Step 15: Deleting Resources (Important!) AWS services can accrue charges, so it’s essential to clean up and delete the resources we’ve used to avoid unexpected costs.</p><ul><li>AWS Amplify: delete the app</li><li>DynamoDB: delete the database</li><li>AWS API Gateway: delete the endpoint</li><li>AWS Lambda: delete the lambda function</li></ul><h4>Conclusion:</h4><p>Building an end-to-end AWS web application from scratch can be a challenging yet rewarding experience. Each step in this process plays a vital role in creating a functional and secure application. By following this guide, you’ll gain valuable insights into the AWS ecosystem and the architecture of web applications, setting you on a path to becoming a proficient AWS developer.</p><p>Just follow me for more content <a href="https://medium.com/u/cca3bc280239">Dergham Lahcene</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b43485aa4b9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Client Application (MERN Stack app) Creation with React, FastAPI, Kubernetes, Helm, and…]]></title>
            <link>https://blog.devops.dev/automating-client-application-mern-stack-app-creation-with-react-fastapi-kubernetes-helm-and-159a1ea7b7e?source=rss-cca3bc280239------2</link>
            <guid isPermaLink="false">https://medium.com/p/159a1ea7b7e</guid>
            <category><![CDATA[helm]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Dergham Lahcene]]></dc:creator>
            <pubDate>Fri, 26 May 2023 15:46:38 GMT</pubDate>
            <atom:updated>2023-05-30T18:43:37.885Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automating Client Application (MERN Stack app) Creation with React, FastAPI, Kubernetes, Helm, and Bash script</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*0CX7uETCCRpVxWG5Ib8BxA.png" /></figure><p>Before we dive into the details of automating the creation of client applications using React, FastAPI, and Kubernetes, it’s important to mention that this article is a continuation of a previous article titled “Testing Journey Chronicles: Deploying MERN Stack App in Kubernetes Cluster with Automation.” If you haven’t read that article yet, I highly recommend checking it out to gain a better understanding of the overall testing and deployment process.</p><p>The previous article (link: <a href="https://medium.com/@l.dergham/testing-journey-chronicles-deploying-mern-stack-app-in-kubernetes-cluster-with-automation-93f4501fbd21">https://medium.com/@l.dergham/testing-journey-chronicles-deploying-mern-stack-app-in-kubernetes-cluster-with-automation-93f4501fbd21</a>)</p><h3>Introduction:</h3><p>In this article, we will explore the process of automating the creation of client applications using React, FastAPI, and Kubernetes. We will dive into the step-by-step approach of building a system that efficiently handles client information, executes Bash scripts, and leverages the power of Kubernetes to create frontend and backend APIs for each client within separate namespaces. Let’s get started!</p><p>Repository Links:</p><ul><li>Project Repository: <a href="https://github.com/LahceneDer/Automate_Deploy_MERN_CRUD_App_K8s">GitHub Repository</a></li><li>Frontend (React) Application Repository: <a href="https://github.com/LahceneDer/Automate_Deploy_MERN_CRUD_App_K8s/tree/main/client-info">GitHub Repository</a></li><li>Backend (FastAPI) API Repository: <a href="https://github.com/LahceneDer/Automate_Deploy_MERN_CRUD_App_K8s/tree/main/client-info-fastapi">GitHub Repository</a></li><li>Bash Script for Application Creation: <a href="https://github.com/LahceneDer/Automate_Deploy_MERN_CRUD_App_K8s/blob/main/scripts/create-app.sh">GitHub Repository</a></li><li>Frontend (React) Application Repository (Client): <a href="https://github.com/LahceneDer/Automate_Deploy_MERN_CRUD_App_K8s/tree/main/client">GitHub Repository</a></li><li>Backend (Node.js) API Repository (Server): <a href="https://github.com/LahceneDer/Automate_Deploy_MERN_CRUD_App_K8s/tree/main/server">GitHub Repository</a></li></ul><h3>1. Frontend Application (React)</h3><p>The frontend application serves as the interface for collecting client information and sending it to the backend API. The React application provides a user-friendly form where clients can enter their information and initiate the application creation process.</p><p>The frontend application repository (<a href="https://github.com/LahceneDer/Automate_Deploy_MERN_CRUD_App_K8s/tree/main/client-info">GitHub Repository</a>) contains the necessary code and configurations for building and running the React application. It includes components, styles, and form validation logic to ensure a seamless user experience.</p><h3>2. Backend API (FastAPI)</h3><p>The backend API built with FastAPI receives the client information from the frontend application and executes the Bash script responsible for creating the client applications. FastAPI provides a robust and efficient framework for building APIs with Python.</p><p>The backend API repository (<a href="https://github.com/LahceneDer/Automate_Deploy_MERN_CRUD_App_K8s/tree/main/client-info-fastapi">GitHub Repository</a>) contains the implementation of the FastAPI server. It includes endpoints for receiving client information, executing the Bash script, and returning the relevant response.</p><h3>3. Bash Script for Application Creation</h3><p>To automate the process of creating client applications, a Bash script is used. The script takes the client information received from the backend API and utilizes Kubernetes and Helm to generate the required resources for the frontend and backend applications within separate namespaces.</p><p>The Bash script repository (<a href="https://github.com/LahceneDer/Automate_Deploy_MERN_CRUD_App_K8s/blob/main/scripts/create-app.sh">GitHub Repository</a>) provides the script’s code and necessary configurations. It interacts with Kubernetes and Helm to deploy the applications based on the provided client information.</p><h4>Configuring and Deploying the Frontend and Backend Applications ( Client information Application )</h4><p>To successfully deploy the frontend and backend applications for the client information system, follow the steps outlined below:</p><p>Update the Kubernetes Node IP Address in the ClientInfoForm.js File:</p><ul><li>Navigate to the project directory and go inside the client-info folder.</li><li>Open the file src/ClientInfoForm.js.</li><li>Locate the variable K8S_NODE_IP and update it with your Kubernetes Node IP address.</li><li>Save the changes.</li></ul><p>Rebuild and Push the Docker Image:</p><ul><li>Open a terminal and navigate to the project directory.</li><li>Build the Docker image using the following command:</li></ul><blockquote>docker build -t your-docker-hub-username/image-name .</blockquote><ul><li>Replace your-docker-hub-username/image-name with your own Docker Hub username and desired image name.</li><li>Push the Docker image to your Docker Hub repository using the following command:</li></ul><blockquote>docker push your-docker-hub-username/image-name</blockquote><p>Update the Frontend Deployment Configuration:</p><ul><li>Open the frontend-deployment.yaml file located in the project directory.</li><li>Find the image field under the containers section.</li><li>Replace lahcenedergham/k8s-client-info-app with your-docker-hub-username/image-name.</li><li>Save the changes and exit the file.</li></ul><p>Deploy the Frontend Application:</p><ul><li>Run the following command to create the deployment and service for the client info frontend app:</li></ul><blockquote>kubectl apply -f frontend-deployment.yaml</blockquote><p>Deploy the Backend API:</p><ul><li>Go inside the client-info-fastapi folder in the project directory.</li><li>Run the following command to create the deployment and service for the client info API:</li></ul><blockquote>kubectl apply -f backend-fastapi-deployment.yaml</blockquote><p>Verify Deployment:</p><ul><li>To see all the components you have created, run the following command:</li></ul><blockquote>kubectl get all</blockquote><p>Accessing the Applications:</p><ul><li>The client info frontend application will be accessible using the following URL: <a href="http://your-node-ip:30000.">http://your-node-ip:30000.</a></li><li>The client info API can be accessed using the URL: <a href="http://your-node-ip:30002.">http://your-node-ip:30002.</a></li></ul><p>By following these steps, you will have successfully configured and deployed the frontend and backend applications for the client information system. Make sure to replace your-docker-hub-username with your actual Docker Hub username and image-name with your desired image name.</p><p>Feel free to explore and test the applications using the provided URLs and continue with the automation process.</p><h3>Conclusion</h3><p>In this article, we explored the process of automating the creation of client applications using React, FastAPI, and Kubernetes. We discussed the frontend and backend components of the system, along with the Bash script responsible for deploying the applications. By following this approach, you can efficiently handle client information and leverage the power of Kubernetes to create separate applications for each client.</p><p>By utilizing the provided repository links, you can dive into the code and explore the implementation details. Feel free to modify and adapt the solution to fit your specific requirements.</p><p>Happy automating!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=159a1ea7b7e" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/automating-client-application-mern-stack-app-creation-with-react-fastapi-kubernetes-helm-and-159a1ea7b7e">Automating Client Application (MERN Stack app) Creation with React, FastAPI, Kubernetes, Helm, and…</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing Journey Chronicles: Deploying MERN Stack App in Kubernetes Cluster with Automation]]></title>
            <link>https://medium.com/@l.dergham/testing-journey-chronicles-deploying-mern-stack-app-in-kubernetes-cluster-with-automation-93f4501fbd21?source=rss-cca3bc280239------2</link>
            <guid isPermaLink="false">https://medium.com/p/93f4501fbd21</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[helm]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Dergham Lahcene]]></dc:creator>
            <pubDate>Fri, 12 May 2023 13:46:09 GMT</pubDate>
            <atom:updated>2023-05-12T13:46:09.649Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*0CX7uETCCRpVxWG5Ib8BxA.png" /></figure><h3>Introduction</h3><p>In my continuous quest to enhance my testing skills, I embarked on an exciting project to deploy a MERN (MongoDB, Express.js, React.js, Node.js) stack application in a Kubernetes cluster. This article shares the journey, challenges faced, and the testing process involved. Please note that the project is still a work in progress, and I will be writing a follow-up article to present the solutions.</p><p><strong>The MERN Stack App</strong>: The MERN stack app I’m working with is a powerful demonstration of the capabilities offered by this technology stack. It leverages MongoDB as the database, Express.js and Node.js for the backend API, and React.js for the frontend user interface. With its modular and scalable architecture, the MERN stack provides a solid foundation for building robust web applications.</p><p><strong>Deployment in Kubernetes Cluster</strong>: To harness the benefits of containerization and orchestration, I chose to deploy the MERN stack app in a Kubernetes cluster. Kubernetes offers powerful features for scaling, managing, and ensuring high availability of applications. It allows us to separate concerns and manage the application components efficiently.</p><p><strong>Helm Chart for Automation</strong>: To streamline the deployment process, I opted for Helm, the popular Kubernetes package manager. Helm enables me to create reusable and customizable charts that encapsulate the application components and configurations. By leveraging Helm charts, I can easily deploy and manage the MERN stack app with consistent configurations across multiple environments.</p><p><strong>Testing Process Overview</strong>: Throughout the project, testing has played a crucial role in ensuring the quality and reliability of the deployed application. The testing process involves multiple stages, including:</p><ol><li>Functional Testing: Rigorous functional testing is conducted to verify that the application meets the specified requirements. This includes testing the frontend user interface, backend API endpoints, data persistence, and interactions between different components.</li><li>Performance Testing: Performance testing helps assess the application’s behavior under different loads and stress conditions. By simulating high user traffic and measuring response times, throughput, and resource utilization, we gain insights into the application’s performance characteristics.</li><li>Integration Testing: Integration testing ensures that all the components of the MERN stack app work seamlessly together. It involves validating the interactions between the frontend, backend, and database components to detect any integration issues or inconsistencies.</li><li>Security Testing: Security testing is an essential aspect of the testing process. It involves identifying potential vulnerabilities, securing API endpoints, implementing proper authentication and authorization mechanisms, and adhering to security best practices.</li></ol><p><strong>The Project’s Current State</strong>: As mentioned earlier, the project is still a work in progress. While I have successfully deployed the MERN stack app in the Kubernetes cluster and automated the deployment process using Helm, there are challenges to overcome. These challenges primarily revolve around ensuring each client has their own dedicated database instance.</p><p><strong>Next Steps and Future Article</strong>: To address the challenge of shared databases, I am currently working on implementing a solution that allows each client to have their own isolated database. I will be sharing the detailed solution in a follow-up article, which will outline the steps taken to achieve this objective.</p><p><strong>Conclusion</strong>: Deploying a MERN stack app in a Kubernetes cluster and automating the deployment process with Helm has been an enlightening and rewarding experience. Through rigorous testing and continuous learning, I’m confident in delivering a robust and reliable application. Stay tuned for the upcoming article, where I will present the solutions to the shared database challenge.</p><p>#TestingJourney #QualityAssurance #SoftwareTesting #MERNStack #Kubernetes #DevOps #DeploymentAutomation #Helm #ContinuousLearning</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93f4501fbd21" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DevOps Project — Part 4]]></title>
            <link>https://medium.com/@l.dergham/devops-project-part-4-92d6641ed752?source=rss-cca3bc280239------2</link>
            <guid isPermaLink="false">https://medium.com/p/92d6641ed752</guid>
            <category><![CDATA[orchestration]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Dergham Lahcene]]></dc:creator>
            <pubDate>Sat, 25 Feb 2023 00:49:49 GMT</pubDate>
            <atom:updated>2023-02-25T00:49:49.361Z</atom:updated>
            <content:encoded><![CDATA[<h3>DevOps Project — Part 4</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mv9QZcLEan1O8wZ5V4K2OQ.png" /></figure><p>In <a href="https://medium.com/@l.dergham/devops-project-part-3-9e4eb8bfa291">Part 3</a> we <em>Containerized FastAPI Application (CRUD App) with Postgresql Database.</em></p><p>In this article we will =&gt;</p><h4>Deploy a FastAPI app with a PostgreSQL database using Kubernetes:</h4><p>To deploy a FastAPI app with a PostgreSQL database using Kubernetes, you will need to perform the following steps:</p><ol><li>Create a Docker image of your FastAPI app with the database connection settings and the necessary dependencies installed. You can use a Dockerfile to build the image.</li><li>Push the Docker image to a container registry like Docker Hub, Amazon ECR, or Google Container Registry.</li><li>Create a Kubernetes deployment for your FastAPI app, specifying the container image and the environment variables needed for the database connection.</li><li>Create a Kubernetes service to expose your app within the cluster, so that it can be accessed by other pods.</li><li>Create a Kubernetes stateful set for your PostgreSQL database, specifying the container image, the persistent volume claims, and the environment variables needed for the database settings.</li><li>Create a Kubernetes service to expose the PostgreSQL database within the cluster, so that it can be accessed by other pods.</li><li>Update the configuration of your FastAPI app to use the DNS name of the PostgreSQL service as the database host.</li><li>Deploy the Kubernetes resources to your cluster and verify that your app and database are running correctly.</li></ol><p>Before we start the deployment, we will dive into some concepts to help us understand all the steps.</p><h4>Kubernetes:</h4><p>Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF). Kubernetes provides a framework for deploying, scaling, and managing containerized applications and services across a cluster of machines. It abstracts away the underlying infrastructure and provides a unified API for managing the resources of the cluster.</p><p>With Kubernetes, you can:</p><ul><li>Deploy and manage containers at scale</li><li>Load balance traffic across containers</li><li>Automatically scale up or down based on demand</li><li>Roll out updates or rollbacks with ease</li><li>Monitor and troubleshoot containerized applications</li><li>Maintain high availability and resilience</li><li>And more.</li></ul><p>Kubernetes is widely used in production environments and is supported by a large and active community of contributors. It is compatible with a variety of container runtimes and works with most popular cloud providers.</p><p>In Kubernetes, there are several components that work together to provide a platform for deploying and managing containerized applications. These components include:</p><ol><li><strong>Control Plane:</strong> This is the set of components that manage the Kubernetes cluster. It includes the API server, etcd, kube-scheduler, kube-controller-manager, and cloud-controller-manager.</li><li><strong>Nodes:</strong> These are the worker machines in the Kubernetes cluster that run the applications. Each node has a container runtime, such as Docker or containerd, and a kubelet that communicates with the control plane.</li><li><strong>Pods:</strong> These are the smallest deployable units in Kubernetes. A pod is a single instance of a running process in a cluster.</li><li><strong>Services:</strong> These provide a stable IP address and DNS name for a set of pods. Services allow other components in the cluster to communicate with the pods in a decoupled and reliable way.</li><li><strong>Volumes:</strong> These are used to provide persistent storage for containers in a cluster. Volumes can be backed by a variety of storage systems, including local disks, network file systems, and cloud storage.</li><li><strong>ConfigMaps and Secrets:</strong> These are used to store configuration data and sensitive information, respectively, and make them available to pods running in the cluster.</li><li><strong>Ingress:</strong> This is used to expose HTTP and HTTPS routes from outside the cluster to services running inside the cluster.</li><li><strong>Namespace:</strong> This provides a way to logically partition the cluster into virtual sub-clusters, allowing different teams or applications to operate independently in the same physical cluster.</li></ol><p>Now, we can start with first step which is :</p><ul><li>Push the Docker image to a container registry like Docker Hub .</li></ul><p>In the last article, we created dockerfile and docker compose and created docker images for both FastAPI App and Postgres DB, and now we have to push the FastAPI image to the Docker hub.</p><pre>docker push lahcenedergham/fastapi-image</pre><p>you can replace “lahcenedergham” by your docker hub username.</p><ul><li>Create a Kubernetes deployment for your FastAPI app, specifying the container image and the environment variables needed for the database connection.</li></ul><h4>Kubernetes installation:</h4><p>Kubernetes can be installed on various platforms such as on-premises servers, cloud providers, or even on a single local machine for development and testing purposes. The installation process may vary depending on the platform and the deployment method you choose.</p><p>Here is a brief overview of the installation process for some popular deployment options:</p><ol><li>Minikube: Minikube is a tool that allows you to run Kubernetes locally on your machine. To install Minikube, you need to have a hypervisor installed (e.g., VirtualBox or KVM) and then download the Minikube binary from the official website. Once installed, you can start Minikube and use the kubectl command-line tool to interact with your local Kubernetes cluster.</li><li>Cloud providers: Most cloud providers offer Kubernetes as a managed service, which means that you don’t have to worry about installing or maintaining the Kubernetes cluster yourself. You can simply create a new Kubernetes cluster from the provider’s dashboard and start deploying your applications.</li><li>On-premises servers: If you want to install Kubernetes on your own servers, you can use one of the popular Kubernetes installation tools such as kubeadm, kops, or Rancher. These tools automate the installation process and provide you with a fully functional Kubernetes cluster.</li><li>Container images: Another way to install Kubernetes is by using container images. You can download a pre-built Kubernetes image from the official registry (Docker Hub) and run it on any platform that supports containerization. This approach is useful if you want to run Kubernetes in a lightweight and portable environment.</li></ol><p>Regardless of the installation method you choose, it is important to follow the Kubernetes best practices and security guidelines to ensure that your cluster is secure and stable</p><p>We choose the first option ( just a choice) , If you want to install Kubernetes locally for development or testing purposes, Minikube is a great option.</p><p>To install Kubernetes using the command line, you can follow these general steps:</p><ol><li>Install a container runtime, such as Docker, on your machine.</li><li>Install the kubectl command-line tool.</li><li>Install a Kubernetes distribution, such as Minikube, on your machine.</li><li>Start the Kubernetes cluster using the appropriate command.</li><li>Verify that the cluster is running and get the cluster information using the appropriate command.</li></ol><p>Here are the commands to install Kubernetes using Minikube on Ubuntu:</p><ul><li>Install Docker:</li></ul><pre>sudo apt-get update<br>sudo apt-get install -y docker.io<br>sudo systemctl start docker<br>sudo systemctl enable docker</pre><ul><li>Install kubectl:</li></ul><pre>sudo apt-get update<br>sudo apt-get install -y apt-transport-https ca-certificates curl<br>curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -<br>echo &quot;deb https://apt.kubernetes.io/ kubernetes-xenial main&quot; | sudo tee /etc/apt/sources.list.d/kubernetes.list<br>sudo apt-get update<br>sudo apt-get install -y kubectl</pre><ul><li>Install Minikube:</li></ul><pre>curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb<br>sudo dpkg -i minikube_latest_amd64.deb</pre><ul><li>Start the Kubernetes cluster:</li></ul><pre>minikube start</pre><ul><li>Verify that the cluster is running and get the cluster information:</li></ul><pre>kubectl cluster-info<br>kubectl get nodes</pre><p>before we create the deployment, we should create secret for the environment variables</p><p>Here’s an example of fastapi secret yaml file:</p><pre>apiVersion: v1<br>kind: Secret<br>metadata:<br>  name: fastapi-secret<br>  labels:<br>    app: fastapi<br>data: <br>  URL : cG9zdGdyZXNxbDovL2Zhc3RhcGlfdXNlcjpmYXN0YXBpX3Bhc3N3ZEBwb3N0Z3Jlcy1zZXJ2aWNlOjU0MzIvZmFzdGFwaV9kYg==</pre><p>to encode URL, Here’s an example :</p><pre>echo -n &quot;postgresql://user:password@localhost:5432/mydatabase&quot; | base64</pre><p>output: cG9zdGdyZXNxbDovL3VzZXI6cGFzc3dvcmRAbG9jYWxob3N0OjU0MzIvbXlkYXRhYmFzZQ==</p><p>Then , Create FastApi deployment and service …</p><p>Here’s an example Kubernetes Deployment and Service</p><pre># fastapi-deployment.yaml<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: fastapi<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: fastapi<br>  template:<br>    metadata:<br>      labels:<br>        app: fastapi<br>    spec:<br>      containers:<br>        - name: fastapi<br>          image: lahcenedergham/fastapi-image:latest<br>          env:<br>          - name: DATABASE_URL<br>            valueFrom:<br>              secretKeyRef:<br>                name: fastapi-secret<br>                key: URL<br>          ports:<br>            - containerPort: 5000</pre><pre># fastapi-service.yaml<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: fastapi<br>spec:<br>  type: ClusterIP<br>  selector:<br>    app: fastapi<br>  ports:<br>    - name: http<br>      port: 5000<br>      targetPort: 5000<br>      protocol: TCP</pre><p>Now, we should create fastapi secret first then deployment and service ,</p><p>Creating Kubernetes secrets before deployment is considered a best practice because it helps to keep sensitive information like passwords, API keys, and certificates secure. Kubernetes secrets are used to store such information in an encrypted format, and then the secrets can be mounted as environment variables or volumes to the containers running inside the pod.</p><p>By creating a Kubernetes secret before deployment, you can ensure that sensitive data is not visible in the YAML files or the container logs, reducing the risk of accidental exposure of sensitive information. Additionally, Kubernetes secrets can be managed independently from the deployment manifest files, which allows you to update secrets without having to redeploy the entire application.</p><p>To create those components :</p><pre>kubectl apply -f fastapi-secret.yaml<br>kubectl apply -f fastapi-deployment.yaml<br>kubectl apply -f fastapi-service.yaml</pre><p>To check if the components completely created :</p><pre>kubectl get all | grep fastapi</pre><p>or</p><pre>kubectl get deployments<br>kubectl get pods<br>kubectl get secrets<br>kubectl get services</pre><p>Now, we move to Postgres database deployment, We will follow the next steps</p><p>1- Create postgres secret</p><p>2- Create postgres deployment</p><p>3- Create postgres service</p><p>Here’s an example of yaml files:</p><pre>#postgres-secret.yaml<br>apiVersion: v1<br>kind: Secret<br>metadata: <br>  name: postgres-secret<br>type: Opaque<br>data:<br>  postgres-username: ZmFzdGFwaV91c2Vy<br>  postgres-password: ZmFzdGFwaV9wYXNzd2Q=<br>  postgres-database: ZmFzdGFwaV9kYg==</pre><p>To encode the username, passwd and database name we use the same command:</p><pre>echo -n &quot;postgres_user&quot; | base64<br>echo -n &quot;postgres_passwd&quot; | base64<br>echo -n &quot;postgres_db&quot; | base64</pre><pre>#postgres-deployment.yaml<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: postgres<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: postgres<br>  template:<br>    metadata:<br>      labels:<br>        app: postgres<br>    spec:<br>      containers:<br>        - name: postgres<br>          image: postgres<br>          ports:<br>            - containerPort: 5432<br>          env:<br>            - name: POSTGRES_USER<br>              valueFrom:<br>                secretKeyRef:<br>                  name: postgres-secret<br>                  key: postgres-username<br>            - name: POSTGRES_PASSWORD<br>              valueFrom:<br>                secretKeyRef:<br>                  name: postgres-secret<br>                  key: postgres-password<br>            - name: POSTGRES_DB<br>              valueFrom:<br>                secretKeyRef:<br>                  name: postgres-secret<br>                  key: postgres-database<br>          ports:<br>            - containerPort: 5432</pre><pre># postgres-service.yaml<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: postgres-service<br>spec:<br>  selector:<br>    app: postgres<br>  ports:<br>    - name: postgres-service-port<br>      port: 5432<br>      targetPort: 5432</pre><p>To create postgres secret, deployment and service :</p><pre>kubectl apply -f postgres-secret.yaml<br>kubectl apply -f postgres-deployment.yaml<br>kubectl apply -f postgres-service.yaml</pre><p>To check if the components completely created :</p><pre>kubectl get all | grep postgres</pre><p>Now, we’re done with all components …</p><p>But we have to expose our fastapi service to access the app from our browser using kubernetes ingress</p><p>To enable ingress on minikube, you can follow these steps:</p><ul><li>Start minikube with the ingress addon enabled:</li></ul><pre>minikube start --addons=ingress</pre><ul><li>Verify that the ingress addon is enabled:</li></ul><pre>minikube addons list</pre><p>This should show ingress: enabled.</p><ul><li>Deploy an ingress controller:</li></ul><p>You can use the Nginx ingress controller by applying the following YAML manifest:</p><pre>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.0/deploy/static/provider/cloud/deploy.yaml</pre><p>This will create a deployment for the ingress controller and a service to expose it.</p><ul><li>Verify that the ingress controller is running:</li></ul><pre>kubectl get pods -n ingress-nginx</pre><p>To set up an Ingress for a FastAPI app running in Kubernetes, you can follow these steps:</p><ul><li>Create an Ingress YAML file that defines the routing rules for your app. Here’s an example file that forwards all requests to the / endpoint to the FastAPI app running on port 5000:</li></ul><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: my-ingress<br>  annotations:<br>    nginx.ingress.kubernetes.io/rewrite-target: /<br>spec:<br>  rules:<br>  - host: myapp.example.com<br>    http:<br>      paths:<br>      - path: /<br>        pathType: Prefix<br>        backend:<br>          service:<br>            name: fastapi-service<br>            port:<br>              name: http</pre><p>In this example, the host field specifies the domain name that you want to use to access your app, and the backend field specifies the Kubernetes Service that is exposing your FastAPI app.</p><ul><li>Apply the Ingress YAML file to your Kubernetes cluster using the kubectl apply command:</li></ul><pre>kubectl apply -f my-ingress.yaml</pre><ul><li>Create a DNS record that points to the IP address of the Kubernetes Ingress controller. The exact process for doing this depends on your DNS provider.</li><li>Test your app by visiting the domain name that you specified in the host field of your Ingress YAML file.</li></ul><p>Finally !!! we have all done</p><p>You can access to you app now =&gt; myapp.example.com ( in your browser )</p><p>Thank you for your patient</p><p><a href="https://www.linkedin.com/in/lahcene-dergham/">Lahcene Dergham</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92d6641ed752" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>