<?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 Paul Adino on Medium]]></title>
        <description><![CDATA[Stories by Paul Adino on Medium]]></description>
        <link>https://medium.com/@adinopaul001?source=rss-b787949521e4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mizPnDEkUxUWZayQ22yL3Q.jpeg</url>
            <title>Stories by Paul Adino on Medium</title>
            <link>https://medium.com/@adinopaul001?source=rss-b787949521e4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:27:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adinopaul001/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[Beyond the MCP Basics]]></title>
            <link>https://medium.com/@adinopaul001/beyond-the-mcp-basics-8e0111e8cddf?source=rss-b787949521e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e0111e8cddf</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[canary-deployments]]></category>
            <dc:creator><![CDATA[Paul Adino]]></dc:creator>
            <pubDate>Fri, 16 Oct 2026 09:02:18 GMT</pubDate>
            <atom:updated>2026-10-16T09:02:18.011Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring Model Context Protocol Through an AI-Powered Canary Deployment Agent</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5OFZ3VraQ9QwgURpEABVTg.jpeg" /></figure><h3>Introduction</h3><p>In this age of AI, new concepts seem to emerge every now and then. There is one in particular that I have been hearing about quite often. Whenever there is talk of agents or agentic AI, this word seems to follow: MCPs.</p><p>This is what we are going to talk about today. Not just definitions that you can Google, but also how MCP can be used in a practical scenario. We’ll walk through an example, explore the architecture behind it, and look at some of the problems you might encounter along the way. Hopefully, by the end, you’ll understand not only what MCP is, but also why it matters and where it can be useful.</p><p>But first, we need to understand the problem it is trying to solve.</p><h3>1. What Is MCP, and Why Do We Need It?</h3><p>Large language models (LLMs), such as ChatGPT and Claude, rely on context to generate relevant responses and make informed decisions. AI agents take this a step further by using models alongside tools, external information, and instructions to accomplish tasks.</p><p>However, a model’s usefulness depends partly on the information and capabilities available to it. Without access to the right data or tools, it may provide incomplete answers, rely on outdated information, or make incorrect assumptions.</p><p>Traditionally, connecting an AI application to different databases, APIs, and software systems requires developers to build individual integrations. As the number of systems grows, maintaining these integrations can become increasingly complex.</p><p>The <strong>Model Context Protocol (MCP)</strong> addresses this challenge by providing a standardized way for AI applications to discover and interact with external tools and contextual information.</p><p>Think of it as a common interface between an AI application and the systems it needs to work with. Instead of designing an entirely different integration approach for every tool, developers can expose capabilities through MCP servers that compatible applications can discover and invoke.</p><p>MCP does not automatically make every service compatible, nor does it decide what an agent should do. The underlying integrations still have to be built, and the application still needs logic to decide when and how to use them.</p><p>So, where does this become interesting?</p><p>Imagine we have a DevOps deployment agent whose job is to roll out software updates, monitor production, and stop a rollout if something goes wrong.</p><p>To accomplish this, the agent needs to interact with three different systems:</p><ul><li>A traffic router that controls which version of an application receives user requests.</li><li>A monitoring system that tells us how the application is performing.</li><li>A deployment pipeline that tracks releases and deployment status.</li></ul><p>Without a standardized integration approach, the agent would need custom communication logic for each system. With MCP, we can expose the relevant capabilities through tools and let the AI application discover and invoke them through a common protocol.</p><p>This gives us an interesting problem to explore: <strong>How can we use MCP to connect an AI agent to the systems involved in a canary deployment, and what would it take to make that process reliable?</strong></p><h3>2. Our Use Case: An Autonomous Canary Deployment Agent</h3><p>Before looking at MCP in detail, let’s understand the deployment process.</p><p>A canary deployment introduces a new version of an application to a small portion of live traffic before making it available to everyone. Rather than immediately replacing the existing version, we gradually increase the amount of traffic directed to the new version while monitoring its behaviour.</p><p>For example, we might progress through these stages:</p><p>5% → 25% → 50% → 100%</p><p>At each stage, we observe the application and determine whether it is safe to proceed.</p><p>Our proposed agent will help coordinate this process. It will change traffic allocation, collect operational metrics, evaluate predefined thresholds, and either advance to the next stage or initiate a rollback.</p><p>To do this, it needs access to three external systems.</p><h3>World 1: The traffic router — the hands on the faucet</h3><p>A traffic router directs incoming requests to the appropriate application instances. This could involve an ingress controller, an API gateway, or Envoy Proxy.</p><p>For our example, assume the existing application is running version v1, while the new version is v2.</p><p>The agent needs a way to request that only 5% of eligible traffic goes to v2, while the remaining 95% continues to v1.</p><p>If the new version begins returning errors, the agent should be able to request that canary traffic be reduced to zero.</p><p>The important distinction is that the agent does not change traffic simply because the model thinks it should. The routing integration must validate the request, enforce the permitted range, and verify that the change was actually applied.</p><h3>World 2: The telemetry engine — the eyes and vitals</h3><p>The agent also needs visibility into what happens after the traffic changes.</p><p>A monitoring system such as Prometheus collects and stores metrics that help us understand application behaviour. These might include:</p><ul><li>HTTP 5xx error rates.</li><li>CPU and memory usage.</li><li>Database connection failures.</li><li>Request latency, including p99 latency.</li><li>Other application-specific health indicators.</li></ul><p>Suppose the agent has directed 5% of traffic to v2. After an appropriate observation window, it asks the monitoring system whether the new version is experiencing elevated errors or unacceptable latency.</p><p>Without reliable telemetry, the agent has no sound basis for deciding whether the deployment should proceed.</p><p>It is equally important to recognize that missing metrics do not mean the application is healthy. If the monitoring system cannot provide a reliable answer, the agent needs to treat the result as unknown rather than assume the rollout is safe.</p><h3>World 3: The deployment pipeline — the system of record</h3><p>The third system manages the release and deployment lifecycle.</p><p>This could involve GitHub Actions, Argo CD, or another deployment platform, depending on how the environment is designed.</p><p>The agent needs to know which version is being deployed and whether the deployment has succeeded. If a canary fails, reducing its traffic may not be enough: the unsuccessful rollout may still need to be marked as failed, and the deployment controller may need to restore the last known good version.</p><p>For this example, GitHub Actions can represent the pipeline and release workflow. However, changing traffic through Envoy and reverting the deployed application are separate operations. A real implementation must connect those operations explicitly rather than assume that a traffic change automatically rolls back a release.</p><p>Now that we understand the three systems, we can explore how MCP fits into the design.</p><h3>3. Understanding the Architecture</h3><p>Our proposed system separates the agent’s decision-making logic from the integrations that communicate with external services.</p><p>At a high level, it consists of four components:</p><ol><li><strong>The agent and orchestrator:</strong> Manage the deployment workflow and determine what should happen next.</li><li><strong>The MCP host and clients:</strong> Manage MCP connections, discover available tools, and route tool calls to the appropriate servers.</li><li><strong>The MCP servers:</strong> Expose specific capabilities, such as changing traffic allocation or querying telemetry.</li><li><strong>The external systems:</strong> Envoy or its control plane, Prometheus, and the deployment pipeline.</li></ol><p>The interaction looks like this:</p><pre>AGENT APPLICATION<br>        +---------------------------+<br>        |       LLM / Evaluator     |<br>        |             |             |<br>        |      Orchestrator         |<br>        |             |             |<br>        |       MCP Host            |<br>        |        /       \          |<br>        |  MCP Client  MCP Client   |<br>        +------|-----------|--------+<br>               |           |<br>             stdio    Streamable HTTP<br>               |           |<br>        +------v----+ +----v---------+<br>        | MCP Server| | MCP Server   |<br>        |   Envoy   | | Prometheus   |<br>        +-----|-----+ +------|-------+<br>              |              |<br>        +-----v-----+  +-----v-------+<br>        | Traffic   |  | Metrics     |<br>        | Control   |  | Database    |<br>        +-----------+  +-------------+</pre><p>The diagram shows two representative MCP connections. A deployment-pipeline integration could be added using another MCP server or another suitable integration mechanism.</p><h3>What happens inside this architecture?</h3><p>The MCP host is part of the AI application. It manages the MCP clients, which establish sessions with the individual MCP servers.</p><p>Each server exposes tools with names, descriptions, and input schemas. For example, one server might expose set_canary_weight, while another exposes query_canary_telemetry.</p><p>The host can discover these tools and make their descriptions available to the model. When a tool call is selected, the host routes it through the appropriate MCP client to the server that implements it.</p><p>The server then validates and handles the request, interacts with the underlying system, and returns a result.</p><p>MCP uses JSON-RPC 2.0 messages for protocol communication. The actual transport depends on how the client and server are connected. For example, a local server may communicate over standard input and output (stdio), while a remotely accessible server can use Streamable HTTP.</p><p>This is the central idea: the model does not need to implement a separate low-level API integration every time it wants to use a tool. The application uses MCP to manage that interaction.</p><p>However, MCP does not provide the entire deployment workflow. The orchestrator, policy checks, monitoring logic, and recovery mechanisms still have to be designed.</p><h3>4. Designing the Repository</h3><p>Let’s translate the architecture into a possible Python project structure.</p><pre>devops-canary-agent/<br>├── configs/<br>│   ├── agent_config.yaml<br>│   └── mcp_servers.json<br>├── src/<br>│   ├── agent/<br>│   │   ├── orchestrator.py<br>│   │   ├── prompts.py<br>│   │   └── evaluator.py<br>│   ├── host/<br>│   │   ├── mcp_host.py<br>│   │   ├── client_session.py<br>│   │   └── transport/<br>│   │       └── stdio_transport.py<br>│   └── servers/<br>│       ├── custom_envoy/<br>│       │   ├── server.py<br>│       │   ├── envoy_client.py<br>│       │   └── schemas.py<br>│       └── thirdparty_prometheus/<br>│           ├── server.py<br>│           ├── prometheus_client.py<br>│           └── schemas.py<br>├── tests/<br>│   ├── unit/<br>│   └── integration/<br>├── pyproject.toml<br>└── README.md</pre><p>This structure is a proposed blueprint, not a requirement imposed by MCP. The modules can be organized differently depending on the framework and deployment environment.</p><p>The important thing is the separation of responsibilities.</p><ul><li>orchestrator.py manages the canary lifecycle.</li><li>evaluator.py applies deterministic deployment policies and validates observed metrics.</li><li>mcp_host.py manages the MCP connections and tool discovery.</li><li>custom_envoy/server.py exposes traffic-control tools.</li><li>envoy_client.py communicates with the chosen traffic-control API.</li><li>thirdparty_prometheus/server.py exposes telemetry tools.</li><li>prometheus_client.py queries Prometheus and converts its response into a form the agent can use.</li></ul><p>Notice that the external API logic lives in helper modules rather than being mixed into the agent’s reasoning code. This makes the integrations easier to test and maintain.</p><h3>5. Building the First Integration: Traffic Control</h3><p>Let’s start with the Envoy integration.</p><p>Our MCP server will expose a tool called set_canary_weight. It accepts a service name and a traffic percentage, validates the inputs, and delegates the actual network request to a helper.</p><p>The tool might be described using a schema like this:</p><pre>SET_CANARY_TOOL_SCHEMA = {<br>    &quot;name&quot;: &quot;set_canary_weight&quot;,<br>    &quot;description&quot;: (<br>        &quot;Updates the percentage of traffic &quot;<br>        &quot;routed to a canary deployment.&quot;<br>    ),<br>    &quot;inputSchema&quot;: {<br>        &quot;type&quot;: &quot;object&quot;,<br>        &quot;properties&quot;: {<br>            &quot;service&quot;: {<br>                &quot;type&quot;: &quot;string&quot;<br>            },<br>            &quot;weight&quot;: {<br>                &quot;type&quot;: &quot;integer&quot;,<br>                &quot;minimum&quot;: 0,<br>                &quot;maximum&quot;: 100<br>            }<br>        },<br>        &quot;required&quot;: [&quot;service&quot;, &quot;weight&quot;]<br>    }<br>}</pre><p>This illustrates the tool’s input contract. A complete MCP server would register the tool using the chosen SDK and implement the corresponding request handler.</p><p>The schema tells the host and model what arguments the tool expects. It also establishes a basic constraint: the traffic percentage must be between zero and one hundred.</p><p>Schema validation alone, however, is not sufficient for production safety. The server must enforce the same constraints, authenticate requests, authorize the requested operation, and ensure that the service is eligible for the change.</p><h3>The helper that communicates with the external API</h3><p>The server should not need to know all the details of HTTP communication. We can place that responsibility in a separate helper.</p><pre>import httpx<br>class EnvoyClient:<br>    def __init__(<br>        self,<br>        base_url: str,<br>        timeout_seconds: float = 5.0,<br>    ):<br>        self.base_url = base_url.rstrip(&quot;/&quot;)<br>        self.timeout = timeout_seconds</pre><pre>    async def update_canary_weight(<br>        self,<br>        service: str,<br>        weight: int,<br>    ) -&gt; dict:<br>        if not 0 &lt;= weight &lt;= 100:<br>            raise ValueError(<br>                &quot;Canary weight must be between 0 and 100&quot;<br>            )</pre><pre>        endpoint = (<br>            f&quot;{self.base_url}/api/v1/routes/{service}&quot;<br>        )</pre><pre>        payload = {<br>            &quot;service_name&quot;: service,<br>            &quot;target_cluster&quot;: f&quot;{service}-canary&quot;,<br>            &quot;weight&quot;: weight,<br>        }</pre><pre>        async with httpx.AsyncClient(<br>            timeout=self.timeout<br>        ) as client:<br>            response = await client.post(<br>                endpoint,<br>                json=payload,<br>            )<br>            response.raise_for_status()<br>            return response.json()</pre><p>This is an illustrative helper for a hypothetical traffic-control API. The endpoint and payload are part of the example integration; they are not a universal Envoy API contract.</p><p>A few details are worth noting.</p><p>First, the helper validates the traffic percentage before sending the request. Second, the HTTP client has a timeout, so a stalled control-plane request does not wait indefinitely. Third, raise_for_status() makes HTTP errors visible to the caller instead of treating an unsuccessful response as a successful update.</p><p>The server’s tool handler would call this helper and return a structured result to the MCP host.</p><p>For a successful request, the response might report that the requested weight was accepted. A robust implementation should also verify the effective routing configuration, because a successful HTTP response does not necessarily prove that the intended traffic distribution is active.</p><h3>6. Adding Observability with Prometheus</h3><p>The next integration is responsible for determining whether the canary is healthy.</p><p>Our telemetry tool will accept a service name and an observation window, query Prometheus, and return the resulting metrics.</p><p>Instead of passing raw PromQL responses to the agent, we can convert them into a small, clearly defined result:</p><pre>{<br>  &quot;service&quot;: &quot;checkout-api&quot;,<br>  &quot;status&quot;: &quot;ok&quot;,<br>  &quot;error_rate_percentage&quot;: 0.04,<br>  &quot;window_observed_seconds&quot;: 120<br>}</pre><p>This is an example of the result we want our helper to produce, not a live result from a running system.</p><p>The advantage is that the agent receives the information it needs without having to interpret a large time-series response or construct queries itself.</p><h3>Querying the error rate</h3><p>Suppose Prometheus exposes an http_requests_total counter with service and status labels.</p><p>A simplified PromQL query for the percentage of HTTP 5xx responses over a sliding window is:</p><pre>100 *<br>sum(rate(http_requests_total{<br>  service=&quot;checkout-api&quot;,<br>  status=~&quot;5..&quot;<br>}[2m]))<br>/<br>sum(rate(http_requests_total{<br>  service=&quot;checkout-api&quot;<br>}[2m]))</pre><p>The rate() function estimates the per-second increase in a counter over the selected window. We then divide the rate of 5xx responses by the rate of all requests and multiply by 100.</p><p>This query assumes that the relevant metrics and labels exist and that the denominator is meaningful. A real implementation must also handle cases where there are no matching series or no traffic.</p><p>The Python helper can submit the query through Prometheus’s HTTP API, check the HTTP response, validate the Prometheus response status, and extract the numeric result.</p><p>It should not automatically interpret an empty result as zero errors. If no requests have reached the canary, for example, there may be no evidence of health at all.</p><p>The helper should return an explicit unknown or unavailable state when the data is insufficient.</p><h3>What about p99 latency?</h3><p>The architecture also includes a latency threshold, because a deployment can return successful responses while still making the application significantly slower.</p><p>If the application exposes suitable histogram metrics, Prometheus can calculate a latency percentile using histogram_quantile(). The exact query depends on the histogram metric name, labels, and bucket configuration.</p><p>The latency query should be implemented and validated separately, then included in the telemetry result. If it is not implemented, the system must not claim to have verified the p99 latency threshold.</p><p>This is an important distinction between designing a capability and actually implementing it.</p><h3>7. Putting the Pieces Together: The Canary Lifecycle</h3><p>We now have the main building blocks: a tool for changing traffic and a tool for observing application health.</p><p>The orchestrator coordinates the overall workflow.</p><p>A simplified policy configuration might look like this:</p><pre>service: &quot;checkout-api&quot;</pre><pre>canary_strategy:<br>  steps: [5, 25, 50, 100]<br>  stabilization_window_seconds: 60</pre><pre>slo_thresholds:<br>  max_error_rate_percent: 0.50<br>  max_p99_latency_ms: 300</pre><p>The configuration separates deployment policy from the implementation of the MCP servers.</p><p>We can now describe the lifecycle in five steps.</p><p><strong>Step 1: Initialize the rollout.</strong></p><p>The orchestrator loads the configuration, confirms the target service and deployment version, and checks that the necessary tools and monitoring data are available.</p><p><strong>Step 2: Shift traffic.</strong></p><p>The orchestrator invokes set_canary_weight with the next configured traffic percentage.</p><p><strong>Step 3: Observe the application.</strong></p><p>The system waits for a suitable stabilization period, accounting for the monitoring scrape interval and the time required for enough canary requests to accumulate.</p><p><strong>Step 4: Evaluate the metrics.</strong></p><p>The telemetry tool returns the observed error rate and latency. Deterministic policy logic compares the values against the configured thresholds.</p><p>The outcome should be one of three states:</p><ul><li><strong>Healthy:</strong> Sufficient valid telemetry is available, and all required thresholds pass.</li><li><strong>Breached:</strong> A configured threshold has been exceeded.</li><li><strong>Unknown:</strong> The data is missing, stale, invalid, or otherwise insufficient to establish health.</li></ul><p><strong>Step 5: Advance or stop.</strong></p><p>If the canary is healthy, the orchestrator advances to the next traffic percentage. If a threshold is breached, it initiates the configured rollback procedure. If health is unknown, it must not promote the canary; it should hold or reduce exposure according to the defined safety policy and alert an operator.</p><p>The loop continues until the deployment reaches 100% traffic or the rollout is stopped.</p><p>A simplified representation of the decision logic looks like this:</p><pre>for weight in traffic_steps:</pre><pre>    await set_canary_weight(service, weight)<br>    await wait_for_stabilization()</pre><pre>    metrics = await query_canary_telemetry(service)</pre><pre>    if not metrics_are_valid(metrics):<br>        await hold_and_alert(service)<br>        return &quot;DEPLOYMENT_HELD&quot;</pre><pre>    if violates_slo(metrics, thresholds):<br>        await rollback_canary(service)<br>        return &quot;DEPLOYMENT_ABORTED&quot;</pre><pre>return &quot;DEPLOYMENT_SUCCESSFUL&quot;</pre><p>This is illustrative orchestration logic rather than a complete runnable implementation. The helper functions represent the integrations and policy checks described above.</p><p>One important design principle is that the model should not be the sole authority deciding whether numerical thresholds have passed. The LLM can assist with interpreting incidents and explaining results, but deterministic code should enforce the deployment policy.</p><h3>8. Failure Modes: What Happens When Things Go Wrong?</h3><p>A deployment agent needs more than a successful execution path. It must also handle failures in the systems it depends on.</p><p>Let’s examine some of the failure scenarios that matter in this architecture.</p><h3>Failure 1: The frozen pipe problem</h3><p>When an MCP server uses stdio transport, the client and server exchange protocol messages through the process’s standard input and output streams.</p><p>Suppose a developer adds a debugging statement that writes directly to stdout:</p><pre>print(&quot;Updating canary traffic...&quot;)</pre><p>If this output shares the same stream as the MCP protocol messages, the client may receive unexpected text where it expects a valid protocol message. That can break message parsing and interrupt communication.</p><p>The solution is to send diagnostic logs to stderr and reserve stdout exclusively for protocol communication.</p><p>There is another concern: if a server writes to a pipe faster than the client can read, the pipe buffer can fill and block the writing process. The exact buffer capacity varies by operating system and configuration, so it should not be treated as a fixed universal value.</p><p>This is why transport handling, logging, and process supervision matter even when the tool itself appears straightforward.</p><h3>Failure 2: Stale telemetry</h3><p>Prometheus collects metrics at configured intervals. If the scrape interval is 15 seconds, changing traffic and immediately querying the monitoring system may not provide enough new observations to assess the canary.</p><p>For example, the agent could increase traffic from 5% to 25% and query a 60-second window immediately afterward. Much of the available data may reflect the period before the change.</p><p>A waiting period can help, but simply waiting twice the scrape interval does not guarantee that the data is fresh or statistically useful.</p><p>The implementation should account for scrape timing, query windows, ingestion delays, and the number of requests observed at the new traffic level. It should also distinguish between a valid zero-error measurement and the absence of usable measurements.</p><h3>Failure 3: The control plane hangs</h3><p>Imagine the agent invokes the traffic-control tool, but the underlying control-plane API stops responding.</p><p>Without a network timeout, the HTTP request may remain blocked for an extended period. The tool handler cannot complete, and the orchestrator may be unable to progress.</p><p>With a timeout, the request fails within a bounded period, allowing the application to handle the error.</p><p>However, a timeout introduces an important ambiguity: the request may have been applied even if the response never reached the client.</p><p>The agent must therefore reconcile the actual traffic state before retrying or deciding what to do next. Blindly repeating a state-changing operation can create unexpected behaviour if the operation is not designed to be safely repeatable.</p><h3>Failure 4: Prometheus returns no usable result</h3><p>A new canary may not yet have received requests. The relevant metric series may be absent, or the denominator in the error-rate calculation may be zero.</p><p>Prometheus may return a successful API response containing an empty result or a non-finite result rather than an HTTP error.</p><p>The helper must validate the returned data before converting it into a number. It should distinguish between a valid measurement, a breached threshold, and insufficient data.</p><p>Otherwise, a missing metric could accidentally become a reported error rate of zero, leading the orchestrator to promote an unhealthy or untested release.</p><h3>Failure 5: The orchestrator crashes at 50%</h3><p>Consider what happens if the Python process running the orchestrator is terminated while the canary is receiving 50% of live traffic.</p><p>Does Envoy automatically restore the previous routing configuration?</p><p>Not necessarily.</p><p>The traffic configuration may remain at 50% even though the agent responsible for monitoring it is no longer running. MCP does not provide an automatic rollback mechanism when a client or host process terminates.</p><p>This is one of the most important architectural questions in the entire project.</p><p>A more resilient design would include an independent recovery mechanism, such as a watchdog or controller that can detect an abandoned rollout, reconcile the desired and actual states, and execute a defined recovery procedure.</p><p>The system should also record its rollout state durably, enforce permissions on state-changing tools, and alert operators when recovery cannot be completed.</p><p>The broader lesson is that <strong>an agent that can initiate a deployment change must also be designed to handle the consequences when its own execution fails.</strong></p><h3>9. Security and Operational Safeguards</h3><p>Because this agent can influence live traffic and deployment state, security cannot be treated as an afterthought.</p><p>A few safeguards should be part of the design from the beginning:</p><ul><li><strong>Least privilege:</strong> Give each integration only the permissions it needs. A telemetry server should not have unnecessary routing or deployment permissions.</li><li><strong>Input validation:</strong> Validate service names, traffic percentages, query parameters, and other tool arguments before making external requests.</li><li><strong>Explicit authorization:</strong> Restrict which deployments and operations the agent can modify.</li><li><strong>Auditability:</strong> Record requested changes, observed state, policy decisions, and rollback outcomes.</li><li><strong>Bounded execution:</strong> Set network timeouts, limit retries, and define how the system behaves when dependencies become unavailable.</li><li><strong>Independent recovery:</strong> Ensure that a crashed agent cannot leave a rollout unmanaged indefinitely.</li><li><strong>Human oversight:</strong> Consider requiring approval for production changes, especially where the consequences of an incorrect action are significant.</li></ul><p>MCP standardizes tool communication, but it does not automatically provide these safeguards. They must be implemented in the application, the MCP servers, and the underlying infrastructure.</p><h3>10. Bringing It All Together</h3><p>Let’s return to the question we started with: how can an AI agent interact with multiple infrastructure systems without requiring a separate integration approach for every tool?</p><p>Our proposed architecture uses MCP to expose traffic-control and telemetry capabilities through a common protocol. The host discovers those tools, the agent application coordinates their use, and the underlying integrations communicate with the actual infrastructure.</p><p>The orchestrator controls the canary lifecycle, while deterministic policy checks determine whether a rollout can proceed. Monitoring data provides the evidence needed to evaluate application health, and recovery mechanisms handle cases where the deployment or the agent itself fails.</p><p>It is worth remembering that these are separate responsibilities. MCP provides the communication interface, not the entire autonomous deployment system.</p><p>The architecture becomes useful when we combine that standardized interface with reliable integrations, explicit policy enforcement, monitoring, and recovery mechanisms.</p><p>For a practical implementation, the next step would be to build and test the individual MCP servers, connect them to a simulated traffic router and telemetry source, and exercise the complete lifecycle before considering any real production deployment.</p><p>That gives us a way to explore MCP beyond definitions and diagrams: by understanding how it fits into an actual engineering problem, what it makes easier, and what we still have to design ourselves.</p><h3>Conclusion</h3><p>MCP is an interesting development because it helps bridge the gap between AI applications and the tools or information they need to work with. But connecting an agent to infrastructure is only part of the challenge.</p><p>Once we introduce actions such as changing production traffic, the conversation shifts from simply making tools available to making sure those tools are used correctly, that the results are trustworthy, and that the system can recover when something goes wrong.</p><p>That is what makes the canary deployment scenario useful. It lets us explore not just how MCP works, but also the engineering decisions required to use it responsibly.</p><p>And, as with most things in DevOps, getting the happy path to work is only the beginning. The real test is what happens when things don’t go according to plan.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e0111e8cddf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a CI/CD Pipeline with GitHub Actions]]></title>
            <link>https://medium.com/@adinopaul001/building-a-ci-cd-pipeline-with-github-actions-4093be2e5219?source=rss-b787949521e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4093be2e5219</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[google-cloud-run]]></category>
            <dc:creator><![CDATA[Paul Adino]]></dc:creator>
            <pubDate>Thu, 15 Oct 2026 05:36:29 GMT</pubDate>
            <atom:updated>2026-10-15T05:36:29.725Z</atom:updated>
            <content:encoded><![CDATA[<h3>Testing, scanning, and deploying a containerized microservice to Google Cloud Run</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I1OzI9EZoSANPJMQxVGF-A.jpeg" /></figure><h3>Introduction: Why CI/CD?</h3><p>Ever wanted to build your own CI/CD pipeline but weren’t sure where to start? There are several tools available, including Jenkins, GitHub Actions, Azure Pipelines, and AWS CodePipeline. In this guide, I’ll use GitHub Actions to explore the fundamentals and then put them into practice with Google’s open-source Online Boutique microservices demo.</p><p>First, why do we need CI/CD?</p><p>Imagine an application is already running in production and a team is working on its codebase. New features need to be added, bugs need to be fixed, and existing functionality needs to be improved. Every change needs to be integrated, tested, packaged, and released. If these steps depend heavily on manual work, releases can become slow and inconsistent, and small mistakes can make their way into production.</p><p>Continuous Integration and Continuous Delivery or Deployment (CI/CD) address this challenge by automating key stages of the software delivery process. The objective is to make changes more frequent, predictable, and reliable while reducing the risks associated with releasing them.</p><p>CI/CD does not automatically mean that an application can be updated without downtime. Instead, it gives a team a repeatable process for validating and releasing changes. Downtime depends on the deployment strategy and the architecture of the application as well.</p><p>In this guide, we’ll build a workflow that tests the frontend service, builds a container image, scans it for critical vulnerabilities, publishes the image to GitHub Container Registry (GHCR), and deploys it to Google Cloud Run. We’ll also configure GitHub Actions to authenticate to Google Cloud using Workload Identity Federation rather than a long-lived service-account key.</p><blockquote><strong><em>Scope note:</em></strong><em> This workflow deploys the frontend service, not the entire Online Boutique application. The frontend still needs valid network addresses for the other microservices. Those dependencies must already be deployed and reachable, or you must deploy and configure them as part of a wider system.</em></blockquote><h3>1. What is GitHub Actions?</h3><p>GitHub Actions is an automation platform integrated into GitHub. It runs workflows defined in YAML files in response to events such as a push, pull request, or manual trigger.</p><p>A workflow contains one or more jobs, and each job contains steps. Steps can run shell commands or use reusable actions maintained by GitHub and the wider community.</p><p>For example, a workflow can automatically run tests whenever a developer pushes a change. If the tests pass, later jobs can build and scan a container image, publish it to a registry, and deploy it to a cloud platform.</p><p>This makes the release process more consistent: rather than relying on someone to remember every command, the workflow records the steps and executes them in a repeatable order.</p><h3>2. Architecture overview</h3><p>The pipeline in this guide uses the following components:</p><ul><li><strong>GitHub repository:</strong> Stores the application source code and workflow definition.</li><li><strong>GitHub Actions:</strong> Runs the automated workflow on a hosted runner.</li><li><strong>Go tooling:</strong> Runs go vet and the frontend&#39;s unit tests.</li><li><strong>Docker Buildx:</strong> Builds the frontend container image.</li><li><strong>Trivy:</strong> Scans the image for known vulnerabilities.</li><li><strong>GitHub Container Registry (GHCR):</strong> Stores the published image.</li><li><strong>Google Cloud Workload Identity Federation:</strong> Lets GitHub Actions authenticate to Google Cloud without storing a long-lived service-account JSON key.</li><li><strong>Google Cloud Run:</strong> Runs the container as a managed service.</li><li><strong>Smoke test:</strong> Sends a request to the deployed service’s health endpoint to check that it responds.</li></ul><h3>Pipeline flow</h3><pre>Code pushed to main<br>        |<br>        v<br>Path filter checks whether frontend files changed<br>        |<br>        v<br>Go setup -&gt; go vet -&gt; unit tests<br>        |<br>        v<br>Build frontend container image<br>        |<br>        v<br>Trivy vulnerability scan<br>        |<br>        v<br>Push the scanned image to GHCR<br>        |<br>        v<br>Authenticate to Google Cloud using Workload Identity Federation<br>        |<br>        v<br>Deploy the image to Cloud Run<br>        |<br>        v<br>Run a remote smoke test</pre><p>The jobs are connected with dependencies. The image-building job waits for the test job, and deployment waits for the image to pass the scan and be published. If a required job fails, GitHub Actions does not proceed to the dependent job.</p><h3>3. Configure Google Cloud and GitHub authentication</h3><p>Before the workflow can deploy anything, Google Cloud needs to trust the identity presented by GitHub Actions and grant it only the permissions required for deployment.</p><h3>Step 1: Select the Google Cloud project and enable APIs</h3><p>Set the active project in your local Cloud SDK environment:</p><pre>gcloud config set project YOUR_PROJECT_ID</pre><p>Enable the APIs required by the setup. The exact list depends on the resources and authentication commands you use; for this workflow, Cloud Run, IAM, the IAM Credentials API, and Security Token Service are relevant.</p><pre>gcloud services enable \<br>  run.googleapis.com \<br>  iam.googleapis.com \<br>  iamcredentials.googleapis.com \<br>  sts.googleapis.com</pre><p><strong>Why it matters:</strong> Google Cloud APIs must be enabled for the related services to accept requests. If an API is disabled, otherwise valid commands can fail with an API-not-enabled error.</p><h3>Step 2: Create a dedicated service account</h3><p>Create a service account for the deployment workflow rather than authenticating as your personal Google account.</p><pre>gcloud iam service-accounts create github-runner-sa \<br>  --display-name=&quot;GitHub Actions deployment&quot;</pre><p><strong>Why it matters:</strong> A dedicated identity makes it easier to review, restrict, and revoke the permissions used by automation. The name github-runner-sa is only an example.</p><h3>Step 3: Grant the required permissions</h3><p>Grant the service account only the roles needed for your deployment design. A basic Cloud Run deployment may require permissions to manage Cloud Run services and to act as the runtime service account. The exact roles depend on whether the workflow creates services, which runtime identity is used, and where the image is stored.</p><p>For example, the deployment identity may need roles/run.admin and roles/iam.serviceAccountUser, but do not grant these blindly: confirm the permissions required by your project and apply least privilege. If the image is stored in a private registry, image-pull permissions must also be configured for the identity that actually pulls the image.</p><h3>Step 4: Create a Workload Identity Pool and OIDC provider</h3><p>Workload Identity Federation allows Google Cloud to trust a short-lived OpenID Connect (OIDC) token issued to a GitHub Actions workflow. The pool groups external identities, while the provider defines how Google Cloud evaluates tokens from GitHub.</p><p>Your provider setup must map relevant token claims and apply an attribute condition that restricts trust to the intended repository and, where appropriate, branch or workflow. Follow the current Google Cloud documentation for the exact commands and supported attribute conditions.</p><p><strong>Why it matters:</strong> This avoids keeping a long-lived service-account key in GitHub secrets. The workflow requests a short-lived identity token and exchanges it through the configured federation relationship.</p><h3>Step 5: Authorize the repository</h3><p>Allow only the intended GitHub repository identity to impersonate the deployment service account. Do not configure the provider to trust every repository in GitHub.</p><p>For example, the intended repository could be represented as YOUR_GITHUB_USERNAME/YOUR_REPOSITORY. Use the actual repository owner and name in your attribute condition and service-account binding.</p><p><strong>Why it matters:</strong> Trusting GitHub as an identity provider is not enough on its own. The configuration should also determine which repository is allowed to use the deployment identity.</p><h3>Step 6: Add the workflow’s authentication values</h3><p>The GitHub Actions workflow needs the Workload Identity Provider resource name and the deployment service-account email. These are configuration identifiers, not passwords.</p><h3>4. Build the GitHub Actions workflow</h3><p>Create a file at:</p><pre>.github/workflows/frontend-ci.yaml</pre><p>The example below illustrates the workflow structure. Before running it, configure the repository-specific values and make sure the frontend’s dependent microservices are reachable. The image-publishing example assumes that Cloud Run can pull the published GHCR image; for a private package, configure an appropriate image-pull authentication mechanism or use a registry integrated with your Google Cloud setup.</p><pre>name: Frontend CI/CD</pre><pre><br>on:<br>  push:<br>    branches: [&quot;main&quot;]<br>    paths:<br>      - &quot;src/frontend/**&quot;<br>      - &quot;.github/workflows/frontend-ci.yaml&quot;</pre><pre>permissions:<br>  contents: read<br>  packages: write<br>  id-token: write</pre><pre>env:<br>  # Use a lowercase image path, as required by container registries.<br>  IMAGE_NAME: ghcr.io/YOUR_GITHUB_USERNAME/frontend<br>  GCP_REGION: us-central1<br>  CLOUD_RUN_SERVICE: frontend</pre><pre>jobs:<br>  test:<br>    name: Lint and test<br>    runs-on: ubuntu-24.04</pre><pre>    steps:<br>      - name: Check out repository<br>        uses: actions/checkout@v4</pre><pre>      - name: Set up Go<br>        uses: actions/setup-go@v5<br>        with:<br>          go-version-file: src/frontend/go.mod<br>          cache-dependency-path: src/frontend/go.sum</pre><pre>      - name: Run go vet<br>        working-directory: src/frontend<br>        run: go vet -copylocks=false ./...</pre><pre>      - name: Run unit tests<br>        working-directory: src/frontend<br>        run: go test -v ./...</pre><pre>  build-scan-publish:<br>    name: Build, scan, and publish image<br>    needs: test<br>    runs-on: ubuntu-24.04</pre><pre>    steps:<br>      - name: Check out repository<br>        uses: actions/checkout@v4</pre><pre>      - name: Set up Docker Buildx<br>        uses: docker/setup-buildx-action@v3</pre><pre>      - name: Build frontend image<br>        uses: docker/build-push-action@v6<br>        with:<br>          context: src/frontend<br>          load: true<br>          tags: frontend:ci</pre><pre>      - name: Scan image for critical vulnerabilities<br>        uses: aquasecurity/trivy-action@master<br>        with:<br>          image-ref: frontend:ci<br>          format: table<br>          exit-code: &quot;1&quot;<br>          ignore-unfixed: true<br>          severity: CRITICAL</pre><pre>      - name: Log in to GitHub Container Registry<br>        uses: docker/login-action@v3<br>        with:<br>          registry: ghcr.io<br>          username: ${{ github.actor }}<br>          password: ${{ secrets.GITHUB_TOKEN }}</pre><pre>      - name: Tag and push the scanned image<br>        env:<br>          IMAGE_NAME: ${{ env.IMAGE_NAME }}<br>          IMAGE_TAG: ${{ github.sha }}<br>        run: |<br>          docker tag frontend:ci &quot;$IMAGE_NAME:$IMAGE_TAG&quot;<br>          docker push &quot;$IMAGE_NAME:$IMAGE_TAG&quot;</pre><pre>  deploy:<br>    name: Deploy to Cloud Run<br>    needs: build-scan-publish<br>    runs-on: ubuntu-24.04</pre><pre>    steps:<br>      - name: Authenticate to Google Cloud<br>        uses: google-github-actions/auth@v2<br>        with:<br>          workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}<br>          service_account: ${{ vars.GCP_DEPLOY_SERVICE_ACCOUNT }}</pre><pre>      - name: Set up Google Cloud SDK<br>        uses: google-github-actions/setup-gcloud@v2</pre><pre>      - name: Deploy frontend<br>        env:<br>          IMAGE_NAME: ${{ env.IMAGE_NAME }}<br>          IMAGE_TAG: ${{ github.sha }}<br>        run: |<br>          gcloud run deploy &quot;$CLOUD_RUN_SERVICE&quot; \<br>            --image &quot;$IMAGE_NAME:$IMAGE_TAG&quot; \<br>            --region &quot;$GCP_REGION&quot; \<br>            --platform managed \<br>            --allow-unauthenticated \<br>            --min 0 \<br>            --max 1</pre><pre>      - name: Run remote smoke test<br>        run: |<br>          URL=&quot;$(gcloud run services describe &quot;$CLOUD_RUN_SERVICE&quot; \<br>            --region &quot;$GCP_REGION&quot; \<br>            --format=&#39;value(status.url)&#39;)&quot;</pre><pre>          echo &quot;Cloud Run URL: $URL&quot;<br>          curl --fail --retry 3 --retry-delay 2 &quot;$URL/_healthz&quot;</pre><blockquote><strong><em>Important implementation notes</em></strong></blockquote><ul><li>Replace YOUR_GITHUB_USERNAME with your lowercase GitHub username or organization. Configure GCP_WORKLOAD_IDENTITY_PROVIDER and GCP_DEPLOY_SERVICE_ACCOUNT as GitHub Actions repository variables.</li><li>Pin third-party actions to reviewed commit SHAs in a production workflow. Version tags are convenient for learning, but a tag is not as immutable as a commit SHA.</li><li>The example scans a locally built image and then pushes that same local image under its commit SHA. This makes the artifact relationship clearer than rebuilding the image after scanning.</li><li>--allow-unauthenticated makes the Cloud Run service publicly accessible. Use it only if public access is appropriate for your application.</li><li>The workflow above is a template, not a guarantee that a fresh Online Boutique checkout will run without additional configuration. In particular, configure the frontend’s service-address environment variables to point to real, reachable dependencies. Do not use 127.0.0.1 for separate microservices unless those services genuinely run in the same container or network namespace.</li><li>The image must be pullable by Cloud Run. GitHub Actions logging in to GHCR only authenticates the workflow to push; it does not automatically grant Cloud Run permission to pull a private image.</li><li>Pin the Trivy action to a reviewed release or commit SHA rather than leaving @master in a production pipeline.</li></ul><h3>5. Understanding the workflow</h3><h3>Stage 1: Triggering the pipeline</h3><pre>on:<br>  push:<br>    branches: [&quot;main&quot;]<br>    paths:<br>      - &quot;src/frontend/**&quot;<br>      - &quot;.github/workflows/frontend-ci.yaml&quot;</pre><p>This tells GitHub Actions to start the workflow when changes are pushed to main and the changed files match one of the listed paths.</p><p>The path filter helps avoid running the frontend pipeline when an unrelated part of the repository changes. It also means that a change outside those paths will not trigger this workflow.</p><h3>Stage 2: Linting and unit testing</h3><p>The workflow checks out the code, installs the Go version specified by the frontend module, runs go vet, and executes the unit tests.</p><p>go vet looks for suspicious constructs in Go code, while go test executes the package&#39;s tests. These checks catch some problems before the application is packaged.</p><p>The build-scan-publish job declares needs: test, so it cannot proceed successfully unless the test job succeeds. This is an important CI principle: failed validation should prevent later release stages from running.</p><h3>Stage 3: Building and scanning the container image</h3><p>The pipeline builds the frontend as a Docker image. It then uses Trivy to scan that image for known vulnerabilities.</p><p>The current scan policy fails the job when it finds critical vulnerabilities, while ignore-unfixed: true excludes vulnerabilities for which no fix is available. This is a defined security threshold, not a guarantee that the image is vulnerability-free. Teams should choose thresholds that fit their risk tolerance and review findings that the pipeline does not block.</p><h3>Stage 4: Publishing the image</h3><p>Once the scan passes, the workflow logs in to GHCR and pushes the image with the commit SHA as its tag.</p><p>A commit-specific tag makes it easier to identify which source revision produced an image. It is also more reliable for deployments than relying only on a mutable tag such as latest, which may point to a different build later.</p><p>The image that is published is the same local image that passed the scan. This reduces the chance that the pipeline scans one artifact but deploys a separately rebuilt artifact.</p><h3>Stage 5: Authenticating to Google Cloud</h3><p>The deployment job uses the Google authentication action and the Workload Identity Federation provider configured earlier.</p><p>The workflow has id-token: write permission so GitHub Actions can request an OIDC token. Google Cloud evaluates that token against the configured provider and repository trust conditions before granting access to the deployment identity.</p><p>This is preferable to storing a long-lived service-account key because it avoids leaving a reusable private key in the repository’s secret store.</p><h3>Stage 6: Deploying to Cloud Run</h3><p>The deployment command asks Cloud Run to run the image identified by the current commit SHA.</p><p>Cloud Run manages the underlying infrastructure for the containerized service. However, deploying the frontend alone does not deploy the other Online Boutique services. The frontend must be configured with correct addresses for the catalog, cart, currency, checkout, and other services it uses.</p><p>Also note that this example updates one stable Cloud Run service. Cloud Run creates a new revision when a new version is deployed. A successful deployment does not, by itself, prove that every dependency or user journey is working correctly.</p><h3>Stage 7: Running a smoke test</h3><p>After deployment, the workflow retrieves the service URL and sends a request to /_healthz using curl.</p><p>The --fail option makes HTTP error responses fail the command, and the retry options allow a few attempts if the endpoint is not immediately responsive.</p><p>This is a basic smoke test: it checks that the deployed endpoint responds as expected. It is not a full end-to-end test of the shopping experience, and a successful health check does not guarantee that all downstream microservices are reachable.</p><h3>6. What this pipeline achieves — and what it does not</h3><p>The pipeline automates several repetitive delivery tasks:</p><ul><li>It validates code changes before building an image.</li><li>It applies a defined vulnerability threshold before publishing the image.</li><li>It publishes a versioned container image.</li><li>It authenticates to Google Cloud without relying on a long-lived service-account key.</li><li>It deploys the image and performs a basic post-deployment check.</li></ul><p>There are also limitations worth understanding:</p><ul><li>The example deploys only the frontend service.</li><li>The frontend’s dependent services must be deployed and configured separately.</li><li>The registry must allow Cloud Run to pull the image.</li><li>The Trivy policy checks for critical vulnerabilities, not every possible security issue.</li><li>A smoke test is useful but does not replace integration or end-to-end testing.</li><li>Production use would benefit from additional controls, such as pull-request validation, environment approvals, rollback procedures, monitoring, and a deliberate strategy for managing old revisions and images.</li></ul><p>These limitations are not reasons to avoid building the pipeline. They are part of understanding the boundary between a working demonstration and a production-ready delivery system.</p><h3>7. Conclusion</h3><p>CI/CD is not simply a way to deploy code faster. It is a way to make the process of integrating, validating, and releasing changes more consistent and repeatable.</p><p>In this example, GitHub Actions orchestrates the workflow, Go tooling validates the code, Docker packages the service, Trivy checks the image against a vulnerability policy, GHCR stores the artifact, and Google Cloud Run runs the container. Workload Identity Federation provides a more secure way for the workflow to authenticate to Google Cloud.</p><p>The most important lesson is that a green pipeline is only one part of reliable delivery. The artifact must be the one that was tested, the deployment environment must be configured correctly, and the application must be verified after release. Understanding those relationships is what turns a collection of automation steps into a useful CI/CD pipeline</p><p><strong><em>Full project file: github.com/PJAdino/microservices-demo/.github/workflows/frontend-ci.yaml</em></strong></p><p><strong><em>Connect on LinkedIn: linkedin.com/in/pauladino</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4093be2e5219" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA["Defending From the Inside: How Linux Taught Me What Security Actually Means"]]></title>
            <link>https://aws.plainenglish.io/episode-2-defending-from-the-inside-how-linux-taught-me-what-security-actually-means-b783a8f73c68?source=rss-b787949521e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b783a8f73c68</guid>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cloud-security]]></category>
            <dc:creator><![CDATA[Paul Adino]]></dc:creator>
            <pubDate>Fri, 05 Jun 2026 20:02:44 GMT</pubDate>
            <atom:updated>2026-06-05T20:08:59.820Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Episode 2: A practical walk through Defence in Depth and Least Privilege using a Linux server</strong></h3><p><strong>In this post</strong></p><ol><li><strong>What are Defence in Depth and Least Privilege?</strong></li><li><strong>Layer 1 — Identity: Who Are You?</strong></li><li><strong>Layer 2 — Groups and Ownership: Who Gets What?</strong></li><li><strong>Layer 3 — Sudo Policy: How Much Power?</strong></li><li><strong>Layer 4 — ACLs: The Surgical Layer</strong></li><li><strong>Layer 5 — PAM: The Authentication Pipeline</strong></li><li><strong>Layer 6 — SSH Hardening: Controlling the Front Door</strong></li><li><strong>Layer 7 — Audit Trails: Security Without Visibility is Just Assumption</strong></li><li><strong>Bringing It All Together: Automation as the Final Layer</strong></li><li><strong>The Bigger Picture</strong></li></ol><p>Whenever I spoke to anyone in cybersecurity, went through AWS certification material, or explored cloud engineering content, two terms kept appearing — <em>Defence in Depth</em> and the <em>Principle of Least Privilege</em>.</p><p>At the time, they felt less like concepts and more like mantras. Words you were supposed to accept as true without fully understanding what they looked like in practice.</p><p>But the more I pursued DevSecOps and cloud engineering, the more these ideas kept resurfacing, not as theory, but as rules quietly shaping how real systems are designed and secured.</p><p>That shift is what pushed me to properly understand them. Not through a textbook, but through building.</p><p>In this post, I will walk through what these principles actually mean, using a Linux server as the environment. Through user management, permissions, and automation, I will show how these ideas appear when you actually interact with a system.</p><p><strong><em>This is a long read. If you want the summary version first, there is a video walkthrough linked below. But I promise the full read is worth it.</em></strong></p><p><a href="https://1drv.ms/v/c/57fe5a4ee15b26ef/IQDPtGkpbisJRYdyuhCKoRQBASTHhb96RX71Ww5O7Qcgyuc?e=Batbei">Architecting_Linux_Security__The_Defense-In-Depth_Stack.mp4</a></p><h3><strong>1. What are Defence in Depth and Least Privilege?</strong></h3><p><strong><em>Defence in Depth</em></strong> is the idea of securing a system through multiple independent layers of protection rather than relying on just one. If one layer fails, another is already there to slow things down or stop them from progressing further.</p><p><strong><em>The Principle of Least Privilege</em></strong> means giving users or processes only the minimum access they need to do their job, nothing extra. The less unnecessary access something has, the less damage it can cause if something goes wrong.</p><p>When I first thought about it, I related it to living in a gated community. There is a main gate to enter the estate but even after that, you still have building entrances, then your apartment door, and even inside your own space there are locks on certain things. Not everything is freely open just because you are “inside.”</p><p>That is Defence in Depth, multiple barriers at different levels.</p><p>Least Privilege is what decides what you can actually touch once you are inside. Even if you are in the estate, you do not automatically get access to every building. Even in your own building, you do not get access to every apartment. Your access is limited to what you actually need, nothing more.</p><p>Now the interesting part is how these ideas actually appear inside a real system.</p><h3><strong>2. Layer 1 — Identity: Who Are You?</strong></h3><p>Think about that secured estate again. To even enter, you need an identity, something that proves who you are. Nothing gets through without being identified first.</p><p>That is exactly what Linux does through users and groups.</p><p>When I started working on a Linux server, which I called <strong><em>SecureBox</em></strong>, the first thing I had to understand was the identity layer.</p><p>In Linux, not all users are the same. There are three categories:</p><ul><li><strong>Human users</strong> — real people interacting with the system</li><li><strong>System users </strong>— services running in the background</li><li><strong>Root</strong> — the highest privilege level with full system control</li></ul><p>What surprised me is that a human user is not just a label. It has structure. It needs a home directory, a place to exist inside the system, and a login shell, a way to interact with it.</p><p>System users are intentionally different. They often have no home directory and no login shell, because they are designed only to run services. At first this felt unnecessary. But it is actually a security control. If a service account never needs to log in, why give it the ability to? By removing that capability, Linux reduces the number of ways an attacker could potentially abuse the account.</p><p>This is where identity becomes more than just a name. It is a definition of what you are allowed to do.</p><h4><strong>2.1 First friction point — Least Privilege in action</strong></h4><p>While trying to create users, I immediately ran into a permission error. The system was telling me I did not have enough privilege to do this.</p><p>To move forward, I had to use <strong><em>sudo</em></strong>, a command that temporarily elevates access to root-level permissions.</p><p>That moment made something concrete: access in Linux is not automatic. It is deliberately granted.</p><h4><strong>2.2 The identities I created</strong></h4><p>For the <strong><em>SecureBox</em></strong> server, I defined two types of users.</p><p>Human users representing roles:</p><ul><li><strong>Alex</strong> — system administrator</li><li><strong>Bob</strong> — developer</li><li><strong>Vekez </strong>— auditor</li></ul><p>Service users representing processes:</p><ul><li><strong>Nginx</strong> — web server</li><li><strong>Backendapp </strong>— application service</li><li><strong>Db</strong>— database service</li></ul><p>At this point I stopped thinking in terms of people and started thinking in terms of roles. Some identities represent humans. Others represent services running in the background. Linux treats both the same way, as identities that need to be defined, controlled, and audited.</p><h3><strong>3. Layer 2 — Groups and Ownership: Who Gets What?</strong></h3><p>Managing users individually does not scale. That is where groups come in.</p><p>Think of groups as shared access categories inside the estate. Instead of assigning access one person at a time, you assign it based on shared responsibility.</p><p>I structured it like this:</p><ul><li><strong>Developers</strong> — Alex and Bob. Both need to work with application files.</li><li><strong>Webteam</strong> — Bob and Nginx. The developer deploys, the web server serves.</li><li><strong>Auditors </strong>— Vekez. Read-only access to logs and system activity.</li></ul><p>The important lesson here was to design groups from need first, not from job titles. A group should represent a genuine <em>shared access</em> requirement. If nothing is actually being shared, the group probably should not exist.</p><p>Once the groups were defined, I had to connect them to real parts of the system, actual directories, each with a clear <em>ownership </em>assignment.</p><p>So I started by assigning ownership based on responsibility, not convenience.</p><p>For example, the backend service is the one generating and writing application logs, so it naturally becomes responsible for the log directory. The same logic applies to the web server handling deployed content, and the auditor role that needs visibility into system activity.</p><p>With that in mind, I mapped access into the file system:</p><ul><li><strong>/opt/backend</strong> — contains the backend application and its configuration. Owned by the backend service, with access given to the Developers group who maintain it.</li><li><strong>/srv/web </strong>— contains the web application files served to users. Owned by Nginx, with access given to the Web Team responsible for deployment.</li><li><strong>/var/log/app </strong>— contains system and application logs used for monitoring and debugging. Owned by the backend service, with read access given to the Auditors group.</li></ul><p>At this point, ownership, groups, and resources were no longer separate ideas. They started forming a single structure of controlled access.</p><p>But having ownership alone was not enough.</p><p>The next layer was deciding what each identity could actually do with those resources, whether they could read them, modify them, or execute them.</p><p>In Linux, this is controlled through <strong><em>permissions</em></strong>:</p><ul><li>read (view the contents)</li><li>write (modify or change them)</li><li>execute (run or access them as a program or directory)</li></ul><p>So instead of just saying who owns what, I had to define what level of control each group had over each directory.</p><p>For example, developers might be able to read and write the backend application files, but not have unrestricted control over system logs. Auditors, on the other hand, might only be allowed to read logs without modifying them, since their role is purely observation and review.</p><p>When you translate these permissions into Linux notation, they are represented as a numeric pattern like <strong>750,</strong> which encodes exactly who gets read, write, and execute access across owner, group, and others.</p><p>At this stage, the system was not just organized anymore. It was actively enforcing boundaries.</p><pre>#!/bin/bash<br><br># Add Developers group (if it doesn&#39;t already exist)<br>sudo groupadd developers<br># Add user Alex to the Developers group<br>sudo usermod -aG developers alex<br># Change ownership of backend directory<br>sudo chown backendapp:developers /opt/backend<br># Set read/write/execute permissions using numeric mode<br>sudo chmod 750 /opt/backend</pre><h3><strong>4. Layer 3 — Sudo Policy: How Much Power?</strong></h3><p>So we have our groups and users in place, and we have assigned ownership to different file paths of the system based on the roles they are supposed to operate in. We have seen how shared access patterns are structured through groups, and how different file paths of the system are owned based on the identity responsible for them.</p><p>What if I told you all of this is still not enough?</p><p>What if I told you that even with all these restrictions, Vekez, who is only supposed to be in the auditor group, could still access the backend application path and delete everything inside it?</p><p>And the reason this is possible is because of one thing: <strong>sudo</strong>.</p><p>You have seen we have even used it in the identity layer section, but sudo is actually a <em>privilege escalation tool</em>. It temporarily lifts a user into higher privileges, basically giving them root-level power for whatever command they run.</p><p>And this is where the problem starts.</p><p>Because now, suddenly, every user who has sudo access is no longer fully bound by the structure we created. One wrong privilege, and the entire system boundary can be bypassed.</p><p>So we need another wall of protection in our <em>SecureBox</em> kingdom.</p><p>This is where <strong>sudo policy</strong> comes in.</p><p><strong>Sudo policy</strong> is not just about allowing users to run commands, it is about defining which commands they are allowed to run, and under what conditions. Everyone might have sudo in some form, but not everyone can use it for everything.</p><p>For example, Vekez, our auditor, might only be allowed to read logs. Bob, the developer, might only be allowed to restart a backend service. And Alex, our system admin, might have full administrative control.</p><p>This is least privilege in its strictest form, not just limiting access to files, but limiting what elevated power can even do.</p><p>But this power has to be controlled carefully.</p><p>Because one small syntax mistake in a sudo policy can completely break the system, either locking you out or unintentionally giving too much access. This is why we use <strong><em>visudo</em></strong>, which validates the policy before saving it, making sure no errors slip through.</p><p>So instead of blindly trusting sudo access, we shape it into rules like:</p><ul><li>Alex gets full administrative control</li><li>Bob can only restart the backend service</li><li>Vekez can only read system logs</li></ul><p>Some actions require a password for verification, while others can be allowed without one for automation purposes, depending on how critical they are.</p><p>At this point, the system is no longer just organized. It is actively enforced. Even if a user exists in the system, their actual power is strictly defined by policy.</p><p>And this is where everything connects: defence in depth builds the layers, but least privilege decides exactly how much power exists inside those layers.</p><pre># Alex given all admin rights<br>Alex ALL=(ALL) ALL<br><br># Bob given backend service restart privileges<br>Bob ALL=(root) NOPASSWD: /usr/bin/systemctl restart Backendapp<br><br># Vekez given reading logs privileges<br>Vekez ALL=(root) PASSWD: /usr/bin/journalctl</pre><h3><strong>5. Layer 4 — ACLs: The Surgical Layer</strong></h3><p>So as we did for our groups in the identity layer, access in Linux can broadly be thought of in three categories: the <strong><em>owner</em></strong> of the file, the <strong><em>group</em></strong> assigned to it, and <strong><em>everyone else</em></strong> outside of those two.</p><p>At first, this model feels complete. Everything fits neatly into these three buckets.</p><p>But once systems become more real and more complex, you start to notice a limitation.</p><p>There are cases where access is not as simple as “group or not group.” You might assume that changing group membership or using elevated commands would solve it, but then you realize these tools are solving different problems entirely.</p><p>This is where <strong><em>Access Control Lists</em></strong> come in.</p><p>An ACL is <strong><em>a way of attaching extra, fine-grained permissions directly to a file or directory</em></strong>. Instead of only relying on owner, group, and others, you can define access for specific users individually, without disturbing the group structure.</p><p>So now the system is no longer limited to broad categories. It becomes more precise.</p><p>For example, the directory /opt/myapp is owned by backendapp and assigned to the developers group with permission 750. This means Bob, as part of Developers, gets read and execute access. But deploying the application requires more than that. It involves creating and replacing files, which needs write access. The group itself does not have that level of permission.</p><p>So instead of expanding the entire Developers group, which would break the security model, we apply an ACL. Bob is given specific rwx access to /opt/myapp, not because of the group he belongs to, but because of his specific role as a deployer. Alex, as system administrator, already has elevated access through sudo, so no special ACL is required.</p><p>This is what makes ACLs powerful. They allow surgical precision in access control. Not broader categories, but individual exceptions where they are actually needed.</p><p>This is where I ran into a deeper question.</p><p><strong>ACLs </strong>started to feel very similar to <strong>sudo policies</strong>. In both cases, you are essentially giving specific users access to specific capabilities. So I found myself asking: why do I even need ACLs if I can just define a sudo policy that gives Bob access to the logs, or restrict what Vekez can do through sudo rules?</p><p>But the difference only became clear when I looked at what level of the system each one operates on.</p><ul><li><strong><em>sudo</em></strong> is about actions. It controls what commands a user is allowed to execute with elevated privileges.</li><li><strong><em>ACLs </em></strong>are about resources. They control direct access to files and directories without changing the user’s privilege level.</li></ul><p>That distinction changes everything.</p><p>Because sudo is still tied to privilege escalation. It temporarily changes what a user can do. ACLs do not change what a user can do. They change what a user can touch.</p><p>Now have a layered system:</p><ul><li><strong>Groups</strong> provide broad access based on shared responsibility</li><li><strong>ACLs</strong> provide fine-grained exceptions for specific users</li><li><strong>Sudo</strong> provides controlled privilege escalation for administrative power</li></ul><p>Together, they form the <em>full access control </em>toolkit at the filesystem level.</p><p>And the key idea is simple: each tool exists for a different level of precision. Using the right one is what separates a system that “works” from a system that is properly designed.</p><pre>#!/bin/bash<br><br># Bob deployment access to app directory<br>sudo setfacl -m u:Bob:rwx /opt/myapp</pre><h3><strong>6. Layer 5 — PAM: The Authentication Pipeline</strong></h3><p>Now if all of this is new to you, or you have never really interacted with Linux beyond hearing about it, this section is probably the most relatable part.</p><p>Because in one way or another, we are always being authenticated into something. Whether it is an app, your email, your laptop, or even a system login, there is always a moment where you have to prove who you are before you are allowed in.</p><p>And that is where <strong>PAM</strong> comes in.</p><p>Ever wondered how systems are able to enforce password rules, or require password changes after a certain period, or even lock an account after too many failed attempts?</p><p>This is what PAM handles in Linux.</p><p>So instead of Linux simply checking a password and returning yes or no, authentication goes through a structured pipeline. A chain of modules evaluates different conditions before access is granted.</p><p><strong><em>PAM is essentially the middleware layer that intercepts every authentication request on the system.</em></strong></p><p>When a user tries to log in, their credentials are not just checked once. They are processed through <em>multiple stages</em>, each responsible for a different part of the decision.</p><p>These stages are:</p><ul><li><strong>Authentication </strong>— Is this the correct password or key?</li><li><strong>Account</strong> — Is this account allowed to log in right now, or is it expired, locked, or restricted?</li><li><strong>Password</strong> — When changing a password, does it meet complexity requirements?</li><li><strong>Session</strong> — What should happen when a session starts or ends? Things like mounting directories, applying limits, or logging activity.</li></ul><p>Each stage runs its own set of rules and modules independently.</p><p>And when you look at it this way, you start to see how much actually happens when you simply “log into” a Linux system. Nothing is a single check. It is a <em>layered</em> verification process. And in a way, this reinforces the idea of <em>defence in depth</em> again, because access is only granted when every layer approves it.</p><p>With PAM, you can also enforce policies like <strong><em>password expiration</em></strong>, <strong><em>complexity rules</em></strong>, and <strong><em>account lockouts</em></strong>, all controlled centrally through configuration rather than manual enforcement.</p><pre>#!/bin/bash<br><br># Install password quality module<br>sudo apt install -y libpam-pwquality<br># Set password aging on human accounts<br>sudo chage -M 30 -W 14 Alex<br>sudo chage -M 30 -W 14 Bob<br>sudo chage -M 30 -W 14 Vekez</pre><h3><strong>7. Layer 6 — SSH Hardening: Controlling the Front Door</strong></h3><p>Now this part will feel slightly contradictory compared to the password and PAM section because here, we start moving away from password authentication entirely.</p><p>To understand why, you have to think about how systems are actually attacked.</p><p>Attackers do not try a password once. They try many, thousands, sometimes millions of combinations through automated systems. This is where brute-force attacks come in. Even if there are limits in place, over time, it is still a weak entry point.</p><p>So the question becomes: <em>why rely on something that can be guessed?</em></p><p>This is where <strong>SSH</strong> changes the model entirely.</p><h4><strong>7.1 What SSH actually does</strong></h4><p><em>SSH (Secure Shell) is the standard way of remotely accessing Linux systems over a network</em>. In fact, for most internet-facing Linux servers, it is the primary remote access method and also one of the most frequently targeted services.</p><p>So instead of relying on passwords, SSH uses <strong>cryptographic key pairs</strong>.</p><p>Here is how it works:</p><p>You generate a <strong>public key</strong> and a <strong>private key</strong></p><ul><li>The <strong>public key</strong> is placed on the server</li><li>The <strong>private key</strong> stays with you and is never shared</li></ul><p>When you try to log in, the server does not ask for a password. Instead, it checks whether your private key can correctly prove ownership of the matching public key, without ever exposing the key itself.</p><p>It is not “typing the right value” anymore. It is mathematical verification between two linked keys.</p><h4><strong>7.2 Why this is more secure</strong></h4><p>Unlike passwords, these keys:</p><ul><li>are extremely long and complex</li><li>cannot realistically be guessed or brute-forced</li><li>do not get transmitted in plain form during login</li></ul><p>This alone makes SSH significantly stronger than password-based authentication.</p><p>Common key types include:</p><ul><li><strong>RSA</strong> (older, still used)</li><li><strong>Ed25519 </strong>(modern, faster, and more secure in most cases)</li></ul><p>I will leave the deeper cryptography comparisons for later, but the key idea is simple: not all keys are equal, but all are stronger than passwords when used correctly.</p><h4><strong>7.3 Deciding who gets SSH access</strong></h4><p>Once SSH becomes the main access method, the next question is no longer “can they log in?” but “who should be allowed to log in at all?”</p><p>Going back to our users:</p><ul><li><strong>Alex (system admin)</strong> — needs full SSH access for server management</li><li><strong>Bob (developer)</strong> — may need SSH for deployment and debugging</li><li><strong>Vekez (auditor) </strong>— does not need shell access, only log viewing through controlled methods</li></ul><p>So now access is no longer just about authentication. It becomes about whether a user should ever get a shell on the system in the first place.</p><h4><strong>7.4 SSH configuration (hardening layer)</strong></h4><p>Once SSH is enabled, we tighten it through configuration rules like:</p><pre>PermitRootLogin no<br>PasswordAuthentication no<br>AllowUsers alex bob</pre><p>What this means in practice:</p><ul><li><strong>Root login</strong> is disabled to prevent direct full-system access</li><li><strong>Password authentication</strong> is turned off (key-only login)</li><li>Only specific users are <strong>allowed</strong> to connect via SSH</li></ul><p>This is where SSH becomes not just a tool, but a controlled entry gate.</p><h4><strong>7.5 The takeaway</strong></h4><p>SSH hardening is not just replacing passwords. It is removing an entire class of attack surface and replacing it with controlled cryptographic identity.</p><p>At this point, authentication is no longer about what you know<em> (passwords)</em> but about what you possess <em>(keys)</em>.</p><h3><strong>8. Layer 7 — Audit Trails: Security Without Visibility is Just Assumption</strong></h3><p>In real systems, especially in corporations, security is not just about restricting access.</p><p>Because even if you have users, groups, permissions, sudo policies, and SSH hardening in place, there is still one critical question: what happens when something goes wrong?</p><p>If a service goes down, or a web server is shut off, or a file is modified unexpectedly, the system still needs to answer one thing clearly: who did it?</p><p>This is where audit trails become important.</p><p>In many enterprise Linux systems, this is handled by a service like <strong><em>auditd</em></strong>, the Linux Audit Daemon.</p><p>Unlike sudo logs or application logs, auditd is not just interested in what commands were run. It is designed to capture system-level activity, even when it bypasses higher layers of logging.</p><p>And this is where the key difference becomes clear.</p><p>For example, if someone modifies /etc/passwd directly, without using sudo or without triggering application-level logging, that action may not appear in standard logs.</p><p>But auditd still captures it, <em>because it monitors system calls at a lower level, not just user commands</em>.</p><p>So even if a user bypasses a higher layer of logging, the underlying filesystem change is still recorded.</p><p>This is what makes it different. It operates below the level of:</p><ul><li>sudo command logs</li><li>application logs</li><li>user session tracking</li></ul><p>It watches actual system activity: file writes, permission changes, authentication attempts, and sensitive configuration modifications.</p><p>In practice, audit rules can be written to watch specific files or actions, so that any interaction with them is recorded regardless of how it was triggered.</p><p>For example, even if a change happens outside of <em>sudo</em>, through a script, or through a misconfigured service, it is still captured.</p><p>And this is the key idea: <em>audit logging is not about trust. It is about proof.</em></p><p>It provides the <strong><em>visibility layer</em></strong> that sits underneath everything else, making system actions traceable even when other layers fail or are bypassed.</p><p>At this point, visibility becomes part of security itself. Because security without visibility is just assumption. And auditd is what turns those assumptions into something verifiable.</p><pre>## Sudoers modifications<br>-w /etc/sudoers -p wa -k sudo_modification<br>-w /etc/sudoers.d/ -p wa -k sudo_modification<br>## User database modifications<br>-w /etc/passwd -p wa -k user_modification<br>-w /etc/shadow -p wa -k user_modification<br>-w /etc/group -p wa -k user_modification<br>## Sudo execution<br>-w /usr/bin/sudo -p x -k sudo_command_use<br>sudo augenrules --load</pre><h4><strong>Checkpoint: The Full Stack So Far</strong></h4><p>The defence in depth model now spans seven layers: identity, group ownership, sudo policy, access control lists, PAM authentication, SSH hardening, and audit trails.</p><p>Each layer addresses a different kind of risk that the others cannot fully handle on their own.</p><p>Together, they form a structured, layered security model, not just in theory, but as a coherent and verifiable system of access control.</p><h3><strong>9. Bringing It All Together: Automation as the Final Layer</strong></h3><p>Now imagine this same setup, identity, groups, sudo policy, ACLs, PAM authentication, SSH hardening, and audit trails, but not just for one server.</p><p>Imagine twenty, fifty, or even hundreds of servers.</p><p>At that point, doing this manually is no longer realistic.</p><p>So the question becomes: how do companies actually manage this at scale?</p><p>This is where <em>automation </em>comes in, specifically tools like <strong>Ansible</strong>.</p><p>Everything that was built manually across these seven layers can be translated into an <strong>Ansible playbook </strong>that provisions an entire server automatically.</p><p>This represents a shift from manual system crafting to DevOps engineering, where configuration is no longer something you apply step by step, but something written once in a playbook, reviewed, version-controlled, and reproduced consistently across any number of machines.</p><p>The power of this approach lies in two key ideas.</p><p>First is<strong> <em>idempotency</em></strong>, meaning an Ansible playbook can be run multiple times and the result stays the same. The system checks the current state before making changes. If everything is already correct, it does nothing. If something is missing or misconfigured, it corrects it.</p><p>Second is <strong><em>state-driven execution</em></strong> across multiple servers, where each machine is treated independently, but managed through the same Ansible playbook logic. No server is configured manually. All of them converge to the same desired state.</p><p>To apply this across twenty or more servers, Ansible uses an <em>inventory file</em>. Instead of targeting only localhost, you define a list of machines, their IP addresses, SSH details, and grouping, inside the inventory. Using SSH keys, Ansible connects to each server and applies the same playbook simultaneously across all of them.</p><p>This is the core value of <strong>Infrastructure as Code</strong>: the same provisioning logic written once, applied consistently at scale through Ansible.</p><p>And the most important insight from this entire shift is simple: Infrastructure as Code is not just about convenience. <em>It is about eliminating undocumented systems</em>.</p><p>When everything is defined in an Ansible playbook, there are no “mystery servers” that nobody understands. No fragile setups that only one person knows how to fix. No hidden configurations lost when someone leaves.</p><p>Instead, there is a single source of truth, an Ansible playbook that describes exactly what every server is, how it should behave, and why it exists that way.</p><pre>- name: SecureBox server provisioning<br>  hosts: securebox<br>  become: true<br>tasks:<br>    #-- Prerequisites -------------------<br>    - name: Install acl package<br>      ansible.builtin.apt:<br>        name: acl<br>        state: present<br>    - name: Install auditd package<br>      ansible.builtin.apt:<br>        name: auditd<br>        state: present<br>    # Groups<br>    - name: Create Developers group<br>      ansible.builtin.group:<br>        name: developers<br>        state: present<br>    - name: Create Webteam group<br>      ansible.builtin.group:<br>        name: webteam<br>        state: present<br>    - name: Create Auditors group<br>      ansible.builtin.group:<br>        name: auditors<br>        state: present<br>    # Service accounts<br>    - name: Create nginx service account<br>      ansible.builtin.user:<br>        name: nginx<br>        system: true<br>        shell: /usr/sbin/nologin<br>        create_home: false<br>        groups: webteam<br>        append: true<br>        state: present<br>    - name: Create backendapp service account<br>      ansible.builtin.user:<br>        name: backendapp<br>        system: true<br>        shell: /usr/sbin/nologin<br>        create_home: false<br>        state: present<br>    - name: Create db service account<br>      ansible.builtin.user:<br>        name: db<br>        system: true<br>        shell: /usr/sbin/nologin<br>        create_home: false<br>        state: present<br>    # Human accounts<br>    - name: Create alex admin account<br>      ansible.builtin.user:<br>        name: alex<br>        shell: /bin/bash<br>        create_home: true<br>        groups: developers<br>        append: true<br>        state: present<br>    - name: Create bob developer account<br>      ansible.builtin.user:<br>        name: bob<br>        shell: /bin/bash<br>        create_home: true<br>        groups:<br>          - developers<br>          - webteam<br>        append: true<br>        state: present<br>    - name: Create vekez auditor account<br>      ansible.builtin.user:<br>        name: vekez<br>        shell: /bin/bash<br>        create_home: true<br>        groups: auditors<br>        append: true<br>        state: present<br>    # Directories<br>    - name: Create application directory<br>      ansible.builtin.file:<br>        path: /opt/myapp<br>        state: directory<br>        owner: backendapp<br>        group: developers<br>        mode: &#39;2750&#39;<br>    - name: Create log directory<br>      ansible.builtin.file:<br>        path: /var/log/myapp<br>        state: directory<br>        owner: backendapp<br>        group: auditors<br>        mode: &#39;0750&#39;<br>    - name: Create web directory<br>      ansible.builtin.file:<br>        path: /srv/web<br>        state: directory<br>        owner: nginx<br>        group: webteam<br>        mode: &#39;0750&#39;<br>    # Sudo policy<br>    - name: Deploy sudo policy<br>      ansible.builtin.template:<br>        src: templates/securebox_sudo.j2<br>        dest: /etc/sudoers.d/securebox<br>        owner: root<br>        group: root<br>        mode: &#39;0440&#39;<br>        validate: /usr/sbin/visudo -cf %s<br>    # ACLs<br>    - name: Give bob deployment access to app directory<br>      ansible.builtin.acl:<br>        path: /opt/myapp<br>        entity: bob<br>        etype: user<br>        permissions: rwx<br>        recalculate_mask: no_mask<br>        state: present<br>    - name: Give vekez read access to log directory<br>      ansible.builtin.acl:<br>        path: /var/log/myapp<br>        entity: vekez<br>        etype: user<br>        permissions: rx<br>        state: present<br>    - name: Set default ACL for vekez on log directory<br>      ansible.builtin.acl:<br>        path: /var/log/myapp<br>        entity: vekez<br>        etype: user<br>        permissions: rx<br>        default: true<br>        state: present<br>    # PAM - Password aging<br>    - name: Set password aging for alex<br>      ansible.builtin.command:<br>        cmd: chage -M 90 -W 14 alex<br>      changed_when: false<br>    - name: Set password aging for bob<br>      ansible.builtin.command:<br>        cmd: chage -M 90 -W 14 bob<br>      changed_when: false<br>    - name: Set password aging for vekez<br>      ansible.builtin.command:<br>        cmd: chage -M 90 -W 14 vekez<br>      changed_when: false<br>    # SSH Hardening<br>    - name: Disable root SSH login<br>      ansible.builtin.lineinfile:<br>        path: /etc/ssh/sshd_config<br>        regexp: &#39;^#?PermitRootLogin&#39;<br>        line: &#39;PermitRootLogin no&#39;<br>        state: present<br>      notify: Restart SSH<br>    - name: Disable password authentication<br>      ansible.builtin.lineinfile:<br>        path: /etc/ssh/sshd_config<br>        regexp: &#39;^#?PasswordAuthentication&#39;<br>        line: &#39;PasswordAuthentication no&#39;<br>        state: present<br>      notify: Restart SSH<br>    - name: Restrict SSH to authorized users<br>      ansible.builtin.lineinfile:<br>        path: /etc/ssh/sshd_config<br>        regexp: &#39;^#?AllowUsers&#39;<br>        line: &#39;AllowUsers vboxuser alex bob&#39;<br>        state: present<br>      notify: Restart SSH<br>    # Auditd<br>    - name: Deploy audit rules<br>      ansible.builtin.copy:<br>        dest: /etc/audit/rules.d/audit.rules<br>        content: |<br>          ## Sudoers modifications<br>          -w /etc/sudoers -p wa -k sudo_modification<br>          -w /etc/sudoers.d/ -p wa -k sudo_modification<br>          ## User database modifications<br>          -w /etc/passwd -p wa -k user_modification<br>          -w /etc/shadow -p wa -k user_modification<br>          -w /etc/group  -p wa -k user_modification<br>          ## Sudo execution<br>          -w /usr/bin/sudo -p x -k sudo_command_use<br>        owner: root<br>        group: root<br>        mode: &#39;0640&#39;<br>    - name: Enable and start auditd<br>      ansible.builtin.service:<br>        name: auditd<br>        state: started<br>        enabled: true<br>    - name: Reload audit rules<br>      ansible.builtin.command:<br>        cmd: augenrules --load<br>      changed_when: false<br>      failed_when: false<br>    # Systemd service unit<br>    - name: Deploy Backendapp service unit<br>      ansible.builtin.copy:<br>        dest: /etc/systemd/system/Backendapp.service<br>        content: |<br>          [Unit]<br>          Description=Backend Application<br>          [Service]<br>          ExecStart=/bin/sleep infinity<br>          [Install]<br>          WantedBy=multi-user.target<br>        owner: root<br>        group: root<br>        mode: &#39;0644&#39;<br>    - name: Reload systemd daemon<br>      ansible.builtin.systemd:<br>        daemon_reload: true<br>    - name: Enable and start Backendapp service<br>      ansible.builtin.systemd:<br>        name: Backendapp<br>        state: started<br>        enabled: true<br>  handlers:<br>    - name: Restart SSH<br>      ansible.builtin.service:<br>        name: ssh<br>        state: restarted</pre><h3><strong>10. The Bigger Picture</strong></h3><p>I started this post because two phrases kept appearing everywhere I looked, <strong><em>Defence in Depth</em></strong> and <strong><em>Least Privilege,</em></strong> and I could not fully see what they meant in practice.</p><p>Now I can.</p><p><strong>Defence in Depth</strong> is not a concept. It is eight concrete decisions: who exists on the system, what they can access, what they can do with elevated power, how they prove who they are, how they connect remotely, and whether every action is recorded. Each decision covers what the others cannot.</p><p><strong>Least Privilege</strong> is what gives each of those decisions meaning. It is the principle that runs through every layer, every account, every permission, every sudo rule, asking the same question: does this identity actually need this access to do its job?</p><p>When both ideas are applied together, the result is not just a secure server. It is a system where every access decision has a reason, and every reason is verifiable.</p><p><strong><em>Full project documentation and Ansible playbook: github.com/PJAdino/securebox</em></strong></p><p><strong><em>Connect on LinkedIn: linkedin.com/in/pauladino</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*faqSNZrfrvGmW8x-mG8N8Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b783a8f73c68" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/episode-2-defending-from-the-inside-how-linux-taught-me-what-security-actually-means-b783a8f73c68">&quot;Defending From the Inside: How Linux Taught Me What Security Actually Means&quot;</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built an App That Worked… So Why Was Everyone Talking About Microservices?]]></title>
            <link>https://medium.com/@adinopaul001/i-built-an-app-that-worked-so-why-was-everyone-talking-about-microservices-01e6567a334f?source=rss-b787949521e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/01e6567a334f</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Paul Adino]]></dc:creator>
            <pubDate>Mon, 13 Apr 2026 15:47:08 GMT</pubDate>
            <atom:updated>2026-04-13T18:58:13.771Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Episode 1: The Day I Realized My App Wasn’t Just One Thing</strong></h3><p>At the time, I was in an internship and actively applying for roles. One of the applications required me to build something practical — a system that could demonstrate core concepts like CRUD operations and basic data handling, along with a simple interface to show how the system actually works.</p><p>So, I built a Book Inventory Management System. Nothing fancy — just something that worked.</p><p>The goal wasn’t complexity. It was clarity:</p><ul><li>how data is created, stored, updated, and deleted</li><li>how logic flows through an application</li><li>how the frontend and backend connect</li></ul><p>I used Python, and for the backend, I used Flask, a lightweight web framework for Python used to build APIs and web applications. Flask handles things like routing (connecting URLs to functions) and allows you to expose backend logic over HTTP.</p><p>I structured everything myself, making sure I understood each part instead of just following templates. By the end, I had a working system — but everything still lived in one place, tightly connected as a single unit.</p><p><strong>What I Built</strong></p><p>My project followed a simple structure. Everything was tightly connected:</p><ul><li>The backend handled request logic through Flask.</li><li>The frontend displayed data through a simple HTML interface.</li><li>The system relied on a file-based approach for storing information.</li></ul><p>All of it was still part of one application. A single flow. A single unit.</p><p>Looking at the structure, it was still simple and tightly connected:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*k1RQa_qRPeNqe2nBEca_kA.png" /></figure><p>Everything lived in one codebase, running as one system. At the time, that felt right — and even now, it makes sense in terms of simplicity. It’s easy to understand because nothing is separated or running independently.</p><p><strong>The Shift</strong></p><p>While I was building and applying, something else kept showing up in the background.</p><p>In my internship, especially during stand-ups and sprint discussions, I kept hearing the same word repeatedly: <strong>Microservices</strong>.</p><p>Not as an introduction, but more like something already in motion. People would say things like:</p><ul><li>“We’re cleaning up these microservices.”</li><li>“This service needs to be updated.”</li><li>“That microservice is handling that part now.”</li></ul><p>It wasn’t being explained. It was just part of the conversation, like everyone already had context.</p><p>And me? I was just there trying to keep up.</p><p>You know those meetings where people casually use terms like you’re supposed to already understand them? That was basically my experience.</p><p>At some point, I’d just sit there thinking:<br>“Okay… microservices… what exactly is that?”</p><p>It sounded important, but I wasn’t even sure if it was a tool, a system, or just some architecture concept I was missing.</p><p>So, like anyone trying to figure things out quietly in the background, I did what I usually do first — I asked ChatGPT. I searched it up: microservices.</p><p>The explanation came back, but honestly, it still felt a bit abstract at first. Something about it made sense in theory, but didn’t fully stick immediately in practice.</p><p>It was one of those things where you understand it in the moment… and then later you’re not fully sure you understood it at all.</p><p>But it stayed in my mind, because now I was hearing it everywhere.</p><p><strong>What is a Microservice?</strong></p><p>A microservice is an architectural approach where an application is built as a collection of small, independent services. Each service is responsible for a specific function within the system and can run, deploy, and scale independently from the others.</p><p>Instead of one large application handling everything, the system is split into multiple smaller components that communicate with each other, usually over network calls like HTTP.</p><p>For example, one service might handle user management, another might handle data storage, and another might handle business logic. Each of these services operates on its own but works together to form the full system.</p><p><strong>So, What Does This Actually Mean?</strong></p><p>When I looked at this definition, I started comparing it directly to what I had already built.</p><p>My project was the opposite of that.</p><p>Everything I built lived in one place:</p><ul><li>the Flask backend handling all logic</li><li>the frontend templates handling display</li><li>the custom RDBMS logic handling data storage</li></ul><p>All of it was bundled into a single application.</p><p>At that point, I realized what I had built was what is referred to as a <strong>monolithic structure</strong>.</p><p>A monolith is basically a system where all parts of an application are tightly connected and deployed as one unit. Everything shares the same codebase and runtime.</p><p>In my case, my Book Inventory Management System followed exactly that pattern. One project. One codebase. One running system.</p><p><strong>Why That Matters</strong></p><p>At first, it felt unnecessary.</p><p>My system already worked. It was simple. Clean. Understandable.</p><p>So why break it?</p><p>But the more I looked at how real systems are built, the more it started to make sense.</p><p>With microservices, the benefits are pretty clear:</p><ul><li>You can update one part without touching everything else.</li><li>You can scale only what actually needs scaling.</li><li>One failure doesn’t bring down the whole system.</li><li>Different teams can work independently on different services.</li></ul><p>That last one is a big reason companies move in this direction.</p><p>But it’s not all perfect.</p><p>Because microservices also introduce new problems:</p><ul><li>More systems = more complexity.</li><li>Services have to constantly talk to each other.</li><li>Debugging becomes harder.</li><li>Deployment is no longer simple.</li></ul><p>So it’s not “better.” It’s just different tradeoffs.</p><p>This is why many large systems didn’t start as microservices. They started as monoliths and evolved over time.</p><p>Companies like Netflix and Amazon followed this kind of path — starting simple, then breaking things apart as scale forced them to. Not because microservices were trendy, but because complexity made them necessary.</p><p>And here’s the funny part I didn’t expect:</p><p>Some systems that went fully into microservices are now simplifying parts of their architecture again, because too many services can also become a problem on their own.</p><p>So it’s not a straight upgrade path. It depends on what you’re trying to solve.</p><p>But at that point, I wasn’t trying to go deep into architecture debates. I just needed to understand what this thing actually was.</p><p><strong>The Experiment</strong></p><p>So I didn’t stop there.</p><p>After understanding the idea of microservices, I kept going back to my own project and asking a different question:</p><p><em>“If I had to break this thing apart… what would it actually look like?”</em></p><p>Not in theory anymore. In my own system.</p><p>That’s when I started looking at real microservices diagrams online. Almost every one of them had the same shape:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Bn_0iuW123vStBDGQ2giw.png" /></figure><p>At the center of everything, two things kept showing up:</p><ul><li>An API Gateway</li><li>Something called a Messaging Queue</li></ul><p>At first, I didn’t really get why they were always there. But I started breaking it down slowly.</p><p>The API Gateway was the easier one. It basically looked like a front door.</p><p>Instead of the frontend talking directly to different parts of the system, everything goes through one place first.</p><p>So:<br>Client → Gateway → Service</p><p>That made sense.</p><p>In my head, I started comparing it to my own project. Right now, my frontend was just calling the backend directly. No middle layer. No routing. Nothing.</p><p>So I could already see where this “gateway thing” would sit — even if I wasn’t actually building it.</p><p>The messaging queue was different. That one took longer to click.</p><p>Because it wasn’t about direct requests. It was more like:<br>“Don’t wait for me, I’ll handle it later.”</p><p>One service drops a message. Another service picks it up when it’s ready.</p><p>No direct waiting. No blocking.</p><p>That idea felt strange at first, but also… powerful.</p><p>Because it meant parts of a system don’t need to be “online together” all the time.</p><p><strong>The Re-Structure (What I Tried)</strong></p><p>So after all that, I went back to my project and tried to reshape it.</p><p>Not rebuild it. Not improve it. Just… rethink it.</p><p>If I followed the microservices idea — even loosely — my structure would look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*8mWx9OUvnG5DHEbgUzYI1w.png" /></figure><p>The gateway layer became that idea:</p><ul><li>app.py → starts the application</li><li>routes.py → decides where requests should go</li></ul><p>So instead of handling logic itself, the gateway just receives requests and forwards them.</p><p>Almost like:<br><em>“This request? Send it to the book service.”</em></p><p>That was the only real change I introduced. Everything else stayed the same.</p><p><strong>Reality Check</strong></p><p>And to be honest… this didn’t give me any real microservice benefits.</p><p>Nothing was running independently. Nothing was deployed separately. It was still one system underneath.</p><p>So, in practice, this change was… kind of pointless.</p><p>But also not.</p><p>Because the goal wasn’t to optimize anything. It was to understand the idea of separating responsibilities at an architectural level.</p><p>And adding the gateway helped me see that more clearly.</p><p><strong>Where I Got Stuck</strong></p><p>But this is where things got confusing again.</p><p>Because breaking things apart like this? That part was easy.</p><p>The real problem was:<br>How do these parts actually run separately?</p><p>Because now I wasn’t just thinking about code anymore. I was thinking about:</p><ul><li>how each part starts</li><li>how they connect</li><li>how they exist independently</li></ul><p>And that’s where I hit a wall.</p><p><strong>The Question That Changed Everything</strong></p><p>If this gateway and backend are supposed to be separate…<br>How do I actually run them like that?<br>Without everything breaking?</p><p>That’s when I started hearing about Docker again.</p><p>But that’s a story for another day.</p><p><strong>What I Took From This</strong></p><p>Looking back, I didn’t really build anything new here. But I learned how to see systems differently.</p><p>I started with something simple: a single application that just worked.</p><p>Then I understood that this way of building has a name: a monolith.</p><p>And from there, I started seeing how systems can be broken down into smaller parts — what people call microservices.</p><p>Not as a replacement. Not as an upgrade. Just as a different way of structuring things.</p><p>And one thing became very clear:</p><p>Breaking code apart is easy.<br>Understanding how those parts actually exist… that’s something else entirely.</p><p>Still figuring this out one step at a time. I’ll be sharing more as I keep learning.</p><p>Feel free to connect:<br><a href="https://www.linkedin.com/in/pauladino/">LinkedIn</a><br><a href="https://github.com/PJAdino">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01e6567a334f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>