<?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"><channel><title><![CDATA[Turing Technology Services]]></title><description><![CDATA[Practical lessons on software architecture, platform engineering and AI in large organisations, by Ferhat Yildiz of Turing Technology Services.]]></description><link>https://blog.turingts.com</link><image><url>https://cdn.hashnode.com/uploads/logos/6ad858beca6b1f0a715e21e0/3bf22f1e-ffe8-4ad7-b821-6ac49a8d19dd.png</url><title>Turing Technology Services</title><link>https://blog.turingts.com</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 01:24:50 GMT</lastBuildDate><atom:link href="https://blog.turingts.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Observability on Azure AKS: Metrics, Logs and Traces]]></title><description><![CDATA[Connect Azure managed Prometheus, Container insights and OpenTelemetry on AKS, then follow an HTTP failure from metrics to logs and spans.]]></description><link>https://blog.turingts.com/observability-on-azure-aks-metrics-logs-and-traces</link><guid isPermaLink="true">https://blog.turingts.com/observability-on-azure-aks-metrics-logs-and-traces</guid><category><![CDATA[Kubernetes]]></category><category><![CDATA[Azure]]></category><category><![CDATA[observability]]></category><category><![CDATA[OpenTelemetry]]></category><category><![CDATA[Terraform]]></category><category><![CDATA[aks]]></category><category><![CDATA[AKS,Azure kubernetes services]]></category><category><![CDATA[azure kubernetes service]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Wed, 04 Nov 2026 13:40:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/93ff8869-a3cc-4686-a20f-a0970796a489.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Applications can appear healthy while some requests are slow, background tasks fail or dependencies become unreliable. To understand what users are experiencing, we need to see what is happening inside the application and the services it depends on. We use metrics, logs and traces with Azure Monitor and Grafana to investigate failed requests on AKS.</p>
<p>Metrics, logs and traces give us different views of that behaviour. In this guide, we add them to an existing AKS and Terraform setup, then use a small demo application to follow a failed request and understand what happened.</p>
<h2>Why do we need observability for applications on AKS?</h2>
<p>When an API starts returning errors, we need to know how widespread the problem is, which requests were involved and where those requests failed.</p>
<p><strong>Observability</strong> means using evidence from the system to understand its behaviour. That evidence, or telemetry, comes in several forms:</p>
<ul>
<li><strong>Metrics</strong> are measurements over time: request counts, error rates and response durations. They reveal patterns, but normally do not identify one individual request.</li>
<li><strong>Logs</strong> record individual events. Structured fields let us find a request without searching unstructured messages by eye.</li>
<li><strong>Traces</strong> describe the operations performed for a request. Each operation is a span, with a start, an end and context. A trace can connect work across services when they propagate that context.</li>
</ul>
<p>We will use <strong>Podinfo</strong>, an upstream demo service, rather than create another application project. Its metrics describe requests; its debug request-start logs include a trace ID; its OpenTelemetry instrumentation produces spans with that same ID. The investigation is manual: a graph narrows the time window, a log identifies a request and a trace confirms the outcome.</p>
<p>This follows the same exercise as <a href="https://blog.turingts.com/observability-on-amazon-eks-metrics-logs-and-traces">Observability on Amazon EKS: Metrics, Logs and Traces</a>. Here, Azure’s native services provide the collection and storage paths.</p>
<h2>What does each component do?</h2>
<p>Azure's native agents collect Prometheus metrics and container logs. A separate OpenTelemetry Collector forwards only traces. Azure Monitor workspaces and Log Analytics workspaces store different signals; Grafana and Azure's investigation tools query those stores.</p>
<table>
<thead>
<tr>
<th>Component</th>
<th>Role in this guide</th>
</tr>
</thead>
<tbody><tr>
<td>Existing AKS cluster</td>
<td>Runs Podinfo and the collectors; its provisioning and pipeline already exist.</td>
</tr>
<tr>
<td>Azure Monitor managed service for Prometheus</td>
<td>Stores scraped metrics in an <strong>Azure Monitor workspace</strong>. We query them with PromQL.</td>
</tr>
<tr>
<td>Azure Monitor metrics add-on (<code>ama-metrics</code>)</td>
<td>Owns the Podinfo scrape. It reads <code>/metrics</code> and sends samples to the managed service.</td>
</tr>
<tr>
<td>Container insights / Azure Monitor Agent (<code>ama-logs</code>)</td>
<td>Collects container stdout/stderr. It sends Podinfo's JSON events to <strong>ContainerLogV2</strong> in a <strong>Log Analytics workspace</strong>.</td>
</tr>
<tr>
<td>Data Collection Rule (DCR)</td>
<td>Describes collection, destinations and, where configured, ingestion transformations. A DCR association connects an agent's rule to the AKS resource.</td>
</tr>
<tr>
<td>OpenTelemetry Collector</td>
<td>Receives Podinfo OTLP/gRPC spans and forwards HTTP/protobuf to Azure Monitor. It neither scrapes this application nor tails its logs.</td>
</tr>
<tr>
<td>Application Insights and Log Analytics</td>
<td>Provide trace investigation and KQL queries over the native OTLP span store.</td>
</tr>
<tr>
<td>Grafana Community Edition (OSS) on AKS</td>
<td>Self-hosted metrics interface, using a dedicated federated workload identity to query the Azure Monitor workspace.</td>
</tr>
<tr>
<td>Terraform, Helm and kubectl</td>
<td>Reuse the existing deployment process. One <code>observability/</code> Terraform configuration creates the monitoring backends, rules, identities, roles and Collector/Grafana Helm releases. Only settings on the existing AKS resource remain in its current configuration. kubectl deploys Podinfo separately.</td>
</tr>
</tbody></table>
<p>Prometheus samples are stored in an <strong>Azure Monitor workspace</strong>; container logs and native OTLP spans are stored in <strong>Log Analytics</strong>. This example creates one Log Analytics workspace for both logs and traces, so the two KQL queries use the same destination. Separate workspaces are an optional adaptation, not a prerequisite. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/kubernetes-monitoring-enable">[1]</a> · <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/opentelemetry-protocol-ingestion">[2]</a></p>
<h2>Architecture: how do the signals travel?</h2>
<p>Podinfo's metrics travel through Azure's native metrics add-on to an Azure Monitor workspace. Container insights sends its logs to Log Analytics; an OpenTelemetry Collector forwards its traces through Azure Monitor's native OTLP ingestion. Grafana queries the metrics.</p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/490264d7-8e17-430b-a712-a5288e9820fc.png" alt="Podinfo on AKS: metrics through the native Azure Monitor metrics add-on into an Azure Monitor workspace; stderr through Container insights and its DCR into ContainerLogV2; gRPC spans through a traces-only Collector into Azure Monitor native OTLP and OTelSpans. Grafana CE inside AKS queries metrics with its dedicated federated identity; Log Analytics queries logs and traces." /></p>
<p>The three lanes show the same Podinfo deployment. Grafana CE runs inside AKS; the Azure query interfaces remain outside it. The Collector belongs only in the trace lane: adding another Prometheus receiver would duplicate the native agent's scrape.</p>
<h3>How do traces reach Azure Monitor?</h3>
<p>Podinfo 6.9.2 exports OTLP/gRPC. Azure Monitor's direct Collector ingestion uses HTTP/protobuf and Microsoft Entra authentication. The Collector converts gRPC to HTTP/protobuf and authenticates to Azure using a workload identity.</p>
<p>Microsoft describes direct Collector ingestion as <strong>generally available</strong>; the separate AMA and AKS application-monitoring add-ons remain preview. We use the direct route with Podinfo’s existing instrumentation. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/opentelemetry-options">[28]</a></p>
<p>The example files are available in the companion repository:</p>
<p><a class="embed-card" href="https://github.com/ferhaty/aks-observability">https://github.com/ferhaty/aks-observability</a></p>

<h2>1. What needs to exist before we add the example?</h2>
<p>Use an existing, managed-identity AKS cluster with Linux amd64 capacity, OIDC and Workload Identity enabled, an established Terraform pipeline with configured AzureRM, AzAPI and Helm providers, and working kubectl access to that cluster.</p>
<p><strong>The workspaces, Application Insights, collection rules and dedicated identities are created by the example</strong>, rather than supplied as preprovisioned prerequisites.</p>
<p>The pipeline needs permission to create monitoring resources, identities and scoped role assignments, read AKS ARM properties and write DCR associations at AKS scope, plus Kubernetes access for Helm. Contributor alone cannot create role assignments. Changes to AKS use its existing deployment permissions and Terraform configuration; do not import the cluster into another state.</p>
<p>Use one Azure public-cloud region for AKS and the monitoring resources. Check native OTLP and Application Insights availability there, and register the required Azure resource providers through your existing subscription setup.</p>
<p>The pipeline needs network access to the Kubernetes API, provider/chart registries and its state backend. Workloads need image-registry access and the relevant Azure ingestion, Prometheus query and Entra endpoints. Grafana downloads its pinned plugin from Grafana’s catalog during startup; restricted environments need an approved preinstalled image or mirror. The example uses authenticated public telemetry endpoints, not Private Link/AMPLS or a cross-region design.</p>
<p>Use a dedicated <code>demo</code> namespace for Podinfo and <code>observability</code> for the Collector and Grafana after checking existing use. The local Grafana login Secret is created before Helm as shown below; no Azure credential goes in that Secret.</p>
<h3>Keep all new resources in one configuration</h3>
<p>The companion repository groups the observability additions for use with your existing Terraform code. The commands below use this directory layout:</p>
<table>
<thead>
<tr>
<th>Location</th>
<th>Purpose</th>
</tr>
</thead>
<tbody><tr>
<td><code>observability/</code></td>
<td>Creates the Azure Monitor workspace, Log Analytics, Application Insights, DCEs/DCRs/associations, dedicated identities/federations/roles and both Helm releases.</td>
</tr>
<tr>
<td>Existing AKS Terraform configuration</td>
<td>Keeps the cluster resource and its OIDC, Workload Identity, managed-metrics and Container insights settings.</td>
</tr>
<tr>
<td><code>aks-settings/</code></td>
<td>Small snippets to merge into that existing configuration, not another deployable root.</td>
</tr>
<tr>
<td><code>podinfo/</code> and <code>native/</code></td>
<td>Demo workload and one custom scrape job, applied through the existing Kubernetes deployment process.</td>
</tr>
</tbody></table>
<p>Before changing anything, inspect the selected cluster and its current DCR associations. These commands use your existing working kubectl access. Set <code>AKS_ID</code> and <code>KUBE_CONTEXT</code> for the same intended cluster; <code>KUBE_CONTEXT</code> selects the cluster for these shell commands, not Terraform provider authentication. The <code>:?required</code> checks stop these commands if either variable is unset:</p>
<p><code>steps/01-inspect.sh</code>:</p>
<pre><code class="language-shell">: "${AKS_ID:?required}" "${KUBE_CONTEXT:?required}"
az aks show --ids "$AKS_ID"   --query '{id:id,identity:identity,metrics:azureMonitorProfile.metrics,logs:addonProfiles.omsagent,oidc:oidcIssuerProfile,workloadIdentity:securityProfile.workloadIdentity}'
az monitor data-collection rule association list-by-resource --resource "$AKS_ID"
kubectl --context "$KUBE_CONTEXT" -n kube-system get pods
</code></pre>
<p>If monitoring already serves other workloads, reconcile its destinations and rules first. This example creates a new installation; it does not migrate shared monitoring or add a duplicate collection path.</p>
<p>OIDC and Workload Identity must be enabled before installing the federated workloads. If they are not, merge these properties inside the <strong>existing</strong> AKS resource and apply that configuration first, keeping its resource address and unrelated settings:</p>
<p><code>aks-settings/identity.hcl</code>:</p>
<pre><code class="language-json"># Merge INSIDE the existing azurerm_kubernetes_cluster resource before observability.
# Preserve its resource address and every unrelated setting.
oidc_issuer_enabled       = true
workload_identity_enabled = true
</code></pre>
<p>Check compatibility with the existing cluster module/provider before changing it. This snippet does not create a cluster. <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-azurerm/v5.12.0/website/docs/r/kubernetes_cluster.html.markdown">[5]</a></p>
<p>The observability configuration reads AKS through a data source. It checks the identity prerequisites and uses the cluster’s region and issuer without retrieving cluster credentials:</p>
<p><code>observability/existing.tf</code>:</p>
<pre><code class="language-json">data "azurerm_resource_group" "monitoring" {
  name = var.resource_group_name
}
# Read only: AKS remains managed by its existing Terraform configuration.
# Read ARM properties, not cluster credentials; Helm uses its existing provider configuration.
data "azapi_resource" "aks" {
  type      = "Microsoft.ContainerService/managedClusters@2024-10-01"
  name      = var.aks_name
  parent_id = "/subscriptions/${var.subscription_id}/resourceGroups/${var.aks_resource_group_name}"
  response_export_values = [
    "properties.oidcIssuerProfile",
    "properties.securityProfile.workloadIdentity"
  ]
  lifecycle {
    postcondition {
      condition = try(
        self.output.properties.oidcIssuerProfile.enabled == true &amp;&amp;
        startswith(self.output.properties.oidcIssuerProfile.issuerURL, "https://") &amp;&amp;
        self.output.properties.securityProfile.workloadIdentity.enabled == true,
        false
      )
      error_message = "Enable OIDC and Workload Identity in the existing AKS configuration before applying observability."
    }
  }
}
</code></pre>
<p>There is one small link back to the cluster configuration: Container insights needs the new Log Analytics workspace ID. The order is therefore existing OIDC/Workload Identity → apply observability → enable the native monitoring add-ons in the existing AKS configuration. The last step uses one workspace-ID output; Helm needs no exported input file. The complete apply sequence appears after the Collector and Grafana configuration below.</p>
<h3>Create the destinations and the native OTLP route</h3>
<p>The first resources are the two different workspace types and workspace-based Application Insights:</p>
<p><code>observability/backends.tf</code>:</p>
<pre><code class="language-json">resource "azurerm_monitor_workspace" "metrics" {
  name                          = "${var.name}-metrics"
  resource_group_name           = var.resource_group_name
  location                      = data.azapi_resource.aks.location
  public_network_access_enabled = true
}
resource "azurerm_log_analytics_workspace" "logs" {
  name                = "${var.name}-logs"
  resource_group_name = var.resource_group_name
  location            = data.azapi_resource.aks.location
  sku                 = "PerGB2018"
  retention_in_days   = 30
}
# Manual OTLP orchestration: ordinary workspace-based AI; do not enable
# automatic OTLP workspace creation in the portal as a second onboarding path.
resource "azurerm_application_insights" "traces" {
  name                         = "${var.name}-traces"
  resource_group_name          = var.resource_group_name
  location                     = data.azapi_resource.aks.location
  workspace_id                 = azurerm_log_analytics_workspace.logs.id
  application_type             = "other"
  retention_in_days            = 30
  local_authentication_enabled = false
}
</code></pre>
<p>Use Microsoft’s <strong>manual resource orchestration</strong> path: create workspace-based Application Insights with automatic OTLP provisioning <strong>Off</strong>, then associate it through the DCR below. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/opentelemetry-protocol-ingestion">[2]</a></p>
<p>AzAPI supplies the native OTLP DCR fields that AzureRM does not expose. This is a <strong>direct-traces-only</strong> version of Microsoft’s template: all three trace streams, Log Analytics and Application Insights enrichment, without the unused AMA, logs and metrics flows. <a href="https://github.com/microsoft/AzureMonitorCommunity/blob/67ecd88b374a71e4b5701d81e7ef5f53cdf71dc9/Azure%20Services/Azure%20Monitor/OpenTelemetry/OTLP_DCE_DCR_ARM_Template.txt">[27]</a> · <a href="https://learn.microsoft.com/en-us/azure/templates/microsoft.insights/2024-03-11/datacollectionrules">[29]</a></p>
<p><code>observability/otlp.tf</code>:</p>
<pre><code class="language-json"># Narrowed from Microsoft's OTLP_DCE_DCR_ARM_Template.txt:
# direct Collector traces only; keep all three trace streams and AI enrichment.
# These native OTLP fields are absent from AzureRM 5.12.0; use the documented ARM API.
# Keep AzAPI schema validation enabled; no live ARM preflight is part of local tests.
resource "azapi_resource" "trace_dce" {
  type      = "Microsoft.Insights/dataCollectionEndpoints@2024-03-11"
  name      = "${var.name}-otlp"
  parent_id = data.azurerm_resource_group.monitoring.id
  location  = data.azapi_resource.aks.location
  body = {
    properties = {
      description = "Direct OTLP trace ingestion"
      networkAcls = { publicNetworkAccess = "Enabled" }
    }
  }
  response_export_values = ["properties.logsIngestion.endpoint"]
}
locals {
  trace_streams = [
    "Microsoft-OTel-Traces-Spans",
    "Microsoft-OTel-Traces-Events",
    "Microsoft-OTel-Traces-Resources"
  ]
}
resource "azapi_resource" "trace_dcr" {
  type                      = "Microsoft.Insights/dataCollectionRules@2024-03-11"
  name                      = "${var.name}-otlp"
  parent_id                 = data.azurerm_resource_group.monitoring.id
  location                  = data.azapi_resource.aks.location
  schema_validation_enabled = true
  body = {
    properties = {
      description              = "Direct OTLP traces with Application Insights association"
      dataCollectionEndpointId = azapi_resource.trace_dce.id
      references = {
        applicationInsights = [{
          resourceId = azurerm_application_insights.traces.id
          name       = "applicationInsightsResource"
        }]
      }
      directDataSources = {
        otelTraces = [{
          streams                        = local.trace_streams
          enrichWithResourceAttributes   = ["*"]
          enrichWithReference            = "applicationInsightsResource"
          replaceResourceIdWithReference = true
          name                           = "otelTracesDataSourceDirect"
        }]
      }
      destinations = {
        logAnalytics = [{
          workspaceResourceId = azurerm_log_analytics_workspace.logs.id
          name                = "myLAW"
        }]
      }
      dataFlows = [{ streams = local.trace_streams, destinations = ["myLAW"] }]
    }
  }
  response_export_values = ["properties.immutableId"]
}
locals {
  trace_endpoint = "${trimsuffix(azapi_resource.trace_dce.output.properties.logsIngestion.endpoint, "/")}/datacollectionRules/${azapi_resource.trace_dcr.output.properties.immutableId}/streams/Microsoft-OTLP-Traces/otlp/v1/traces"
}
</code></pre>
<p>The full Collector URL is derived from the DCE’s returned <strong>logs ingestion endpoint</strong> and the DCR’s returned <strong>immutable ID</strong>. The DCR’s Azure resource ID is used for RBAC, not in that URL. The Application Insights reference associates native spans with the component; it does not convert them into classic AppTraces. No endpoint or resource ID needs to be copied from the portal.</p>
<p>The same configuration creates the native Prometheus DCE/DCR and ContainerInsights DCR and associates both rules with the existing AKS resource. Their configuration follows below. Creating these associations does not itself enable the native agents; their AKS settings are applied after the new workspace exists. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/kubernetes-monitoring-enable">[1]</a></p>
<h2>2. Give each identity one clear job</h2>
<p>The pipeline deploys resources, native add-ons collect telemetry, the Collector's workload identity writes traces, and Grafana reads metrics. These are different principals with different scopes; they should not share one deployment credential.</p>
<table>
<thead>
<tr>
<th>Identity</th>
<th>Responsibility</th>
</tr>
</thead>
<tbody><tr>
<td>Pipeline Azure identity</td>
<td>Create the monitoring resources, dedicated identities/federations, scoped roles and Helm releases. Update AKS through its existing configuration; the supplied example shows that apply separately.</td>
</tr>
<tr>
<td>AKS control-plane/cluster identity</td>
<td>Existing cluster operations; current Container insights managed-identity authentication uses this identity.</td>
</tr>
<tr>
<td>Kubelet identity</td>
<td>Existing node responsibilities such as registry access; not a blanket grant for the Collector.</td>
</tr>
<tr>
<td>Native metrics ingestion identity</td>
<td>Managed by the native AKS metrics add-on during onboarding. Do not substitute the Grafana reader or Collector identity.</td>
</tr>
<tr>
<td>Collector user-assigned identity</td>
<td>Federated to one Kubernetes service account; <code>Monitoring Metrics Publisher</code> on the <strong>trace DCR</strong>.</td>
</tr>
<tr>
<td>Grafana user-assigned identity</td>
<td>Federated only to <code>observability:grafana</code>; <code>Monitoring Data Reader</code> on the <strong>Azure Monitor workspace</strong>, not trace-ingestion rights.</td>
</tr>
<tr>
<td>Human investigator</td>
<td>Access to the intended Log Analytics workspaces and Application Insights experience; separate from the agent and Grafana roles.</td>
</tr>
</tbody></table>
<p>Current Container insights managed-identity authentication does not require adding <code>Monitoring Metrics Publisher</code> to the cluster. The Collector's direct OTLP route does require that role on its DCR. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/opentelemetry-protocol-ingestion">[2]</a> · <a href="https://learn.microsoft.com/en-us/azure/aks/managed-identity-overview">[8]</a> · <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-authentication">[9]</a></p>
<p>The <code>observability/</code> directory groups the new monitoring resources and Helm releases for your existing Terraform setup. Add these files to the root where your AzureRM, AzAPI and Helm providers are already configured, keeping their existing subscription, tenant and cluster settings. If you run this directory separately, reuse the provider configuration there too; it is not inherited from another folder. <code>versions.tf</code> declares only the required provider packages and versions.</p>
<p><code>observability/versions.tf</code>:</p>
<pre><code class="language-json">terraform {
  required_version = "&gt;= 1.10.0, &lt; 2.0.0"
  required_providers {
    azurerm = { source = "hashicorp/azurerm", version = "5.12.0" }
    azapi   = { source = "Azure/azapi", version = "2.13.0" }
    helm    = { source = "hashicorp/helm", version = "3.3.0" }
  }
  # Reuse the existing Terraform setup and provider configurations.
}
</code></pre>
<p>Supply the existing subscription, tenant, resource-group and AKS names. New endpoints and identity IDs are direct resource references, not inputs to copy:</p>
<p><code>observability/terraform.tfvars.example</code>:</p>
<pre><code class="language-json">name                      = "store-observability"
subscription_id           = "00000000-0000-4000-8000-000000000000"
tenant_id                 = "22222222-2222-4222-8222-222222222222"
resource_group_name       = "existing-monitoring-rg"
aks_name                  = "existing-aks"
aks_resource_group_name   = "existing-aks-rg"
grafana_admin_secret_name = "grafana-admin"
</code></pre>
<p>The variable declarations are in <code>observability/variables.tf</code>. <code>grafana_admin_secret_name</code> identifies an existing Kubernetes Secret; its value is a name, not a password.</p>
<p>The two identities receive separate federations and grants:</p>
<p><code>observability/identity.tf</code>:</p>
<pre><code class="language-json">resource "azurerm_user_assigned_identity" "traces" {
  name                = "${var.name}-traces"
  resource_group_name = var.resource_group_name
  location            = data.azapi_resource.aks.location
}
resource "azurerm_federated_identity_credential" "traces" {
  name                      = "podinfo-collector"
  user_assigned_identity_id = azurerm_user_assigned_identity.traces.id
  audience                  = ["api://AzureADTokenExchange"]
  issuer                    = data.azapi_resource.aks.output.properties.oidcIssuerProfile.issuerURL
  subject                   = "system:serviceaccount:observability:otel-collector"
}
resource "azurerm_role_assignment" "trace_ingestion" {
  scope                = azapi_resource.trace_dcr.id
  role_definition_name = "Monitoring Metrics Publisher"
  principal_id         = azurerm_user_assigned_identity.traces.principal_id
}
resource "azurerm_user_assigned_identity" "grafana" {
  name                = "${var.name}-grafana"
  resource_group_name = var.resource_group_name
  location            = data.azapi_resource.aks.location
}
resource "azurerm_federated_identity_credential" "grafana" {
  name                      = "${var.name}-grafana"
  user_assigned_identity_id = azurerm_user_assigned_identity.grafana.id
  audience                  = ["api://AzureADTokenExchange"]
  issuer                    = data.azapi_resource.aks.output.properties.oidcIssuerProfile.issuerURL
  subject                   = "system:serviceaccount:observability:grafana"
}
resource "azurerm_role_assignment" "grafana_metrics" {
  scope                = azurerm_monitor_workspace.metrics.id
  role_definition_name = "Monitoring Data Reader"
  principal_id         = azurerm_user_assigned_identity.grafana.principal_id
}
</code></pre>
<p>The federation matches the exact issuer, service-account subject and <code>api://AzureADTokenExchange</code> audience. Its client ID identifies the workload identity; the role assignments use principal/object IDs. The pinned provider uses <code>user_assigned_identity_id</code>, not older <code>parent_id</code> examples. <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-azurerm/v5.12.0/website/docs/r/federated_identity_credential.html.markdown">[10]</a></p>
<p>The new Grafana identity has its own federation and workspace-scoped reader assignment. Its service-account subject is <code>system:serviceaccount:observability:grafana</code>; it does not reuse the Collector identity or the node identity. The service-account annotation receives the <strong>client ID</strong>, while Azure role assignments receive the <strong>principal/object ID</strong>. Broader inherited access is not narrowed by this assignment. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/metrics/prometheus-grafana">[11]</a></p>
<h2>3. Let the native metrics agent own the scrape</h2>
<p>Add one Podinfo job to the replica-level <code>ama-metrics-prometheus-config</code> ConfigMap. Do not also enable annotation scraping, a PodMonitor/ServiceMonitor or a Collector Prometheus receiver for the same endpoint.</p>
<p>Save this as <code>native/prometheus-config</code>, without a file extension:</p>
<pre><code class="language-yaml">scrape_configs:
  - job_name: podinfo
    scrape_interval: 15s
    scrape_timeout: 10s
    metrics_path: /metrics
    static_configs:
      - targets: [podinfo.demo.svc.cluster.local:9898]
</code></pre>
<p>The native add-on consumes the <code>prometheus-config</code> key from <code>ama-metrics-prometheus-config</code> in <code>kube-system</code>. This is different from <code>ama-metrics-settings-configmap</code>, which controls defaults and other agent settings. Do not place this Service target in the per-node ConfigMap: that would make every node scrape it. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/prometheus-metrics-scrape-configmap">[12]</a></p>
<p>Inspect the existing configuration first:</p>
<pre><code class="language-shell">kubectl --context "$KUBE_CONTEXT" -n kube-system get configmap ama-metrics-prometheus-config -o yaml
</code></pre>
<p>If it exists, merge this job through its existing deployment process without deleting other jobs. If it does not exist and creation is approved, create it once:</p>
<pre><code class="language-shell">kubectl --context "$KUBE_CONTEXT" -n kube-system create configmap ama-metrics-prometheus-config   --from-file=prometheus-config=native/prometheus-config
</code></pre>
<p>The <code>create</code> operation refuses an existing object rather than replacing it. Preserve this configuration in the existing deployment process after the exercise. Check the agent's config-processing logs and target status if it rejects the job; Microsoft's <code>promconfigvalidator</code> is shipped inside the managed agent for validating its exact accepted configuration.</p>
<p>This Service-based target deliberately uses <strong>one Podinfo replica</strong>. A Service can route successive scrapes to different replicas; that does not produce trustworthy per-process counter histories. Adopt per-pod discovery and explicit ownership before scaling. The native add-on's own built-in targets remain under their existing configuration.</p>
<h2>4. Keep container logs on the Container insights path</h2>
<p>Container insights collects Podinfo's stderr and stores it in <code>ContainerLogV2</code>. Keep the JSON message and its trace ID intact. Do not add Fluent Bit or a Collector log pipeline alongside this route.</p>
<p>The observability configuration creates the complete native rules and associations, not a fragment that assumes they already exist. Its Prometheus forwarder routes to the new Azure Monitor workspace; its ContainerInsights extension routes only <code>Microsoft-ContainerLogV2</code> to the new Log Analytics workspace. It does not enable the full inventory/performance stream set required by every Container insights dashboard. <a href="https://raw.githubusercontent.com/Azure/prometheus-collector/main/AddonTerraformTemplate/main.tf">[31]</a> · <a href="https://raw.githubusercontent.com/microsoft/Docker-Provider/ci_prod/scripts/onboarding/aks/onboarding-msi-terraform/main.tf">[32]</a></p>
<p><code>observability/native.tf</code>:</p>
<pre><code class="language-json">resource "azurerm_monitor_data_collection_endpoint" "metrics" {
  name                          = "${var.name}-prometheus"
  resource_group_name           = var.resource_group_name
  location                      = data.azapi_resource.aks.location
  kind                          = "Linux"
  public_network_access_enabled = true
}
resource "azurerm_monitor_data_collection_rule" "metrics" {
  name                        = "${var.name}-prometheus"
  resource_group_name         = var.resource_group_name
  location                    = data.azapi_resource.aks.location
  kind                        = "Linux"
  data_collection_endpoint_id = azurerm_monitor_data_collection_endpoint.metrics.id
  destinations {
    monitor_account {
      monitor_account_id = azurerm_monitor_workspace.metrics.id
      name               = "MonitoringAccount1"
    }
  }
  data_flow {
    streams      = ["Microsoft-PrometheusMetrics"]
    destinations = ["MonitoringAccount1"]
  }
  data_sources {
    prometheus_forwarder {
      streams = ["Microsoft-PrometheusMetrics"]
      name    = "PrometheusDataSource"
    }
  }
}
resource "azurerm_monitor_data_collection_rule_association" "metrics" {
  name                    = "${var.name}-prometheus"
  target_resource_id      = data.azapi_resource.aks.id
  data_collection_rule_id = azurerm_monitor_data_collection_rule.metrics.id
}
resource "azurerm_monitor_data_collection_rule" "logs" {
  name                = "${var.name}-container-insights"
  resource_group_name = var.resource_group_name
  location            = data.azapi_resource.aks.location
  destinations {
    log_analytics {
      workspace_resource_id = azurerm_log_analytics_workspace.logs.id
      name                  = "ciworkspace"
    }
  }
  data_sources {
    extension {
      name           = "ContainerInsightsExtension"
      extension_name = "ContainerInsights"
      streams        = ["Microsoft-ContainerLogV2"]
      extension_json = jsonencode({
        dataCollectionSettings = {
          interval               = "1m"
          namespaceFilteringMode = "Off"
          namespaces             = []
          enableContainerLogV2   = true
        }
      })
    }
  }
  data_flow {
    streams       = ["Microsoft-ContainerLogV2"]
    destinations  = ["ciworkspace"]
    transform_kql = "source"
  }
}
resource "azurerm_monitor_data_collection_rule_association" "logs" {
  name                    = "ContainerInsightsExtension"
  target_resource_id      = data.azapi_resource.aks.id
  data_collection_rule_id = azurerm_monitor_data_collection_rule.logs.id
}
</code></pre>
<p>There is only one native rule for each signal path. If adapting an existing shared installation, preserve its required streams and destinations rather than installing these associations alongside its existing ones.</p>
<p><code>source</code> preserves the incoming events. This matters because our correlation event is <strong>debug-level</strong>, not error-level. A filter that keeps only <code>error</code> and <code>critical</code> would discard the request-start event even when its eventual response is HTTP 500. If the rule currently uses <code>Microsoft-ContainerInsights-Group-Default</code>, expand it into the required individual streams before defining a separate transformed flow; do not collect the group and the same explicit stream twice. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-transformations">[13]</a></p>
<p>The DCR's <code>namespaceFilteringMode</code> is not an inclusion filter for <code>ContainerLogV2</code> stdout/stderr. Agent-side namespace exclusions are configured through <code>container-azm-ms-agentconfig</code>; verify that stderr collection is enabled and <code>demo</code> is not excluded. Merge any required changes into the shared ConfigMap, preserving its other settings. A DCR transformation can filter <code>PodNamespace</code> after transport, but it is not the same as preventing collection at the agent. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-data-collection-filter">[14]</a></p>
<p>For this exercise, preserve any existing shared agent collection policy and query only <code>demo</code>. The new workspace starts with 30-day retention. Choose any dedicated ingestion filter, different retention period or Basic-versus-Analytics table plan separately.</p>
<h2>5. Install a traces-only Collector with Helm</h2>
<p>The Collector accepts gRPC inside the cluster and exports HTTPS HTTP/protobuf to the native OTLP endpoint created in the same configuration. Microsoft Entra Workload ID supplies its projected token. The Collector has no metrics or logs pipeline.</p>
<p><code>observability/helm.tf</code>:</p>
<pre><code class="language-json">resource "helm_release" "collector" {
  name             = "otel-collector"
  namespace        = "observability"
  create_namespace = false
  repository       = "https://open-telemetry.github.io/opentelemetry-helm-charts"
  chart            = "opentelemetry-collector"
  version          = "0.176.1"
  values = [templatefile("${path.module}/collector.yaml.tftpl", {
    client_id      = azurerm_user_assigned_identity.traces.client_id
    tenant_id      = var.tenant_id
    trace_endpoint = local.trace_endpoint
  })]
  depends_on = [
    azurerm_federated_identity_credential.traces,
    azurerm_role_assignment.trace_ingestion
  ]
  wait    = true
  timeout = 600
}
</code></pre>
<p><code>observability/collector.yaml.tftpl</code>:</p>
<pre><code class="language-yaml">fullnameOverride: otel-collector
mode: deployment
replicaCount: 1
rollout: {strategy: Recreate, rollingUpdate: {}}
autoscaling: {enabled: false}
image: {repository: otel/opentelemetry-collector-contrib, tag: '0.162.0'}
command: {name: otelcol-contrib}
nodeSelector:
  kubernetes.io/os: linux
  kubernetes.io/arch: amd64
serviceAccount:
  create: true
  name: otel-collector
  automountServiceAccountToken: false
  annotations:
    azure.workload.identity/client-id: '${client_id}'
    azure.workload.identity/tenant-id: '${tenant_id}'
podLabels:
  azure.workload.identity/use: 'true'
clusterRole: {create: false}
presets:
  logsCollection: {enabled: false}
  hostMetrics: {enabled: false}
  kubernetesAttributes: {enabled: false}
  kubeletMetrics: {enabled: false}
  kubernetesEvents: {enabled: false}
  kubernetesObjects: {enabled: false}
  clusterMetrics: {enabled: false}
  annotationDiscovery: {logs: {enabled: false}, metrics: {enabled: false}}
  profiling: {enabled: false}
  resourceDetection: {enabled: false}
resources:
  requests: {cpu: 100m, memory: 256Mi}
  limits: {memory: 512Mi}
ports:
  otlp: {enabled: true, containerPort: 4317, servicePort: 4317, hostPort: null}
  otlp-http: {enabled: false}
  jaeger-compact: {enabled: false}
  jaeger-thrift: {enabled: false}
  jaeger-grpc: {enabled: false}
  zipkin: {enabled: false}
  metrics: {enabled: false}
service: {enabled: true, type: ClusterIP}
config:
  extensions:
    azure_auth:
      workload_identity:
        client_id: '$${env:AZURE_CLIENT_ID}'
        tenant_id: '$${env:AZURE_TENANT_ID}'
        federated_token_file: '$${env:AZURE_FEDERATED_TOKEN_FILE}'
      scopes: ['https://monitor.azure.com/.default']
  receivers:
    jaeger: null
    zipkin: null
    prometheus: null
    otlp:
      protocols:
        grpc: {endpoint: '$${env:MY_POD_IP}:4317'}
        http: null
  processors:
    memory_limiter: {check_interval: 1s, limit_percentage: 75, spike_limit_percentage: 15}
    batch: {timeout: 5s, send_batch_size: 512, send_batch_max_size: 512}
  exporters:
    debug: null
    otlp_http/azure:
      traces_endpoint: '${trace_endpoint}'
      encoding: proto
      compression: none
      auth: {authenticator: azure_auth}
      sending_queue: {enabled: true, queue_size: 100, num_consumers: 1}
      retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 60s}
  service:
    extensions: [health_check, azure_auth]
    pipelines:
      logs: null
      metrics: null
      traces: {receivers: [otlp], processors: [memory_limiter, batch], exporters: [otlp_http/azure]}
</code></pre>
<p>Keep the doubled dollar signs: Terraform's <code>templatefile</code> turns <code>$${env:...}</code> into <code>${env:...}</code>, which the Collector expands at runtime. The Helm provider downloads the chart from its repository.</p>
<p>The <code>azure.workload.identity/use: "true"</code> Pod label and service-account annotations cause the existing workload-identity webhook to project a federated token and inject the Azure identity environment variables. Ordinary Kubernetes API-token automount is disabled; the workload-identity projection is separate. Do not give Podinfo this identity. <a href="https://learn.microsoft.com/en-us/azure/aks/workload-identity-deploy-cluster">[15]</a></p>
<p>For contrib 0.162.0, <code>azure_auth.workload_identity</code> is the explicit authentication shape, and <code>https://monitor.azure.com/.default</code> is the requested scope. It is used on the <strong>outbound exporter</strong>, not to authenticate clients of the Collector's gRPC receiver. <a href="https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector-contrib/v0.162.0/extension/azureauthextension/README.md">[16]</a></p>
<p>The complete values file removes the chart's unused default receivers and pipelines while retaining <code>health_check</code> for its probes. Podinfo’s Prometheus histogram is collected separately by the native metrics agent.</p>
<p>The release waits for its federation and DCR-scoped role assignment. This orders resource creation, but Azure authorization can still take time to propagate. Complete the Grafana configuration and apply sequence in the next section before checking the Collector rollout:</p>
<pre><code class="language-shell">kubectl --context "$KUBE_CONTEXT" -n observability rollout status deployment/otel-collector --timeout=180s
kubectl --context "$KUBE_CONTEXT" -n observability logs deployment/otel-collector --tail=100
</code></pre>
<p>An authentication failure belongs to the trace path: inspect the Pod label, injected environment names, token-file mount, federation subject/issuer and DCR-scoped assignment. Do not print the token. Allow time for role propagation, then verify an incoming span in Azure.</p>
<h2>6. Run Grafana CE on AKS and connect the metrics workspace</h2>
<p>Like the EKS example, we deploy <strong>Grafana Community Edition (Grafana OSS)</strong> through Helm in the existing <code>observability</code> namespace. It runs behind a private <code>ClusterIP</code> Service, accessed through a local port-forward. The OSS image and the open-source Azure Prometheus plugin require no Enterprise licence.</p>
<p>Grafana 13 no longer provides Azure authentication through the core Prometheus datasource. The <strong>Azure Monitor Managed Service for Prometheus</strong> plugin supplies this integration with <strong>Workload Identity</strong> authentication. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/metrics/prometheus-grafana">[11]</a> · <a href="https://github.com/grafana/azure-prometheus-datasource/blob/v1.0.10/docs/sources/configure.md">[17]</a> · <a href="https://grafana.com/grafana/plugins/grafana-azureprometheus-datasource/">[18]</a></p>
<h3>Supply the local admin Secret before Helm</h3>
<p>Check whether <code>observability</code> already exists. Only if it is absent and creation is approved, run:</p>
<p><code>steps/00-namespace.sh</code>:</p>
<pre><code class="language-shell"># Only if observability is absent and its creation is approved. Refuses replacement.
: "${KUBE_CONTEXT:?required}"
kubectl --context "$KUBE_CONTEXT" create namespace observability
</code></pre>
<p>If <code>grafana-admin</code> already exists, confirm its keys and reuse it; do not overwrite another installation's credentials. For a new Secret, set <code>GRAFANA_ADMIN_USER_FILE</code> and <code>GRAFANA_ADMIN_PASSWORD_FILE</code> to approved local files containing the chosen username and password, without trailing newlines. Restrict access to those files and keep them out of Git, Terraform variables/state and shell tracing. The command passes file paths, not password values:</p>
<pre><code class="language-shell">: "${KUBE_CONTEXT:?required}" "${GRAFANA_ADMIN_USER_FILE:?required}" "${GRAFANA_ADMIN_PASSWORD_FILE:?required}"
kubectl --context "$KUBE_CONTEXT" -n observability create secret generic grafana-admin \
  --from-file=admin-user="$GRAFANA_ADMIN_USER_FILE" \
  --from-file=admin-password="$GRAFANA_ADMIN_PASSWORD_FILE"
</code></pre>
<p>This <code>create</code> refuses an existing Secret. Helm consumes <code>admin.existingSecret</code>; it does not generate or embed an admin password in the example. Protect the Secret with the cluster's existing RBAC and encryption policy, and remove local credential files according to the existing credential-handling process. Azure queries use Grafana’s federated workload identity.</p>
<p><code>observability/grafana.tf</code>:</p>
<pre><code class="language-json">resource "helm_release" "grafana" {
  name             = "grafana"
  namespace        = "observability"
  create_namespace = false
  repository       = "https://grafana-community.github.io/helm-charts"
  chart            = "grafana"
  version          = "14.0.1"
  values = [templatefile("${path.module}/grafana.yaml.tftpl", {
    client_id         = azurerm_user_assigned_identity.grafana.client_id
    tenant_id         = var.tenant_id
    query_url         = azurerm_monitor_workspace.metrics.query_endpoint
    admin_secret_name = var.grafana_admin_secret_name
  })]
  depends_on = [
    azurerm_federated_identity_credential.grafana,
    azurerm_role_assignment.grafana_metrics
  ]
  wait    = true
  timeout = 600
}
</code></pre>
<p><code>observability/grafana.yaml.tftpl</code>:</p>
<pre><code class="language-yaml">fullnameOverride: grafana
replicas: 1
image:
  registry: docker.io
  repository: grafana/grafana
  tag: 13.2.4-distroless
nodeSelector:
  kubernetes.io/os: linux
  kubernetes.io/arch: amd64
serviceAccount:
  create: true
  name: grafana
  automountServiceAccountToken: false
  annotations:
    azure.workload.identity/client-id: '${client_id}'
    azure.workload.identity/tenant-id: '${tenant_id}'
podLabels:
  azure.workload.identity/use: 'true'
automountServiceAccountToken: false
rbac: {create: false}
admin:
  existingSecret: '${admin_secret_name}'
  userKey: admin-user
  passwordKey: admin-password
service: {type: ClusterIP}
ingress: {enabled: false}
persistence: {enabled: false}
testFramework: {enabled: false}
securityContext:
  runAsNonRoot: true
  runAsUser: 472
  runAsGroup: 472
  fsGroup: 472
resources:
  requests: {cpu: 100m, memory: 256Mi}
  limits: {memory: 512Mi}
grafana.ini:
  auth:
    azure_auth_enabled: true
  azure:
    cloud: AzureCloud
    managed_identity_enabled: false
    workload_identity_enabled: true
    forward_settings_to_plugins: grafana-azure-monitor-datasource, prometheus, grafana-azure-data-explorer-datasource, mssql, grafana-azureprometheus-datasource, grafana-databricks-datasource
plugins:
  - grafana-azureprometheus-datasource@1.0.10@https://grafana.com/api/plugins/grafana-azureprometheus-datasource/versions/1.0.10/download?os=linux&amp;arch=amd64
shadowBundledPlugins: false
datasources:
  datasources.yaml:
    apiVersion: 1
    datasources:
      - name: Azure Prometheus
        uid: azure-prometheus
        type: grafana-azureprometheus-datasource
        access: proxy
        isDefault: true
        editable: false
        url: '${query_url}'
        jsonData:
          httpMethod: POST
          timeInterval: 15s
          manageAlerts: false
          oauthPassThru: false
          azureCredentials:
            authType: workloadidentity
</code></pre>
<p>The chart installs the pinned plugin synchronously through <code>GF_PLUGINS_PREINSTALL_SYNC</code>. <code>azure_auth_enabled</code> enables Azure datasource authentication; <code>workload_identity_enabled</code> enables federation, and <code>forward_settings_to_plugins</code> includes this plugin while retaining the pinned server's other defaults. No legacy <code>prometheus_azure_auth</code> feature toggle is needed. <a href="https://github.com/grafana-community/helm-charts/blob/grafana-14.0.1/charts/grafana/templates/_pod.tpl">[19]</a> · <a href="https://github.com/grafana/grafana/blob/v13.2.4/conf/defaults.ini">[20]</a></p>
<p>The Pod label and service-account annotations ask AKS's workload-identity webhook to inject <code>AZURE_CLIENT_ID</code>, <code>AZURE_TENANT_ID</code> and <code>AZURE_FEDERATED_TOKEN_FILE</code>, together with its projected token volume. The plugin's workload credential reads those values. Ordinary Kubernetes API-token automount remains disabled. Grafana runs as UID/GID 472 with <code>fsGroup: 472</code>; the projected token must be readable by that process. Inspect the admitted Pod's volume permissions if cluster policy changes them, without printing the token. Keep <code>managed_identity_enabled</code> disabled so authentication uses the projected workload token rather than node IMDS. <a href="https://github.com/grafana/grafana-azure-sdk-go/blob/v2.4.1/aztokenprovider/retriever_workloadidentity.go">[21]</a> · <a href="https://learn.microsoft.com/en-us/azure/aks/workload-identity-deploy-cluster">[15]</a></p>
<h3>Apply the configuration and enable native collection</h3>
<p>With all files, the existing provider configuration and the Grafana Secret ready, use the existing pipeline to initialize, review and apply <code>observability/</code>. The plan creates the monitoring backends, rules, associations, dedicated identities and both Helm releases; it must not change or replace AKS. Helm receives its endpoints and client IDs directly from the resources above.</p>
<p>Read the single value needed by the existing AKS configuration, from the repository’s <code>example/</code> directory:</p>
<p><code>steps/00-workspace-id.sh</code>:</p>
<pre><code class="language-shell">terraform -chdir=observability output -raw log_analytics_workspace_id
</code></pre>
<p>Pass that value through the cluster pipeline’s normal inputs as <code>observability_log_analytics_workspace_id</code>. Add this variable to the existing AKS configuration:</p>
<p><code>aks-settings/variables.tf.example</code>:</p>
<pre><code class="language-json"># Add to the existing AKS configuration when enabling the monitoring add-ons.
variable "observability_log_analytics_workspace_id" {
  description = "log_analytics_workspace_id output from the observability configuration."
  type        = string
}
</code></pre>
<p>Then merge the following blocks inside its existing AKS resource and review/apply that configuration. Keep the OIDC and Workload Identity settings already enabled:</p>
<p><code>aks-settings/monitoring.hcl</code>:</p>
<pre><code class="language-json"># Merge INSIDE the same existing AKS resource after observability has been applied.
monitor_metrics {
  annotations_allowed = null
  labels_allowed      = null
}
oms_agent {
  log_analytics_workspace_id      = var.observability_log_analytics_workspace_id
  msi_auth_for_monitoring_enabled = true
}
</code></pre>
<p>This enables the native metrics and Container insights agents against the prepared rules and destinations. Until this step, native metrics and container logs will not arrive. The native agents use AKS-managed authentication; do not reuse either Helm workload identity or add a blanket Publisher grant. <a href="https://raw.githubusercontent.com/Azure/prometheus-collector/main/AddonTerraformTemplate/main.tf">[31]</a> · <a href="https://raw.githubusercontent.com/microsoft/Docker-Provider/ci_prod/scripts/onboarding/aks/onboarding-msi-terraform/main.tf">[32]</a> · <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-authentication">[9]</a></p>
<p>Inspect the actual add-ons and associations again with <code>steps/01-inspect.sh</code>, then verify native ingestion. Do not run portal or CLI onboarding alongside these files: it can create another set of rules or destinations. If the workspace is replaced later, update the cluster’s input deliberately; the workspace and cluster settings remain linked.</p>
<h3>Open Grafana and verify the datasource</h3>
<p>Keep this port-forward running in a separate terminal:</p>
<pre><code class="language-shell">kubectl --context "$KUBE_CONTEXT" -n observability rollout status deployment/grafana --timeout=180s
kubectl --context "$KUBE_CONTEXT" -n observability port-forward service/grafana 3000:80
</code></pre>
<p>Open <code>http://localhost:3000</code> and sign in with the credentials supplied through <code>grafana-admin</code>. In <strong>Connections → Data sources</strong>, open <strong>Azure Prometheus</strong> and run <strong>Save &amp; test</strong>. Its URL and <strong>Workload Identity</strong> authentication are provisioned from code; change that code rather than adding a second datasource. Verify the datasource against Azure, then run <code>up{job="podinfo"}</code> after generating traffic below.</p>
<p>For an authentication or startup failure, inspect the dedicated service account, admitted Pod and logs:</p>
<pre><code class="language-shell">kubectl --context "$KUBE_CONTEXT" -n observability get serviceaccount grafana -o yaml
kubectl --context "$KUBE_CONTEXT" -n observability get pods -l app.kubernetes.io/instance=grafana -o yaml
kubectl --context "$KUBE_CONTEXT" -n observability logs deployment/grafana --tail=100
</code></pre>
<p>Check plugin installation, the workload label, injected environment names, token mount, exact issuer/subject/audience and the reader assignment on the intended workspace. Allow role propagation and verify DNS/HTTPS reachability to Entra and the query endpoint. Do not print bearer tokens or replace federation with a static client secret.</p>
<p>This single-replica lab disables persistence, as in the EKS example. Provisioned datasource configuration returns after replacement, but locally saved dashboards, users and other database changes do not; use versioned provisioning or persistent storage before retaining Grafana beyond the exercise. Restrict access with network policy and Kubernetes port-forward authorization.</p>
<p>Metrics are queried in Grafana, while logs and traces are investigated in Azure’s Log Analytics/Application Insights tools. Correlation uses a manual trace-ID lookup; automatic Grafana log-to-trace links can be added later.</p>
<h2>7. Deploy upstream Podinfo separately</h2>
<p>Podinfo supplies the request handler, metrics, logs and tracing without a Dockerfile or application build pipeline. Keep it private and use one replica; the pinned image is the same upstream release used for the EKS exercise.</p>
<p>Podinfo’s trace implementation uses an OTLP <strong>gRPC</strong> client. <code>http://</code> below selects plaintext gRPC to port 4317; it does not mean OTLP/HTTP, and there is no <code>/v1/traces</code> suffix on this application endpoint. <a href="https://raw.githubusercontent.com/stefanprodan/podinfo/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/tracer.go">[22]</a></p>
<p><code>podinfo/podinfo.yaml</code>:</p>
<pre><code class="language-yaml">apiVersion: v1
kind: Namespace
metadata: {name: demo}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: podinfo, namespace: demo}
spec:
  replicas: 1
  strategy: {type: Recreate}
  selector: {matchLabels: {app: podinfo}}
  template:
    metadata: {labels: {app: podinfo}}
    spec:
      automountServiceAccountToken: false
      enableServiceLinks: false
      nodeSelector: {kubernetes.io/os: linux, kubernetes.io/arch: amd64}
      securityContext: {runAsNonRoot: true, runAsUser: 10001, runAsGroup: 10001, fsGroup: 10001}
      containers:
        - name: podinfo
          image: ghcr.io/stefanprodan/podinfo:6.9.2@sha256:cab90e04829cdae73199a8402882a4e3ccaf251b8a0d50bdefede0ab3f6371e7
          command: [./podinfo]
          args: [--port=9898, --level=debug, --random-delay=false, --random-error=false]
          env:
            - {name: PODINFO_OTEL_SERVICE_NAME, value: podinfo}
            - name: OTEL_EXPORTER_OTLP_ENDPOINT
              value: http://otel-collector.observability.svc.cluster.local:4317
          ports: [{name: http, containerPort: 9898}]
          readinessProbe: {httpGet: {path: /readyz, port: http}}
          livenessProbe: {httpGet: {path: /healthz, port: http}, initialDelaySeconds: 5}
          resources:
            requests: {cpu: 100m, memory: 64Mi}
            limits: {cpu: 500m, memory: 128Mi}
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities: {drop: [ALL]}
          volumeMounts: [{name: data, mountPath: /data}]
      volumes: [{name: data, emptyDir: {sizeLimit: 16Mi}}]
---
apiVersion: v1
kind: Service
metadata: {name: podinfo, namespace: demo}
spec:
  type: ClusterIP
  selector: {app: podinfo}
  ports: [{name: http, port: 9898, targetPort: http}]
</code></pre>
<p>Review the namespace and resource names before applying through your approved context:</p>
<pre><code class="language-shell">kubectl --context "$KUBE_CONTEXT" apply -f podinfo/podinfo.yaml
kubectl --context "$KUBE_CONTEXT" -n demo rollout status deployment/podinfo --timeout=180s
kubectl --context "$KUBE_CONTEXT" -n demo get pods -l app=podinfo
</code></pre>
<p>Podinfo exposes fault-injection and environment/configuration inspection endpoints. Do not put credentials or sensitive configuration in this demo, expose it through a public ingress, or give it a Kubernetes API token. Use the cluster’s enforced NetworkPolicies to restrict clients and access to the Collector’s port 4317 before broader use.</p>
<h2>8. Follow a deliberate HTTP 500 across all three signals</h2>
<p>Start with the response seen by the client, then check metrics, the request-start log and the matching server span.</p>
<h3>Generate bounded traffic</h3>
<p>Keep this port-forward running in a separate terminal:</p>
<pre><code class="language-shell">kubectl --context "$KUBE_CONTEXT" -n demo port-forward service/podinfo 9898:9898
</code></pre>
<p>It binds locally by default. In another terminal, generate successful and failing requests for roughly a minute, allowing several scrapes:</p>
<pre><code class="language-shell">for i in $(seq 1 30); do
  curl --fail --silent --show-error http://localhost:9898/status/200
  curl --silent --show-error --output /dev/null --write-out 'HTTP %{http_code}\n'     http://localhost:9898/status/500
  sleep 2
done
curl --fail --silent --show-error http://localhost:9898/delay/1
curl --fail --silent --show-error http://localhost:9898/metrics
</code></pre>
<p>Expect <code>HTTP 500</code> from the deliberately failing endpoint. That curl command omits <code>--fail</code> intentionally. <code>/delay/1</code> gives a separate slow request without introducing another service.</p>
<h3>Find the metric signal</h3>
<p>Select the intended Prometheus datasource in Grafana and a time range covering the requests. Run these queries separately: scrape health, missing scrape samples, request rate by response status and the fraction of status-route requests returning 5xx:</p>
<pre><code class="language-promql">up{job="podinfo"}
absent_over_time(up{job="podinfo"}[5m])
sum by (status) (rate(http_request_duration_seconds_count{job="podinfo",path="status"}[5m]))
(
  sum(rate(http_request_duration_seconds_count{job="podinfo",path="status",status=~"5.."}[5m]))
  / sum(rate(http_request_duration_seconds_count{job="podinfo",path="status"}[5m]))
)
and (sum(rate(http_request_duration_seconds_count{job="podinfo",path="status"}[5m])) &gt; 0)
</code></pre>
<p>If the workspace contains multiple clusters, add the intended <code>cluster</code> label to every selector after checking its actual value. Do not combine identical <code>job="podinfo"</code> series from unrelated clusters.</p>
<p>Podinfo's <code>http_requests_total</code> has only <code>status</code> as an application label. The <code>http_request_duration_seconds</code> histogram also has <code>method</code> and <code>path</code>; the named status route is <code>path="status"</code>, not <code>/status/500</code>. Its <code>_count</code> series lets us exclude probes and scrape requests from the exercise's error fraction. <a href="https://raw.githubusercontent.com/stefanprodan/podinfo/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/metrics.go">[23]</a></p>
<p><code>up=1</code> indicates a successful scrape; the response-status rate queries show application errors. A missing <code>up</code> calls for checking the native agent, accepted configuration and workspace destination. <code>up=0</code> calls for checking the target and reachability. The rate queries need several samples; the denominator guard suppresses the error fraction when the request rate is zero.</p>
<h3>Find the request-start event in Log Analytics</h3>
<p>Open <strong>Logs</strong> for the Container insights Log Analytics workspace, select the correct cluster/resource scope and run:</p>
<pre><code class="language-kusto">ContainerLogV2
| where TimeGenerated &gt; ago(30m)
| where PodNamespace == "demo" and ContainerName == "podinfo"
| extend event = parse_json(tostring(LogMessage))
| where tostring(event.msg) == "request started"
| where tostring(event.uri) == "/status/500"
| project TimeGenerated, PodName,
          method = tostring(event.method),
          uri = tostring(event.uri), trace_id = tostring(event.trace_id)
| order by TimeGenerated desc
| take 20
</code></pre>
<p>If more than one cluster writes this namespace/container name to the workspace, also filter <code>_ResourceId</code> to the intended AKS resource ID. <code>ContainerLogV2</code> provides the Kubernetes fields; <code>LogMessage</code> contains the application's event. <code>parse_json(tostring(LogMessage))</code> gives us a consistent way to read its JSON fields. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/containerlogv2">[24]</a></p>
<p>Copy one nonempty <code>trace_id</code>. These debug events describe <strong>request start</strong>, not response completion: they do not contain status or duration. Podinfo's logger can sample repeated events under load, so this is not an exhaustive access audit. <a href="https://raw.githubusercontent.com/stefanprodan/podinfo/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/logging.go">[25]</a></p>
<p>If the query is empty, first inspect the application's own logs:</p>
<pre><code class="language-shell">kubectl --context "$KUBE_CONTEXT" -n demo logs deployment/podinfo --tail=100
</code></pre>
<p>Then check <code>--level=debug</code>, tracing enablement, stderr exclusions, the DCR stream/destination and any transformations.</p>
<h3>Look up the same trace ID in the Azure span store</h3>
<p>Open <strong>Logs</strong> for the new Log Analytics workspace: this example sends container logs and traces to the same workspace. Replace the placeholder with the unchanged 32-hex trace ID from your own event:</p>
<pre><code class="language-kusto">let wanted_trace = "&lt;32-hex-trace-id-from-the-request-log&gt;";
OTelSpans
| where TimeGenerated &gt; ago(30m)
| where TraceId == wanted_trace
| project TimeGenerated, TraceId, SpanId, ParentSpanId, Name, Kind,
          ServiceName, StatusCode, ResultCode,
          http_status = tostring(Attributes["http.response.status_code"]),
          DurationMs
| order by TimeGenerated asc
</code></pre>
<p>Native OTLP spans are stored in <strong><code>OTelSpans</code></strong>, with <code>TraceId</code>, <code>SpanId</code>, <code>ParentSpanId</code>, <code>Kind</code>, <code>StatusCode</code> and <code>Attributes</code>. Query <code>TraceId</code> using the unchanged value from Podinfo’s request-start event. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/otelspans">[26]</a></p>
<p>For this pinned Podinfo version, the server span is named <code>GET /status/{code:[0-9]+}</code>. Inspect its HTTP result and error status; its child <code>statusHandler</code> span shares the trace ID but need not be marked as an error. A deliberate 500 does not require an exception event. The relevant server attribute is <code>http.response.status_code=500</code>.</p>
<p>The trace DCR associates these spans with the new Application Insights resource. Microsoft documents <strong>Search</strong> and <strong>Transaction details</strong> for OpenTelemetry investigation; inspect a trace sample there when that experience is available for your resource. The explicit lookup for this exercise remains the <code>OTelSpans</code> query above, and the portal experience has not been tested here. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/collect-use-observability-data">[3]</a> · <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/app/failures-performance-transactions">[30]</a></p>
<p>Do not expect complete Application Insights Performance/Failures dashboards or its prebuilt OTLP metric queries from this setup. Microsoft says those experiences expect <strong>delta OTLP metrics with exponential histograms</strong>. This Collector sends only traces; Podinfo’s Prometheus histogram stays on the native metrics path and is queried in Grafana. We do not add a duplicate metrics pipeline just to populate a dashboard. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/opentelemetry-protocol-ingestion">[2]</a></p>
<p>If no span appears, keep the same trace ID and check the trace destination, time window, Collector export errors, HTTP/protobuf endpoint and Entra authorization. Allow ingestion time and inspect an actual <code>OTelSpans</code> record before relying on a saved query or dashboard.</p>
<h2>9. What should we keep, and what should we remove?</h2>
<p>Keep the investigation path and resource boundaries. Remove only the example workload, scrape job and lab interfaces when finished; retain shared AKS monitoring and stored data according to the existing retention policy.</p>
<p>The single-replica Collector uses finite in-memory queues and retries; queued spans are lost if its process restarts. Its ClusterIP gRPC receiver is unauthenticated: any allowed client can send data that the Collector then authenticates to Azure. Restrict the receiver with enforced network policy and review TLS/client authentication for wider use.</p>
<p>Budget separately for managed Prometheus ingestion/storage/queries, Log Analytics ingestion/retention/scans, native OTLP data, and Grafana CE's AKS CPU/memory plus any persistent storage you later enable. Grafana CE carries no managed-Grafana service fee; include its operational maintenance in the budget. Review the new workspace’s 30-day retention and table plans before extending the lab. Debug logging is useful for the exercise but should not become an unreviewed cluster-wide collection policy.</p>
<p>Stop both local port-forwards, then delete only Podinfo's Deployment and Service:</p>
<pre><code class="language-shell">kubectl --context "$KUBE_CONTEXT" -n demo delete deployment/podinfo service/podinfo
</code></pre>
<p>Remove only the <code>podinfo</code> scrape job, preserving every unrelated job. To remove Collector and Grafana while retaining the Azure backends, remove their two Helm release blocks from <code>observability/</code> and review/apply that change. Do not destroy the whole configuration. After Grafana is gone, delete <code>grafana-admin</code> only if it was created exclusively for this exercise and is unused. Leave shared Secrets and namespaces in place; delete <code>demo</code> only if it contains no other resources and is no longer needed.</p>
<p>For an unused Secret created exclusively for this example:</p>
<pre><code class="language-shell">kubectl --context "$KUBE_CONTEXT" -n observability delete secret grafana-admin
</code></pre>
<p>To retire the monitoring backends too, first remove dependent workloads and Helm releases. Disable only the dedicated monitoring add-on blocks in the existing AKS configuration and apply that change. Then review removal of the associations and remaining resources in <code>observability/</code>. Check shared consumers and retention/export requirements: deleting workspaces deletes stored telemetry. Keep OIDC/Workload Identity if other workloads use them; never destroy the AKS configuration or a shared resource group as tutorial cleanup.</p>
<h2>Frequently asked questions</h2>
<h3>Why use Azure's native metrics and log agents instead of one Collector for everything?</h3>
<p>They fit the requested managed Azure paths and avoid another independently operated log collector. Keeping the OpenTelemetry Collector focused on traces makes scrape ownership and troubleshooting explicit. An all-Collector architecture is another valid design, but it changes onboarding, identity and operational responsibilities.</p>
<h3>Does enabling Container insights also give me managed Prometheus?</h3>
<p>They are separate collection paths and destinations, even when the onboarding interface enables them together. Container logs go to Log Analytics; managed Prometheus samples go to an Azure Monitor workspace. Verify both add-ons, rules, associations and destinations.</p>
<h3>Why does the log not say HTTP 500?</h3>
<p>Podinfo emits a debug event when the request starts. It supplies the trace ID, URI and method, not the final response status. Use the client's response and matching server span to establish the outcome.</p>
<h3>Can I keep the tooling and replace Podinfo with my own service?</h3>
<p>Yes. Replace its scrape target, instrumentation and queries with your application's actual telemetry contract. Preserve one scrape owner, explicit log-to-trace correlation and scoped identities. Recheck discovery before scaling beyond this example's single Service target.</p>
<h2>Sources</h2>
<p>[1] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/kubernetes-monitoring-enable">Azure monitoring setup</a></p>
<p>[2] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/opentelemetry-protocol-ingestion">Native OTLP ingestion</a></p>
<p>[3] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/collect-use-observability-data">Preview scope and limitations</a></p>
<p>[4] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/kubernetes-open-protocol">AKS-specific OTLP onboarding</a></p>
<p>[5] <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-azurerm/v5.12.0/website/docs/r/kubernetes_cluster.html.markdown">Pinned AKS provider schema</a></p>
<p>[6] <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-azurerm/v5.12.0/website/docs/r/monitor_data_collection_rule.html.markdown">DCR schema</a></p>
<p>[7] <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-azurerm/v5.12.0/website/docs/r/monitor_data_collection_rule_association.html.markdown">Association schema</a></p>
<p>[8] <a href="https://learn.microsoft.com/en-us/azure/aks/managed-identity-overview">AKS identities</a></p>
<p>[9] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-authentication">Container insights authentication</a></p>
<p>[10] <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-azurerm/v5.12.0/website/docs/r/federated_identity_credential.html.markdown">Pinned federation resource</a></p>
<p>[11] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/metrics/prometheus-grafana">Grafana authentication and roles</a></p>
<p>[12] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/prometheus-metrics-scrape-configmap">Custom scrape configuration</a></p>
<p>[13] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-transformations">DCR transformations</a></p>
<p>[14] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-data-collection-filter">Container log filtering</a></p>
<p>[15] <a href="https://learn.microsoft.com/en-us/azure/aks/workload-identity-deploy-cluster">Workload identity deployment</a></p>
<p>[16] <a href="https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector-contrib/v0.162.0/extension/azureauthextension/README.md">Pinned Azure authentication extension</a></p>
<p>[17] <a href="https://github.com/grafana/azure-prometheus-datasource/blob/v1.0.10/docs/sources/configure.md">Pinned plugin configuration</a></p>
<p>[18] <a href="https://grafana.com/grafana/plugins/grafana-azureprometheus-datasource/">Plugin compatibility</a></p>
<p>[19] <a href="https://github.com/grafana-community/helm-charts/blob/grafana-14.0.1/charts/grafana/templates/_pod.tpl">Pinned chart template</a></p>
<p>[20] <a href="https://github.com/grafana/grafana/blob/v13.2.4/conf/defaults.ini">Grafana 13.2.4 settings</a></p>
<p>[21] <a href="https://github.com/grafana/grafana-azure-sdk-go/blob/v2.4.1/aztokenprovider/retriever_workloadidentity.go">Pinned workload credential implementation</a></p>
<p>[22] <a href="https://raw.githubusercontent.com/stefanprodan/podinfo/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/tracer.go">Podinfo tracer</a></p>
<p>[23] <a href="https://raw.githubusercontent.com/stefanprodan/podinfo/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/metrics.go">Pinned metrics implementation</a></p>
<p>[24] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/containerlogv2">ContainerLogV2 schema</a></p>
<p>[25] <a href="https://raw.githubusercontent.com/stefanprodan/podinfo/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/logging.go">Logging middleware</a></p>
<p>[26] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/otelspans">OTelSpans table reference</a></p>
<p>[27] <a href="https://github.com/microsoft/AzureMonitorCommunity/blob/67ecd88b374a71e4b5701d81e7ef5f53cdf71dc9/Azure%20Services/Azure%20Monitor/OpenTelemetry/OTLP_DCE_DCR_ARM_Template.txt">Microsoft native OTLP manual-orchestration template, pinned revision</a></p>
<p>[28] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/containers/opentelemetry-options">OpenTelemetry options and path-specific availability status</a></p>
<p>[29] <a href="https://learn.microsoft.com/en-us/azure/templates/microsoft.insights/2024-03-11/datacollectionrules">Native OTLP DCR ARM fields</a></p>
<p>[30] <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/app/failures-performance-transactions">Application Insights transaction investigation</a></p>
<p>[31] <a href="https://raw.githubusercontent.com/Azure/prometheus-collector/main/AddonTerraformTemplate/main.tf">Microsoft native Prometheus Terraform onboarding</a></p>
<p>[32] <a href="https://raw.githubusercontent.com/microsoft/Docker-Provider/ci_prod/scripts/onboarding/aks/onboarding-msi-terraform/main.tf">Microsoft Container insights Terraform onboarding</a></p>
]]></content:encoded></item><item><title><![CDATA[Cloud Native: A Practical Introduction for Engineers]]></title><description><![CDATA[A story-led introduction to cloud native for engineers: its history, the six building blocks, how they fit, and how to run your first container.]]></description><link>https://blog.turingts.com/cloud-native-a-practical-introduction-for-engineers</link><guid isPermaLink="true">https://blog.turingts.com/cloud-native-a-practical-introduction-for-engineers</guid><category><![CDATA[cloud native]]></category><category><![CDATA[Kubernetes]]></category><category><![CDATA[containers]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Platform Engineering ]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[Cloud Computing]]></category><category><![CDATA[Microservices]]></category><category><![CDATA[gitops]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Tue, 03 Nov 2026 10:57:28 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/e99efd0f-efa9-4eb0-8618-f88c70092208.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Cloud native grew from the need to isolate applications, reproduce their environments and operate them across machines. This introduction traces that history, explains how containers, runtimes, Kubernetes, GitOps and observability fit together, and walks through building, running and scaling a small application on a local Kubernetes cluster.</p>
<p>Before teams could request machines through an API, they had to work with the hardware and operating systems available to them. Sharing a server raised questions about isolation and capacity. Giving each application its own virtual machine improved separation, but left teams managing operating systems and reproducing application environments. Containers addressed another part of that work; managing them across machines created a further problem to solve.<a href="https://kubernetes.io/docs/concepts/overview/">[2]</a></p>
<p>Cloud native grew out of these overlapping developments rather than one invention. To understand it, we will follow three threads: isolating work, renting capacity and scheduling applications. Along the way, a fictional online store and its orders API will show why each change matters.</p>
<h2>Where did cloud native come from?</h2>
<p>Cloud native draws on several developments: isolating workloads, obtaining infrastructure programmatically and managing applications across machines. These threads overlap; they are not a sequence every organisation followed or proof that Kubernetes is the right destination for every application.<a href="https://kubernetes.io/docs/concepts/overview/">[2]</a><a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a></p>
<h3>Isolating work on one machine</h3>
<p>Sharing hardware raises a basic problem: how much should one application be able to see or consume? Unix Version 7, released in 1979, included <code>chroot</code>, which changes the root used for pathname lookup. That narrowed filesystem view was not a complete security sandbox, nor a way to package an application for another machine.<a href="https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/man/man2/chdir.2">[3]</a><a href="https://en.wikipedia.org/wiki/Seventh_Edition_Unix">[4]</a><a href="https://man7.org/linux/man-pages/man2/chroot.2.html">[5]</a></p>
<p>FreeBSD 4.0 introduced jails in March 2000, extending the mechanisms available for separated execution environments. Solaris 10 included Zones in 2005, allowing isolated environments within an operating-system instance. These developments addressed sharing a host without requiring a complete virtual machine for every workload. They were related ideas, not interchangeable implementations.<a href="https://www.freebsd.org/releases/">[6]</a><a href="https://www.freebsd.org/releases/4.0R/notes/">[7]</a><a href="https://docs.oracle.com/cd/E19461-01/819-2328/6n4khb8hi/">[8]</a></p>
<p>Linux acquired its own mechanisms incrementally. Mount namespaces were present in Linux 2.4.19 in 2002.<a href="https://cdn.kernel.org/pub/linux/kernel/v2.4/">[61]</a> Linux 2.6.24, released in January 2008, added control groups, PID namespaces and basic network namespaces. Namespaces separate selected resource views; control groups, usually shortened to cgroups, organise processes for resource accounting and control. They answer different questions: what can a process see, and what resources may its group use?<a href="https://man7.org/linux/man-pages/man7/mount_namespaces.7.html">[9]</a><a href="https://kernelnewbies.org/Linux_2_6_24">[10]</a><a href="https://man7.org/linux/man-pages/man7/cgroups.7.html">[11]</a></p>
<p>Linux Containers, or LXC, brought several kernel mechanisms together; its first release was in August 2008. Crucially, these containers share the host kernel rather than each booting an independent one. Isolation still depends on the mechanisms and configuration involved.<a href="https://stgraber.org/category/lxc/">[12]</a><a href="https://linuxcontainers.org/lxc/introduction/">[13]</a></p>
<p>Isolation alone did not solve the store's deployment problem. Imagine its orders API working on an engineer's laptop, then failing on the test server: a different Python version, an incompatible library or a missing operating-system package. Fixing that server could make the tests pass, only for production to reveal another difference. “It works on my machine” described a real gap: the team had moved the code, but had not reproduced the environment it depended on.<a href="https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-a-container/">[32]</a></p>
<p>Without a repeatable way to package that environment, a release could become a handover of installation instructions, scripts and undocumented fixes. Engineers had to determine whether a failure came from the application or the machine. Updating a shared dependency for one application could break another. Rolling back the code did not necessarily undo changes made to the server. Adding a replacement machine meant recreating those assumptions yet again.</p>
<p>Automation and standardised VM images could reduce this work. The attraction of application containers was a more portable unit: package the application and its user-space dependencies together, test that package, then move the same artifact between compatible environments instead of reconstructing it at each deployment.</p>
<p>Docker was publicly demonstrated by Solomon Hykes at PyCon on 15 March 2013. It helped popularise the workflow of building, sharing and running packaged applications; it did not invent process isolation. For our store, the useful change is that the application and its user-space dependencies can travel together. Host kernel and CPU compatibility, configuration and external services still matter.<a href="https://www.docker.com/blog/docker-nine-years-young/">[14]</a><a href="https://docs.docker.com/build/building/multi-platform/">[15]</a></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/90178a26-b2fe-4942-81b2-fdcd38bb3fe3.jpg" alt="Solomon Hykes presenting on stage beside a DockerCon 2017 podium." /></p>
<p><em>Docker founder Solomon Hykes presenting at DockerCon 2017. Photo: Docker, via <a href="https://www.cnbc.com/2018/03/28/docker-founder-solomon-hykes-is-leaving-the-software-start-up.html">CNBC</a>.</em></p>
<h3>Renting machines by the hour</h3>
<p>Packaging software does not supply hardware. The second thread concerned how teams obtained capacity. Amazon announced the limited beta of Elastic Compute Cloud, or EC2, on 25 August 2006, offering virtual machines with hourly charging. That made renting machine capacity a practical alternative to owning every server, without making capacity planning disappear.<a href="https://aws.amazon.com/blogs/aws/amazon_ec2_beta/">[16]</a></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/65de4aed-8f13-410a-88c6-109fc74e74d1.jpg" alt="Gloved hands holding a rack-mount server in front of server racks and cabling inside an AWS data center." /></p>
<p><em>Server hardware inside an AWS data center. Photo: © Noah Berger, 2023 / <a href="https://amazongca.getbynder.com/web/B022CC90-A9C5-4523-834EB09E3ED141E1?viewType=grid&amp;mediaId=0B663EC4-9249-4CEB-8268CC5B1927ED94">AWS press kit</a>.</em></p>
<p>Replaceable infrastructure creates an application-design question: what must survive when a particular machine goes away? Heroku introduced the Twelve-Factor App methodology in 2011, documenting practices for service applications, including declarative setup and reducing differences between development and production. The lesson for the store is to make its environment reproducible, rather than relying on an administrator's knowledge of one host.<a href="https://12factor.net/blog/evolving-twelve-factor">[17]</a><a href="https://12factor.net">[18]</a></p>
<p>The “pets versus cattle” analogy captures the intended change in attitude, although its history is less tidy than a single invention date. In Randy Bias's retrospective, he encountered Bill Baker's scale-up/scale-out analogy in “2011 or 2012” and adapted it to cloud infrastructure and disposability. It is a metaphor for replacing instances, not permission to neglect the data or people depending on them.<a href="https://cloudscaling.com/blog/cloud-computing/the-history-of-pets-vs-cattle/">[19]</a></p>
<p>For the fictional store, replacing an API process should not mean replacing its order history. Separating disposable execution from persistent data makes the proposed design possible, but database availability and recovery remain separate engineering work.</p>
<h3>Scheduling work across many machines</h3>
<p>Once applications can be reproduced and machines replaced, somebody must still decide where each workload runs. Google's Borg system addressed cluster management at substantial scale; its EuroSys 2015 paper describes experience accumulated before the paper appeared. Kubernetes drew on that experience without simply publishing Borg under another name.<a href="https://research.google/pubs/large-scale-cluster-management-at-google-with-borg/">[20]</a><a href="https://kubernetes.io/blog/2024/06/06/10-years-of-kubernetes/">[21]</a></p>
<p>Kubernetes's first public-repository commit was on 6 June 2014; its public announcement followed on 10 June. Version 1.0 and the founding of the Cloud Native Computing Foundation, or CNCF, followed on 21 July 2015. Separately, the Open Container Initiative, or OCI, formed on 22 June 2015 to develop open container standards—not to declare every specification finished that day.<a href="https://kubernetes.io/blog/2024/06/06/10-years-of-kubernetes/">[21]</a><a href="https://www.cncf.io/news/announcement/2015/07/new-cloud-native-computing-foundation-drive-alignment-among-container">[22]</a><a href="https://opencontainers.org/about/overview/">[23]</a></p>
<p><a class="embed-card" href="https://youtu.be/RBAQyqgFl4w?si=HmlXCSpMWXvL1wYM">https://youtu.be/RBAQyqgFl4w?si=HmlXCSpMWXvL1wYM</a></p>

<p><em>What is the Open Container Initiative? — Canonical Ubuntu.</em></p>
<p>Kubernetes became CNCF's first graduated project on 6 March 2018. Amazon EKS and Azure Kubernetes Service reached general availability that June. These milestones widened the available operating models; they did not settle every team's architecture choice.<a href="https://www.cncf.io/announcements/2018/03/06/cloud-native-computing-foundation-announces-kubernetes-first-graduated-project/">[24]</a><a href="https://aws.amazon.com/blogs/aws/amazon-eks-now-generally-available/">[25]</a><a href="https://azure.microsoft.com/en-us/blog/azure-kubernetes-service-aks-ga-new-regions-new-features-new-productivity/">[26]</a></p>
<p>The vocabulary also evolved. CNCF's Technical Oversight Committee approved version 1.0 of its cloud-native definition in June 2018 and version 1.1 in February 2024. OpenTelemetry emerged from OpenTracing and OpenCensus in 2019 and graduated within CNCF in 2026. Kubernetes 1.37, “Garhwal”, was released on 26 August 2026. These are different kinds of milestone: shared definitions, telemetry standards and software releases.<a href="https://raw.githubusercontent.com/cncf/toc/1b3bc9302b4ff440caf9b8f22ed070723cdfb4c9/DEFINITION.md">[27]</a><a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a><a href="https://www.cncf.io/blog/2019/05/21/a-brief-history-of-opentelemetry-so-far/">[28]</a><a href="https://www.cncf.io/projects/opentelemetry/">[29]</a><a href="https://kubernetes.io/blog/2026/08/26/kubernetes-v1-37-release/">[30]</a></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/c61c2ef2-f1d9-48d7-a685-98dddd9a91f9.png" alt="A single left-to-right timeline shows chroot in 1979, EC2 beta in 2006, cgroups in 2008, the twelve-factor app in 2011, Docker in 2013, Kubernetes in 2014, CNCF graduation in 2018 and Kubernetes v1.37 in 2026. Milestones alternate above and below the axis." /></p>
<p><em>Figure 1 — Selected milestones in cloud-native history, shown chronologically from left to right. Isolation and packaging, rented capacity and scheduling developed along different paths. Spacing is schematic, not proportional to elapsed time; this is not an inevitable progression. chroot changes pathname roots and is not a complete security sandbox.</em></p>
<p>In CNCF's 2025 survey, 82% of responding container users reported production Kubernetes use, compared with 66% in the 2023 survey. The relevant 2025 question had 351 respondents after filtering and excluding uncertain answers. This is evidence of adoption within that surveyed population, not a census of all organisations or the same companies tracked over time.<a href="https://www.cncf.io/wp-content/uploads/2026/01/CNCF_Annual_Survey_Report_final.pdf">[31]</a></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/efaf0129-7c73-4472-9fff-a36a78738a1a.jpg" alt="A speaker presents on a large stage in front of a packed audience at KubeCon + CloudNativeCon Europe 2025 in London." /></p>
<p><em>A presentation at KubeCon + CloudNativeCon Europe 2025 in London, illustrating the growth of the cloud-native community. Photo: <a href="https://www.flickr.com/photos/143247548@N03/54435630091/">CNCF</a>, <a href="https://creativecommons.org/licenses/by-nc/2.0/">CC BY-NC 2.0</a>.</em></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/93444536-c896-4f7c-b025-1ff5d023001f.png" alt="Four columns compare bare metal, virtual machines, containers and orchestrated containers. Stacked blocks distinguish OS and hardware, hypervisors and guest operating systems, container runtimes, and containers distributed across machines." /></p>
<p><em>Figure 2 — Coexisting deployment models, not a universal progression: bare metal runs applications on an OS; VMs add guest operating systems; containers package dependencies while sharing a host kernel; orchestration places them across machines. Startup times and sizes depend on workload and platform.</em><a href="https://kubernetes.io/docs/concepts/overview/">[2]</a></p>
<p>The history explains why these capabilities exist. It leaves a more useful question than which product won: what should their combination allow a team to do?</p>
<p>Imagine a fictional online store in 2006. A customer uses its website to submit an order; an orders API handles the request and stores the result. The API and database share a server. Before a busy period, the team must arrange additional capacity, reproduce the application environment and decide what happens if that machine fails.</p>
<p>Now imagine a possible design for the same store in 2026. Replaceable API replicas run across machines, traffic enters through a gateway and the database lives separately. Routine releases use a defined delivery path rather than edits on individual hosts. This changes where the work happens; it does not remove infrastructure, data ownership or operational responsibility.</p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/282ba254-374f-43f0-adf1-c762cbb331c5.png" alt="A 2006 website feeds an orders API and database on one server. In a conceptual 2026 design, a website and Gateway feed three orders API replicas on separate machines, with a managed database." /></p>
<p><em>Figure 3 — Fictional store designs: one server holds the orders API and database; replicas occupy three machines with a separate managed database. This is conceptual, not the lab or a migration prescription; capacity timings are not claimed.</em></p>
<p><strong>Cloud native is a set of practices for changing and operating software repeatably, not a particular hosting location.</strong><a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a> We will trace the problems those practices address, connect six useful building blocks and follow a deliberately small workload into a local cluster. This is an introduction, not a production Kubernetes tutorial. What do these developments mean for the way we build and operate software?</p>
<h2>What does “cloud native” actually mean?</h2>
<p>Cloud native means organising development and operation around repeatable, programmatic changes and interoperating systems. It is not synonymous with renting a cloud server. CNCF's definition explicitly covers public, private and hybrid environments, and its technology list is non-exhaustive.<a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a></p>
<p>The first paragraph of CNCF's version 1.1 definition, approved on 26 February 2024, reads:<a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a></p>
<blockquote>
<p>Cloud native practices empower organizations to develop, build, and deploy workloads in computing environments (public, private, hybrid cloud) to meet their organizational needs at scale in a programmatic and repeatable manner. It <strong>is characterized by loosely coupled systems that interoperate in a manner that is secure, resilient, manageable, sustainable, and observable.</strong></p>
</blockquote>
<p>The phrase “programmatic and repeatable” means the store's next release should not depend on reconstructing an undocumented sequence. “Loosely coupled” means components can interact without every change forcing coordinated replacement of the entire system. Resilience and observability concern what happens when reality differs from expectations: can the service recover, and can its owners understand the failure?</p>
<p>The adjacent Benefits section describes frequent, predictable changes with “minimal toil and clear separation of concerns”. That is an intended benefit of practices combined with automation, not a guarantee delivered by installing a cluster.<a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a></p>
<p>The comparison below describes operating habits, not a boundary between old and new hardware. VMs can be automated and declarative; Kubernetes can run stateful workloads. Moving a monolith onto a cloud VM, by itself, tells us little about how it is built, released or operated.<a href="https://kubernetes.io/docs/concepts/overview/">[2]</a><a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a></p>
<table>
<thead>
<tr>
<th>Concern</th>
<th>Host-centred manual approach</th>
<th>Cloud-native-oriented practice</th>
</tr>
</thead>
<tbody><tr>
<td>Deployment unit</td>
<td>Files and dependencies installed on a named host</td>
<td>Versioned, digest-identified workload artifact</td>
</tr>
<tr>
<td>Capacity</td>
<td>Arrange and configure individual machines</td>
<td>Request capacity through an automated interface</td>
</tr>
<tr>
<td>Scaling</td>
<td>Repeat host setup and configuration</td>
<td>Adjust a declared workload requirement</td>
</tr>
<tr>
<td>Failure handling</td>
<td>Investigate and repair the individual instance</td>
<td>Replace disposable instances; recover persistent state separately</td>
</tr>
<tr>
<td>Configuration</td>
<td>Settings accumulate on hosts</td>
<td>Review and version declarations</td>
</tr>
<tr>
<td>Release cadence</td>
<td>Coordinate bespoke deployment steps</td>
<td>Automate a repeatable delivery path</td>
</tr>
<tr>
<td>State</td>
<td>Persistence may be mixed with application execution</td>
<td>Identify data ownership and lifecycle explicitly</td>
</tr>
</tbody></table>
<p>For the store, the test is practical: can another engineer reproduce the service, change it safely and investigate its behaviour? A hosting label cannot answer those questions. The building blocks matter because they make parts of that work explicit.</p>
<h2>What are the building blocks?</h2>
<p>We will use six concerns to organise the design: packaging, orchestration, networking, declarative configuration, observability and delivery automation. This is a teaching model, not an official CNCF checklist. Security, identity and persistent data cut across it and still need deliberate design.<a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/20c21493-dd98-4563-b23a-1a1b321b92b8.png" alt="Three runtime-oriented concerns form a stack beneath the orders API: containers and images, orchestration and service networking. Beside them are declarative configuration and GitOps, observability and delivery automation. The hosting context can be public, private or hybrid." /></p>
<p><em>Figure 4 — Six concerns, not compulsory products or a four-layer taxonomy. Images, orchestration and networking support the API; declarative configuration/GitOps, observability and delivery automation span the stack. Public, private and hybrid are hosting contexts, not a seventh block.</em></p>
<h3>Containers and images</h3>
<p>The store needs a reliable answer to “what exactly are we running?” A <strong>container image</strong> packages application files and dependencies; a runtime starts containers from it. A <strong>registry</strong> stores and distributes images. Containers share a host kernel, so a packaged environment is not a complete independent machine.<a href="https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-a-container/">[32]</a><a href="https://docs.docker.com/build/building/multi-platform/">[15]</a></p>
<p>The runtime is the software that actually manages containers on a machine. <strong>containerd</strong> pulls and stores images, starts and stops containers, and supervises their execution. Docker is not a competing name for the same layer: Docker Engine uses containerd underneath its developer-facing tools. On Linux, containerd commonly delegates the low-level work of creating a container process to <strong>runc</strong>, an implementation of the Open Container Initiative (OCI) runtime specification.<a href="https://containerd.io/">[62]</a><a href="https://docs.docker.com/engine/daemon/alternative-runtimes/">[63]</a></p>
<p>An image <strong>digest</strong> identifies immutable content. A tag is a movable reference, even when its name resembles a Git commit. For repeatable releases, record the digest or explicitly enforce a registry policy rather than assuming a meaningful tag cannot change.<a href="https://kubernetes.io/docs/concepts/containers/images/">[33]</a></p>
<p>The cost is maintaining the packaged software: freezing an artifact makes it identifiable, not permanently safe. In our proposed delivery process, dependency updates must lead to a rebuilt, checked artifact rather than manual repairs inside running containers.</p>
<h3>Orchestration</h3>
<p>A container image does not decide which machine should run it or replace a missing instance. Kubernetes manages workloads across a <strong>cluster</strong> of <strong>nodes</strong>. A <strong>Pod</strong> is its workload execution unit; our example puts one application container in each Pod. A <strong>Deployment</strong> manages ReplicaSets, which maintain the requested number of Pods.<a href="https://kubernetes.io/docs/concepts/architecture/">[34]</a><a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/">[35]</a><a href="https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/">[36]</a></p>
<p>This is <strong>reconciliation</strong>: controllers compare desired state with observed state and act on the difference. The scheduler assigns an unscheduled Pod to a node; that node's kubelet asks a runtime such as containerd or CRI-O to run it through the <strong>Container Runtime Interface (CRI)</strong>. The API server exposes cluster state, with etcd storing the API data. These are cooperating components, not one omniscient scheduler.<a href="https://kubernetes.io/docs/concepts/architecture/">[34]</a><a href="https://kubernetes.io/docs/concepts/architecture/controller/">[37]</a></p>
<p>Kubernetes does not need Docker Engine on the node. An image built with Docker can run through containerd, provided it matches the node's operating system and CPU architecture. Docker is the build tool used in our exercise; containerd is a runtime that can execute the resulting image.<a href="https://kubernetes.io/docs/setup/production-environment/container-runtimes/">[64]</a><a href="https://docs.docker.com/build/building/multi-platform/">[15]</a></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/e6e315b6-0083-47c9-942b-c5cdc66fa64a.jpg" alt="Audience members seen from behind watch a presenter and a Kubernetes architecture slide on the CloudNativeCon and KubeCon stage." />
<em>A Kubernetes presentation at CloudNativeCon + KubeCon, Seattle, 8 November 2016. Photo: <a href="https://www.flickr.com/photos/143247548@N03/30769669832/">Stan Olszewski / SOSKIphoto, via CNCF</a>, <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>; cropped.</em></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/d32c52de-d4c5-44ea-a361-fd4e58d0d7cc.png" alt="A Deployment asking for three replicas enters the API server and etcd. The Deployment controller manages a ReplicaSet whose controller creates a Pod. The scheduler assigns a node, then kubelet and runtime run its containers. Pod status and a deleted Pod feed back through the API server." /></p>
<p><em>Figure 5 — One workload lifecycle: the Deployment controller manages ReplicaSets, whose controller creates Pod objects; the scheduler assigns a node; kubelet and runtime start containers. Deletion triggers reconciliation, not immediate readiness. etcd stores cluster data, not only desired state. Solid arrows summarise dependencies, not direct RPCs; watches, writes and status updates use the API server.</em><a href="https://kubernetes.io/docs/concepts/architecture/">[34]</a><a href="https://kubernetes.io/docs/concepts/architecture/controller/">[37]</a><a href="https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/">[36]</a></p>
<p>A container process restart and a replacement Pod are different events. Deleting a controller-owned Pod creates a shortfall for its ReplicaSet to address; replacement does not mean the old Pod is resurrected. Available capacity, image access and application health still determine whether the new workload becomes ready. The cost is operating this control system, directly or through a managed service.<a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/">[35]</a><a href="https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/">[36]</a><a href="https://docs.aws.amazon.com/eks/latest/userguide/shared-responsibility.html">[38]</a></p>
<h3>Service networking</h3>
<p>Replaceable Pods create a new problem: callers cannot rely on their individual addresses. A Kubernetes <strong>Service</strong> represents a set of backends; cluster Domain Name System, or DNS, gives callers names to resolve. DNS answers a lookup—it is not another proxy through which every application request travels.<a href="https://kubernetes.io/docs/concepts/services-networking/service/">[39]</a><a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/">[40]</a></p>
<p>For the broader store architecture, an edge gateway can route incoming traffic towards the service. Gateway API describes configuration that needs an implementation; a basic local cluster does not automatically provide a public gateway. Extra routing layers also mean more places to investigate a failed request.<a href="https://kubernetes.io/docs/concepts/services-networking/gateway/">[41]</a></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/8ce4da47-635e-4e21-865f-177de7d11862.png" alt="A client uses a separate DNS lookup, then sends a request through a Gateway implementation and the orders Service to orders API replicas and an external database. A dashed telemetry path leads from explicitly instrumented replicas through a Collector to metrics, logs and traces backends. This is conceptual, not the lab." /></p>
<p><em>Figure 6 — Public DNS is a separate lookup, not an HTTP hop. A configured Gateway routes through the Service abstraction or directly to its endpoints. Explicitly instrumented applications export signals through a configured Collector to storage/query backends; Kubernetes does not install this application instrumentation, Collector or storage/query backend by default. The database is external.</em><a href="https://kubernetes.io/docs/concepts/services-networking/service/">[39]</a><a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/">[40]</a><a href="https://kubernetes.io/docs/concepts/services-networking/gateway/">[41]</a><a href="https://opentelemetry.io/docs/what-is-opentelemetry/">[42]</a></p>
<h3>Declarative configuration and GitOps</h3>
<p>Even a replaceable service can drift if its intended configuration lives only in someone's terminal history. A <strong>manifest</strong> declares resources and their desired properties. Helm packages related Kubernetes resources as charts; it does not by itself continuously reconcile a cluster.<a href="https://helm.sh/docs/topics/charts/">[43]</a></p>
<p><strong>GitOps</strong> puts versioned, declarative desired state in Git and connects reviewed changes to the running environment. The principles are not tied to a particular product. Two implementation options differ mainly in who initiates deployment and when the desired and actual states are compared.</p>
<ul>
<li><strong>Push-based GitOps:</strong> a Git change triggers a deployment pipeline. For example, Terraform can plan and apply Kubernetes manifests: during planning it reads the managed resources by default and determines the changes needed. Once the run finishes, another trigger, scheduled run or separate drift-checking process is needed for the next comparison. The pipeline uses a deployment identity with access to the target cluster; that identity can be temporary.<a href="https://developer.hashicorp.com/terraform/cli/commands/plan">[65]</a></li>
<li><strong>Pull-based GitOps:</strong> an agent retrieves the desired configuration and repeatedly compares it with the target environment. The agent holds or obtains the permissions needed to apply changes; the delivery pipeline can update Git without deploying directly to the cluster. Argo CD and Flux are examples, not prerequisites. Automatic synchronisation, deletion and self-healing depend on the implementation and its settings.<a href="https://argo-cd.readthedocs.io/en/stable/user-guide/auto_sync/">[45]</a><a href="https://fluxcd.io/flux/">[46]</a></li>
</ul>
<p>In both arrangements, Kubernetes controllers continue maintaining the resources already declared in the cluster. The distinction is the <strong>Git-to-cluster reconciliation loop</strong>, not whether Kubernetes replaces failed Pods. Push and pull describe different deployment arrangements, not a ranking of good and bad practice.<a href="https://kubernetes.io/docs/concepts/architecture/controller/">[37]</a></p>
<p>OpenGitOps uses a stricter definition that explicitly requires automatic pulling and continuous reconciliation. Here, the push/pull comparison makes the implementation choices explicit rather than making any one tool a requirement.<a href="https://opengitops.dev">[44]</a></p>
<p>For the store, a reviewed configuration change can say which image and replica count should run. The cost is treating that repository as an operational interface, including deciding who can change it and how emergency intervention is reconciled afterwards.</p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/d65729da-e9e0-4083-9805-08414aeb8032.png" alt="Side-by-side push-based and pull-based GitOps. A deployment pipeline checks and applies desired state during triggered runs; a reconciliation agent fetches desired state and repeatedly compares it with the cluster. Kubernetes controllers operate continuously in both cases." /></p>
<p><em>Figure 7 — Two representative GitOps deployment arrangements: a triggered pipeline versus an ongoing reconciliation agent. Both use versioned desired state and observe actual state. Agent placement and permissions vary by implementation; Kubernetes controllers remain active in both.</em></p>
<p>Argo CD and Flux are two implementations of pull-based GitOps. Argo CD organises delivery around applications, with a web UI and CLI for management and status. Flux provides composable Kubernetes controllers for retrieving configuration and reconciling resources and Helm releases. Both compare desired configuration with the cluster; their settings determine how changes are applied. They are options, not requirements for GitOps.<a href="https://argo-cd.readthedocs.io/en/stable/operator-manual/architecture/">[66]</a><a href="https://fluxcd.io/flux/">[46]</a></p>
<p>Figure 8 shows how such a reconciler fits into the wider flow: CI publishes an image, a reviewed configuration change enters Git, and the reconciler updates the cluster.</p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/313ab570-d330-4c18-9add-6ed663c10a8b.png" alt="Code review triggers CI and image publication. A separate reviewed digest change enters Git desired state, which Argo CD or Flux reconciles into cluster workloads. The cluster pulls its image by digest from a separate registry. Instrumented telemetry and developer feedback close the loop." /></p>
<p><em>Figure 8 — CI tests, builds and publishes an image; a reviewed digest change enters Git desired state. Argo CD or Flux reconciles it; the runtime separately pulls the image. Instrumented telemetry informs changes. Commit-SHA tags are not immutable; sync, recovery and emergency access require policy.</em><a href="https://opengitops.dev">[44]</a><a href="https://argo-cd.readthedocs.io/en/stable/user-guide/auto_sync/">[45]</a></p>
<h3>Observability</h3>
<p>A running Pod does not tell the store whether customers are receiving useful responses. <strong>Metrics</strong> describe measurements over time, <strong>logs</strong> record events and <strong>traces</strong> follow requests through components. These complementary signals help answer different questions, but applications and collection paths must actually produce them.<a href="https://opentelemetry.io/docs/concepts/signals/">[47]</a></p>
<p>OpenTelemetry supports instrumentation, collection and export; it is not the database or dashboard where every signal is stored and explored. Prometheus collects and stores time-series metrics. Figure 6 separates these roles rather than drawing “observability” as something Kubernetes automatically supplies.<a href="https://opentelemetry.io/docs/what-is-opentelemetry/">[42]</a><a href="https://prometheus.io/docs/introduction/overview/">[48]</a></p>
<p>The cost includes instrumentation work, storage decisions and controlling how much telemetry is produced. Our tiny sample supplies no metrics exporter or tracing stack. The separate <a href="https://blog.turingts.com/observability-on-amazon-eks-metrics-logs-and-traces">Observability on Amazon EKS article</a> explores those integrations in more detail without making them prerequisites for this exercise.</p>
<h3>Delivery automation</h3>
<p>Finally, the store needs a repeatable route from a reviewed source change to a running version. In the proposed workflow, CI tests the code, builds an image, publishes it to a registry and proposes the image digest in desired-state configuration. A reconciler can then apply the accepted change. Kubernetes itself does not build application source code.<a href="https://kubernetes.io/docs/concepts/overview/">[2]</a><a href="https://opengitops.dev">[44]</a></p>
<p>This separates the artifact from the decision to deploy it. The cost is maintaining the delivery path and its permissions as carefully as the application. The <a href="https://blog.turingts.com/github-actions-an-introduction-to-workflows-and-reusable-workflows">GitHub Actions introduction</a> covers workflows and reuse; here, delivery automation is the connection between the other concerns, not another installed lab component.</p>
<table>
<thead>
<tr>
<th>Block</th>
<th>Pain addressed</th>
<th>Representative tools or resources</th>
<th>Continuing cost</th>
</tr>
</thead>
<tbody><tr>
<td>Images and runtime</td>
<td>Environment differs between machines</td>
<td>OCI formats, container runtimes</td>
<td>Artifact maintenance and compatibility</td>
</tr>
<tr>
<td>Orchestration</td>
<td>Workloads need placement and replacement</td>
<td>Kubernetes Deployments and ReplicaSets</td>
<td>Capacity and control-plane ownership</td>
</tr>
<tr>
<td>Service networking</td>
<td>Replica addresses change</td>
<td>Kubernetes Service, DNS, Gateway API</td>
<td>Routing and implementation choices</td>
</tr>
<tr>
<td>Declarative configuration</td>
<td>Intended state becomes unclear</td>
<td>Helm, Argo CD, Flux</td>
<td>Review and reconciliation policy</td>
</tr>
<tr>
<td>Observability</td>
<td>Running does not mean understood</td>
<td>OpenTelemetry, Prometheus</td>
<td>Instrumentation and data volume</td>
</tr>
<tr>
<td>Delivery automation</td>
<td>Releases repeat manual work</td>
<td>CI workflows and a GitOps reconciler</td>
<td>Pipeline maintenance and access</td>
</tr>
</tbody></table>
<p>These entries deliberately mix standards, Kubernetes resources and tools; they are not all separate CNCF projects. The table summarises the roles above rather than prescribing a product for every layer. Enough architecture: which part can we make visible with a small experiment?</p>
<h2>How do you run your first workload?</h2>
<p>Build an application image, run it in a local Kubernetes cluster, then scale it and observe how Kubernetes replaces a deleted Pod. You will use Docker, kind and kubectl on a disposable workstation or VM; no cloud account is needed. kind runs Kubernetes nodes in containers.<a href="https://kind.sigs.k8s.io/docs/user/quick-start/">[51]</a></p>
<p>Use Bash with Docker's daemon running and kind and kubectl installed. Work in a new directory and keep the same terminal and directory throughout. Run the blocks in order, stopping if any command fails. The lab uses a dedicated <code>.intro-kubeconfig</code> file and the explicit <code>kind-intro</code> context, rather than your usual cluster configuration. Reserve the kind name <code>intro</code> for this session: it must not already exist or be created by another session while you work.</p>
<p>The example repository also contains the full automated script. Here, you will run the exercise in seven steps.</p>
<p><a class="embed-card" href="https://github.com/ferhaty/cloud-native-intro">https://github.com/ferhaty/cloud-native-intro</a></p>

<h3>1. Build the application image</h3>
<p>Create <code>app.py</code> and <code>Dockerfile</code> in your working directory. The application returns an empty orders list, its hostname in <code>served_by</code> and a version; <code>/healthz</code> returns <code>ok</code>. It accepts no order submissions and connects to no database. Python's <code>http.server</code> is not intended as a production server.<a href="https://docs.python.org/3/library/http.server.html">[52]</a></p>
<p><strong><code>app.py</code></strong></p>
<pre><code class="language-python">from http.server import BaseHTTPRequestHandler, HTTPServer
import json, os, socket

class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        if self.path == "/healthz":
            body, content_type = b"ok", "text/plain; charset=utf-8"
        else:
            body = json.dumps({
                "orders": [],
                "served_by": socket.gethostname(),
                "version": os.getenv("APP_VERSION", "dev"),
            }).encode()
            content_type = "application/json"
        self.send_response(200)
        self.send_header("Content-Type", content_type)
        self.end_headers()
        self.wfile.write(body)

if __name__ == "__main__":
    HTTPServer(("", 8080), Handler).serve_forever()
</code></pre>
<p><strong><code>Dockerfile</code></strong></p>
<pre><code class="language-dockerfile">FROM python:3.13-slim@sha256:ae14d4ce8771606477a81446e7ef429edd6762305fc50c84507c1041fa8285d1
WORKDIR /app
COPY app.py .
ENV APP_VERSION=1.0.0
EXPOSE 8080
USER 1000
CMD ["python", "app.py"]
</code></pre>
<p>The Dockerfile packages Python and the application, sets its version and defines the startup command. Build that image with:</p>
<pre><code class="language-shell">docker build -t orders-api:1.0.0 .
</code></pre>
<p>This creates the local image <code>orders-api:1.0.0</code>; you do not need Python installed on the host.</p>
<h3>2. Create the local cluster and load the image</h3>
<p>This check refuses an existing <code>intro</code> cluster or kubeconfig file and does not create anything if cluster discovery fails. Only successful creation marks the cluster as belonging to this session.</p>
<pre><code class="language-shell">export KIND_EXPERIMENTAL_PROVIDER=docker
intro_created=false
if ! clusters=$(kind get clusters); then
  printf '%s\n' 'Cannot discover kind clusters; stop here.' &gt;&amp;2
  false
elif printf '%s\n' "$clusters" | grep -Fxq intro; then
  printf '%s\n' 'The intro cluster already exists; stop here.' &gt;&amp;2
  false
elif [[ -e "$PWD/.intro-kubeconfig" || -L "$PWD/.intro-kubeconfig" ]]; then
  printf '%s\n' '.intro-kubeconfig already exists; stop here.' &gt;&amp;2
  false
else
  kind create cluster --name intro --wait 120s \
    --kubeconfig "$PWD/.intro-kubeconfig" \
    --image kindest/node:v1.37.0@sha256:a1ed56cfb0e7b93589bdf97c8cd566405a265939e3620fc4f5de89adff580ae5 &amp;&amp;
  intro_created=true &amp;&amp;
  kind load docker-image orders-api:1.0.0 --name intro
fi
</code></pre>
<p>After success, Kubernetes is running locally and its node has your application image. If creation fails, stop and inspect what remains; do not delete a cluster whose ownership you have not established.</p>
<h3>3. Deploy the workload</h3>
<p>Save <code>orders.yaml</code> beside the application files. The Deployment requests one replica. The Service selects Pods labelled <code>app: orders</code> and routes port 80 to the application's port 8080. The readiness probe checks <code>/healthz</code> before a Pod receives Service traffic.<a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/">[35]</a><a href="https://kubernetes.io/docs/concepts/services-networking/service/">[39]</a></p>
<p><strong><code>orders.yaml</code></strong></p>
<pre><code class="language-yaml">apiVersion: apps/v1
kind: Deployment
metadata:
  name: orders
spec:
  replicas: 1
  selector:
    matchLabels: { app: orders }
  template:
    metadata:
      labels: { app: orders }
    spec:
      containers:
        - name: orders
          image: orders-api:1.0.0
          ports: [{ containerPort: 8080 }]
          readinessProbe:
            httpGet: { path: /healthz, port: 8080 }
          resources:
            requests: { cpu: 50m, memory: 64Mi }
            limits: { memory: 128Mi }
---
apiVersion: v1
kind: Service
metadata:
  name: orders
spec:
  selector: { app: orders }
  ports: [{ port: 80, targetPort: 8080 }]
</code></pre>
<p>The non-<code>latest</code> image tag defaults to <code>IfNotPresent</code>, so Kubernetes can use the image loaded into kind.<a href="https://kubernetes.io/docs/concepts/containers/images/">[33]</a></p>
<pre><code class="language-shell">kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro apply -f orders.yaml &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro rollout status deployment/orders --timeout=120s &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro get pods -l app=orders
</code></pre>
<p>The rollout wait allows time for the application to start. After it succeeds, the listing should show one ready orders Pod.</p>
<h3>4. Send a request</h3>
<p>Start a small client Pod, wait for it to become ready, then use it to call the Service from inside the cluster.</p>
<pre><code class="language-shell">kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro run client --restart=Never \
  --image=curlimages/curl:8.16.0@sha256:463eaf6072688fe96ac64fa623fe73e1dbe25d8ad6c34404a669ad3ce1f104b6 --command -- sleep 3600 &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro wait --for=condition=Ready pod/client --timeout=120s &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro exec client -- curl -fsS --max-time 5 http://orders/
</code></pre>
<p>The JSON response should contain <code>orders: []</code>, version <code>1.0.0</code> and the serving Pod's hostname. Using the in-cluster Service name exercises Service routing rather than forwarding directly to one Pod.</p>
<h3>5. Scale to three replicas</h3>
<p>Change the desired replica count, wait for the rollout and send several separate requests through the same Service.</p>
<pre><code class="language-shell">kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro scale deployment orders --replicas=3 &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro rollout status deployment/orders --timeout=120s &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro get pods -l app=orders &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro exec client -- sh -ec 'for i in $(seq 10); do curl -fsS --max-time 5 http://orders/; echo; done'
</code></pre>
<p>You should now see three ready orders Pods. Compare their names with the responses' <code>served_by</code> values: requests may reach different replicas, but a short sample need not visit every Pod or alternate between them.<a href="https://kubernetes.io/docs/concepts/services-networking/service/">[39]</a></p>
<h3>6. Delete one Pod and observe its replacement</h3>
<p>Capture one orders Pod's name and delete only that Pod. Then wait for the Deployment to recover and list its Pods again.</p>
<pre><code class="language-shell">pod=$(kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro get pods -l app=orders -o jsonpath='{.items[0].metadata.name}') &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro delete pod "$pod" --wait=true --timeout=120s &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro wait --for=condition=Ready pod -l app=orders --timeout=120s &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro rollout status deployment/orders --timeout=120s &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro get pods -l app=orders &amp;&amp;
kubectl --kubeconfig "$PWD/.intro-kubeconfig" --context kind-intro exec client -- curl -fsS --max-time 5 http://orders/
</code></pre>
<p>Compare the names with step 5: the deleted Pod should be gone and a new one should bring the count back to three. The ReplicaSet creates the replacement because the desired count has not changed. Replacement takes time; a successful request afterwards does not prove uninterrupted availability. Reapplying <code>orders.yaml</code> would restore its declared count of one.<a href="https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/">[36]</a><a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/">[35]</a></p>
<p>This demonstrates reconciliation, not recovery from a failed host: all three replicas share one local node. A healthy endpoint also says nothing about correct business rules or recovery of persistent data.</p>
<h3>7. Clean up explicitly</h3>
<p>When finished, remove only the cluster successfully created in step 2. Run this in the same terminal and directory; the session flag prevents deletion when creation was refused or failed. Nothing is removed automatically when you close the terminal.</p>
<pre><code class="language-shell">if [[ "${intro_created:-false}" == true ]]; then
  kind delete cluster --name intro --kubeconfig "$PWD/.intro-kubeconfig" &amp;&amp;
  rm -f "$PWD/.intro-kubeconfig" &amp;&amp;
  intro_created=false
else
  printf '%s\n' 'No successfully created cluster recorded in this session; nothing deleted.'
fi
</code></pre>
<p>This removes the local cluster, including its workload and client Pod, then removes the dedicated kubeconfig. Your source files and locally built image remain. If deletion fails, the kubeconfig and session flag remain available for a retry; inspect any remaining resources before proceeding.</p>
<h2>Where should you go next?</h2>
<p>Use the lab's replacement behaviour as a starting point, then examine one real service's delivery and recovery path. Identify what is reproducible, what depends on a particular machine and who owns failures. That reveals the next useful improvement more clearly than copying a complete reference architecture.</p>
<p>The <a href="https://blog.turingts.com/platform-engineering-a-practical-introduction">Platform Engineering introduction</a> discusses making supported paths easier for teams to use. The <a href="https://blog.turingts.com/site-reliability-engineering-a-practical-introduction-for-engineers">Site Reliability Engineering introduction</a> examines reliability and operational work. Alongside the observability and delivery articles linked earlier, these provide different perspectives on the same problem: changing software while keeping its behaviour understandable.</p>
<p>For infrastructure delivery, <a href="https://blog.turingts.com/deploying-terraform-to-aws-with-github-actions-and-oidc">Deploying Terraform to AWS with GitHub Actions and OIDC</a> explains a separate pipeline; it is not part of this lab.<a href="https://blog.turingts.com/deploying-terraform-to-aws-with-github-actions-and-oidc">[58]</a> The <a href="https://glossary.cncf.io">CNCF glossary</a> offers a shared vocabulary, while the <a href="https://landscape.cncf.io">CNCF landscape</a> is a directory to explore.<a href="https://glossary.cncf.io">[59]</a><a href="https://landscape.cncf.io">[60]</a></p>
<p>There is more to explore beneath each building block, from workload lifecycle to persistent data and safer releases. Future articles can follow those connections without assuming every reader needs the same platform. The durable mental model is the relationship between a declared intention, the mechanisms that realise it and the evidence that it is working.</p>
<h2>Frequently asked questions</h2>
<h3>Is cloud native the same as Kubernetes?</h3>
<p>No. Kubernetes supplies workload-management capabilities; cloud native describes broader practices for developing and operating systems. A cluster can support those practices without automatically providing good delivery, observability or ownership. The CNCF definition does not make Kubernetes mandatory.<a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a><a href="https://kubernetes.io/docs/concepts/overview/">[2]</a></p>
<h3>Do I need microservices to be cloud native?</h3>
<p>No. CNCF lists microservices among a non-exhaustive combination of technologies and architectures, not as an entry requirement. A monolith can benefit from reproducible packaging, declarative deployment and observability. Splitting it into services should address an actual design need, not satisfy a label.<a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a></p>
<h3>Can I be cloud native on-premises?</h3>
<p>Yes. CNCF's definition explicitly includes private and hybrid environments alongside public cloud. The relevant question is how workloads are built, changed and operated, not whose building contains the hardware. On-premises operation still needs infrastructure ownership, just as rented infrastructure retains responsibilities.<a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a><a href="https://docs.aws.amazon.com/eks/latest/userguide/shared-responsibility.html">[38]</a></p>
<h2>Sources</h2>
<p><a href="https://raw.githubusercontent.com/cncf/toc/main/DEFINITION.md">[1]</a> CNCF Cloud Native Definition v1.1 #</p>
<p><a href="https://kubernetes.io/docs/concepts/overview/">[2]</a> Overview | Kubernetes</p>
<p><a href="https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/man/man2/chdir.2">[3]</a> UNIX Seventh Edition manual: chdir, chroot(2) — TUHS source archive</p>
<p><a href="https://en.wikipedia.org/wiki/Seventh_Edition_Unix">[4]</a> Version 7 Unix - Wikipedia</p>
<p><a href="https://man7.org/linux/man-pages/man2/chroot.2.html">[5]</a> chroot(2) - Linux manual page</p>
<p><a href="https://www.freebsd.org/releases/">[6]</a> Release Information | The FreeBSD Project</p>
<p><a href="https://www.freebsd.org/releases/4.0R/notes/">[7]</a> FreeBSD 4.0 Release Notes | The FreeBSD Project</p>
<p><a href="https://docs.oracle.com/cd/E19461-01/819-2328/6n4khb8hi/">[8]</a> Solaris 10 Zones (Sun Java Enterprise System 2005Q4 Installation Guide for UNIX)</p>
<p><a href="https://man7.org/linux/man-pages/man7/mount_namespaces.7.html">[9]</a> mount_namespaces(7) - Linux manual page</p>
<p><a href="https://kernelnewbies.org/Linux_2_6_24">[10]</a> Linux_2_6_24 - Linux Kernel Newbies</p>
<p><a href="https://man7.org/linux/man-pages/man7/cgroups.7.html">[11]</a> cgroups(7) - Linux manual page</p>
<p><a href="https://stgraber.org/category/lxc/">[12]</a> LXC | Stéphane Graber's website</p>
<p><a href="https://linuxcontainers.org/lxc/introduction/">[13]</a> Linux Containers - LXC - Introduction</p>
<p><a href="https://www.docker.com/blog/docker-nine-years-young/">[14]</a> Docker: Nine Years YOUNG | Docker</p>
<p><a href="https://docs.docker.com/build/building/multi-platform/">[15]</a> Multi-platform builds | Docker Docs</p>
<p><a href="https://aws.amazon.com/blogs/aws/amazon_ec2_beta/">[16]</a> Amazon EC2 Beta | AWS News Blog</p>
<p><a href="https://12factor.net/blog/evolving-twelve-factor">[17]</a> The Twelve-Factor App</p>
<p><a href="https://12factor.net">[18]</a> The Twelve-Factor App</p>
<p><a href="https://cloudscaling.com/blog/cloud-computing/the-history-of-pets-vs-cattle/">[19]</a> The History of Pets vs Cattle and How to Use the Analogy Properly | Cloudscaling</p>
<p><a href="https://research.google/pubs/large-scale-cluster-management-at-google-with-borg/">[20]</a> Large-scale cluster management at Google with Borg</p>
<p><a href="https://kubernetes.io/blog/2024/06/06/10-years-of-kubernetes/">[21]</a> 10 Years of Kubernetes | Kubernetes</p>
<p><a href="https://www.cncf.io/news/announcement/2015/07/new-cloud-native-computing-foundation-drive-alignment-among-container">[22]</a> New Cloud Native Computing Foundation to drive alignment among container technologies | CNCF</p>
<p><a href="https://opencontainers.org/about/overview/">[23]</a> About the Open Container Initiative - Open Container Initiative</p>
<p><a href="https://www.cncf.io/announcements/2018/03/06/cloud-native-computing-foundation-announces-kubernetes-first-graduated-project/">[24]</a> Cloud Native Computing Foundation announces Kubernetes® as first graduated project | CNCF</p>
<p><a href="https://aws.amazon.com/blogs/aws/amazon-eks-now-generally-available/">[25]</a> Amazon EKS – Now Generally Available | AWS News Blog</p>
<p><a href="https://azure.microsoft.com/en-us/blog/azure-kubernetes-service-aks-ga-new-regions-new-features-new-productivity/">[26]</a> Azure Kubernetes Service (AKS) GA – New regions, more features, increased productivity | Microsoft Azure Blog</p>
<p><a href="https://raw.githubusercontent.com/cncf/toc/1b3bc9302b4ff440caf9b8f22ed070723cdfb4c9/DEFINITION.md">[27]</a> CNCF Cloud Native Definition v1.0 #</p>
<p><a href="https://www.cncf.io/blog/2019/05/21/a-brief-history-of-opentelemetry-so-far/">[28]</a> A brief history of OpenTelemetry (So Far) | CNCF</p>
<p><a href="https://www.cncf.io/projects/opentelemetry/">[29]</a> OpenTelemetry | CNCF</p>
<p><a href="https://kubernetes.io/blog/2026/08/26/kubernetes-v1-37-release/">[30]</a> Kubernetes v1.37: Garhwal | Kubernetes</p>
<p><a href="https://www.cncf.io/wp-content/uploads/2026/01/CNCF_Annual_Survey_Report_final.pdf">[31]</a> CNCF Annual Cloud Native Survey: The Infrastructure of AI’s Future (January 2026)</p>
<p><a href="https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-a-container/">[32]</a> What is a container? | Docker Docs</p>
<p><a href="https://kubernetes.io/docs/concepts/containers/images/">[33]</a> Images | Kubernetes</p>
<p><a href="https://kubernetes.io/docs/concepts/architecture/">[34]</a> Cluster Architecture | Kubernetes</p>
<p><a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/">[35]</a> Deployments | Kubernetes</p>
<p><a href="https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/">[36]</a> ReplicaSet | Kubernetes</p>
<p><a href="https://kubernetes.io/docs/concepts/architecture/controller/">[37]</a> Controllers | Kubernetes</p>
<p><a href="https://docs.aws.amazon.com/eks/latest/userguide/shared-responsibility.html">[38]</a> Security in Amazon EKS - Amazon EKS</p>
<p><a href="https://kubernetes.io/docs/concepts/services-networking/service/">[39]</a> Service | Kubernetes</p>
<p><a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/">[40]</a> DNS for Services and Pods | Kubernetes</p>
<p><a href="https://kubernetes.io/docs/concepts/services-networking/gateway/">[41]</a> Gateway API | Kubernetes</p>
<p><a href="https://opentelemetry.io/docs/what-is-opentelemetry/">[42]</a> What is OpenTelemetry? | OpenTelemetry</p>
<p><a href="https://helm.sh/docs/topics/charts/">[43]</a> Charts | Helm</p>
<p><a href="https://opengitops.dev">[44]</a> Home | OpenGitOps</p>
<p><a href="https://argo-cd.readthedocs.io/en/stable/user-guide/auto_sync/">[45]</a> Automated Sync Policy - Argo CD - Declarative GitOps CD for Kubernetes</p>
<p><a href="https://fluxcd.io/flux/">[46]</a> Flux Documentation | Flux</p>
<p><a href="https://opentelemetry.io/docs/concepts/signals/">[47]</a> Signals | OpenTelemetry</p>
<p><a href="https://prometheus.io/docs/introduction/overview/">[48]</a> Overview | Prometheus</p>
<p><a href="https://blog.turingts.com/observability-on-amazon-eks-metrics-logs-and-traces">[49]</a> Observability on EKS: Metrics, Logs and Traces</p>
<p><a href="https://blog.turingts.com/github-actions-an-introduction-to-workflows-and-reusable-workflows">[50]</a> GitHub Actions Workflows and Reusable Workflows</p>
<p><a href="https://kind.sigs.k8s.io/docs/user/quick-start/">[51]</a> kind – Quick Start</p>
<p><a href="https://docs.python.org/3/library/http.server.html">[52]</a> http.server — HTTP servers — Python 3.15.2 documentation</p>
<p><a href="https://blog.turingts.com/platform-engineering-a-practical-introduction">[56]</a> Platform Engineering: A Practical Introduction</p>
<p><a href="https://blog.turingts.com/site-reliability-engineering-a-practical-introduction-for-engineers">[57]</a> Site Reliability Engineering: A Practical Introduction
<a href="https://blog.turingts.com/deploying-terraform-to-aws-with-github-actions-and-oidc">[58]</a> Deploying Terraform to AWS with GitHub Actions and OIDC</p>
<p><a href="https://glossary.cncf.io">[59]</a> Cloud Native Glossary</p>
<p><a href="https://landscape.cncf.io">[60]</a> CNCF Landscape — directory, not evidence for project totals</p>
<p><a href="https://cdn.kernel.org/pub/linux/kernel/v2.4/">[61]</a> Linux kernel 2.4 release archive — Linux 2.4.19, August 2002</p>
<p><a href="https://containerd.io/">[62]</a> containerd — container lifecycle and OCI support</p>
<p><a href="https://docs.docker.com/engine/daemon/alternative-runtimes/">[63]</a> Alternative container runtimes | Docker Docs</p>
<p><a href="https://kubernetes.io/docs/setup/production-environment/container-runtimes/">[64]</a> Container Runtimes | Kubernetes</p>
<p><a href="https://developer.hashicorp.com/terraform/cli/commands/plan">[65]</a> Terraform plan command | HashiCorp Developer</p>
<p><a href="https://argo-cd.readthedocs.io/en/stable/operator-manual/architecture/">[66]</a> Architectural Overview | Argo CD</p>
]]></content:encoded></item><item><title><![CDATA[Getting Started with GitHub Copilot and Copilot CLI.]]></title><description><![CDATA[Explore how GitHub Copilot evolved from code suggestions to coding agents, then get started with Copilot CLI using a tiny browser todo app.]]></description><link>https://blog.turingts.com/getting-started-with-github-copilot-and-copilot-cli</link><guid isPermaLink="true">https://blog.turingts.com/getting-started-with-github-copilot-and-copilot-cli</guid><category><![CDATA[Testing]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[github copilot]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Mon, 02 Nov 2026 11:15:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/10b8f6af-82a6-43ae-8d3e-2bc436c4f264.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>GitHub Copilot began as a way to suggest code while a developer typed. It has since grown into an assistant that can explain code and work through coding tasks. This introduction follows that development, then uses Copilot CLI and a tiny todo app to make the ideas practical.</p>
<h2>Where did GitHub Copilot come from?</h2>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/6f2a9377-81de-4edf-b43f-368141ac9000.png" alt="GitHub Copilot in VS Code with the project explorer, code editor and chat pane" style="display:block;margin:0 auto" />

<p><em>Copilot alongside project files and code in VS Code. Microsoft documentation example (</em><a href="https://github.com/microsoft/vscode-docs/blob/main/docs/agents/images/getting-started/explorer-and-chat-view.png"><em>source</em></a><em>;</em> <a href="https://creativecommons.org/licenses/by/3.0/us/"><em>CC BY 3.0 US</em></a><em>).</em></p>
<p>GitHub introduced Copilot as a technical preview on June 29, 2021. It was developed with OpenAI and powered by OpenAI Codex. The first announcement described an “AI pair programmer” that used the surrounding code as context to suggest whole lines or functions. <a href="https://github.blog/news-insights/product-news/introducing-github-copilot-ai-pair-programmer/">[1]</a></p>
<p>The problem was familiar: even a small feature can involve repetitive code, unfamiliar APIs and time spent searching for examples. Copilot brought suggestions into the editor, close to the code already being written. It did not decide what the application should do; the developer still chose which suggestions to accept.</p>
<p>Copilot became generally available to individual developers on June 21, 2022. Its suggestions could include methods, boilerplate and unit tests, rather than only a single word or line. The practical aim was to spend less effort on routine implementation and more on the problem being solved. <a href="https://github.blog/news-insights/product-news/github-copilot-is-generally-available-to-all-developers/">[2]</a></p>
<h2>How did completions become chat and coding agents?</h2>
<p>Completions help when you know what you want to write next. They are less suited to questions such as “What does this file do?” or “Why is this test failing?” A conversation gives the developer room to ask, clarify and follow up.</p>
<p>In March 2023, GitHub announced its Copilot X vision, including chat in the editor. GitHub described chat that would explain code, help generate tests and propose bug fixes. This was an expansion of the interaction, not just a longer autocomplete suggestion. <a href="https://github.blog/news-insights/product-news/github-copilot-x-the-ai-powered-developer-experience/">[3]</a></p>
<p>The next step was to let an agent work through several actions. GitHub announced agent mode in preview for VS Code in February 2025, including the ability to iterate on changes, respond to errors and suggest terminal commands. In May 2025, it introduced a coding agent in public preview that could take an assigned issue, work in a cloud development environment and return a pull request for review. <a href="https://github.blog/news-insights/product-news/github-copilot-the-agent-awakens/">[4]</a> <a href="https://github.blog/changelog/2025-05-19-github-copilot-coding-agent-in-public-preview/">[5]</a></p>
<p>The distinction is useful: a completion suggests code; chat helps you discuss it; an agent can use tools to work towards a goal. These are complementary ways of working, not a reason to stop reviewing the result.</p>
<h2>What can Copilot help with today?</h2>
<p>Copilot can help you understand a codebase, write or refactor code, investigate bugs, prepare tests and review changes. The available features depend on the client, plan and organization policies. <a href="https://docs.github.com/en/copilot/get-started/about-github-copilot">[6]</a></p>
<p>You can meet that assistance in several places:</p>
<ul>
<li><strong>In your editor:</strong> keep suggestions and explanations beside the code you are working on.</li>
<li><strong>In Copilot CLI:</strong> ask questions and request changes from the terminal, using an interactive conversation. <a href="https://docs.github.com/en/copilot/concepts/copilot-surfaces/copilot-cli">[7]</a></li>
<li><strong>In the GitHub Copilot app:</strong> connect a local folder or repository, work in an agent session and inspect changes in a visual interface. <a href="https://docs.github.com/en/copilot/get-started/quickstart-copilot-app">[8]</a></li>
<li><strong>On GitHub:</strong> use repository and pull-request workflows to delegate and review work. <a href="https://docs.github.com/en/copilot/get-started/about-github-copilot">[6]</a></li>
</ul>
<p>Copilot CLI can discuss a change, but it can also work on project files and run tools. Read the proposed actions as well as the conversation. We will use this interactive CLI workflow for the small exercise below. <a href="https://docs.github.com/en/copilot/concepts/copilot-surfaces/copilot-cli">[7]</a></p>
<h2>How do you get started with Copilot CLI?</h2>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/7a31c500-ca6b-4980-8083-8583cf7d7ce7.png" alt="GitHub Copilot CLI inspecting a project in a macOS terminal" style="display:block;margin:0 auto" />

<p><em>Copilot CLI inspecting a project in a macOS terminal. Still from</em> <a href="https://github.blog/ai-and-ml/github-copilot/github-copilot-cli-how-to-get-started/"><em>GitHub’s demonstration by Andrea Griffiths</em></a><em>, October 2025.</em></p>
<p>You need GitHub Copilot access that permits CLI use. If access comes through an organization, its administrator can disable the CLI. On Windows, GitHub lists PowerShell 6 or later as a prerequisite. Node.js 22 or later is required only for the npm installation method below—not for every installation method or for opening our browser app. <a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli">[9]</a></p>
<h3>Install the CLI</h3>
<p>Choose <strong>one</strong> installation method for your platform; you do not need to run all three.</p>
<p><strong>Windows — WinGet</strong></p>
<p>Run in PowerShell:</p>
<pre><code class="language-powershell">winget install GitHub.Copilot
</code></pre>
<p><strong>macOS and Linux — Homebrew</strong></p>
<p>If you use Homebrew, run:</p>
<pre><code class="language-shell">brew install --cask copilot-cli
</code></pre>
<p><strong>Windows, macOS and Linux — npm</strong></p>
<p>If you already use Node.js 22 or later, run:</p>
<pre><code class="language-shell">npm install -g @github/copilot
</code></pre>
<p>GitHub also provides an install script for macOS and Linux, and standalone executables. See the official installation guide for those alternatives. <a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli">[9]</a></p>
<h3>Open a small working folder</h3>
<p>Create an empty folder for the exercise, then start an interactive session inside it:</p>
<pre><code class="language-shell">mkdir my-copilot-todo
cd my-copilot-todo
copilot
</code></pre>
<p>Confirm the folder-trust prompt only for a location you trust. If prompted to sign in, enter <code>/login</code> inside Copilot and follow its instructions. You can then ask a question or request a change in ordinary language. Read permission requests before approving commands. <a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/overview">[10]</a></p>
<h3>Choose an AI model</h3>
<p>The AI model is what Copilot uses to interpret your request and generate its response. Inside an interactive Copilot CLI session, enter:</p>
<pre><code class="language-text">/model
</code></pre>
<p>Choose a model from the available list. You can use <code>/model</code> again to switch during the same session. Available choices depend on your access and organization settings. Models differ in speed, capability and usage cost; for this small exercise, start with the current selection rather than searching for a universally best model. <a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/cli-best-practices">[12]</a> For a broader introduction to AI models and how they power agents, see <a href="https://blog.turingts.com/agentic-ai-a-deep-dive">Agentic AI: A Deep Dive</a>.</p>
<h3>Start with a clear request</h3>
<p>Describe the result you want and the limits that matter. “Build an app” leaves many decisions open. “Build a three-file todo app that opens directly in a browser” gives Copilot a much smaller target.</p>
<h2>Build a tiny todo app</h2>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/22cb3b54-bbff-438a-a80b-a559cd26f5c6.png" alt="Tiny todo reference app with task entry, completed and open tasks, delete buttons and an Open tasks filter" style="display:block;margin:0 auto" />

<p><em>The todo app with task entry, completion and delete controls, and an Open tasks filter.</em></p>
<p>The complete example code and prompts are available in <a href="https://github.com/ferhaty/copilot-todo-demo">ferhaty/copilot-todo-demo</a>. Download the repository and open <code>index.html</code> to try the finished app, including the filter, or follow the exercise below to build your own version.</p>
<p>Our application does only three things to begin with: add a task, mark it complete or incomplete, and delete it. A small follow-up adds a filter for unfinished tasks. It uses plain HTML, CSS and JavaScript, with no framework, backend, database or build process. Refreshing the page clears the tasks.</p>
<p>This follows the small, incremental teaching approach of GitHub’s Copilot CLI course. That course builds a Node.js command-line calculator, adds features and tests, and finishes with pull-request review. Here, we use a browser todo app and keep the work local. <a href="https://github.com/skills/create-applications-with-the-copilot-cli">[11]</a></p>
<h3>Create the first version</h3>
<p>Give Copilot this prompt:</p>
<pre><code class="language-text">Create a tiny browser todo app using index.html, style.css and app.js.
Let me add a task, mark it complete or incomplete, and delete it.
Use plain HTML, CSS and JavaScript. No framework, backend,
database, dependencies or build step. Opening index.html directly
must work: use a classic script, not modules, imports or fetch.
Keep tasks in memory; refreshing clears them. Reject blank or
whitespace-only tasks. Render task text with textContent, not innerHTML.
Use labelled controls and make it usable on desktop and mobile.
Explain the files and how to check the result.
Do not publish, deploy or create a remote repository.
</code></pre>
<p>Read the proposed changes and approve only the commands needed for this task. If Copilot starts adding a framework or server, ask it to keep to the three-file version.</p>
<p>Once the files exist, open <code>index.html</code> directly in your browser. The intended result needs no <code>npm install</code>, development server or build command. If yours requires one, ask Copilot to return to the three-file brief. Add two tasks, tick one, untick it and delete the other. Try submitting an empty or whitespace-only task as well.</p>
<h3>Add one follow-up feature</h3>
<p>After checking the first version, ask for a single change:</p>
<pre><code class="language-text">Add an Open tasks filter beside All.
All shows every task; Open tasks hides completed tasks.
Switching filters must not delete or reset tasks.
Keep adding, completing and deleting working in either view.
Show a clear message when no open tasks remain.
Keep the same three files and add no dependencies or other features.
</code></pre>
<p>Complete one task and select <strong>Open tasks</strong>: it should disappear from that view, but return when you select <strong>All</strong>. Add and delete a task with the filter active. This small extension teaches the useful loop: describe one change, inspect it and check the behavior again.</p>
<h3>Let Autopilot work through a task</h3>
<p>In standard Interactive mode, you guide the conversation with follow-up prompts. Autopilot lets Copilot continue through multiple steps without waiting for a new instruction after each one—for example, making the filter change, checking it and addressing problems it finds. It stops when it considers the task complete, encounters a blocking problem or reaches a configured limit. <a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/use-autopilot-mode">[13]</a></p>
<p>Press <strong>Shift+Tab</strong> until the status line shows <strong>Autopilot</strong>, then enter a clear task such as the filter request above. Keep the requested outcome and checks specific; Autopilot does not make an unclear requirement clearer.</p>
<p>Autopilot controls continuation, not permissions. If you choose <strong>Manual Approval</strong>, tool requests that still require approval are automatically denied, which can prevent completion. Enabling all permissions grants much broader access; it is not necessary just to learn the CLI. Start with Interactive mode for the first version of this app. <a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/use-autopilot-mode">[13]</a></p>
<p>To interrupt a running turn, press <strong>Esc twice</strong>. Use <strong>Shift+Tab</strong> to return to Interactive mode before your next prompt: Autopilot stays selected by default after finishing a task. Inspect the changes with <code>/diff</code> and check the app yourself before accepting the result. <a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/use-autopilot-mode">[13]</a></p>
<h2>Review the result and keep permissions small</h2>
<p>A confident answer is not proof that the application works. Open the files yourself and try the behavior you asked for. Check the page at a narrow width and use the keyboard as well as the mouse. Enter <code>&lt;b&gt;Read this literally&lt;/b&gt;</code> as a task: it should remain text, not become HTML.</p>
<p>You can also ask Copilot for a second look:</p>
<pre><code class="language-text">Review these three files without changing them.
Look for problems with adding, completing, deleting and filtering
tasks, blank input and safe text rendering.
List concrete findings and say what you have not tested.
</code></pre>
<p>Treat that response as assistance, not independent approval. If a test was proposed, check whether it was actually run. For this tiny app, a short browser checklist is enough to get started; a testing framework is not a prerequisite.</p>
<p>Keep the exercise in its own folder, avoid sensitive files and retain manual command approval while learning. A trusted folder is not a security sandbox: GitHub notes that permission scoping is heuristic and does not guarantee protection of every file outside it. Do not grant blanket tool permissions simply to avoid prompts. <a href="https://docs.github.com/en/copilot/concepts/copilot-surfaces/copilot-cli">[7]</a></p>
<h2>Conclusion</h2>
<p>Copilot’s progression from completions to chat and agents reflects a broader goal: helping with more of the work around writing code. You do not need a large project to understand that progression. A tiny todo app gives you a complete first loop—make a clear request, inspect the files, try the result and ask for one focused improvement.</p>
<p>The todo app is deliberately simple: its purpose is to introduce the workflow, not to show the limits of Copilot CLI. In practice, you can use it to help build websites, APIs, command-line tools and automation scripts, or to extend and improve existing applications. Larger projects involve more decisions and integration work, but the same approach applies: explain the goal, work through focused changes and check the result.</p>
<p>To try this on another project, open its folder, run <code>copilot</code>, and describe a specific change. Use <code>/diff</code> to inspect the result, then run the application and any relevant tests.</p>
<h2>Sources</h2>
<p>Documentation accessed October 31, 2026.</p>
<ol>
<li><a href="https://github.blog/news-insights/product-news/introducing-github-copilot-ai-pair-programmer/">Introducing GitHub Copilot: your AI pair programmer - The GitHub Blog</a></li>
<li><a href="https://github.blog/news-insights/product-news/github-copilot-is-generally-available-to-all-developers/">GitHub Copilot is generally available to all developers - The GitHub Blog</a></li>
<li><a href="https://github.blog/news-insights/product-news/github-copilot-x-the-ai-powered-developer-experience/">GitHub Copilot X: The AI-powered developer experience - The GitHub Blog</a></li>
<li><a href="https://github.blog/news-insights/product-news/github-copilot-the-agent-awakens/">GitHub Copilot: The agent awakens - The GitHub Blog</a></li>
<li><a href="https://github.blog/changelog/2025-05-19-github-copilot-coding-agent-in-public-preview/">GitHub Copilot coding agent in public preview - GitHub Changelog</a></li>
<li><a href="https://docs.github.com/en/copilot/get-started/about-github-copilot">About GitHub Copilot — GitHub Docs</a></li>
<li><a href="https://docs.github.com/en/copilot/concepts/copilot-surfaces/copilot-cli">GitHub Copilot CLI</a></li>
<li><a href="https://docs.github.com/en/copilot/get-started/quickstart-copilot-app">Getting started with the GitHub Copilot app</a></li>
<li><a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli">Installing GitHub Copilot CLI</a></li>
<li><a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/overview">Using GitHub Copilot CLI</a></li>
<li><a href="https://github.com/skills/create-applications-with-the-copilot-cli">Create applications with the Copilot CLI — GitHub Skills</a></li>
<li><a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/cli-best-practices">Best practices for GitHub Copilot CLI — model selection</a></li>
<li><a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/use-autopilot-mode">Using Autopilot mode in GitHub Copilot CLI</a></li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Deploying Terraform to Azure with GitHub Actions and OIDC]]></title><description><![CDATA[Automate Terraform deployments to Azure with OIDC, isolated environments, Blob state and separate plan/apply approvals in GitHub Actions.]]></description><link>https://blog.turingts.com/deploying-terraform-to-azure-with-github-actions-and-oidc</link><guid isPermaLink="true">https://blog.turingts.com/deploying-terraform-to-azure-with-github-actions-and-oidc</guid><category><![CDATA[Terraform]]></category><category><![CDATA[Azure]]></category><category><![CDATA[GitHub Actions]]></category><category><![CDATA[Infrastructure as code]]></category><category><![CDATA[ci-cd]]></category><category><![CDATA[OIDC]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Sun, 01 Nov 2026 19:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/2d96dde9-507b-45a1-ad66-0fa3aaac7fff.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As applications grow, infrastructure changes become more frequent. Repeating those changes by hand takes time and makes it easy to miss a setting or configure environments differently. The goal is to make delivery repeatable and faster, while keeping control over what changes and who can deploy it.</p>
<p>Infrastructure as Code turns those settings into version-controlled configuration. Terraform describes the infrastructure we want; GitHub Actions provides a shared process for checking, reviewing and applying changes. Instead of relying on someone remembering the right commands, each change follows the same path.</p>
<p>That process also needs access to Azure. Storing a reusable client secret in GitHub creates another credential to protect and rotate. OpenID Connect, or OIDC, lets an authorised job exchange its GitHub identity for temporary Azure access instead. The trust relationship defines which jobs may authenticate; Azure permissions still define what they may do.<a href="https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation">[1]</a></p>
<p>To put these pieces together, imagine an online store where a customer submits an order at checkout. The store places an order event on a queue, so a separate worker can process it. We will manage that queue with Terraform, check proposed changes against Dev, deploy there automatically after merge, and promote the same code through Stage and Production with separate approvals for plan and apply.</p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/295dd2fd-d89d-4b5c-8d35-83e4d0a86f16.png" alt="Promotion pipeline: trusted pull request plans against Dev; approved merge deploys Dev automatically; Stage and Production each require approval before plan and again before apply." /></p>
<p><em>One commit moves through all three environments. Each environment gets its own plan against its own state.</em></p>
<h2>What are we setting up?</h2>
<p>We are building a Terraform delivery pipeline for an Azure Service Bus namespace and order-events queue across separate Dev, Stage and Production subscriptions. Each environment has its own state storage and deployment identity. GitHub Actions controls the process; OIDC supplies temporary access.</p>
<p>This is the Azure companion to <a href="https://blog.turingts.com/deploying-terraform-to-aws-with-github-actions-and-oidc">Deploying Terraform to AWS with GitHub Actions and OIDC</a>. The promotion model stays the same, with Azure-specific identity, state access and queue behaviour.</p>
<p>The setup has three parts:</p>
<ul>
<li><strong>Terraform:</strong> the workload definition, plus a separate one-time foundation for each environment.</li>
<li><strong>Azure access:</strong> one user-assigned managed identity per subscription, shared by that environment's plan and apply jobs.</li>
<li><strong>GitHub Actions:</strong> trusted PRs plan against Dev; merging into <code>main</code> deploys Dev automatically, followed by gated Stage and Production deployments.</li>
</ul>
<p>This example uses three existing Azure subscriptions associated with one existing Microsoft Entra tenant, Azure public cloud, and West Europe. A managed identity is an Azure-managed security identity; here, a federated credential lets GitHub use it without attaching the runner to an Azure VM.<a href="https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-create-trust-user-assigned-managed-identity">[2]</a></p>
<h3>What do you need before starting?</h3>
<p>You need basic Terraform/YAML knowledge, repository administration rights, and an approved administrator Azure CLI login for each subscription. The administrator must be able to create resource groups, storage, managed identities and federated credentials, and assign Azure roles. We are not creating subscriptions or a tenant.</p>
<p>Have an administrator register <code>Microsoft.Storage</code>, <code>Microsoft.ManagedIdentity</code> and <code>Microsoft.ServiceBus</code> in each subscription. The examples disable automatic resource-provider registration, so routine deployment identities do not need subscription-wide registration rights.<a href="https://github.com/hashicorp/terraform-provider-azurerm/blob/v5.12.0/website/docs/index.html.markdown">[3]</a></p>
<p>This guide assumes a private repository with trusted contributors and a GitHub plan that supports required environment reviewers for private repositories. GitHub Free, Pro and Team offer required reviewers only for public repositories; check your organisation's capabilities before building around these gates. Do not make sensitive plans public to obtain them.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/deployments-and-environments">[4]</a></p>
<h2>1. Define the infrastructure</h2>
<p>Dev, Stage and Production each have a separate subscription, Service Bus namespace and queue, state storage account/container, and deployment identity. Azure RBAC permissions remain scoped separately within the shared tenant.</p>
<p>Separate each environment's administrator-controlled foundation from the resources the pipeline manages. Bootstrap creates two resource groups: <code>store-foundation-&lt;environment&gt;</code> for identity and state, and <code>store-&lt;environment&gt;</code> as the workload boundary. The workload configuration creates the namespace and queue inside that second group; it does not manage its own identity or role assignments.</p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/65712770-19e4-46c7-8beb-0c1b7cf3dbaf.png" alt="Three separate Azure subscriptions, each with an administrator-owned managed identity, federated trust, state account and role assignments, plus a workload resource group containing a Service Bus namespace and order-events queue." /></p>
<p><em>Bootstrap owns each foundation and creates the workload resource group. The pipeline manages the namespace and queue. Bootstrap state stays on the administrator's workstation, separately for each subscription.</em></p>
<p>Keep this code in a dedicated <code>store-infra</code> repository, separate from the application. <code>.github/workflows/</code> contains the checks and deployments. <code>bootstrap/</code> creates each subscription's foundation locally once; <code>terraform/</code> holds the workload and its environment-specific inputs and backend files.</p>
<p>The complete example is available below. Work from its <code>store-infra/</code> directory; the workflows remain inactive until you copy that directory's contents into your own separately configured private repository.</p>
<p><a class="embed-card" href="https://github.com/ferhaty/terraform-azure-github-actions-oidc">https://github.com/ferhaty/terraform-azure-github-actions-oidc</a></p>

<pre><code class="language-text">store-infra/
├── .gitignore
├── .github/workflows/
│   ├── pr.yml
│   ├── deploy.yml
│   └── environment.yml
├── bootstrap/
│   ├── versions.tf
│   ├── state.tf
│   ├── identity.tf
│   └── .terraform.lock.hcl
└── terraform/
    ├── versions.tf
    ├── variables.tf
    ├── main.tf
    ├── .terraform.lock.hcl
    ├── tests/queue.tftest.hcl
    └── vars/
        ├── dev.tfvars
        ├── dev.backend.hcl
        ├── stage.tfvars
        ├── stage.backend.hcl
        ├── production.tfvars
        └── production.backend.hcl
</code></pre>
<p>Use a repository <code>.gitignore</code> to keep local state, provider downloads and saved plans out of commits:</p>
<pre><code class="language-text">**/.terraform/*
*.tfstate
*.tfstate.*
*.tfplan
plan/
crash.log
*.auto.tfvars
</code></pre>
<h3>Define the namespace and queue</h3>
<p>In <code>terraform/versions.tf</code>, pin Terraform and the AzureRM provider, then declare the Azure Blob backend:</p>
<pre><code class="language-json">terraform {
  required_version = "= 1.17.1"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "= 5.12.0"
    }
  }
  backend "azurerm" {}
}
provider "azurerm" {
  features {}
  resource_provider_registrations = "none"
}
</code></pre>
<p>The provider manages Azure resources. The backend stores Terraform state. Each requires its own authentication configuration.<a href="https://developer.hashicorp.com/terraform/language/backend/azurerm">[5]</a><a href="https://github.com/hashicorp/terraform-provider-azurerm/blob/v5.12.0/website/docs/index.html.markdown">[3]</a></p>
<p>Use <code>terraform/variables.tf</code> for the environment and globally unique namespace name:</p>
<pre><code class="language-json">variable "environment" {
  type = string
  validation {
    condition     = contains(["dev", "stage", "production"], var.environment)
    error_message = "Choose dev, stage or production."
  }
}
variable "namespace_name" {
  type        = string
  description = "Globally unique Service Bus namespace name; replace the example value."
  validation {
    condition     = can(regex("^[a-z][a-z0-9-]{4,48}[a-z0-9]$", var.namespace_name))
    error_message = "Use 6-50 lowercase letters, digits or hyphens; start with a letter and end with a letter or digit."
  }
}
</code></pre>
<p>In <code>terraform/main.tf</code>, create the workload inside the resource group that bootstrap prepares:</p>
<pre><code class="language-json">resource "azurerm_servicebus_namespace" "store" {
  name                = var.namespace_name
  location            = "westeurope"
  resource_group_name = "store-${var.environment}"
  sku                 = "Standard"
  local_auth_enabled  = false
  minimum_tls_version = "1.2"
  tags = {
    Service     = "store"
    Environment = var.environment
    ManagedBy   = "Terraform"
  }
}
resource "azurerm_servicebus_queue" "orders" {
  name                                 = "order-events-${var.environment}"
  namespace_id                         = azurerm_servicebus_namespace.store.id
  default_message_ttl                  = "P4D"
  lock_duration                        = "PT1M"
  max_delivery_count                   = 10
  dead_lettering_on_message_expiration = true
}
output "queue_id" {
  value = azurerm_servicebus_queue.orders.id
}
</code></pre>
<p>Service Bus has its own message lifecycle. <code>P4D</code> sets the default message time-to-live to four days. Senders can specify a shorter TTL, and expired messages are not delivered normally. This queue sends expired messages to its dead-letter subqueue.<a href="https://github.com/hashicorp/terraform-provider-azurerm/blob/v5.12.0/website/docs/r/servicebus_queue.html.markdown">[6]</a><a href="https://learn.microsoft.com/en-us/azure/service-bus-messaging/message-expiration">[7]</a></p>
<p><code>PT1M</code> gives a receiver a one-minute PeekLock to process a message before settling it. A successful consumer completes the message; an abandoned message or an expired lock can lead to another delivery. The delivery limit is ten. Consumers must handle redelivery and monitor/drain the dead-letter subqueue.<a href="https://github.com/hashicorp/terraform-provider-azurerm/blob/v5.12.0/website/docs/r/servicebus_queue.html.markdown">[6]</a><a href="https://learn.microsoft.com/en-us/azure/service-bus-messaging/message-transfers-locks-settlement">[8]</a></p>
<p>Size the namespace and tune these queue settings for your workload before production use. <code>local_auth_enabled = false</code> disables SAS authentication. Application producers and consumers need their own Entra identities and appropriate Service Bus data roles, separate from the infrastructure deployment identity.<a href="https://github.com/hashicorp/terraform-provider-azurerm/blob/v5.12.0/website/docs/r/servicebus_namespace.html.markdown">[9]</a></p>
<h3>Give each environment its own inputs and state</h3>
<p>Create the following files under <code>terraform/vars/</code>. Replace every example namespace and storage account name with your own globally unique names. Storage account names allow 3–24 lowercase letters or digits; namespace names have different rules. Passing a local naming check does not prove global availability.<a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules">[10]</a></p>
<p><code>dev.tfvars</code>:</p>
<pre><code class="language-json">environment    = "dev"
namespace_name = "store-dev-replace-me"
</code></pre>
<p><code>stage.tfvars</code>:</p>
<pre><code class="language-json">environment    = "stage"
namespace_name = "store-stage-replace-me"
</code></pre>
<p><code>production.tfvars</code>:</p>
<pre><code class="language-json">environment    = "production"
namespace_name = "store-production-replace-me"
</code></pre>
<p><code>dev.backend.hcl</code>:</p>
<pre><code class="language-json">storage_account_name = "replacedevstate"
container_name       = "tfstate"
key                  = "store/dev/terraform.tfstate"
use_oidc             = true
use_azuread_auth     = true
</code></pre>
<p><code>stage.backend.hcl</code>:</p>
<pre><code class="language-json">storage_account_name = "replacestagestate"
container_name       = "tfstate"
key                  = "store/stage/terraform.tfstate"
use_oidc             = true
use_azuread_auth     = true
</code></pre>
<p><code>production.backend.hcl</code>:</p>
<pre><code class="language-json">storage_account_name = "replaceproductionstate"
container_name       = "tfstate"
key                  = "store/production/terraform.tfstate"
use_oidc             = true
use_azuread_auth     = true
</code></pre>
<p>The <code>.tfvars</code> file supplies workload settings to <code>plan</code>; <code>.backend.hcl</code> selects the state location during <code>init</code>. The GitHub environment supplies the identity and subscription IDs. Separate subscriptions, storage accounts and scoped Azure roles provide environment isolation.</p>
<p>The backend uses Microsoft Entra authentication for the Blob data plane, not a storage account key or SAS token. <code>use_oidc = true</code> enables federation; <code>use_azuread_auth = true</code> ensures the backend uses Entra authorisation instead of retrieving a storage key. Standard storage endpoints let it address the container directly, without management-plane endpoint lookup.<a href="https://developer.hashicorp.com/terraform/language/backend/azurerm">[5]</a></p>
<p>Azure Blob leases provide Terraform's backend locking. State contains the relationship between configuration and managed resources, and can include sensitive values. Keep state and saved plans out of Git; protect the container and restrict workflow logs and artifacts.<a href="https://developer.hashicorp.com/terraform/language/backend/azurerm">[5]</a><a href="https://developer.hashicorp.com/terraform/cli/commands/plan">[11]</a></p>
<h3>Prepare the foundation locally</h3>
<p>Create all the files in this guide, including the bootstrap reference below, before running these commands. Generate and commit both provider locks:</p>
<pre><code class="language-bash">terraform -chdir=bootstrap providers lock -platform=linux_amd64 -platform=darwin_arm64
terraform -chdir=terraform providers lock -platform=linux_amd64 -platform=darwin_arm64
</code></pre>
<p><code>linux_amd64</code> covers the Ubuntu runners; <code>darwin_arm64</code> is an Apple Silicon workstation example. Replace it with your workstation's platform, or add another <code>-platform</code> argument. CI will use <code>-lockfile=readonly</code> rather than changing the lock during a deployment.<a href="https://developer.hashicorp.com/terraform/cli/commands/providers/lock">[12]</a></p>
<p>Bootstrap deliberately has no remote backend block: its initial state is local. Use a clean working directory and separate secured state for each subscription. Run these three command groups separately in the same Bash shell, after replacing the IDs and names. The fail-fast setting stops on errors and may close an interactive shell.</p>
<p>First, select and inspect the administrator's Dev context:</p>
<pre><code class="language-bash"># From store-infra, after your approved Dev administrator Azure CLI login:
set -euo pipefail
export ARM_SUBSCRIPTION_ID="REPLACE-WITH-DEV-SUBSCRIPTION-ID"
export ARM_TENANT_ID="REPLACE-WITH-TENANT-ID"
export ARM_USE_CLI=true ARM_USE_OIDC=false
az account set --subscription "$ARM_SUBSCRIPTION_ID"
az account show --query '{subscription:id,tenant:tenantId,name:name}'
</code></pre>
<p>Confirm that both the subscription and tenant are the intended Dev context before continuing. The workflow's OIDC identity is not used for this administrator step.</p>
<p>Then initialise and plan the foundation:</p>
<pre><code class="language-bash">umask 077
mkdir "$HOME/store-foundation-dev"
cp bootstrap/*.tf bootstrap/.terraform.lock.hcl "$HOME/store-foundation-dev/"
terraform -chdir="$HOME/store-foundation-dev" init -lockfile=readonly
terraform -chdir="$HOME/store-foundation-dev" plan -out=foundation.tfplan   -var="subscription_id=$ARM_SUBSCRIPTION_ID"   -var="tenant_id=$ARM_TENANT_ID"   -var='environment=dev'   -var='state_account_name=replacedevstate'   -var='github_repository_subject=example-org@123/store-infra@456'
terraform -chdir="$HOME/store-foundation-dev" show foundation.tfplan
</code></pre>
<p>Review the resources and role scopes in that plan. Only after accepting them, run the apply group; applying a saved plan does not ask for another confirmation:</p>
<pre><code class="language-bash">terraform -chdir="$HOME/store-foundation-dev" apply foundation.tfplan
</code></pre>
<p>Repeat for Stage and Production with their own subscription IDs, environment values, globally unique state account names and new directories (<code>store-foundation-stage</code> and <code>store-foundation-production</code>). Keep the common tenant and repository identity consistent. Never switch subscriptions over another environment's existing local state.</p>
<p>If a step fails after creating the directory, retain it and its state. Recheck the administrator context, then run init and a fresh plan there; do not delete the directory or repeat the initial copy to start over. Secure and back up each foundation state and plan separately. The workflow identity receives no access to those local files.</p>
<p>After bootstrap, put each <code>state_account_name</code> output in the matching backend file. Keep the foundation account and workload namespace names distinct. State storage is created before CI needs it; bootstrap is never part of the workflow.</p>
<h2>2. Connect GitHub to Azure with OIDC</h2>
<p>OIDC replaces a stored client secret with a trust relationship. GitHub issues a signed, short-lived assertion identifying the job. Microsoft Entra validates that assertion against a federated credential on the managed identity, then issues an access token for the requested Azure API.<a href="https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-create-trust-user-assigned-managed-identity">[2]</a><a href="https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation">[1]</a></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/44fd882e-2fc3-4a26-a331-0674883cc52c.png" alt="OIDC sequence: Terraform requests a signed GitHub identity token with the AzureADTokenExchange audience, exchanges it through Microsoft Entra, and obtains separate API-specific access for Azure Resource Manager and Blob Storage." /></p>
<p><em>The GitHub assertion audience is <code>api://AzureADTokenExchange</code>. The provider and backend use Azure API-specific access tokens—not that GitHub assertion—to manage the workload and access state.</em></p>
<h3>Why not store a client secret?</h3>
<p>A stored client secret is reusable until it expires or is revoked, and replacements must reach every system using it. Federation removes that long-lived credential from GitHub. Each authorised job requests temporary access based on its identity, without a client secret to distribute.<a href="https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation">[1]</a></p>
<p>A compromised workflow can misuse its assigned permissions while its token is valid, which may extend beyond job completion. Azure roles determine those permissions independently of OIDC authentication. Protect workflow changes, Terraform code, runners and approval rules.</p>
<p>Access is controlled at three levels:</p>
<ul>
<li><strong>Federated credential:</strong> which issuer, audience and subject may authenticate as this managed identity.</li>
<li><strong>Azure RBAC:</strong> what that identity can do, and at which resource scopes.</li>
<li><strong>GitHub environment rules:</strong> when a job can start and which branches may use that environment.</li>
</ul>
<p><code>id-token: write</code> permits the job to request a GitHub OIDC token. It grants no Azure role by itself.<a href="https://docs.github.com/en/actions/reference/security/oidc">[13]</a></p>
<h3>Trust the exact repository and environment</h3>
<p>This example assumes GitHub immutable subject claims. Check the repository's OIDC settings and use its actual owner/repository names and numeric IDs. For the illustrative identity <code>example-org@123/store-infra@456</code>, the exact subjects are:</p>
<p><strong>GitHub environment — Federated subject</strong></p>
<ul>
<li><code>dev</code>, including trusted PR planning<br /><code>repo:example-org@123/store-infra@456:environment:dev</code></li>
<li><code>stage</code><br /><code>repo:example-org@123/store-infra@456:environment:stage</code></li>
<li><code>production</code><br /><code>repo:example-org@123/store-infra@456:environment:production</code></li>
</ul>
<p>An environment replaces the branch or PR context in the subject; it is not appended to it. That means the federated subject alone does not impose a <code>main</code> branch restriction—GitHub's environment rules must do that.<a href="https://docs.github.com/en/actions/reference/security/oidc">[13]</a></p>
<p>Microsoft Entra accepts an explicitly configured subject string and requires an exact match; no wildcard is needed. The Terraform resource below supplies that string directly, rather than relying on a portal form to infer it. Use the issuer <code>https://token.actions.githubusercontent.com</code> and audience <code>api://AzureADTokenExchange</code> exactly.<a href="https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-create-trust-user-assigned-managed-identity">[2]</a></p>
<p>In <code>bootstrap/identity.tf</code>, create the identity, trust and two role assignments:</p>
<pre><code class="language-json">resource "azurerm_user_assigned_identity" "terraform" {
  name                = "store-terraform-${var.environment}"
  location            = azurerm_resource_group.foundation.location
  resource_group_name = azurerm_resource_group.foundation.name
}
resource "azurerm_federated_identity_credential" "github" {
  name                      = "github-${var.environment}"
  user_assigned_identity_id = azurerm_user_assigned_identity.terraform.id
  issuer                    = "https://token.actions.githubusercontent.com"
  audience                  = ["api://AzureADTokenExchange"]
  subject                   = "repo:${var.github_repository_subject}:environment:${var.environment}"
}
resource "azurerm_role_assignment" "workload" {
  scope                = azurerm_resource_group.workload.id
  role_definition_name = "Contributor"
  principal_id         = azurerm_user_assigned_identity.terraform.principal_id
  principal_type       = "ServicePrincipal"
}
resource "azurerm_role_assignment" "state" {
  scope                = azurerm_storage_container.state.id
  role_definition_name = "Storage Blob Data Contributor"
  principal_id         = azurerm_user_assigned_identity.terraform.principal_id
  principal_type       = "ServicePrincipal"
}
output "client_id" {
  value = azurerm_user_assigned_identity.terraform.client_id
}
output "tenant_id" {
  value = var.tenant_id
}
output "subscription_id" {
  value = var.subscription_id
}
</code></pre>
<p>There is one identity per environment, not a separate read-only plan principal. Both plan and apply—and Dev PR planning—receive the same deployment-capable permissions.</p>
<p><code>Contributor</code> is scoped to the workload resource group, not the subscription. It can manage and delete that group's resources, including the group itself, but it does not grant permission to assign Azure roles. This role covers all resource types within the workload group; a custom role can narrow it to Service Bus operations. Keep the group dedicated to this workload.<a href="https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/privileged">[14]</a></p>
<p><code>Storage Blob Data Contributor</code> is scoped separately to that environment's state container. Management-plane Contributor alone does not provide the backend's Blob data access. The Blob role also permits deletion of that state container. The deployment identity cannot modify the foundation resource group itself, its managed identity, federated credential or role assignments.<a href="https://developer.hashicorp.com/terraform/language/backend/azurerm">[5]</a><a href="https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/storage">[15]</a></p>
<p>New identities, federated credentials and role assignments can take time to propagate. If the first exchange or backend access fails, confirm the exact tenant/client IDs, subject and role scope, then allow propagation and retry the failed setup step. Do not fix a propagation delay by granting subscription-wide Owner access.</p>
<h3>Use native Terraform OIDC authentication</h3>
<p>The workflows below use the AzureRM provider and AzureRM backend's native GitHub OIDC support. They discover the job's <code>ACTIONS_ID_TOKEN_REQUEST_URL</code> and <code>ACTIONS_ID_TOKEN_REQUEST_TOKEN</code>, request the GitHub assertion, and perform the Entra exchange. No <code>azure/login</code> step or manually copied token is required.<a href="https://developer.hashicorp.com/terraform/language/backend/azurerm">[5]</a><a href="https://github.com/hashicorp/terraform-provider-azurerm/blob/v5.12.0/website/docs/index.html.markdown">[3]</a></p>
<p>Both use the managed identity's client ID and tenant ID. The provider obtains access for Azure Resource Manager; the backend obtains access for Azure Storage. <code>api://AzureADTokenExchange</code> is the audience of the incoming GitHub assertion, not a universal Azure API access-token audience. Adding <code>azure/login</code> would be a different authentication path, not a substitute for configuring the backend.</p>
<h3>Configure the GitHub environments</h3>
<p>Create <code>dev</code>, <code>stage</code> and <code>production</code> before running the workflows. A job referencing a missing environment can create one without your intended protection rules, so the YAML alone is not the approval configuration.<a href="https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments">[16]</a></p>
<ul>
<li><strong>Dev:</strong> no required reviewers. Under selected deployment branch rules, allow <code>main</code> and <code>refs/pull/*/merge</code>, so trusted PRs can plan and merged changes can deploy automatically.</li>
<li><strong>Stage and Production:</strong> allow only <code>main</code>, enable required reviewers, and disable self-review and administrator bypass where supported. Each environment requires approval before its plan job and a separate approval before its dependent apply job.</li>
<li><strong>Repository:</strong> protect <code>main</code> with PR review and passing checks, prevent direct pushes, and require review of workflow and Terraform changes.</li>
<li><strong>Forks:</strong> do not enable write tokens or secrets for fork PR workflows, and do not use <code>pull_request_target</code> to execute proposed code.<a href="https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments">[16]</a><a href="https://docs.github.com/en/actions/reference/security/secure-use">[17]</a></li>
</ul>
<p>Create these GitHub environment secrets in each of <code>dev</code>, <code>stage</code> and <code>production</code> under <strong>Settings → Environments → Environment secrets</strong>:</p>
<table>
<thead>
<tr>
<th>Secret</th>
<th>Value from that environment's bootstrap</th>
</tr>
</thead>
<tbody><tr>
<td><code>AZURE_CLIENT_ID</code></td>
<td><code>client_id</code></td>
</tr>
<tr>
<td><code>AZURE_TENANT_ID</code></td>
<td><code>tenant_id</code></td>
</tr>
<tr>
<td><code>AZURE_SUBSCRIPTION_ID</code></td>
<td><code>subscription_id</code></td>
</tr>
</tbody></table>
<p>The workflows read these environment secrets and map them to <code>ARM_CLIENT_ID</code>, <code>ARM_TENANT_ID</code> and <code>ARM_SUBSCRIPTION_ID</code> for Terraform. West Europe is set directly in the HCL.</p>
<p>For simplicity, the example uses public Azure service endpoints protected by Entra authorisation. Disabling anonymous Blob access restricts authorisation while leaving the public network endpoint available. If your policy requires private endpoints, supply runners with the necessary network access and design that separately.</p>
<h2>3. Check pull requests and plan against Dev</h2>
<p>The PR workflow has one <code>plan</code> job. It checks formatting, initialises Dev's real Blob backend using OIDC, validates and mock-tests the workload, and plans against Dev. Bootstrap remains outside CI.</p>
<p>Planning executes Terraform configuration and provider code with Dev's deployment-capable identity and reads its state. This path is only for trusted same-repository contributors. The guard excludes public repositories, forks and untrusted author associations, but it is not a sandbox against a hostile collaborator.<a href="https://docs.github.com/en/actions/reference/security/secure-use">[17]</a></p>
<p>Use <code>.github/workflows/pr.yml</code>:</p>
<pre><code class="language-yaml">name: Terraform PR checks
on:
  pull_request:
    branches: [main]
permissions:
  contents: read
env:
  TF_IN_AUTOMATION: 'true'
  TF_INPUT: 'false'
jobs:
  plan:
    if: &gt;-
      github.event.repository.private == true &amp;&amp;
      github.event.pull_request.head.repo.id == github.event.repository.id &amp;&amp;
      contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association) &amp;&amp;
      github.actor != 'dependabot[bot]'
    runs-on: ubuntu-24.04
    timeout-minutes: 15
    environment: dev
    permissions:
      contents: read
      id-token: write
    env:
      ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
      ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
      ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
      ARM_USE_OIDC: 'true'
      ARM_USE_AZUREAD: 'true'
      ARM_USE_CLI: 'false'
    concurrency:
      group: terraform-store-azure-dev
      cancel-in-progress: false
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          ref: ${{ github.sha }}
          persist-credentials: false
      - uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1
        with:
          terraform_version: 1.17.1
          terraform_wrapper: false
      - name: Format
        run: terraform -chdir=terraform fmt -check -recursive
      - name: Initialize Dev backend
        run: terraform -chdir=terraform init -input=false -lockfile=readonly -backend-config=vars/dev.backend.hcl
      - name: Validate
        run: terraform -chdir=terraform validate
      - name: Mock tests
        run: terraform -chdir=terraform test
      - name: Plan against Dev
        run: terraform -chdir=terraform plan -input=false -no-color -lock-timeout=5m -var-file=vars/dev.tfvars
</code></pre>
<p>Init authenticates to the backend before accessing Dev state; plan authenticates the AzureRM provider for resource operations. The PR plan uses the proposed merge revision and appears in the restricted job log. It is review feedback, not a plan to apply after merge.</p>
<p>Commit <code>terraform/.terraform.lock.hcl</code> and keep readonly init in CI. <code>TF_INPUT=false</code> disables input prompts; <code>TF_IN_AUTOMATION</code> only adjusts Terraform's output for automation.</p>
<p><code>terraform/tests/queue.tftest.hcl</code> checks all three environment mappings with a mock provider:</p>
<pre><code class="language-json">mock_provider "azurerm" {
  mock_resource "azurerm_servicebus_namespace" {
    defaults = {
      id = "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/mock/providers/Microsoft.ServiceBus/namespaces/mock-namespace"
    }
  }
}
run "queue_dev" {
  command = plan
  variables {
    environment    = "dev"
    namespace_name = "store-dev-mock"
  }
  assert {
    condition     = azurerm_servicebus_namespace.store.resource_group_name == "store-dev" &amp;&amp; azurerm_servicebus_queue.orders.name == "order-events-dev"
    error_message = "Workload and queue must belong to the selected environment."
  }
  assert {
    condition     = !azurerm_servicebus_namespace.store.local_auth_enabled &amp;&amp; azurerm_servicebus_queue.orders.default_message_ttl == "P4D" &amp;&amp; azurerm_servicebus_queue.orders.lock_duration == "PT1M" &amp;&amp; azurerm_servicebus_queue.orders.max_delivery_count == 10 &amp;&amp; azurerm_servicebus_queue.orders.dead_lettering_on_message_expiration
    error_message = "Keep Entra authentication and the intended message lifecycle settings."
  }
}
run "queue_stage" {
  command = plan
  variables {
    environment    = "stage"
    namespace_name = "store-stage-mock"
  }
  assert {
    condition     = azurerm_servicebus_namespace.store.resource_group_name == "store-stage" &amp;&amp; azurerm_servicebus_queue.orders.name == "order-events-stage"
    error_message = "Workload and queue must belong to the selected environment."
  }
  assert {
    condition     = !azurerm_servicebus_namespace.store.local_auth_enabled &amp;&amp; azurerm_servicebus_queue.orders.default_message_ttl == "P4D" &amp;&amp; azurerm_servicebus_queue.orders.lock_duration == "PT1M" &amp;&amp; azurerm_servicebus_queue.orders.max_delivery_count == 10 &amp;&amp; azurerm_servicebus_queue.orders.dead_lettering_on_message_expiration
    error_message = "Keep Entra authentication and the intended message lifecycle settings."
  }
}
run "queue_production" {
  command = plan
  variables {
    environment    = "production"
    namespace_name = "store-production-mock"
  }
  assert {
    condition     = azurerm_servicebus_namespace.store.resource_group_name == "store-production" &amp;&amp; azurerm_servicebus_queue.orders.name == "order-events-production"
    error_message = "Workload and queue must belong to the selected environment."
  }
  assert {
    condition     = !azurerm_servicebus_namespace.store.local_auth_enabled &amp;&amp; azurerm_servicebus_queue.orders.default_message_ttl == "P4D" &amp;&amp; azurerm_servicebus_queue.orders.lock_duration == "PT1M" &amp;&amp; azurerm_servicebus_queue.orders.max_delivery_count == 10 &amp;&amp; azurerm_servicebus_queue.orders.dead_lettering_on_message_expiration
    error_message = "Keep Entra authentication and the intended message lifecycle settings."
  }
}
</code></pre>
<p>Mock providers supply simulated resource data for these configuration checks.<a href="https://developer.hashicorp.com/terraform/language/tests/mocking">[18]</a></p>
<h2>4. Deploy Dev, then promote through Stage and Production</h2>
<p>A merge triggers a push to <code>main</code>. Dev plans and applies automatically. After Dev succeeds, Stage waits for approval to plan, then for a second approval to apply that saved plan. Production follows the same sequence after Stage succeeds. All jobs use the same commit; every environment gets a new plan against its own subscription, inputs and state.</p>
<p>Use <code>.github/workflows/deploy.yml</code> to define that sequence:</p>
<pre><code class="language-yaml">name: Terraform Deploy
on:
  push:
    branches: [main]
  workflow_dispatch:
permissions:
  contents: read
  id-token: write
jobs:
  dev:
    if: github.ref == 'refs/heads/main'
    uses: ./.github/workflows/environment.yml
    with:
      environment: dev
    secrets:
      AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
      AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
      AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
  stage:
    needs: dev
    uses: ./.github/workflows/environment.yml
    with:
      environment: stage
    secrets:
      AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
      AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
      AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
  production:
    needs: stage
    uses: ./.github/workflows/environment.yml
    with:
      environment: production
    secrets:
      AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
      AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
      AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
</code></pre>
<p>The local reusable workflow avoids repeating the same jobs three times. The caller passes the three named secrets; each plan and apply job selects its environment to receive that environment’s values. In <code>.github/workflows/environment.yml</code>, both jobs reference the same target environment, and apply depends on plan:</p>
<pre><code class="language-yaml">name: Terraform Environment
on:
  workflow_call:
    inputs:
      environment:
        required: true
        type: string
    secrets:
      AZURE_CLIENT_ID:
        required: true
      AZURE_TENANT_ID:
        required: true
      AZURE_SUBSCRIPTION_ID:
        required: true
permissions:
  contents: read
  id-token: write
env:
  TF_IN_AUTOMATION: 'true'
  TF_INPUT: 'false'
  TARGET_ENV: ${{ inputs.environment }}
jobs:
  plan:
    if: &gt;-
      github.ref == 'refs/heads/main' &amp;&amp;
      contains(fromJSON('["dev","stage","production"]'), inputs.environment)
    runs-on: ubuntu-24.04
    timeout-minutes: 15
    environment: ${{ inputs.environment }}
    env:
      ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
      ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
      ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
      ARM_USE_OIDC: 'true'
      ARM_USE_AZUREAD: 'true'
      ARM_USE_CLI: 'false'
    concurrency:
      group: terraform-store-azure-${{ inputs.environment }}
      cancel-in-progress: false
    outputs:
      artifact_id: ${{ steps.upload.outputs.artifact-id }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          ref: ${{ github.sha }}
          persist-credentials: false
      - uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1
        with:
          terraform_version: 1.17.1
          terraform_wrapper: false
      - name: Format
        run: terraform -chdir=terraform fmt -check -recursive
      - name: Initialize environment backend
        run: terraform -chdir=terraform init -input=false -lockfile=readonly -backend-config="vars/$TARGET_ENV.backend.hcl"
      - name: Validate
        run: terraform -chdir=terraform validate
      - name: Mock tests
        run: terraform -chdir=terraform test
      - name: Create saved plan
        run: |
          mkdir -p plan
          terraform -chdir=terraform plan -input=false -no-color -lock-timeout=5m -var-file="vars/$TARGET_ENV.tfvars" -out=../plan/tfplan
      - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        id: upload
        with:
          name: tfplan-${{ inputs.environment }}-${{ github.run_id }}-${{ github.run_attempt }}
          path: plan/tfplan
          retention-days: 1
          if-no-files-found: error
          overwrite: false
  apply:
    needs: plan
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-24.04
    timeout-minutes: 15
    environment: ${{ inputs.environment }}
    env:
      ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
      ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
      ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
      ARM_USE_OIDC: 'true'
      ARM_USE_AZUREAD: 'true'
      ARM_USE_CLI: 'false'
    concurrency:
      group: terraform-store-azure-${{ inputs.environment }}
      cancel-in-progress: false
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          ref: ${{ github.sha }}
          persist-credentials: false
      - uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1
        with:
          terraform_version: 1.17.1
          terraform_wrapper: false
      - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
        with:
          artifact-ids: ${{ needs.plan.outputs.artifact_id }}
          path: plan/
          merge-multiple: true
          digest-mismatch: error
      - name: Initialize matching backend
        run: terraform -chdir=terraform init -input=false -lockfile=readonly -backend-config="vars/$TARGET_ENV.backend.hcl"
      - name: Apply only this environment's saved plan
        run: terraform -chdir=terraform apply -input=false -lock-timeout=5m ../plan/tfplan
</code></pre>
<p>Approve Stage or Production planning first. When that plan job finishes, read the proposed changes directly in its GitHub Actions log before approving apply. The artifact contains only the binary <code>tfplan</code>.</p>
<p>Apply checks out the same commit, downloads the exact artifact ID produced by its plan job in the same workflow run, initialises the matching backend and applies that saved plan. It does not generate a replacement plan after approval. Dev follows the same implementation without manual gates.</p>
<p>The run attempt in the artifact name avoids collisions with an earlier attempt. Never apply a PR plan, a different environment's plan or an artifact selected merely by a familiar filename. Saved plans can contain sensitive values, so keep the repository, job logs and artifacts restricted; the example retains the plan for one day.<a href="https://developer.hashicorp.com/terraform/cli/commands/plan">[11]</a></p>
<h3>How do you retry a failed promotion?</h3>
<p>Restart at the chosen environment's plan job in the existing workflow run. GitHub can rerun that job and its dependents while retaining the original commit and ref; the completed upstream environments need not run again. Stage and Production keep their plan and apply approval gates.<a href="https://docs.github.com/en/actions/how-tos/manage-workflow-runs/re-run-workflows-and-jobs">[19]</a></p>
<p>A Dev-plan rerun can continue through Stage and Production; a Stage-plan rerun can continue through Production; a Production-plan rerun stays there. Select the actual plan job in the expanded reusable workflow. Use <strong>Run workflow</strong> from <code>main</code> when you want a new run using its selected revision, starting at Dev instead. Check the intended revision before rerunning: a fresh plan from older code can propose reversing newer infrastructure changes.</p>
<p>If the plan expired, is missing or stale, or apply partially changed resources, make a fresh plan and review it again before applying. Each new plan supplies its own artifact ID to its dependent apply job.</p>
<h2>5. Handle overlapping changes and failures</h2>
<p>The actual jobs use concurrency groups <code>terraform-store-azure-dev</code>, <code>terraform-store-azure-stage</code> and <code>terraform-store-azure-production</code>. PR planning shares Dev's group with Dev deployment jobs. The reusable-workflow caller does not hold the same group, avoiding nested lock ownership.</p>
<p><code>cancel-in-progress: false</code> avoids interrupting an active apply. GitHub concurrency is repository-scoped and is not a guaranteed FIFO queue; pending work can be superseded. Blob leases remain Terraform's state-level safeguard.<a href="https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency">[20]</a><a href="https://developer.hashicorp.com/terraform/language/backend/azurerm">[5]</a></p>
<p>Neither mechanism reserves state across an approval gap. The plan job releases its concurrency group and state lock when it finishes, so another run can change state while approval waits. Terraform rejects a saved plan whose state is stale. Direct Azure changes are not prevented by a Terraform lock either: regenerate and review a plan when state or infrastructure changes.</p>
<p>A failed apply may leave partial changes. Inspect the actual state and resources, correct the cause, and plan again. Restoring an old state file is not an infrastructure rollback. Only force-unlock after confirming the operation that held the lock is no longer running.</p>
<p>For drift detection, a separate trusted workflow can run <code>terraform plan -detailed-exitcode</code> without an apply job: <code>0</code> means no changes, <code>1</code> an error and <code>2</code> proposed changes. A job using Stage or Production still encounters that environment's approval rules. Decide whether to change the code or correct the resource rather than automatically reverting every difference.<a href="https://developer.hashicorp.com/terraform/cli/commands/plan">[11]</a></p>
<h2>Reference: complete the local bootstrap</h2>
<p>These files complete the foundation used by the earlier commands. Combine them with <code>bootstrap/identity.tf</code>, reuse the configuration for each subscription, and keep its state separate. The deployment workflows never apply these files.</p>
<p><code>bootstrap/versions.tf</code>:</p>
<pre><code class="language-json">terraform {
  required_version = "= 1.17.1"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "= 5.12.0"
    }
  }
}
provider "azurerm" {
  features {}
  subscription_id                 = var.subscription_id
  tenant_id                       = var.tenant_id
  resource_provider_registrations = "none"
  storage_use_azuread             = true
}
variable "subscription_id" {
  type = string
}
variable "tenant_id" {
  type = string
}
variable "environment" {
  type = string
  validation {
    condition     = contains(["dev", "stage", "production"], var.environment)
    error_message = "Choose dev, stage or production."
  }
}
variable "state_account_name" {
  type = string
  validation {
    condition     = can(regex("^[a-z0-9]{3,24}$", var.state_account_name))
    error_message = "Use a globally unique storage account name: 3-24 lowercase letters or digits."
  }
}
variable "github_repository_subject" {
  type        = string
  description = "Immutable repository identity without repo: or environment suffix; e.g. example-org@123/store-infra@456."
  validation {
    condition     = can(regex("^[A-Za-z0-9_.-]+@[0-9]+/[A-Za-z0-9_.-]+@[0-9]+$", var.github_repository_subject))
    error_message = "Use owner and repository names with immutable numeric IDs."
  }
}
</code></pre>
<p><code>bootstrap/state.tf</code>:</p>
<pre><code class="language-json">resource "azurerm_resource_group" "foundation" {
  name     = "store-foundation-${var.environment}"
  location = "westeurope"
}
resource "azurerm_resource_group" "workload" {
  name     = "store-${var.environment}"
  location = "westeurope"
}
resource "azurerm_storage_account" "state" {
  name                            = var.state_account_name
  resource_group_name             = azurerm_resource_group.foundation.name
  location                        = azurerm_resource_group.foundation.location
  account_tier                    = "Standard"
  account_replication_type        = "LRS"
  account_kind                    = "StorageV2"
  min_tls_version                 = "TLS1_2"
  https_traffic_only_enabled      = true
  shared_access_key_enabled       = false
  allow_nested_items_to_be_public = false
  default_to_oauth_authentication = true
  blob_properties {
    versioning_enabled = true
    delete_retention_policy {
      days = 7
    }
  }
  lifecycle {
    prevent_destroy = true
  }
}
resource "azurerm_storage_container" "state" {
  name                  = "tfstate"
  storage_account_id    = azurerm_storage_account.state.id
  container_access_type = "private"
}
output "state_account_name" {
  value = azurerm_storage_account.state.name
}
</code></pre>
<p>The state account uses private containers, HTTPS, disabled Shared Key access, Blob versioning and a seven-day deleted-blob retention policy. <code>LRS</code> is a simple redundancy choice, not a cross-region recovery design. <code>prevent_destroy</code> guards deletion through this configuration; it is not an independent Azure deletion lock.</p>
<p>Bootstrap's resource-management permissions create the account, container and role assignments. CI then uses its separate Blob data role for state operations. Keep administrator recovery access and backups outside routine deployment permissions.</p>
<h2>Frequently asked questions</h2>
<h3>Do I need an app registration or a client secret?</h3>
<p>This implementation uses a user-assigned managed identity with a federated credential. An app registration is an alternative way to support federation. No client secret or storage key is passed to GitHub.<a href="https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-create-trust-user-assigned-managed-identity">[2]</a></p>
<h3>Is the plan identity read-only?</h3>
<p>No. Plan and apply share one deployment identity per environment. Even a PR plan has Dev's workload-management and state permissions. Trusted contributors, protected workflow code and environment gates are part of the security boundary.</p>
<h3>Why does Blob access fail when workload deployment is allowed?</h3>
<p>Workload management and state access use different scopes and APIs. Check the state container's Storage Blob Data Contributor assignment, tenant/client IDs, backend authentication flags, propagation and network access. Contributor on the workload resource group is not sufficient for Blob state access.<a href="https://developer.hashicorp.com/terraform/language/backend/azurerm">[5]</a><a href="https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/storage">[15]</a></p>
<h3>Why not plan again after the second approval?</h3>
<p>That approval is for the changes reviewers just inspected. Apply the saved plan they reviewed. If it is no longer valid, generate a new plan and obtain approval for the updated changes.<a href="https://developer.hashicorp.com/terraform/cli/commands/plan">[11]</a></p>
<h2>Sources</h2>
<p>[1] <a href="https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation">Microsoft — Workload identity federation</a></p>
<p>[2] <a href="https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-create-trust-user-assigned-managed-identity">Microsoft — Federated credentials for a user-assigned managed identity</a></p>
<p>[3] <a href="https://github.com/hashicorp/terraform-provider-azurerm/blob/v5.12.0/website/docs/index.html.markdown">AzureRM 5.12.0 — Authentication and registration</a></p>
<p>[4] <a href="https://docs.github.com/en/actions/reference/workflows-and-actions/deployments-and-environments">GitHub — Deployments and environments</a></p>
<p>[5] <a href="https://developer.hashicorp.com/terraform/language/backend/azurerm">HashiCorp — AzureRM backend</a></p>
<p>[6] <a href="https://github.com/hashicorp/terraform-provider-azurerm/blob/v5.12.0/website/docs/r/servicebus_queue.html.markdown">AzureRM 5.12.0 — Service Bus queue</a></p>
<p>[7] <a href="https://learn.microsoft.com/en-us/azure/service-bus-messaging/message-expiration">Microsoft — Message expiration</a></p>
<p>[8] <a href="https://learn.microsoft.com/en-us/azure/service-bus-messaging/message-transfers-locks-settlement">Microsoft — Message locks and settlement</a></p>
<p>[9] <a href="https://github.com/hashicorp/terraform-provider-azurerm/blob/v5.12.0/website/docs/r/servicebus_namespace.html.markdown">AzureRM 5.12.0 — Service Bus namespace</a></p>
<p>[10] <a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules">Microsoft — Resource naming rules</a></p>
<p>[11] <a href="https://developer.hashicorp.com/terraform/cli/commands/plan">HashiCorp — Terraform plan</a></p>
<p>[12] <a href="https://developer.hashicorp.com/terraform/cli/commands/providers/lock">HashiCorp — Provider dependency locks</a></p>
<p>[13] <a href="https://docs.github.com/en/actions/reference/security/oidc">GitHub — OpenID Connect reference</a></p>
<p>[14] <a href="https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/privileged">Microsoft — Privileged built-in roles</a></p>
<p>[15] <a href="https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/storage">Microsoft — Storage built-in roles</a></p>
<p>[16] <a href="https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments">GitHub — Managing environments</a></p>
<p>[17] <a href="https://docs.github.com/en/actions/reference/security/secure-use">GitHub — Secure use</a></p>
<p>[18] <a href="https://developer.hashicorp.com/terraform/language/tests/mocking">HashiCorp — Mock providers</a></p>
<p>[19] <a href="https://docs.github.com/en/actions/how-tos/manage-workflow-runs/re-run-workflows-and-jobs">GitHub — Re-running workflows and jobs</a></p>
<p>[20] <a href="https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency">GitHub — Workflow concurrency</a></p>
]]></content:encoded></item><item><title><![CDATA[Managing Secrets on EKS with External Secrets Operator and AWS Secrets Manager]]></title><description><![CDATA[Synchronize AWS Secrets Manager values into EKS with scoped IRSA, Terraform and Helm, then test refresh behavior and application reloads.]]></description><link>https://blog.turingts.com/managing-secrets-on-eks-with-external-secrets-operator-and-aws-secrets-manager</link><guid isPermaLink="true">https://blog.turingts.com/managing-secrets-on-eks-with-external-secrets-operator-and-aws-secrets-manager</guid><category><![CDATA[Kubernetes]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Terraform]]></category><category><![CDATA[Security]]></category><category><![CDATA[secrets]]></category><category><![CDATA[secrets management]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Sat, 31 Oct 2026 17:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/55ee835a-61cf-4291-8e5e-a564a989b470.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Applications running on EKS often need secrets such as database passwords or API keys. External Secrets Operator can automatically synchronize values from AWS Secrets Manager into Kubernetes Secrets, which containers consume through environment variables or mounted files.</p>
<p>Imagine an online store where a customer submits an order at checkout. The checkout service calls a payment provider using an API key stored in AWS Secrets Manager. We will configure ESO to create and update a Kubernetes Secret containing that key, then make it available to the checkout container.</p>
<p>Putting the value in a manifest makes deployment reproducible, but also puts a credential in source control. Passing it through Terraform can move that exposure into state and saved plans instead. Marking a Terraform value <code>sensitive</code> redacts ordinary output; it does not, by itself, exclude the value from state. <a href="https://developer.hashicorp.com/terraform/language/manage-sensitive-data">[1]</a></p>
<p>The goal is one authoritative secret source, a narrow delivery path, and an explicit application-update procedure. We will build that path on an existing Amazon EKS cluster, using one namespace and one AWS secret.</p>
<h2>What does External Secrets Operator solve?</h2>
<p>External Secrets Operator (ESO) retrieves values from an external secret system and reconciles them into Kubernetes resources. Here, it creates an ordinary Kubernetes Secret. ESO keeps that Kubernetes Secret synchronized with the external value.</p>
<p>Rotating the payment provider's credential and having the application use an updated value are separate steps. <a href="https://external-secrets.io/latest/api/externalsecret/">[2]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/33cddfa5-538b-4e69-82d6-6762b2262e27.png" alt="General ESO architecture: an external provider supplies values to the controller inside Kubernetes. ExternalSecret defines mapping and refresh and references a SecretStore or ClusterSecretStore. ESO creates or updates a Kubernetes Secret consumed by a workload as environment variables or mounted files." style="display:block;margin:0 auto" />

<p><em>ESO synchronizes external values into a Kubernetes Secret; the workload consumes that copy, not the secret provider API.</em></p>
<p>External Secrets Operator can be used with Kubernetes on different cloud platforms and integrates with secret services such as AWS Secrets Manager, Azure Key Vault and Google Secret Manager. In this guide, we focus on AWS, using Amazon EKS and AWS Secrets Manager.</p>
<p>The components have separate jobs:</p>
<table>
<thead>
<tr>
<th>Component</th>
<th>Responsibility in this example</th>
</tr>
</thead>
<tbody><tr>
<td>AWS Secrets Manager</td>
<td>Stores the Terraform-managed demo JSON value and its versions.</td>
</tr>
<tr>
<td>AWS STS and an IAM role</td>
<td>Exchange a trusted Kubernetes service-account identity for temporary credentials, limited to one secret.</td>
</tr>
<tr>
<td>ESO controller</td>
<td>Authenticates, reads the selected value, and reconciles the Kubernetes Secret.</td>
</tr>
<tr>
<td><code>SecretStore</code></td>
<td>Namespaced connection and authentication configuration for Secrets Manager.</td>
</tr>
<tr>
<td><code>ExternalSecret</code></td>
<td>Selects the source property, destination key, refresh policy and ownership behavior.</td>
</tr>
<tr>
<td>Kubernetes Secret</td>
<td>Holds the application-facing copy in <code>shop-secrets-demo</code>.</td>
</tr>
<tr>
<td>Checkout consumer</td>
<td>Receives the copy as a mounted file and an environment variable; it has no AWS role.</td>
</tr>
</tbody></table>
<p>A <code>SecretStore</code> holds connection and authentication configuration. An <code>ExternalSecret</code> identifies the source value and destination mapping through references, keeping the API key out of these definitions. Those definitions can be reviewed in Git. Terraform creates the demo value; ESO delivers it to Kubernetes. <a href="https://external-secrets.io/latest/api/secretstore/">[3]</a> <a href="https://external-secrets.io/latest/provider/aws-secrets-manager/">[4]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/d2c9c65d-4c91-45ee-82f9-c31e7696b183.png" alt="AWS Secrets Manager and STS outside an existing EKS cluster; a namespace-scoped ESO controller uses a reader service account to synchronize one secret into the checkout namespace." style="display:block;margin:0 auto" />

<p><em>The AWS services are outside the cluster. The controller and checkout consumer are inside it. Dashed identity connections and solid configuration/API connections are not application traffic. Terraform supplies the public dummy source value; ESO reads it from Secrets Manager.</em></p>
<h2>Which identity reads the AWS secret?</h2>
<p>ESO reads the secret, not the checkout application. This guide uses ESO's supported <code>auth.jwt.serviceAccountRef</code> route: ESO requests a short-lived token for a designated reader service account, then uses that token with AWS STS to assume the reader's IAM role. <a href="https://external-secrets.io/latest/provider/aws-access/">[5]</a></p>
<p>There are three Kubernetes service accounts worth keeping distinct:</p>
<ul>
<li><code>eso-shop-system/eso-shop</code> runs the controller and supplies its Kubernetes API permissions. It has no AWS role annotation.</li>
<li><code>shop-secrets-demo/checkout-secret-reader</code> is the identity referenced by the SecretStore. Its annotation identifies the IAM role, and AWS trust binds that role to this exact namespace and service-account name.</li>
<li><code>shop-secrets-demo/checkout-demo</code> runs the application-side demonstration. It has no AWS role and does not mount a Kubernetes API token.</li>
</ul>
<p>The reader service account does not need a Pod. ESO calls the Kubernetes TokenRequest API on its behalf. Setting <code>automountServiceAccountToken: false</code> prevents automatic token mounting; it does not prohibit this explicitly authorized token request. <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/">[6]</a></p>
<p>This uses IAM Roles for Service Accounts (IRSA). ESO's AWS documentation specifies that <code>serviceAccountRef</code> cannot be used with EKS Pod Identity associations. We choose IRSA because it supports a distinct identity selected by this namespaced store without assigning the AWS reader role to the controller Pod. <a href="https://external-secrets.io/latest/provider/aws-access/">[5]</a></p>
<p>No optional <code>provider.aws.role</code> is needed here. That field would add an <code>AssumeRole</code> hop after the selected authentication route; the reader service account already points to the final, narrowly scoped role.</p>
<h3>What does the namespace boundary protect?</h3>
<p>A namespaced SecretStore cannot be referenced by an ExternalSecret in a different namespace. That is useful containment, but not complete tenant isolation.</p>
<p>Whoever can create Pods in the application namespace may be able to mount its Secrets; whoever controls a store or its reader service account may affect the authentication path. <a href="https://external-secrets.io/latest/guides/security-best-practices/">[7]</a> <a href="https://kubernetes.io/docs/concepts/security/secrets-good-practices/">[8]</a></p>
<p>For this example, the platform administrator owns the store, reader service account, token Role and RoleBinding. The application team must not have unrestricted edit access to those objects merely because they live beside its Deployment. Kubernetes RBAC is additive: a narrow Role does not cancel a broader existing grant. Workload-creation rights also need policy controls if developers must be prevented from selecting the reader service account for their own Pods. <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/">[9]</a></p>
<p>The controller watches only <code>shop-secrets-demo</code>, and its ordinary secret-management Role is scoped there. Webhook, certificate-controller and CRD installation still involve cluster-level resources.</p>
<p>A namespaced store keeps this example scoped to one namespace. <code>ClusterSecretStore</code> supports centrally managed sharing; its broader availability and namespace conditions require a separate access design. <a href="https://external-secrets.io/latest/guides/security-best-practices/">[7]</a></p>
<p>The example files are available in the companion repository:</p>
<p><a class="embed-card" href="https://github.com/ferhaty/external-secrets-eks">https://github.com/ferhaty/external-secrets-eks</a></p>

<h2>What do you need before starting?</h2>
<p>Use an existing, non-production EKS cluster and an approved AWS administrator/deployment context. This guide does not provision a cluster, establish a CI pipeline, or create an IAM OIDC provider.</p>
<p>You need:</p>
<ul>
<li><strong>Existing IRSA foundation:</strong> the cluster's issuer registered as an IAM OIDC provider in the same AWS account, with the STS audience configured. Use the ARN of that registered IAM OIDC provider. <a href="https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html">[10]</a></li>
<li><strong>Permission to create the demo resources:</strong> Terraform creates a dedicated Secrets Manager secret, its public dummy value, and the reader IAM role and policy in the same account and region. The deployment identity needs create, read (including <code>secretsmanager:GetSecretValue</code>), update and delete permissions for the demo resources; ESO receives read-only access to that one secret.</li>
<li><strong>Deployment tools:</strong> Terraform 1.9 or later, Helm 3, AWS CLI v2, and a kubectl version compatible with your cluster. The configuration below pins the provider, chart and container image for reproducibility. <a href="https://github.com/external-secrets/external-secrets/releases/tag/helm-chart-2.14.0">[11]</a> <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/v6.71.0/website/docs/r/iam_role.html.markdown">[12]</a> <a href="https://raw.githubusercontent.com/docker-library/official-images/master/library/busybox">[13]</a></li>
<li><strong>Kubernetes permissions:</strong> a platform administrator able to install the chart and create the two example namespaces, service accounts and RBAC resources. The application identity does not need these permissions.</li>
<li><strong>Network access:</strong> ESO must reach the Kubernetes API, DNS, STS and Secrets Manager. Image pulls and the admission webhook must also work. In a private cluster, supply the appropriate private endpoints or controlled egress; an IAM policy does not provide connectivity. <a href="https://external-secrets.io/latest/guides/security-best-practices/">[7]</a></li>
</ul>
<p>The chart installation below assumes no existing ESO installation or shared ESO CRD ownership. Check first. If your platform already runs ESO, let its administrator integrate the store, controller-class and RBAC design into that installation; do not install a second owner of its CRDs or disable another team's controllers.</p>
<p>Run the following from a directory containing the files shown below. Replace the account, ARN and context placeholders before proceeding. Execute each stage separately and stop on errors.</p>
<pre><code class="language-bash">export AWS_REGION=us-east-1
export EKS_CONTEXT=YOUR_EXISTING_EKS_CONTEXT
aws sts get-caller-identity
kubectl --context "$EKS_CONTEXT" cluster-info
helm list --all-namespaces --kube-context "$EKS_CONTEXT"
kubectl --context "$EKS_CONTEXT" get namespaces shop-secrets-demo eso-shop-system
</code></pre>
<p>Confirm that the reported AWS identity and cluster match the intended deployment context. The two namespace lookups should report <code>NotFound</code> for a fresh exercise. If either exists, stop and establish ownership rather than reusing or deleting it. Also inspect the existing ESO release/CRDs with your platform administrator before installation.</p>
<p>The intended configuration is one AWS account and region. Cross-account secrets, resource-policy sharing, custom STS audiences, application admission policies and an existing shared ESO installation are outside this walkthrough.</p>
<h2>1. Create the demo secret and grant one service account read access</h2>
<p>Terraform creates <code>shop/demo/checkout</code> with the JSON value <code>{"apiKey":"demo-only-v1"}</code> and grants the reader role access to its actual ARN. This deliberately public dummy value is stored in Terraform state; do not replace it with a real credential. ESO, not Terraform, manages the Kubernetes Secret. The source property <code>apiKey</code> will map to the Kubernetes key <code>api-key</code>.</p>
<p>Save the following as <code>terraform/main.tf</code>.</p>
<pre><code class="language-json">terraform {
  required_version = "&gt;= 1.9.0, &lt; 2.0.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "6.71.0"
    }
  }
}

provider "aws" {
  region              = var.aws_region
  allowed_account_ids = [var.aws_account_id]
}

variable "aws_region" {
  type    = string
  default = "us-east-1"
}

variable "aws_account_id" {
  type = string
  validation {
    condition     = can(regex("^[0-9]{12}$", var.aws_account_id))
    error_message = "Use the intended 12-digit AWS account ID."
  }
}

variable "oidc_provider_arn" {
  description = "Existing IAM OIDC provider for this EKS cluster."
  type        = string
  validation {
    condition     = can(regex("^arn:aws:iam::[0-9]{12}:oidc-provider/oidc\\.eks\\.[a-z0-9-]+\\.amazonaws\\.com/id/[A-Za-z0-9]+$", var.oidc_provider_arn))
    error_message = "Use the existing EKS OIDC provider ARN, not its HTTPS issuer URL."
  }
}

variable "kms_key_arn" {
  description = "Optional customer-managed key ARN; null for aws/secretsmanager."
  type        = string
  default     = null
  validation {
    condition     = var.kms_key_arn == null ? true : can(regex("^arn:aws:kms:[a-z0-9-]+:[0-9]{12}:key/[A-Za-z0-9-]+$", var.kms_key_arn))
    error_message = "Use a complete KMS key ARN, not an alias or wildcard."
  }
}

variable "demo_api_key" {
  description = "Public dummy value for the propagation exercise; never a real credential."
  type        = string
  default     = "demo-only-v1"
}

resource "aws_secretsmanager_secret" "demo" {
  name                    = "shop/demo/checkout"
  kms_key_id              = var.kms_key_arn
  recovery_window_in_days = 30
}

resource "aws_secretsmanager_secret_version" "demo" {
  secret_id     = aws_secretsmanager_secret.demo.id
  secret_string = jsonencode({ apiKey = var.demo_api_key })
}

locals {
  namespace       = "shop-secrets-demo"
  service_account = "checkout-secret-reader"
  oidc_issuer     = split("oidc-provider/", var.oidc_provider_arn)[1]
}

resource "aws_iam_role" "reader" {
  name = "shop-secrets-demo-reader"
  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect    = "Allow"
      Principal = { Federated = var.oidc_provider_arn }
      Action    = "sts:AssumeRoleWithWebIdentity"
      Condition = {
        StringEquals = {
          "${local.oidc_issuer}:aud" = "sts.amazonaws.com"
          "${local.oidc_issuer}:sub" = "system:serviceaccount:${local.namespace}:${local.service_account}"
        }
      }
    }]
  })
  lifecycle {
    precondition {
      condition = (
        split(":", var.oidc_provider_arn)[4] == var.aws_account_id &amp;&amp;
        startswith(local.oidc_issuer, "oidc.eks.${var.aws_region}.amazonaws.com/") &amp;&amp;
        (var.kms_key_arn == null ? true : startswith(var.kms_key_arn, "arn:aws:kms:${var.aws_region}:${var.aws_account_id}:key/"))
      )
      error_message = "OIDC provider and optional KMS key must belong to the intended account and region."
    }
  }
}

resource "aws_iam_role_policy" "reader" {
  name = "read-checkout-demo-secret"
  role = aws_iam_role.reader.id
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = concat([
      {
        Effect   = "Allow"
        Action   = ["secretsmanager:GetSecretValue"]
        Resource = aws_secretsmanager_secret.demo.arn
      }
      ], var.kms_key_arn == null ? [] : [{
        Effect   = "Allow"
        Action   = ["kms:Decrypt"]
        Resource = var.kms_key_arn
        Condition = {
          StringEquals = {
            "kms:ViaService"                  = "secretsmanager.${var.aws_region}.amazonaws.com"
            "kms:EncryptionContext:SecretARN" = aws_secretsmanager_secret.demo.arn
          }
        }
    }])
  })
}

output "secret_arn" {
  value = aws_secretsmanager_secret.demo.arn
}

output "reader_role_arn" {
  value = aws_iam_role.reader.arn
}
</code></pre>
<p>The trust policy has two exact conditions: the STS audience and the service-account subject. The exact service-account subject limits the trust relationship to the designated reader identity. The provider's allowed-account check and resource precondition also catch account/region mismatches. <a href="https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html">[10]</a></p>
<p>The reader role's only Secrets Manager action is <code>GetSecretValue</code>, scoped to one complete ARN. This example uses an explicit <code>data</code> property mapping, not secret discovery, tag fetching, <code>dataFrom.find</code>, or PushSecret. The pinned AWS provider implementation retrieves this mapping through <code>GetSecretValue</code>; its store validation checks credential retrieval, rather than proving access to every referenced secret. Adding other ESO features can require additional permissions. <a href="https://raw.githubusercontent.com/external-secrets/external-secrets/v2.14.0/providers/v1/aws/secretsmanager/secretsmanager.go">[14]</a></p>
<p>Leave <code>kms_key_arn</code> unset to use the AWS-managed <code>aws/secretsmanager</code> key. Terraform then omits a customer key from the secret configuration. For a customer-managed key, supply its exact ARN: Terraform uses it to encrypt the demo secret and scopes the reader's decrypt permission to it. Its key policy must allow the deployment identity to encrypt and decrypt through Secrets Manager, and the reader role to decrypt. The optional IAM statement limits decryption through regional Secrets Manager and to this secret's encryption context; it cannot override an explicit deny or a restrictive key policy. <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_iam-policies.html">[15]</a> <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/security-encryption.html">[16]</a></p>
<p>Save <code>terraform/terraform.tfvars.example</code>, then replace these illustrative identifiers in your working <code>terraform.tfvars</code>:</p>
<pre><code class="language-json">aws_region        = "us-east-1"
aws_account_id    = "111122223333"
oidc_provider_arn = "arn:aws:iam::111122223333:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/EXAMPLE123"
</code></pre>
<pre><code class="language-bash">cp terraform/terraform.tfvars.example terraform/terraform.tfvars
# Edit terraform.tfvars with the existing account, region and OIDC provider; keep the public dummy value.
terraform -chdir=terraform init
terraform -chdir=terraform fmt -check
terraform -chdir=terraform validate
terraform -chdir=terraform plan -out=reader.tfplan
</code></pre>
<p>Inspect the plan before applying. It should create the demo secret, its value version, the reader role and its inline policy—not the existing OIDC provider, cluster or optional encryption key. The fixed secret and role names must be available. Keep the generated dependency lock file in your configuration repository. Keep local state, saved plans and working variable files out of it.</p>
<pre><code class="language-bash">terraform -chdir=terraform apply reader.tfplan
terraform -chdir=terraform output -raw reader_role_arn
export SECRET_ARN=$(terraform -chdir=terraform output -raw secret_arn)
printf '%s\n' "$SECRET_ARN"
</code></pre>
<p>Use the returned role ARN in <code>store.yaml</code> below and the exported <code>SECRET_ARN</code> as the source ARN in <code>externalsecret.yaml</code>. The AWS provider supports managing a role's policy as a separate resource, which keeps the trust relationship and access policy explicit. <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/v6.71.0/website/docs/r/iam_role.html.markdown">[12]</a></p>
<h2>2. Install a controller with a narrow reconciliation scope</h2>
<p>Save <code>namespaces.yaml</code>:</p>
<pre><code class="language-yaml">apiVersion: v1
kind: Namespace
metadata:
  name: shop-secrets-demo
---
apiVersion: v1
kind: Namespace
metadata:
  name: eso-shop-system
</code></pre>
<p>Save <code>eso-values.yaml</code>:</p>
<pre><code class="language-yaml">fullnameOverride: eso-shop
controllerClass: shop-demo
scopedNamespace: shop-secrets-demo
scopedRBAC: true
installCRDs: true
processClusterStore: false
processClusterExternalSecret: false
processClusterGenerator: false
processClusterPushSecret: false
processPushSecret: false
crds:
  annotations:
    helm.sh/resource-policy: keep
  createClusterSecretStore: false
  createClusterExternalSecret: false
  createClusterGenerator: false
  createClusterPushSecret: false
  createPushSecret: false
serviceAccount:
  create: true
  name: eso-shop
  annotations: {}
rbac:
  serviceAccountTokenCreate: false
  servicebindings:
    create: false
  aggregateToView: false
  aggregateToEdit: false
  aggregateToAdmin: false
extraEnv:
  - name: AWS_EC2_METADATA_DISABLED
    value: "true"
</code></pre>
<p>The important choices are the watched namespace, its scoped controller Role, an explicit controller class, and disabled cluster-wide/push reconciliation. The named class ties this store to this controller configuration; it is routing, not authorization.</p>
<p>The chart normally permits service-account token creation within the controller's RBAC scope. We turn that blanket permission off and add one resource-name-constrained grant in the next stage. We also leave the controller without an AWS role annotation and disable AWS SDK instance-metadata credential discovery in its environment. Restrict Pod access to node credentials at the cluster level as well; this single environment setting is not an isolation boundary for arbitrary workloads. <a href="https://external-secrets.io/latest/guides/security-best-practices/">[7]</a></p>
<pre><code class="language-bash">kubectl --context "$EKS_CONTEXT" create -f namespaces.yaml
helm repo add external-secrets https://charts.external-secrets.io
helm repo update external-secrets
helm install eso-shop external-secrets/external-secrets   --version 2.14.0 --namespace eso-shop-system   --kube-context "$EKS_CONTEXT" -f eso-values.yaml   --wait --timeout 5m
kubectl --context "$EKS_CONTEXT" wait   --for=condition=Established --timeout=120s   crd/secretstores.external-secrets.io crd/externalsecrets.external-secrets.io
</code></pre>
<p>The chart renders <code>external-secrets.io/v1</code> CRDs for the resources in this guide, so the manifests below use <code>v1</code> rather than <code>v1beta1</code>. When upgrading, check the chart and its release notes for API and lifecycle changes. This chart renders CRDs through templates, whose lifecycle behavior differs from Helm's <code>crds/</code> directory. <a href="https://github.com/external-secrets/external-secrets/releases/tag/helm-chart-2.14.0">[11]</a> <a href="https://helm.sh/docs/chart_best_practices/custom_resource_definitions/">[18]</a></p>
<p><code>--wait</code> checks installation readiness, not AWS authentication. The first meaningful AWS-backed checks happen when the store and external secret reconcile.</p>
<h2>3. Connect the store and map the required property</h2>
<p>Save <code>store.yaml</code>. Replace the role ARN with Terraform's output and set the same region as the Terraform-created secret.</p>
<pre><code class="language-yaml">apiVersion: v1
kind: ServiceAccount
metadata:
  name: checkout-secret-reader
  namespace: shop-secrets-demo
  annotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::111122223333:role/shop-secrets-demo-reader
automountServiceAccountToken: false
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: eso-checkout-token
  namespace: shop-secrets-demo
rules:
  - apiGroups: [""]
    resources: ["serviceaccounts/token"]
    resourceNames: ["checkout-secret-reader"]
    verbs: ["create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: eso-checkout-token
  namespace: shop-secrets-demo
subjects:
  - kind: ServiceAccount
    name: eso-shop
    namespace: eso-shop-system
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: eso-checkout-token
---
apiVersion: external-secrets.io/v1
kind: SecretStore
metadata:
  name: checkout-aws
  namespace: shop-secrets-demo
spec:
  controller: shop-demo
  provider:
    aws:
      service: SecretsManager
      region: us-east-1
      auth:
        jwt:
          serviceAccountRef:
            name: checkout-secret-reader
</code></pre>
<p>The Role grants ESO permission to create a token only for <code>checkout-secret-reader</code>; the application receives no AWS access through this grant. ESO's chart supplies the separate namespaced permissions it needs to read service-account metadata and manage the target Secret. <a href="https://external-secrets.io/latest/guides/security-best-practices/">[7]</a></p>
<p>Save <code>externalsecret.yaml</code>, replacing the illustrative <code>remoteRef.key</code> ARN with the full <code>SECRET_ARN</code> printed by Terraform, including its generated suffix:</p>
<pre><code class="language-yaml">apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
  name: checkout-credentials
  namespace: shop-secrets-demo
spec:
  refreshPolicy: Periodic
  refreshInterval: 1m
  secretStoreRef:
    name: checkout-aws
    kind: SecretStore
  target:
    name: checkout-credentials
    creationPolicy: Owner
    deletionPolicy: Retain
  data:
    - secretKey: api-key
      remoteRef:
        key: arn:aws:secretsmanager:us-east-1:111122223333:secret:shop/demo/checkout-AbCdEf
        property: apiKey
        version: AWSCURRENT
        decodingStrategy: None
</code></pre>
<p>These settings make the lifecycle explicit:</p>
<ul>
<li><code>Periodic</code> with <code>1m</code> asks ESO to reconcile periodically. It is not a one-minute end-to-end application-update guarantee.</li>
<li><code>AWSCURRENT</code> follows the current Secrets Manager version label. A <code>uuid/...</code> version reference would pin a version instead of following that label. <a href="https://external-secrets.io/latest/provider/aws-secrets-manager/">[4]</a></li>
<li><code>creationPolicy: Owner</code> creates the target Secret with an ownership relationship to this ExternalSecret. Deleting the ExternalSecret normally lets Kubernetes garbage-collect that target.</li>
<li><code>deletionPolicy: Retain</code> retains the Kubernetes copy when source data disappears. It is not a request to retain the copy after deleting its owning ExternalSecret. <a href="https://external-secrets.io/latest/api/externalsecret/">[2]</a></li>
</ul>
<pre><code class="language-bash">kubectl --context "$EKS_CONTEXT" apply -f store.yaml
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo wait   --for=condition=Ready secretstore/checkout-aws --timeout=120s
kubectl --context "$EKS_CONTEXT" apply -f externalsecret.yaml
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo wait   --for=condition=Ready externalsecret/checkout-credentials --timeout=180s
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo get externalsecret checkout-credentials
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo get secret checkout-credentials
</code></pre>
<p>The store becoming Ready means its provider configuration and credentials passed the store check. The ExternalSecret becoming Ready is the more relevant signal that this particular mapping synchronized. Neither condition proves that the checkout service has reloaded or successfully authenticated with a payment provider.</p>
<p>The plain <code>get secret</code> command shows metadata, type and key count, not the values. Avoid <code>-o yaml</code>, <code>-o json</code>, or decoding <code>.data</code> into shared terminal output. Anyone who can read the Kubernetes Secret can recover its value from the base64-encoded data. <a href="https://kubernetes.io/docs/concepts/configuration/secret/">[19]</a></p>
<h2>4. Consume the secret without giving the application an AWS role</h2>
<p>Use a standard BusyBox container as a small credential-consumption probe. It stands in for the checkout process to demonstrate Kubernetes delivery behavior, without requiring a custom application, container build, HTTP endpoint or payment account.</p>
<p>Save <code>consumer.yaml</code>:</p>
<pre><code class="language-yaml">apiVersion: v1
kind: ServiceAccount
metadata:
  name: checkout-demo
  namespace: shop-secrets-demo
automountServiceAccountToken: false
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: checkout-demo
  namespace: shop-secrets-demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: checkout-demo
  template:
    metadata:
      labels:
        app: checkout-demo
    spec:
      serviceAccountName: checkout-demo
      automountServiceAccountToken: false
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
        runAsGroup: 10001
        fsGroup: 10001
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: consumer
          image: busybox:1.37.0
          command: ["sleep", "2147483647"]
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities:
              drop: ["ALL"]
          resources:
            requests:
              cpu: 10m
              memory: 16Mi
            limits:
              cpu: 100m
              memory: 32Mi
          env:
            - name: CHECKOUT_API_KEY
              valueFrom:
                secretKeyRef:
                  name: checkout-credentials
                  key: api-key
          volumeMounts:
            - name: credentials
              mountPath: /run/checkout
              readOnly: true
      volumes:
        - name: credentials
          secret:
            secretName: checkout-credentials
            defaultMode: 0440
</code></pre>
<p>The two delivery forms intentionally use the same Secret. The environment variable is supplied when the container starts. The volume projects the key into <code>/run/checkout/api-key</code>; there is no <code>subPath</code> mount that would prevent automatic projected updates. A real application using the file must reopen it or implement a suitable reload mechanism rather than assuming a value cached in memory will change. <a href="https://kubernetes.io/docs/concepts/configuration/secret/">[19]</a> <a href="https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/">[20]</a></p>
<pre><code class="language-bash">kubectl --context "$EKS_CONTEXT" apply -f consumer.yaml
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo rollout status   deployment/checkout-demo --timeout=120s
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo exec deployment/checkout-demo -- sh -c '
  test -s /run/checkout/api-key &amp;&amp;
  test -n "$CHECKOUT_API_KEY" &amp;&amp;
  test "$CHECKOUT_API_KEY" = "$(cat /run/checkout/api-key)" &amp;&amp;
  printf "File and environment match; values not printed.\n"
'
</code></pre>
<p>After initial synchronization, that command should report that the file and environment match without printing either value. A missing Secret or key should block this consumer from starting; it is not marked optional. If the command exits unsuccessfully, diagnose the reconciliation and mount before continuing.</p>
<p>The consumer has no Kubernetes Secret-reading Role. Kubelet supplies the referenced Secret to the Pod; the application does not need Kubernetes API access merely to consume an injected value. Container execution, Pod creation, node access, broad Secret RBAC and backups remain relevant exposure paths. <a href="https://kubernetes.io/docs/concepts/security/secrets-good-practices/">[8]</a></p>
<h2>5. What happens when the source value changes?</h2>
<p>There are two separate transitions: ESO updates the Kubernetes Secret, then Kubernetes and the application make that value usable. A mounted Secret is updated eventually; an existing container's environment variables are not. ESO leaves the Deployment running; Pod replacement or application reload is a separate step. <a href="https://kubernetes.io/docs/concepts/configuration/secret/">[19]</a> <a href="https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/">[20]</a></p>
<p>In <code>terraform/main.tf</code>, change the <code>demo_api_key</code> default from <code>"demo-only-v1"</code> to <code>"demo-only-v2"</code>, then plan the update:</p>
<pre><code class="language-bash"># In terraform/main.tf, change the demo_api_key default from "demo-only-v1" to "demo-only-v2".
terraform -chdir=terraform plan -out=rotation.tfplan
</code></pre>
<p>Inspect the plan, then apply it separately:</p>
<pre><code class="language-bash">terraform -chdir=terraform apply rotation.tfplan
</code></pre>
<p>Changing <code>secret_string</code> creates a new Secrets Manager version; it does not overwrite the old version. With <code>version_stages</code> omitted, AWS makes the new version <code>AWSCURRENT</code>, which ESO follows. Keep this demo value managed through Terraform rather than changing it with the console or AWS CLI. This exercises propagation, not rotation of a credential in an external payment system. <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/v6.71.0/website/docs/r/secretsmanager_secret_version.html.markdown">[17]</a></p>
<p>Wait for the periodic reconciliation, or request an immediate reconciliation by updating the ExternalSecret annotation. Record the previous <code>refreshTime</code> before changing the source if you want to compare it with the next successful refresh.</p>
<pre><code class="language-bash">kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo annotate   externalsecret checkout-credentials force-sync="$(date +%s)" --overwrite
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo get externalsecret checkout-credentials   -o jsonpath='{.status.refreshTime}{"\n"}{.status.conditions}{"\n"}'
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo exec deployment/checkout-demo -- sh -c '
  test "$(cat /run/checkout/api-key)" = "demo-only-v2" &amp;&amp;
  test "$CHECKOUT_API_KEY" = "demo-only-v1" &amp;&amp;
  printf "New file, old environment; no values printed.\n"
'
</code></pre>
<p>The final command should eventually report “New file, old environment.” Repeat that check after allowing time for reconciliation and kubelet's projected-volume update. A Ready condition that was already true can return immediately; it is not a barrier proving that this particular new version has reached the Pod. The explicit dummy-value comparison checks that distinction without revealing a real key.</p>
<p>Now replace the consumer Pod:</p>
<pre><code class="language-bash">kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo rollout restart deployment/checkout-demo
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo rollout status deployment/checkout-demo --timeout=120s
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo exec deployment/checkout-demo -- sh -c '
  test "$CHECKOUT_API_KEY" = "demo-only-v2" &amp;&amp;
  test "$CHECKOUT_API_KEY" = "$(cat /run/checkout/api-key)" &amp;&amp;
  printf "Replacement Pod uses the new value in both paths.\n"
'
</code></pre>
<p>After rollout, both paths should use the second value. In a real checkout service, also verify a safe authenticated request to the downstream system. A successful Secret sync, a running Pod, and a successful payment-provider request are three different acceptance checks.</p>
<h3>How does propagation fit into credential rotation?</h3>
<p>A credential must change in the system that validates it as well as in the store that distributes it. AWS describes rotation in terms of updating both the secret and the service's credentials.</p>
<p>This walkthrough covers propagation; a full rotation workflow also coordinates a rotation function or the payment provider's credential lifecycle. <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets.html">[21]</a></p>
<p>Where supported, an overlap period in which old and new credentials are valid can accommodate reconciliation, rolling replacement and in-flight requests. Revoke the old credential only after consumers have switched and authentication has been checked. The overlap duration and rollback procedure depend on the actual provider.</p>
<h2>How do you diagnose a failed synchronization?</h2>
<p>Identify the failing layer while keeping secret values out of diagnostic output. Inspect the SecretStore, ExternalSecret conditions and controller logs, then check the consumer only after the destination Secret exists.</p>
<pre><code class="language-bash">kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo describe secretstore checkout-aws
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo describe externalsecret checkout-credentials
kubectl --context "$EKS_CONTEXT" -n eso-shop-system logs deployment/eso-shop --tail=80
</code></pre>
<p>Logs and events can contain resource identifiers or other operational detail. Review and redact them before sharing, and avoid debug logging that could expose credentials.</p>
<table>
<thead>
<tr>
<th>Symptom</th>
<th>First checks</th>
</tr>
</thead>
<tbody><tr>
<td>Store cannot become Ready</td>
<td>Reader service account exists; role annotation is correct; ESO can request its token; IAM provider, subject and audience match; STS is reachable.</td>
</tr>
<tr>
<td>Store Ready, ExternalSecret not Ready</td>
<td>Full secret ARN, region, <code>GetSecretValue</code> permission, KMS authorization if applicable, JSON property <code>apiKey</code>, and Secrets Manager connectivity.</td>
</tr>
<tr>
<td>No controller activity</td>
<td>Store controller class, watched namespace, disabled reconciler settings, controller readiness and Kubernetes RBAC.</td>
</tr>
<tr>
<td>Consumer cannot start</td>
<td>Target Secret exists in the same namespace and contains <code>api-key</code>; image pull and volume permissions work.</td>
</tr>
<tr>
<td>Secret updated, process still uses old value</td>
<td>Environment variables, an application cache, a long-open file descriptor, or a <code>subPath</code> mount; synchronization is not reload.</td>
</tr>
<tr>
<td>A previously working consumer still runs during an outage</td>
<td>It may be using the last synchronized copy. Continued availability is not proof of freshness.</td>
</tr>
</tbody></table>
<p>For a bounded failure exercise, use only the dedicated demo mapping: change <code>remoteRef.property</code> in <code>externalsecret.yaml</code> to a nonexistent property, apply it, and inspect the ExternalSecret condition after reconciliation. Restore <code>apiKey</code>, reapply and confirm recovery. The pinned provider returns an error for a missing property. Do not alter production IAM policies or delete the AWS secret merely to test failure handling. <a href="https://raw.githubusercontent.com/external-secrets/external-secrets/v2.14.0/providers/v1/aws/secretsmanager/secretsmanager.go">[14]</a></p>
<p>Expect an existing target to remain available under the selected retention behavior while failed refreshes need attention. A first-ever failed sync has no previous copy to retain. Monitor both reconciliation failures and freshness, and separately monitor the application's authentication failures. The existing <a href="https://blog.turingts.com/observability-on-amazon-eks-metrics-logs-and-traces">EKS observability walkthrough</a> covers the surrounding metrics, logs and traces stack for optional further reading.</p>
<h2>What remains sensitive after synchronization?</h2>
<p>ESO reduces where people and delivery jobs have to handle the value. The resulting Kubernetes Secret still requires access controls. Limit Secret <code>get</code>, <code>list</code> and <code>watch</code> access; restrict workload creation and execution; protect node access, backups and diagnostic exports.</p>
<p>Encryption at rest protects storage media, not access by an already authorized API caller. <a href="https://kubernetes.io/docs/concepts/security/secrets-good-practices/">[8]</a></p>
<p>A compromised ESO controller can use the AWS permissions and Kubernetes permissions granted to it. The one-secret policy and single reader-token grant bound this example's intended access, but they do not protect against a cluster administrator or a broader existing grant. Keep the controller namespace platform-managed, review chart upgrades, and make admission and network policy part of your real tenant design.</p>
<p>If the requirement is that the value must never exist as a Kubernetes Secret, this reconciliation pattern does not satisfy it. Evaluate a different consumption design, such as direct application retrieval or an appropriate mounted-secret integration, against that requirement.</p>
<h2>Cleanup without deleting shared dependencies</h2>
<p>Remove only the dedicated resources created by this walkthrough. Stop the consumer first, then delete the ExternalSecret and confirm that its owned Kubernetes Secret disappears. Removing the reader role must wait until this example no longer needs it.</p>
<pre><code class="language-bash"># Only for the dedicated example resources created by this walkthrough.
kubectl --context "$EKS_CONTEXT" delete -f consumer.yaml
kubectl --context "$EKS_CONTEXT" delete -f externalsecret.yaml
kubectl --context "$EKS_CONTEXT" -n shop-secrets-demo wait   --for=delete secret/checkout-credentials --timeout=120s
kubectl --context "$EKS_CONTEXT" delete -f store.yaml
helm uninstall eso-shop --namespace eso-shop-system --kube-context "$EKS_CONTEXT"
terraform -chdir=terraform plan -destroy -out=cleanup.tfplan
</code></pre>
<p>Inspect the destroy plan. It should remove the demo secret and its managed version, plus the example IAM role and inline policy. Apply only after that review:</p>
<pre><code class="language-bash">terraform -chdir=terraform apply cleanup.tfplan
</code></pre>
<p>The demo secret is scheduled for deletion with a 30-day recovery window. Its name cannot be reused until AWS finishes deletion; choose a different demo name if you repeat the exercise sooner. Removing only the Terraform version resource would not delete the secret or its current value, so cleanup removes the secret resource too. <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/v6.71.0/website/docs/r/secretsmanager_secret_version.html.markdown">[17]</a> <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/v6.71.0/website/docs/r/secretsmanager_secret.html.markdown">[24]</a> <a href="https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_DeleteSecret.html">[25]</a></p>
<p>The explicit <code>helm.sh/resource-policy: keep</code> annotation in our values retains the CRDs on Helm uninstall; this walkthrough also leaves its namespaces in place for platform-admin inspection. Retained CRDs become an administrator-owned lifecycle concern—do not assume a later reinstall will automatically adopt them. <a href="https://helm.sh/docs/howto/charts_tips_and_tricks/">[22]</a> Deleting these cluster-scoped CRDs can remove custom resources belonging to other users; leave their removal to the platform administrator. An owner can remove the empty example namespaces later after checking for anything added during the exercise. <a href="https://helm.sh/docs/chart_best_practices/custom_resource_definitions/">[18]</a></p>
<h2>Frequently asked questions</h2>
<h3>Does ESO keep secret values out of Terraform state?</h3>
<p>No. ESO does not control what Terraform stores. This example deliberately provisions a public dummy value with Terraform; a real-secret workflow must account for how values are supplied and retained. <a href="https://developer.hashicorp.com/terraform/language/manage-sensitive-data">[1]</a></p>
<h3>Can the checkout application use the reader service account?</h3>
<p>It should not in this design. The application consumes a Kubernetes Secret and needs no AWS role. Giving its Pod the reader identity would create another path to AWS and undermine the intended separation between synchronization and consumption.</p>
<h3>Does changing Secrets Manager restart the application?</h3>
<p>No. ESO reconciles the target Secret. Projected files update eventually, while an existing environment variable remains unchanged. Use an application reload strategy for files or controlled Pod replacement for environment variables, then verify actual downstream authentication. <a href="https://kubernetes.io/docs/concepts/configuration/secret/">[19]</a> <a href="https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/">[20]</a></p>
<h3>Can several namespaces share the same SecretStore?</h3>
<p>Not a namespaced SecretStore. Use independent stores and appropriately scoped identities, or deliberately design a ClusterSecretStore with namespace restrictions and suitable RBAC. <a href="https://external-secrets.io/latest/api/secretstore/">[3]</a> <a href="https://external-secrets.io/latest/guides/security-best-practices/">[7]</a></p>
<h3>How do you verify end-to-end secret delivery?</h3>
<p>Terraform mock-provider tests check configuration using simulated provider responses. Verifying AWS permissions and live secret synchronization requires an end-to-end check in the target environment. <a href="https://developer.hashicorp.com/terraform/language/tests/mocking">[23]</a></p>
<p>Verify that the intended source value reaches the intended Pod, a changed value propagates as expected, and the application safely starts using it.</p>
<h2>Sources</h2>
<ol>
<li><a href="https://developer.hashicorp.com/terraform/language/manage-sensitive-data">Terraform sensitive data</a></li>
<li><a href="https://external-secrets.io/latest/api/externalsecret/">ESO ExternalSecret API</a></li>
<li><a href="https://external-secrets.io/latest/api/secretstore/">ESO SecretStore API</a></li>
<li><a href="https://external-secrets.io/latest/provider/aws-secrets-manager/">ESO AWS Secrets Manager provider</a></li>
<li><a href="https://external-secrets.io/latest/provider/aws-access/">ESO AWS authentication</a></li>
<li><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/">Kubernetes service accounts and TokenRequest</a></li>
<li><a href="https://external-secrets.io/latest/guides/security-best-practices/">ESO security best practices</a></li>
<li><a href="https://kubernetes.io/docs/concepts/security/secrets-good-practices/">Kubernetes Secret security</a></li>
<li><a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/">Kubernetes RBAC</a></li>
<li><a href="https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html">AWS EKS service-account role association</a></li>
<li><a href="https://github.com/external-secrets/external-secrets/releases/tag/helm-chart-2.14.0">ESO Helm chart 2.14.0 release</a></li>
<li><a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/v6.71.0/website/docs/r/iam_role.html.markdown">AWS Terraform provider 6.71.0 IAM role</a></li>
<li><a href="https://raw.githubusercontent.com/docker-library/official-images/master/library/busybox">Docker Official Images BusyBox tags</a></li>
<li><a href="https://raw.githubusercontent.com/external-secrets/external-secrets/v2.14.0/providers/v1/aws/secretsmanager/secretsmanager.go">ESO 2.14.0 AWS provider implementation</a></li>
<li><a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_iam-policies.html">AWS Secrets Manager identity policies</a></li>
<li><a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/security-encryption.html">AWS Secrets Manager KMS encryption</a></li>
<li><a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/v6.71.0/website/docs/r/secretsmanager_secret_version.html.markdown">AWS Terraform provider 6.71.0 secret version</a></li>
<li><a href="https://helm.sh/docs/chart_best_practices/custom_resource_definitions/">Helm custom resource definitions</a></li>
<li><a href="https://kubernetes.io/docs/concepts/configuration/secret/">Kubernetes Secrets</a></li>
<li><a href="https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/">Kubernetes credential distribution</a></li>
<li><a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets.html">AWS Secrets Manager rotation</a></li>
<li><a href="https://helm.sh/docs/howto/charts_tips_and_tricks/">Helm retained-resource annotation</a></li>
<li><a href="https://developer.hashicorp.com/terraform/language/tests/mocking">Terraform mock-provider tests</a></li>
<li><a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/v6.71.0/website/docs/r/secretsmanager_secret.html.markdown">AWS Terraform provider 6.71.0 secret</a></li>
<li><a href="https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_DeleteSecret.html">AWS DeleteSecret API</a></li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Deploying Terraform to AWS with GitHub Actions and OIDC]]></title><description><![CDATA[Run Terraform on AWS with GitHub Actions and OIDC, using scoped roles, shared state and approval of the exact plan you deploy.]]></description><link>https://blog.turingts.com/deploying-terraform-to-aws-with-github-actions-and-oidc</link><guid isPermaLink="true">https://blog.turingts.com/deploying-terraform-to-aws-with-github-actions-and-oidc</guid><category><![CDATA[Terraform]]></category><category><![CDATA[AWS]]></category><category><![CDATA[GitHub Actions]]></category><category><![CDATA[Infrastructure as code]]></category><category><![CDATA[ci-cd]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Fri, 30 Oct 2026 20:05:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/e196a519-91a2-4605-8462-261612056e3a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As applications grow, teams need to create and change infrastructure more often. Repeating those changes by hand takes time and makes it easy to miss a setting or configure environments differently. The goal is to make infrastructure delivery repeatable and faster, while keeping control over what changes and who can deploy it.</p>
<p>With Infrastructure as Code, you define and manage infrastructure through code. Terraform lets you describe the intended infrastructure in configuration files that you keep under version control. A deployment pipeline adds a shared process around those files, so each change follows the same checks, review and approval steps. The team can see what was proposed, who approved it and what was executed.</p>
<p>That automation also needs access to AWS. Rather than storing a long-lived access key in GitHub, OpenID Connect lets authorised jobs obtain temporary credentials for a specific IAM role. Together, Terraform, GitHub Actions and OIDC provide a way to automate infrastructure changes with less manual work and more controlled cloud access.</p>
<p>To see how these pieces work together, we'll build a deployment pipeline for an online store that uses an Amazon SQS queue for order events. We'll manage the queue with Terraform and use GitHub Actions to check proposed changes against Dev before they're reviewed, merged and deployed there automatically. The same code then moves through Stage and Production, with separate approvals for planning and applying the changes.</p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/60ee480d-cd3d-4ca7-a0fd-870b2d141083.png" alt="Simple deployment pipeline: pull request and Dev plan, approved merge, automatic Dev deployment, then Stage and Production with reviewer approvals" /></p>
<p><em>After PR approval and merge, Dev deploys automatically. Stage and Production each require approval to plan, followed by a second approval to apply that saved plan.</em></p>
<h2>What are we setting up?</h2>
<p>We are building a Terraform delivery pipeline for an Amazon SQS queue across isolated Dev, Stage and Production AWS accounts. GitHub Actions checks proposed changes, deploys Dev after merge, and requires approvals for Stage and Production. OIDC provides temporary AWS access.</p>
<p>The setup has three parts:</p>
<ul>
<li><strong>Terraform:</strong> the queue configuration and a separate S3 state bucket in each AWS account.</li>
<li><strong>AWS access:</strong> one IAM role per environment’s AWS account, shared by plan and apply and trusted through GitHub OIDC.</li>
<li><strong>GitHub Actions:</strong> trusted pull requests plan against Dev; merging into <code>main</code> automatically deploys Dev, followed by gated Stage and Production deployments.</li>
</ul>
<p>The queue keeps the example focused on infrastructure delivery. Application code, queue consumers and their permissions are outside the scope. For an introduction to jobs and runners, see <a href="https://blog.turingts.com/github-actions-an-introduction-to-workflows-and-reusable-workflows">GitHub Actions: An Introduction to Workflows and Reusable Workflows</a>.</p>
<p>You need basic Terraform/YAML knowledge, GitHub repository administration and an approved AWS administrator login for each of the three accounts for initial setup. This guide assumes a private repository with trusted contributors and a GitHub plan that supports required environment reviewers for private repositories. GitHub Free, Pro and Team provide that protection only for public repositories; do not publish sensitive plans to obtain it. <a href="https://docs.github.com/en/actions/reference/workflows-and-actions/deployments-and-environments">[1]</a></p>
<h2>1. Define the infrastructure</h2>
<p>Dev, Stage and Production each run in a separate AWS account. Each account contains its own SQS queue, S3 state bucket, GitHub OIDC provider and IAM role for plan and apply; no AWS resources are shared between environments. Keep each account's one-time foundation separate from the infrastructure it supports. That prevents the queue's deployment role from managing its own access controls.</p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/53f3ba95-a205-4f8d-9ccb-787f58bfa34b.png" alt="AWS infrastructure: three isolated Dev, Stage and Production accounts, each with its own GitHub OIDC provider, IAM role shared by plan and apply, SQS queue and S3 state bucket; regional resources use us-east-1." /></p>
<p><em>Each environment has its own AWS account, queue, state bucket and OIDC-based IAM access. Bootstrap manages each account’s foundation separately; the deployment pipeline manages its queue. This is the intended architecture, not a live deployment.</em></p>
<p>Keep this code in a dedicated <code>store-infra</code> GitHub repository, separate from the application code. <code>.github/workflows/</code> holds the checks and deployment jobs. <code>bootstrap/</code> creates each account’s foundation locally once; <code>terraform/</code> defines the queue, with separate input and backend files for Dev, Stage and Production.</p>
<pre><code class="language-text">store-infra/
├── .github/workflows/
│   ├── pr.yml
│   ├── deploy.yml
│   └── environment.yml
├── bootstrap/
│   ├── versions.tf
│   ├── state.tf
│   ├── identity.tf
│   ├── .terraform.lock.hcl
│   └── tests/identity.tftest.hcl
└── terraform/
    ├── versions.tf
    ├── variables.tf
    ├── main.tf
    ├── vars/
    │   ├── dev.tfvars
    │   ├── dev.backend.hcl
    │   ├── stage.tfvars
    │   ├── stage.backend.hcl
    │   ├── production.tfvars
    │   └── production.backend.hcl
    ├── .terraform.lock.hcl
    └── tests/queue.tftest.hcl
</code></pre>
<p>In <code>terraform/versions.tf</code>, pin the toolchain and declare the S3 backend:</p>
<pre><code class="language-json">terraform {
  required_version = "= 1.17.1"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "= 6.71.0"
    }
  }
  backend "s3" {}
}
provider "aws" {
  region = "us-east-1"
}
</code></pre>
<p>Use one shared queue definition. <code>terraform/variables.tf</code> selects the environment:</p>
<pre><code class="language-json">variable "environment" {
  type = string
  validation {
    condition     = contains(["dev", "stage", "production"], var.environment)
    error_message = "Choose dev, stage or production."
  }
}
</code></pre>
<p>In <code>terraform/main.tf</code>, use it for the queue name and tag:</p>
<pre><code class="language-json">resource "aws_sqs_queue" "store" {
  name                       = "order-events-${var.environment}"
  message_retention_seconds  = 345600
  visibility_timeout_seconds = 60
  sqs_managed_sse_enabled    = true
  tags = {
    Service     = "store"
    Environment = var.environment
    ManagedBy   = "Terraform"
  }
}
output "queue_url" {
  value = aws_sqs_queue.store.url
}
</code></pre>
<p>The example uses encryption, four-day retention and a 60-second visibility timeout. These are teaching choices, not production sizing advice. A real queue also needs suitable retry/dead-letter handling and separate application permissions. <a href="https://github.com/hashicorp/terraform-provider-aws/blob/d5f4cd8a1d0a8ab528685adba1dfbd4595368e9d/website/docs/r/sqs_queue.html.markdown">[2]</a></p>
<p>Each environment gets its own account, resource inputs and state bucket. Create these files in <code>terraform/vars/</code> and replace each bucket placeholder with the bucket created locally by bootstrap in that environment’s account.</p>
<p><code>dev.tfvars</code>:</p>
<pre><code class="language-json">environment = "dev"
</code></pre>
<p><code>stage.tfvars</code>:</p>
<pre><code class="language-json">environment = "stage"
</code></pre>
<p><code>production.tfvars</code>:</p>
<pre><code class="language-json">environment = "production"
</code></pre>
<p><code>dev.backend.hcl</code>:</p>
<pre><code class="language-json">bucket       = "REPLACE-WITH-YOUR-DEV-STATE-BUCKET"
key          = "store/dev/terraform.tfstate"
region       = "us-east-1"
encrypt      = true
use_lockfile = true
</code></pre>
<p><code>stage.backend.hcl</code>:</p>
<pre><code class="language-json">bucket       = "REPLACE-WITH-YOUR-STAGE-STATE-BUCKET"
key          = "store/stage/terraform.tfstate"
region       = "us-east-1"
encrypt      = true
use_lockfile = true
</code></pre>
<p><code>production.backend.hcl</code>:</p>
<pre><code class="language-json">bucket       = "REPLACE-WITH-YOUR-PRODUCTION-STATE-BUCKET"
key          = "store/production/terraform.tfstate"
region       = "us-east-1"
encrypt      = true
use_lockfile = true
</code></pre>
<p>The <code>.tfvars</code> file supplies resource settings to <code>plan</code>; the <code>.backend.hcl</code> file selects the state bucket and key during <code>init</code>. AWS credentials determine the account. Separate accounts and account-local IAM permissions provide the isolation; different variable files alone do not isolate state.</p>
<p>State records which AWS resources Terraform manages. Each account’s S3 bucket gives the team a shared location for that environment only; <code>use_lockfile</code> enables native S3 locking to prevent overlapping Terraform writes. DynamoDB locking is deprecated for this backend. The bucket name is not a secret, but state and saved plan files can contain sensitive values and must stay out of Git. <a href="https://developer.hashicorp.com/terraform/language/state">[3]</a><a href="https://developer.hashicorp.com/terraform/language/backend/s3">[4]</a></p>
<h3>Create the foundation first</h3>
<p>Create the foundation locally, once per AWS account, using a pre-existing short-lived administrator login. The pipeline cannot create the bucket and OIDC roles it needs to start. Use the complete <code>bootstrap/</code> configuration shown below, but keep a clean working directory and separate state for each account.</p>
<p>Once you have created all configuration files shown in this guide, prepare both provider locks from the repository before the copy and <code>-lockfile=readonly</code> commands below:</p>
<pre><code class="language-shell">terraform -chdir=bootstrap providers lock -platform=linux_amd64 -platform=darwin_arm64
terraform -chdir=terraform providers lock -platform=linux_amd64 -platform=darwin_arm64
</code></pre>
<p><code>linux_amd64</code> covers the <code>ubuntu-24.04</code> runners; <code>darwin_arm64</code> is an Apple Silicon workstation example. Replace it with your workstation’s platform, or add further <code>-platform=OS_ARCH</code> flags for other workstations. Review and commit both <code>.terraform.lock.hcl</code> files; subsequent init runs keep them unchanged with <code>-lockfile=readonly</code>. <a href="https://developer.hashicorp.com/terraform/language/files/dependency-lock">[5]</a><a href="https://developer.hashicorp.com/terraform/cli/commands/providers/lock">[6]</a></p>
<p>Bootstrap has no explicit backend block, so <code>terraform init</code> uses Terraform’s default local backend. It does not need the S3 bucket it is about to create. For Dev, replace the profile, globally unique bucket name and immutable repository identity before running:</p>
<p>Run these three groups separately in the same Bash shell; do not paste them together as one script. The fail-fast setting stops on errors and may close an interactive shell. First, check the account:</p>
<pre><code class="language-shell"># From the store-infra repository, after a short-lived Dev administrator login:
set -euo pipefail
export AWS_PROFILE=store-dev-admin
aws sts get-caller-identity # Confirm this is the intended Dev account before proceeding.
</code></pre>
<p>Confirm that the returned <code>Account</code> is the intended Dev account before continuing. Only then initialize and plan:</p>
<pre><code class="language-shell">umask 077
mkdir "$HOME/store-foundation-dev"
cp bootstrap/*.tf bootstrap/.terraform.lock.hcl "$HOME/store-foundation-dev/"
terraform -chdir="$HOME/store-foundation-dev" init -lockfile=readonly
terraform -chdir="$HOME/store-foundation-dev" plan -out=foundation.tfplan \
  -var='environment=dev' \
  -var='state_bucket_name=REPLACE-WITH-YOUR-DEV-STATE-BUCKET' \
  -var='github_repository_subject=example-org@123/store-infra@456'
terraform -chdir="$HOME/store-foundation-dev" show foundation.tfplan
</code></pre>
<p>Review the saved plan’s proposed resources and access policy. Only after accepting it, run the apply group below; applying a saved plan does not ask for confirmation again:</p>
<pre><code class="language-shell">terraform -chdir="$HOME/store-foundation-dev" apply foundation.tfplan
</code></pre>
<p>If an operation fails after creating the foundation directory, retain that account’s directory and state. Reopen Bash if needed, repeat the account check, and rerun init and plan in that directory before reviewing again; do not repeat the initial mkdir/copy steps or delete the existing state.</p>
<p>Repeat from the repository for Stage and Production with their own administrator profiles, <code>environment</code> values, bucket names and new directories (<code>store-foundation-stage</code> and <code>store-foundation-production</code>). Keep the repository identity the same. Never switch accounts in a directory containing another account’s state. If GitHub’s OIDC provider already exists in an account, pass its ARN as <code>github_oidc_provider_arn</code> when planning.</p>
<p>Secure and back up each local foundation state and saved plan; never commit them or give the pipeline roles access. Later migration to separate administrator-controlled remote state is optional. <a href="https://developer.hashicorp.com/terraform/cli/commands/init">[7]</a></p>
<p>After bootstrap, put each bucket name in its environment’s backend file. The pipeline authenticates through the existing OIDC role, then initializes <code>terraform/</code> with <code>-backend-config=vars/dev.backend.hcl</code> (or the matching Stage/Production file). That initializes the workload’s S3 backend, not the foundation’s local state.</p>
<p>This example uses three isolated AWS accounts, the standard <code>aws</code> partition and <code>us-east-1</code>. GitHub assumes roles directly in the target account; no cross-account trust or resource access is configured. Customer-managed KMS keys need additional configuration.</p>
<h2>2. Connect GitHub to AWS with OIDC</h2>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/84c57d95-ce81-42c0-97fe-63c30d5a3127.png" alt="OIDC sequence: GitHub Actions requests a signed token, exchanges it with AWS STS for temporary role credentials, and uses those credentials to call AWS APIs." /></p>
<p><em>GitHub supplies the job identity; AWS validates it and issues temporary credentials for the requested role.</em></p>
<h3>Why use OIDC instead of stored access keys?</h3>
<p>OIDC lets GitHub Actions obtain temporary AWS credentials without storing long-lived access keys. AWS verifies the job’s identity against an IAM role’s trust policy before granting access. This avoids managing reusable keys in GitHub and limits how long issued credentials remain usable.</p>
<p>A traditional setup gives the workflow an IAM user's access key ID and secret access key, stored as GitHub secrets. GitHub protects the stored values, but a job that receives them can use or leak them. Those long-lived keys do not automatically expire: a stolen copy can remain usable until the keys are deactivated or deleted. Rotation means replacing them in both AWS and the systems that use them. <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds.md">[8]</a><a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id-credentials-access-keys-update.md">[9]</a></p>
<p>OIDC replaces that stored credential with a trust relationship. AWS does not simply accept whoever possesses a reusable key; it checks a short-lived, signed identity token issued by GitHub for the job. The exchange works like this:</p>
<ol>
<li>GitHub identifies the job: it issues an OIDC token containing claims such as the repository and deployment environment.</li>
<li>AWS checks the trust policy: the token must come from the expected issuer and match the configured audience and subject, such as this repository's <code>production</code> environment.</li>
<li>AWS STS issues temporary credentials: the job assumes an IAM role and uses its permissions to run Terraform. Those credentials expire automatically at the end of their configured lifetime, not necessarily when the job finishes.</li>
</ol>
<p>For example, we can trust only jobs using the <code>production</code> environment in one repository. GitHub's environment rules then restrict that environment to <code>main</code> and require approval before the apply job starts. A different repository cannot assume the role merely by copying the workflow YAML. <a href="https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-aws">[10]</a></p>
<p>The security advantages are concrete:</p>
<ul>
<li>No long-lived AWS key to store or rotate in GitHub. Each authorised job obtains fresh, temporary access.</li>
<li>A shorter exposure window. Stolen session credentials expire, although they can still be abused while valid.</li>
<li>Access tied to workload identity. The trust policy checks the repository and environment rather than relying only on possession of a static secret.</li>
</ul>
<p>OIDC does not automatically reduce permissions: a static key can also be tightly scoped, and an overly powerful OIDC role is still dangerous. Its strength is combining short-lived credentials with specific identity checks and least-privilege roles. A compromised authorised workflow can still misuse its access. Protect workflow changes, runners and environment approvals. <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_oidc.html">[11]</a></p>
<p>The trust policy decides who may assume the role; the permissions policy decides what that role may do. <code>id-token: write</code> only permits requesting GitHub's token—it does not grant AWS permissions.</p>
<p>Use one IAM role in each environment’s AWS account for both plan and apply. It can manage that environment’s queue, state and lock file. PR planning uses Dev’s deployment-capable role too: running <code>terraform plan</code> does not reduce its IAM permissions. Trusted same-repository workflow authors are inside the Dev access boundary.</p>
<p>This example assumes immutable OIDC subject claims. Set <code>github_repository_subject</code> to your repository identity, such as <code>example-org@123/store-infra@456</code>, using your own names and numeric IDs. The subject suffix follows the GitHub environment used by the job:</p>
<table>
<thead>
<tr>
<th>GitHub environment</th>
<th>Subject suffix for plan and apply</th>
</tr>
</thead>
<tbody><tr>
<td><code>dev</code> (including trusted PR planning)</td>
<td><code>:environment:dev</code></td>
</tr>
<tr>
<td><code>stage</code></td>
<td><code>:environment:stage</code></td>
</tr>
<tr>
<td><code>production</code></td>
<td><code>:environment:production</code></td>
</tr>
</tbody></table>
<p>An environment replaces the branch or PR context in the subject; it is not appended to it. <a href="https://docs.github.com/en/actions/reference/security/oidc">[12]</a></p>
<p>In <code>bootstrap/identity.tf</code>, <code>aws_caller_identity</code> supplies the account ID for IAM resource ARNs. It identifies the current caller; it does not independently verify that you selected the intended account:</p>
<pre><code class="language-json">data "aws_caller_identity" "current" {}

locals {
  oidc_arn = var.github_oidc_provider_arn != null ? var.github_oidc_provider_arn : aws_iam_openid_connect_provider.github[0].arn
}
resource "aws_iam_openid_connect_provider" "github" {
  count          = var.github_oidc_provider_arn == null ? 1 : 0
  url            = "https://token.actions.githubusercontent.com"
  client_id_list = ["sts.amazonaws.com"]
}
resource "aws_iam_role" "terraform" {
  name = "store-terraform-${var.environment}"
  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect    = "Allow"
      Principal = { Federated = local.oidc_arn }
      Action    = "sts:AssumeRoleWithWebIdentity"
      Condition = { StringEquals = {
        "token.actions.githubusercontent.com:aud" = "sts.amazonaws.com"
        "token.actions.githubusercontent.com:sub" = "repo:${var.github_repository_subject}:environment:${var.environment}"
      } }
    }]
  })
}
resource "aws_iam_role_policy" "terraform" {
  role = aws_iam_role.terraform.id
  name = "store-state-and-queue"
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Effect   = "Allow"
        Action   = ["s3:ListBucket"]
        Resource = "arn:aws:s3:::${var.state_bucket_name}"
      },
      {
        Effect   = "Allow"
        Action   = ["s3:GetObject", "s3:PutObject"]
        Resource = "arn:aws:s3:::${var.state_bucket_name}/store/${var.environment}/terraform.tfstate"
      },
      {
        Effect   = "Allow"
        Action   = ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"]
        Resource = "arn:aws:s3:::${var.state_bucket_name}/store/${var.environment}/terraform.tfstate.tflock"
      },
      {
        Effect   = "Allow"
        Action   = ["sqs:GetQueueAttributes", "sqs:GetQueueUrl", "sqs:ListQueueTags", "sqs:CreateQueue", "sqs:SetQueueAttributes", "sqs:TagQueue", "sqs:UntagQueue", "sqs:DeleteQueue"]
        Resource = "arn:aws:sqs:us-east-1:${data.aws_caller_identity.current.account_id}:order-events-${var.environment}"
      }
    ]
  })
}
output "role_arn" {
  value = aws_iam_role.terraform.arn
}
</code></pre>
<p>The trust policy checks the exact audience and repository context. Avoid wildcard repository trust. Each bootstrap run creates only its account’s single role. State-object access, bucket listing and queue permissions stay within that account and environment. Each environment’s role can delete its named queue, so review those changes carefully. <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html">[13]</a><a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_sqs.html">[14]</a></p>
<h3>Configure the GitHub environments</h3>
<p>Create <code>dev</code>, <code>stage</code> and <code>production</code> before running the workflow. Map each GitHub environment to its separate AWS account:</p>
<ul>
<li>Dev: no required reviewers. In selected deployment branch rules, allow <code>main</code> and <code>refs/pull/*/merge</code> so trusted PRs can plan against Dev and merged changes can deploy automatically.</li>
<li>Stage and Production: allow only <code>main</code> and enable required reviewers. Each environment is approved twice: first to start its plan job, then to apply the reviewed plan. Disable self-review and administrator bypass where supported.</li>
<li>Protect <code>main</code>: require PR approval and passing checks, prevent direct pushes, and require review of workflow and Terraform changes.</li>
<li>Keep fork workflows credential-free: do not enable Send write tokens or Send secrets to fork pull requests. Do not use <code>pull_request_target</code> to execute proposed code.</li>
</ul>
<p>The PR plan job references <code>dev</code>. Both deployment jobs reference their target environment, making its variables available through <code>vars</code>. GitHub checks protection rules before each job starts. In Stage and Production, approve planning first; once the plan job finishes, review its output in GitHub Actions and approve the dependent apply job. Configure these rules in GitHub before running the workflow. <a href="https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments">[15]</a></p>
<p>Set <code>AWS_REGION</code> to <code>us-east-1</code> as a GitHub repository variable, since all three environments use that region. In each GitHub environment, set <code>AWS_ROLE_ARN</code> from its own account’s bootstrap <code>role_arn</code> output:</p>
<table>
<thead>
<tr>
<th>Location</th>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody><tr>
<td>Repository</td>
<td><code>AWS_REGION</code></td>
<td><code>us-east-1</code></td>
</tr>
<tr>
<td>Each GitHub environment</td>
<td><code>AWS_ROLE_ARN</code></td>
<td>That account’s <code>store-terraform-&lt;environment&gt;</code> role ARN, shared by plan and apply</td>
</tr>
</tbody></table>
<p>The role ARN identifies the target AWS account, so no separate account-ID variable is needed. The workflows read the region through <code>vars.AWS_REGION</code>; the Terraform provider and S3 backend files also use <code>us-east-1</code>. Neither variable is an access key; keep actual credentials, state and plans out of the repository.</p>
<h2>3. Check pull requests and plan against Dev</h2>
<p>The PR workflow has one <code>plan</code> job for trusted same-repository pull requests. It checks formatting, authenticates through the <code>dev</code> GitHub environment, initializes Dev’s S3 backend, validates and tests the code, and creates a plan using Dev’s <code>.tfvars</code>. Foundation creation and checks stay local.</p>
<p>Planning is privileged: it reads Dev state and executes Terraform configuration and provider code. This path assumes all contributors who can push same-repository branches are trusted with that access. The guard below excludes forks, public repositories and untrusted author associations; it is not a sandbox for hostile contributors. Fork PRs and other excluded contexts are skipped by this workflow. <a href="https://docs.github.com/en/actions/reference/security/secure-use">[16]</a></p>
<p>Use <code>.github/workflows/pr.yml</code>:</p>
<pre><code class="language-yaml">name: Terraform PR checks
on:
  pull_request:
    branches: [main]
permissions:
  contents: read
env:
  TF_IN_AUTOMATION: 'true'
  TF_INPUT: 'false'
jobs:
  plan:
    if: &gt;-
      github.event.repository.private == true &amp;&amp;
      github.event.pull_request.head.repo.id == github.event.repository.id &amp;&amp;
      contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association) &amp;&amp;
      github.actor != 'dependabot[bot]'
    runs-on: ubuntu-24.04
    timeout-minutes: 15
    environment: dev
    permissions:
      contents: read
      id-token: write
    concurrency:
      group: terraform-store-dev
      cancel-in-progress: false
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          ref: ${{ github.sha }}
          persist-credentials: false
      - uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1
        with:
          terraform_version: 1.17.1
          terraform_wrapper: false
      - name: Format
        run: terraform -chdir=terraform fmt -check -recursive
      - uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
        with:
          role-to-assume: ${{ vars.AWS_ROLE_ARN }}
          aws-region: ${{ vars.AWS_REGION }}
          role-session-name: tf-pr-${{ github.run_id }}
      - name: Initialize Dev backend
        run: terraform -chdir=terraform init -input=false -lockfile=readonly -backend-config=vars/dev.backend.hcl
      - name: Validate
        run: terraform -chdir=terraform validate
      - name: Mock tests
        run: terraform -chdir=terraform test
      - name: Plan against Dev
        run: terraform -chdir=terraform plan -input=false -no-color -lock-timeout=5m -var-file=vars/dev.tfvars
</code></pre>
<p>Authentication assumes the configured role directly in Dev’s account before initializing the existing S3 backend. Format, init, validate, test and plan are separate steps, so a failure is easy to locate. The PR plan uses the proposed merge revision and appears in the restricted run log; it is feedback for review, not a plan that will be applied after merge.</p>
<p>Commit <code>terraform/.terraform.lock.hcl</code> so CI uses the same provider versions without changing the lock file. <a href="https://developer.hashicorp.com/terraform/language/files/dependency-lock">[5]</a></p>
<p><code>terraform/tests/queue.tftest.hcl</code> checks all three queue identities without accessing AWS:</p>
<pre><code class="language-json">mock_provider "aws" {}
run "queue_dev" {
  command = plan
  variables {
    environment = "dev"
  }
  assert {
    condition     = aws_sqs_queue.store.name == "order-events-dev" &amp;&amp; aws_sqs_queue.store.tags.Environment == "dev"
    error_message = "Queue identity must match its environment-scoped IAM resource."
  }
  assert {
    condition     = aws_sqs_queue.store.sqs_managed_sse_enabled &amp;&amp; aws_sqs_queue.store.message_retention_seconds == 345600
    error_message = "Retain encryption and four-day retention."
  }
}
run "queue_stage" {
  command = plan
  variables {
    environment = "stage"
  }
  assert {
    condition     = aws_sqs_queue.store.name == "order-events-stage" &amp;&amp; aws_sqs_queue.store.tags.Environment == "stage"
    error_message = "Queue identity must match its environment-scoped IAM resource."
  }
  assert {
    condition     = aws_sqs_queue.store.sqs_managed_sse_enabled &amp;&amp; aws_sqs_queue.store.message_retention_seconds == 345600
    error_message = "Retain encryption and four-day retention."
  }
}
run "queue_production" {
  command = plan
  variables {
    environment = "production"
  }
  assert {
    condition     = aws_sqs_queue.store.name == "order-events-production" &amp;&amp; aws_sqs_queue.store.tags.Environment == "production"
    error_message = "Queue identity must match its environment-scoped IAM resource."
  }
  assert {
    condition     = aws_sqs_queue.store.sqs_managed_sse_enabled &amp;&amp; aws_sqs_queue.store.message_retention_seconds == 345600
    error_message = "Retain encryption and four-day retention."
  }
}
</code></pre>
<p>Mock tests do not evaluate real IAM permissions or AWS behavior. The examples were checked locally; no AWS resources were deployed and the GitHub Actions workflows were not executed live. <a href="https://developer.hashicorp.com/terraform/language/tests/mocking">[17]</a></p>
<h2>4. Deploy Dev, then promote through Stage and Production</h2>
<p>An approved merge triggers a push to <code>main</code>. Dev plans and applies automatically. After Dev succeeds, Stage waits for approval to create its plan, then waits for a second approval before applying that saved plan. Production follows the same two-approval sequence after Stage succeeds. All jobs use the same commit, but each environment gets a fresh plan against its own account, state bucket and inputs.</p>
<p>Use <code>.github/workflows/deploy.yml</code> to define the sequence:</p>
<pre><code class="language-yaml">name: Terraform Deploy
on:
  push:
    branches: [main]
  workflow_dispatch:
permissions:
  contents: read
  id-token: write
jobs:
  dev:
    if: github.ref == 'refs/heads/main'
    uses: ./.github/workflows/environment.yml
    with:
      environment: dev
  stage:
    needs: dev
    uses: ./.github/workflows/environment.yml
    with:
      environment: stage
  production:
    needs: stage
    uses: ./.github/workflows/environment.yml
    with:
      environment: production
</code></pre>
<p>The local reusable workflow avoids repeating the same plan/apply jobs three times. In <code>.github/workflows/environment.yml</code>, both jobs reference the same target environment. The apply job depends on plan, so its review follows the completed plan job:</p>
<pre><code class="language-yaml">name: Terraform Environment
on:
  workflow_call:
    inputs:
      environment:
        required: true
        type: string
permissions:
  contents: read
  id-token: write
env:
  TF_IN_AUTOMATION: 'true'
  TF_INPUT: 'false'
  TARGET_ENV: ${{ inputs.environment }}
jobs:
  plan:
    if: &gt;-
      github.ref == 'refs/heads/main' &amp;&amp;
      contains(fromJSON('["dev","stage","production"]'), inputs.environment)
    runs-on: ubuntu-24.04
    timeout-minutes: 15
    environment: ${{ inputs.environment }}
    concurrency:
      group: terraform-store-${{ inputs.environment }}
      cancel-in-progress: false
    outputs:
      artifact_id: ${{ steps.upload.outputs.artifact-id }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          ref: ${{ github.sha }}
          persist-credentials: false
      - uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1
        with:
          terraform_version: 1.17.1
          terraform_wrapper: false
      - name: Format
        run: terraform -chdir=terraform fmt -check -recursive
      - uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
        with:
          role-to-assume: ${{ vars.AWS_ROLE_ARN }}
          aws-region: ${{ vars.AWS_REGION }}
          role-session-name: tf-plan-${{ github.run_id }}
      - name: Initialize environment backend
        run: terraform -chdir=terraform init -input=false -lockfile=readonly -backend-config="vars/$TARGET_ENV.backend.hcl"
      - name: Validate
        run: terraform -chdir=terraform validate
      - name: Mock tests
        run: terraform -chdir=terraform test
      - name: Create saved plan
        run: |
          mkdir -p plan
          terraform -chdir=terraform plan -input=false -no-color -lock-timeout=5m -var-file="vars/$TARGET_ENV.tfvars" -out=../plan/tfplan
      - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        id: upload
        with:
          name: tfplan-${{ inputs.environment }}-${{ github.run_id }}-${{ github.run_attempt }}
          path: plan/tfplan
          retention-days: 1
          if-no-files-found: error
          overwrite: false
  apply:
    needs: plan
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-24.04
    timeout-minutes: 15
    environment: ${{ inputs.environment }}
    concurrency:
      group: terraform-store-${{ inputs.environment }}
      cancel-in-progress: false
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          ref: ${{ github.sha }}
          persist-credentials: false
      - uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1
        with:
          terraform_version: 1.17.1
          terraform_wrapper: false
      - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
        with:
          artifact-ids: ${{ needs.plan.outputs.artifact_id }}
          path: plan/
          merge-multiple: true
          digest-mismatch: error
      - uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
        with:
          role-to-assume: ${{ vars.AWS_ROLE_ARN }}
          aws-region: ${{ vars.AWS_REGION }}
          role-session-name: tf-apply-${{ github.run_id }}
      - name: Initialize matching backend
        run: terraform -chdir=terraform init -input=false -lockfile=readonly -backend-config="vars/$TARGET_ENV.backend.hcl"
      - name: Apply only this environment's saved plan
        run: terraform -chdir=terraform apply -input=false -lock-timeout=5m ../plan/tfplan
</code></pre>
<p>Reviewers check the proposed changes directly in the plan job’s output in GitHub Actions before approving apply. The artifact contains only the saved Terraform plan, so the apply job can execute that same plan. Dev uses the same workflow without manual approval.</p>
<p>The apply job checks out the same commit and downloads the artifact by ID from the plan job in this workflow run. It assumes the same environment role used by plan in its own account, initializes the matching backend and applies that saved plan. No separate verification script is needed.</p>
<p>Each environment must apply its own saved plan, not the PR plan or another environment’s plan. To retry Dev, Stage or Production, re-run that environment’s plan job in the existing workflow run. GitHub re-runs the selected job and its dependents without repeating completed upstream jobs. A Dev rerun can continue through Stage and Production; a Stage rerun can continue through Production; a Production rerun stays within Production. Stage and Production retain their approvals before plan and apply, while Dev runs automatically. Review the new plan in the job output before approving apply.</p>
<p>A job re-run keeps the original commit and Git ref. Each new plan artifact includes the run attempt in its name, and apply downloads the artifact ID returned by its plan job. If the plan is missing or stale, or an apply partially changed resources, re-run planning rather than blindly retrying apply with the old plan. Use Run workflow when you want a new run from the currently selected <code>main</code> revision, starting at Dev. <a href="https://docs.github.com/en/actions/how-tos/manage-workflow-runs/re-run-workflows-and-jobs">[18]</a></p>
<p>Passing a saved plan to <code>terraform apply</code> counts as Terraform's approval and does not prompt again. Stage and Production each have two environment gates: permission to plan, then approval to apply the saved plan. Dev runs both jobs automatically. <a href="https://developer.hashicorp.com/terraform/cli/commands/plan">[19]</a><a href="https://developer.hashicorp.com/terraform/cli/commands/apply">[20]</a></p>
<p>Saved plans can contain secrets in cleartext, and job logs can also expose sensitive information. Keep workflow logs and artifacts restricted; this example retains the plan artifact for one day. <a href="https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/storing-and-sharing-data-from-a-workflow">[21]</a></p>
<h2>5. Handle overlapping changes and failures</h2>
<p>Job-level concurrency uses <code>terraform-store-dev</code>, <code>terraform-store-stage</code> and <code>terraform-store-production</code>. The PR plan and both Dev deployment jobs share the same Dev group, preventing their operations from overlapping. Only the actual jobs hold these groups—not the reusable-workflow callers, which would risk nested deadlock. S3 native locking remains the state-level safeguard. Neither stops a person or another system changing AWS directly. <code>cancel-in-progress: false</code> avoids cancelling an active apply, but GitHub's default pending-run behavior is not a queue that guarantees every dispatch will execute. <a href="https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency">[22]</a></p>
<p>Concurrency does not reserve state across the approval gap. The plan job releases its group and Terraform lock when it ends; another job can change state while approval waits. Terraform rejects a saved plan if its state is stale. If state or infrastructure changes, regenerate the plan and review again. <a href="https://raw.githubusercontent.com/hashicorp/terraform/v1.17.1/internal/backend/local/backend_local.go">[23]</a></p>
<p>For drift detection, a separate trusted scheduled workflow can reference the target GitHub environment and run <code>terraform plan -detailed-exitcode</code> with its environment role and no apply job. The same environment protection rules still apply, including required reviewers: <code>0</code> means no changes, <code>1</code> an error and <code>2</code> proposed changes. Decide whether to update the code or correct the infrastructure rather than automatically reverting every difference. <a href="https://developer.hashicorp.com/terraform/cli/commands/plan">[19]</a></p>
<p>A failed apply can leave partial changes. Inspect the actual state and resources, fix the cause, then make a fresh plan. Do not blindly replay an old plan or restore old state as though that rolls AWS back. Only force-unlock after confirming that the owning operation is no longer running.</p>
<h2>Reference: the bootstrap files</h2>
<p>These files complete the locally created, administrator-controlled foundation for one environment in one AWS account. Reuse the configuration—not the state—for the other two accounts. The queue’s deployment workflow never applies these files.</p>
<p><code>bootstrap/versions.tf</code>:</p>
<pre><code class="language-json">terraform {
  required_version = "= 1.17.1"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "= 6.71.0"
    }
  }
}
provider "aws" {
  region = "us-east-1"
}
variable "environment" {
  type = string
  validation {
    condition     = contains(["dev", "stage", "production"], var.environment)
    error_message = "Choose dev, stage or production."
  }
}
variable "state_bucket_name" {
  type = string
}
variable "github_repository_subject" {
  type        = string
  description = "Immutable repository identity, without repo: or :environment:; e.g. acme@123/store@456."
  validation {
    condition     = can(regex("^[A-Za-z0-9_.-]+@[0-9]+/[A-Za-z0-9_.-]+@[0-9]+$", var.github_repository_subject))
    error_message = "Use the owner and repository names with their immutable numeric IDs."
  }
}
variable "github_oidc_provider_arn" {
  type        = string
  default     = null
  description = "This account's existing GitHub OIDC provider ARN, or null to create one."
  validation {
    condition     = var.github_oidc_provider_arn == null ? true : var.github_oidc_provider_arn == "arn:aws:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/token.actions.githubusercontent.com"
    error_message = "Reuse only the GitHub OIDC provider in the current AWS account."
  }
}
</code></pre>
<p><code>bootstrap/state.tf</code>:</p>
<pre><code class="language-json">resource "aws_s3_bucket" "state" {
  bucket        = var.state_bucket_name
  force_destroy = false
  lifecycle {
    prevent_destroy = true
  }
}
resource "aws_s3_bucket_versioning" "state" {
  bucket = aws_s3_bucket.state.id
  versioning_configuration {
    status = "Enabled"
  }
}
resource "aws_s3_bucket_public_access_block" "state" {
  bucket                  = aws_s3_bucket.state.id
  block_public_acls       = true
  block_public_policy     = true
  ignore_public_acls      = true
  restrict_public_buckets = true
}
resource "aws_s3_bucket_server_side_encryption_configuration" "state" {
  bucket = aws_s3_bucket.state.id
  rule {
    apply_server_side_encryption_by_default {
      sse_algorithm = "AES256"
    }
  }
}
resource "aws_s3_bucket_policy" "tls" {
  bucket = aws_s3_bucket.state.id
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect    = "Deny"
      Principal = "*"
      Action    = "s3:*"
      Resource  = [aws_s3_bucket.state.arn, "${aws_s3_bucket.state.arn}/*"]
      Condition = { Bool = { "aws:SecureTransport" = "false" } }
    }]
  })
}
</code></pre>
<p>The bucket has versioning, encryption, blocked public access and a TLS-only policy. <code>prevent_destroy</code> protects against deletion through this Terraform configuration; it is not an independent AWS deletion control. Keep foundation state and recovery access separate from routine deployments.</p>
<h2>Frequently asked questions</h2>
<h3>Does OIDC mean the workflow has no secrets?</h3>
<p>No. It removes the need to store a long-lived AWS access key for this exchange. The job still receives temporary credentials and may read sensitive state. Protect the code, runner, action dependencies and outputs that can access them. <a href="https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-aws">[10]</a></p>
<h3>Why not generate another plan after approval?</h3>
<p>The first approval authorizes the plan job; the second approves its proposed changes. After that second approval, apply the same saved plan rather than generating a different one. If it is no longer suitable, restart planning and review. <a href="https://developer.hashicorp.com/terraform/cli/commands/plan">[19]</a></p>
<h3>Can one role handle both plan and apply?</h3>
<p>Yes. This example uses one role per isolated AWS account, shared by that environment’s plan and apply jobs. Planning has the same IAM permissions as applying; environment approvals and trusted workflow code control how that access is used.</p>
<h3>Is the state lock enough to prevent every conflict?</h3>
<p>No. It coordinates clients using that backend lock, not every writer to the AWS resource. Use workflow concurrency as well, keep plans short-lived, and replan when the environment changes. <a href="https://developer.hashicorp.com/terraform/language/backend/s3">[4]</a><a href="https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency">[22]</a></p>
<h2>Sources</h2>
<p>[1] <a href="https://docs.github.com/en/actions/reference/workflows-and-actions/deployments-and-environments">GitHub — Deployments and environments</a></p>
<p>[2] <a href="https://github.com/hashicorp/terraform-provider-aws/blob/d5f4cd8a1d0a8ab528685adba1dfbd4595368e9d/website/docs/r/sqs_queue.html.markdown">HashiCorp AWS provider — SQS queue resource (pinned version)</a></p>
<p>[3] <a href="https://developer.hashicorp.com/terraform/language/state">HashiCorp — Terraform state</a></p>
<p>[4] <a href="https://developer.hashicorp.com/terraform/language/backend/s3">HashiCorp — S3 backend</a></p>
<p>[5] <a href="https://developer.hashicorp.com/terraform/language/files/dependency-lock">HashiCorp — Dependency lock file</a></p>
<p>[6] <a href="https://developer.hashicorp.com/terraform/cli/commands/providers/lock">HashiCorp — terraform providers lock command</a></p>
<p>[7] <a href="https://developer.hashicorp.com/terraform/cli/commands/init">HashiCorp — terraform init</a></p>
<p>[8] <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds.md">AWS — Security credentials and credential lifetimes</a></p>
<p>[9] <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id-credentials-access-keys-update.md">AWS — Update access keys</a></p>
<p>[10] <a href="https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-aws">GitHub — Configuring OpenID Connect in Amazon Web Services</a></p>
<p>[11] <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_oidc.html">AWS — OpenID Connect federation</a></p>
<p>[12] <a href="https://docs.github.com/en/actions/reference/security/oidc">GitHub — OpenID Connect reference</a></p>
<p>[13] <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html">AWS — Create a role for an OpenID Connect identity provider</a></p>
<p>[14] <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_sqs.html">AWS — Amazon SQS actions, resources and condition keys</a></p>
<p>[15] <a href="https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments">GitHub — Managing environments for deployment</a></p>
<p>[16] <a href="https://docs.github.com/en/actions/reference/security/secure-use">GitHub — Secure use reference</a></p>
<p>[17] <a href="https://developer.hashicorp.com/terraform/language/tests/mocking">HashiCorp — Mock providers</a></p>
<p>[18] <a href="https://docs.github.com/en/actions/how-tos/manage-workflow-runs/re-run-workflows-and-jobs">GitHub — Re-running workflows and jobs</a></p>
<p>[19] <a href="https://developer.hashicorp.com/terraform/cli/commands/plan">HashiCorp — terraform plan</a></p>
<p>[20] <a href="https://developer.hashicorp.com/terraform/cli/commands/apply">HashiCorp — terraform apply</a></p>
<p>[21] <a href="https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/storing-and-sharing-data-from-a-workflow">GitHub — Storing and sharing data from a workflow</a></p>
<p>[22] <a href="https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency">GitHub — Control workflow concurrency</a></p>
<p>[23] <a href="https://raw.githubusercontent.com/hashicorp/terraform/v1.17.1/internal/backend/local/backend_local.go">HashiCorp — Saved-plan state checks in Terraform 1.17.1</a></p>
]]></content:encoded></item><item><title><![CDATA[Agentic AI: A Deep Dive]]></title><description><![CDATA[Explore AI models, compute, chips and energy, then see how agents and swarms turn those capabilities into practical work.]]></description><link>https://blog.turingts.com/agentic-ai-a-deep-dive</link><guid isPermaLink="true">https://blog.turingts.com/agentic-ai-a-deep-dive</guid><category><![CDATA[AI]]></category><category><![CDATA[ai agents]]></category><category><![CDATA[llm]]></category><category><![CDATA[agents]]></category><category><![CDATA[Harness]]></category><category><![CDATA[Hermes Agent]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Tue, 27 Oct 2026 10:45:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/f93ef42e-f38c-4b31-b506-8b0feedb620d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>For much of AI’s history, the difficult part was turning a useful idea into a system that could handle unfamiliar situations. Today’s agents extend language models with tools and feedback. Understanding that shift helps explain what they can do, why computing infrastructure matters, and where human control still belongs.</p>
<h2>Why did AI move from rules to models that can use tools?</h2>
<p>Early artificial intelligence tried to make aspects of reasoning explicit in software. The 1955 proposal for the Dartmouth summer research project already connected language, learning, abstraction and self-improvement. It also warned that hardware capacity was not the only obstacle: researchers needed better ways to use it.<a href="https://www-formal.stanford.edu/jmc/history/dartmouth/dartmouth.html">[7]</a></p>
<p>A rule-based program is effective when someone can describe the relevant conditions and actions. “If this field is empty, reject the form” is clear and testable. But imagine writing every rule needed to recognise a cat in photographs, understand a differently phrased question, or decide whether two technical documents contradict each other. The difficulty is not simply executing more rules; it is deciding what those rules should be.</p>
<p><strong>Machine learning</strong> changes the approach: instead of specifying every decision, we fit a model to examples. A <strong>model</strong> is the learned mathematical system used to make predictions or generate outputs. <strong>Deep learning</strong> uses neural networks with multiple processing layers to learn increasingly useful representations of the input. These approaches did not make explicit rules obsolete; they made different kinds of problems tractable.</p>
<p>The longer history contains several different approaches—not just a straight path to today's language models. This timeline provides a map before we focus on the recent breakthroughs.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/e528edad-9218-4307-b576-88cfb7ccf434.png" alt="Selected AI milestones: Turing's 1950 imitation game, the 1955 Dartmouth proposal, a 1986 backpropagation paper, Deep Blue in 1997, ImageNet in 2012, transformers in 2017 and GPT-3 in 2020." style="display:block;margin:0 auto" />

<p><em>Selected milestones in AI research, shown in chronological order. Spacing is illustrative rather than proportional to elapsed years.</em><a href="https://openlearninglibrary.mit.edu/assets/courseware/v1/0c0db957c39184b538869f8d9e9a3b56/asset-v1:MITx+24.09x+3T2019+type@asset+block/5_turing_computing_machinery_and_intelligence.pdf">[83]</a><a href="https://www.nature.com/articles/323533a0">[81]</a><a href="https://research.ibm.com/publications/deep-blue">[82]</a></p>
<p>A useful milestone is the 2012 ImageNet paper by Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton. It combined a deep neural network, a large labelled image dataset, techniques to improve training, and an efficient graphics processing unit (GPU) implementation. Its significance here is the combination: data, algorithms and hardware working together, not a chip independently becoming intelligent.<a href="https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks">[8]</a></p>
<p>Language brought another challenge: relationships between words may span a sentence or a much longer passage. In 2017, <em>Attention Is All You Need</em> introduced the <strong>transformer</strong>, an architecture based on attention mechanisms that let it relate different positions in a sequence. Its design also allowed more parallel training than the recurrent approaches compared in the paper.<a href="https://arxiv.org/abs/1706.03762">[3]</a></p>
<p><strong>Large language models (LLMs)</strong> build on this broader development: they learn patterns from extensive training data and generate language from the context supplied to them. The 2020 GPT-3 paper demonstrated that many tasks could be specified through instructions and examples in a prompt, without separately updating the model’s parameters for each task. Subsequent instruction training and training with human feedback helped make models more useful as assistants.<a href="https://arxiv.org/abs/2005.14165">[4]</a><a href="https://arxiv.org/abs/2203.02155">[44]</a></p>
<h2>How have AI models become more capable?</h2>
<p>Successive model generations have expanded both the range of tasks they can attempt and their performance on difficult tasks. Behind that progress is a physical system: research teams, training data, specialised chips, large computing clusters and the electricity needed to keep them running.</p>
<p>An AI model learns numerical parameters—often called <strong>weights</strong>—that determine how it transforms inputs into outputs. It does not contain a separate hand-written program for every question. Once trained, the same language model can be prompted to explain a concept, compare product descriptions or help write a program. To understand why those abilities keep improving, we need to distinguish who develops the model from who supplies the infrastructure.</p>
<h3>What are AI labs and hyperscalers?</h3>
<p>An AI lab develops models: it researches architectures, prepares training data, runs training experiments and evaluates the results. A hyperscaler operates large-scale cloud and data-centre infrastructure. The lab needs computing capacity; the infrastructure operator supplies some or all of the machines and services that provide it.</p>
<p><strong>OpenAI, Anthropic and Google DeepMind</strong> are examples of organisations developing major model families. <strong>Amazon Web Services, Microsoft Azure, Google Cloud and Oracle Cloud Infrastructure</strong> operate cloud infrastructure that can support AI workloads. The roles can overlap: Google develops models, designs its own tensor processing units (TPUs) and operates cloud infrastructure. “AI lab” and “hyperscaler” describe roles, not mutually exclusive types of company.<a href="https://platform.openai.com/docs/models">[25]</a><a href="https://docs.anthropic.com/en/docs/about-claude/models/overview">[26]</a><a href="https://cloud.google.com/tpu/docs/intro-to-tpu">[79]</a></p>
<p>A lab might build its own cluster, obtain capacity from a cloud provider, or use several partners. A <strong>cluster</strong> is a group of connected computers working together. For large AI workloads, specialised processors called <strong>accelerators</strong> handle much of the numerical work. Graphics processing units (GPUs) are a widely used kind; Google's TPUs are another. Oracle, for example, offers GPU infrastructure for both model training and inference.<a href="https://www.oracle.com/cloud/compute/gpu">[70]</a><a href="https://cloud.google.com/tpu/docs/intro-to-tpu">[79]</a></p>
<h3>How do labs train an AI model?</h3>
<p>Training repeatedly gives a model examples, measures its errors and adjusts its weights to improve its predictions. Large-scale training distributes that numerical work across many accelerators. After broad pre-training, additional training and evaluation can make the model more useful for instructions, reasoning and particular applications.</p>
<p>For a language model, a simplified training cycle is:</p>
<ol>
<li><strong>Prepare the data.</strong> Select and process training material, then encode it as <strong>tokens</strong>: the text units the model processes.</li>
<li><strong>Make predictions.</strong> During pre-training, the model learns to predict tokens from their context. When training starts from scratch, the initial weights do not yet provide useful language ability.</li>
<li><strong>Measure and reduce error.</strong> A loss function measures how the predictions differ from the target. Backpropagation computes gradients—how the loss changes as the weights change—and an optimiser uses them to update the weights.</li>
<li><strong>Repeat at scale.</strong> Process many batches of examples, coordinating computation and exchanging information across the cluster. Save checkpoints so training can resume rather than restart after a failure.</li>
<li><strong>Post-train and evaluate.</strong> Use techniques such as instruction examples, preference feedback and reinforcement learning, then test the model's capabilities and limitations before release.<a href="https://arxiv.org/abs/2005.14165">[4]</a><a href="https://arxiv.org/abs/2203.02155">[44]</a><a href="https://developers.google.com/machine-learning/crash-course/neural-networks/backpropagation">[78]</a></li>
</ol>
<p>The accelerators must exchange information efficiently, not just perform arithmetic independently. NVIDIA’s collective-communication library, for example, supports the multi-GPU and multi-node communication used to scale neural-network training. Faster chips alone are not enough if memory movement or communication holds the cluster back.<a href="https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/overview.html">[47]</a></p>
<p><strong>Inference</strong> is the later use of the trained model to answer a request. Training builds its learned capabilities; inference applies them. But a short definition and a difficult debugging problem need not receive the same amount of computational work. This is where reasoning models and <strong>test-time compute</strong> become useful.</p>
<h3>What are reasoning models and test-time compute?</h3>
<p>Reasoning models are trained to work through difficult problems using intermediate reasoning steps. Test-time compute is the computation spent solving a request during inference. Allocating more of it can improve some answers without increasing the model's parameter count.<a href="https://openai.com/index/learning-to-reason-with-llms">[53]</a></p>
<p>OpenAI's o1 research, for example, used reinforcement learning to teach strategies such as breaking problems into smaller steps and reconsidering an approach. Training develops those strategies; test-time computation applies them to the request at hand.<a href="https://openai.com/index/learning-to-reason-with-llms">[53]</a></p>
<p>Extra computation can go into a longer reasoning process, or into generating several candidate solutions and comparing them. These are different techniques. A longer visible answer is not, by itself, evidence of more or better reasoning.<a href="https://openai.com/index/learning-to-reason-with-llms">[53]</a><a href="https://developers.openai.com/api/docs/guides/reasoning">[107]</a></p>
<p>Some APIs expose a <strong>reasoning-effort</strong> setting. Higher effort can help with difficult debugging or planning, but generally increases latency and token use. OpenAI's API bills hidden reasoning tokens as output tokens, so even a short final answer can involve substantial work. Available settings depend on the model.<a href="https://developers.openai.com/api/docs/guides/reasoning">[107]</a></p>
<p>A hard-to-reproduce bug may justify more computation than formatting a short message. Evaluate correctness, waiting time and total cost together; additional reasoning does not guarantee a correct result.</p>
<p>But a model cannot reason about evidence it never receives. A screenshot, a spoken explanation or a video may contain details that a text-only description leaves out. Working directly with those inputs calls for <strong>multimodal models</strong>.</p>
<h3>What are multimodal models?</h3>
<p>Multimodal models work with more than one kind of data, such as text, images, audio or video. Supported input and output types vary: a model may analyse images and produce text without being able to generate images itself.<a href="https://ai.google.dev/gemini-api/docs/image-understanding">[108]</a><a href="https://ai.google.dev/gemini-api/docs/audio">[109]</a><a href="https://ai.google.dev/gemini-api/docs/video-understanding">[110]</a></p>
<p>During software development, that might mean supplying a screenshot of a broken layout alongside an error message, or asking about a screen recording of an intermittent failure. The visual evidence complements the code and logs; it does not replace a test of the running application.</p>
<p>Input understanding and output generation are separate capabilities. Google's documentation, for example, describes audio analysis that produces text responses, while its model catalogue also includes specialised image, speech and video generation models. Check both what the selected model can receive and what it can produce, through the interface you actually use.<a href="https://ai.google.dev/gemini-api/docs/audio">[109]</a><a href="https://ai.google.dev/gemini-api/docs/models">[27]</a></p>
<p>Media also has a computational cost. Google's image guide notes that higher resolution can improve the recognition of fine text and small details while increasing token use and latency. Supplying a clear, relevant image is a different engineering choice from allocating more reasoning effort to interpret it.<a href="https://ai.google.dev/gemini-api/docs/image-understanding">[108]</a></p>
<p>Working with text, images or audio tells you what a model can do, but not where you can run it. If you want to operate the model yourself rather than only send requests to its developer, you need access to its trained weights. That is the role of <strong>open-weight models</strong>.</p>
<h3>What are open-weight models?</h3>
<p>An open-weight model makes its trained parameter files available to download and run under a licence. That gives you a deployment option beyond the developer's hosted API. It does not automatically include the training data, complete training pipeline or unrestricted usage rights.<a href="https://huggingface.co/moonshotai/Kimi-K3">[112]</a><a href="https://huggingface.co/moonshotai/Kimi-K3/raw/main/LICENSE">[113]</a></p>
<p>The practical advantage is choice: use a hosted endpoint or operate the model yourself, subject to the licence. Self-hosting also makes capacity planning, software updates and serving reliability your responsibility. Downloadable weights do not make the hardware or its operation free.</p>
<p><strong>Moonshot AI</strong>, the company behind Kimi, illustrates this approach. Its <strong>Kimi K3</strong> has published weights and native vision capabilities. <strong>Kimi K3.1 Pro</strong> is a post-trained version of K3, developed with more post-training compute for coding and other agentic work.<a href="https://huggingface.co/moonshotai/Kimi-K3">[112]</a><a href="https://www.kimi.ai/blog/kimi-k3-1-pro">[111]</a></p>
<p><strong>Release status matters.</strong> As checked on 26 October 2026, Moonshot's announcement makes K3.1 Pro available through its applications and API, while promising the full weights by <strong>4 November 2026</strong>. Hosted access is available before the announced weight release; they are not the same milestone.<a href="https://www.kimi.ai/blog/kimi-k3-1-pro">[111]</a></p>
<p>Licences also differ. Kimi K3 uses its own licence, with additional conditions for some model-as-a-service businesses. Check the licence attached to the exact release rather than assuming all open-weight models have identical terms, or that a successor inherits its predecessor's licence.<a href="https://huggingface.co/moonshotai/Kimi-K3/raw/main/LICENSE">[113]</a></p>
<p>Having the files is only the first step. To generate responses, you need compatible inference software—the software that loads the weights and runs the model—and hardware with enough memory and computing capacity. That makes local hardware the next practical choice.</p>
<h3>What hardware can run models locally?</h3>
<p>Smaller models can run on a suitable laptop or desktop; larger ones may need more accelerator memory or several machines. The practical limit depends on the full model, its numerical precision, the context you need and the inference software—not just a processor's headline performance.</p>
<p><strong>Quantisation</strong> stores weights at lower precision to reduce their memory footprint, with possible accuracy trade-offs. As a simple illustration, eight billion parameters stored at four bits each need about <strong>4 GB for weights alone</strong>. You still need room for the model's context cache, runtime buffers and other software; fitting the weights is not the same as obtaining fast responses.<a href="https://huggingface.co/docs/transformers/main/en/quantization/overview">[116]</a></p>
<p>For developers who want a dedicated desktop system, <strong>NVIDIA DGX Spark</strong> combines a GB10 Grace Blackwell chip with a <strong>128 GB unified-memory configuration</strong>, shared by its CPU and GPU. NVIDIA advertises inference with models up to <strong>200 billion parameters</strong>. Treat this as a capacity claim whose usefulness depends on precision, model support and workload—not a guarantee that every such model or context configuration will fit or run quickly.<a href="https://www.nvidia.com/en-us/products/workstations/dgx-spark">[114]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/a09036ee-53e7-4ae4-bd09-c8d515414d56.jpg" alt="NVIDIA DGX Spark beside a laptop on a desk, showing the compact gold-coloured local AI computer." style="display:block;margin:0 auto" />

<p><em>DGX Spark beside a laptop: dedicated model-computing hardware in a desktop-sized system. Image: NVIDIA.</em><a href="https://nvidianews.nvidia.com/news/nvidia-dgx-spark-arrives-for-worlds-ai-developers">[115]</a></p>
<p>This does <strong>not</strong> mean every Kimi model fits on one Spark. Moonshot lists Kimi K3 at approximately <strong>2.8 trillion total parameters</strong>, with <strong>104 billion activated</strong> during processing. Its mixture-of-experts design activates only part of the model for each token; the other weights still have to be stored somewhere.<a href="https://huggingface.co/moonshotai/Kimi-K3">[112]</a> Even an illustrative four-bit representation of all 2.8 trillion parameters would require roughly <strong>1.4 TB for raw weights alone</strong>, before overhead. That complete weight set does not fit in one 128 GB Spark's unified memory.</p>
<p>For a single desktop, start with a smaller supported model and test it at the context length and response speed you actually need. Check that the inference engine supports the model architecture, weight format and hardware. A successful download is not a deployment test.</p>
<p>Desktop systems make experimentation and selected deployments possible. Training frontier models and serving large workloads still require much larger pools of computing capacity. AI data centers bring that infrastructure together.</p>
<h3>What are AI data centers?</h3>
<p>AI data centers are physical facilities that bring together accelerator servers, fast networks, storage, electrical infrastructure and cooling to train and serve AI models. The building is only part of the system: its usefulness depends on making all of those components work together.</p>
<p>Training and inference are software processes, but at large scale they need an industrial operating environment. Four supporting systems matter:</p>
<ul>
<li><strong>Compute and memory.</strong> Accelerator servers perform the numerical work; their memory holds the model state and data needed during computation.</li>
<li><strong>High-speed networks.</strong> Accelerators exchange information during distributed training. A cluster is not simply a collection of independent fast chips: communication can become the bottleneck.<a href="https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/overview.html">[47]</a></li>
<li><strong>Storage and operations.</strong> Training data and checkpoints need to be available when required, while operators must monitor failures and keep jobs recoverable.</li>
<li><strong>Power and heat removal.</strong> Electrical infrastructure supplies the racks, and cooling carries away their heat. Crusoe's Abilene design, for example, describes direct-to-chip liquid cooling; the electrical and cooling systems are part of delivering usable compute, not accessories.<a href="https://www.crusoe.ai/resources/newsroom/crusoe-expands-ai-data-center-campus-in-abilene-to-1-2-gigawatts">[96]</a></li>
</ul>
<p><strong>Abilene makes the scale tangible.</strong> In its March 2025 expansion announcement, Crusoe described an eight-building campus of approximately <strong>4 million square feet—about 372,000 square metres—with a planned power capacity of 1.2 GW</strong>. These are announced full-campus design figures, not a measurement of current utilisation or electricity consumption. Crusoe identifies Oracle as the project's primary customer and strategic partner, with DPR Construction as the lead construction partner.<a href="https://www.crusoe.ai/resources/newsroom/crusoe-expands-ai-data-center-campus-in-abilene-to-1-2-gigawatts">[96]</a><a href="https://www.crusoe.ai/resources/newsroom/crusoe-wins-north-american-data-center-project-of-the-year-at-2025-data-center-dynamics-global-awards">[98]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/3d8768d7-5d29-40a6-ae76-0a36a7867bcf.jpg" alt="Oblique aerial photograph published by DPR Construction of the Crusoe Abilene data-center campus under construction, showing multiple large building groups, roads and surrounding infrastructure." style="display:block;margin:0 auto" />

<p><em>Abilene during construction, published by DPR Construction. Roads, vehicles and repeated building groups make the scale visible. The acquisition dates of these project photographs are not independently confirmed.</em><a href="https://www.dpr.com/projects/crusoe-abilene-data-center">[97]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/2b7371a2-5c17-4e68-95e3-6338cf8faf27.jpg" alt="Closer overhead photograph of data-center buildings and surrounding equipment during construction at the Crusoe Abilene campus, published by DPR Construction." style="display:block;margin:0 auto" />

<p><em>A closer aerial view of the buildings and surrounding installations. Photograph published by DPR Construction.</em><a href="https://www.dpr.com/projects/crusoe-abilene-data-center">[97]</a></p>
<p>The closer view below brings that industrial scale back to human dimensions: workers are installing exterior panels along a data-center building. It shows a part of the construction effort that disappears when we speak only about models, tokens and GPUs.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/c4d108bd-ecaa-4993-bf4f-344d89cc00c6.jpg" alt="Construction workers installing exterior panels on a data-center building, in a close-up published by DPR Construction as part of its Abilene project gallery." style="display:block;margin:0 auto" />

<p><em>Workers installing exterior panels at Abilene. Photograph published by DPR Construction.</em><a href="https://www.dpr.com/projects/crusoe-abilene-data-center">[97]</a></p>
<p>AI capacity needs more than processors: chips, memory, packaging, servers, networks, electrical equipment and construction must come together. Next, we trace that supply chain from chipmaking to AI services.</p>
<h3>How do ASML, NVIDIA and Oracle fit into the supply chain?</h3>
<p>They operate at different layers. ASML supplies machines used to manufacture chips; NVIDIA designs accelerators and computing systems; foundries fabricate the silicon; memory and packaging make usable components; server and cloud infrastructure brings them together. AI labs use that capacity to train and serve models.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/2f2ac940-d1ac-4eeb-9614-bb183d578df4.png" alt="Seven conceptual layers, from ASML and production inputs at the bottom through chip fabrication, accelerator packages, servers, cloud infrastructure and models to agents and applications at the top." style="display:block;margin:0 auto" />

<p><em>Read from bottom to top: chipmaking equipment supports the components, infrastructure and software above it. Companies can operate across several layers.</em></p>
<ul>
<li><strong>Design and upstream inputs.</strong> Chip designers work with design software and intellectual property; manufacturing also needs silicon wafers, chemicals, materials and specialised equipment. These are separate capabilities, not activities performed by one company.</li>
<li><strong>Manufacturing equipment — ASML.</strong> Lithography machines help pattern the circuits on silicon wafers. ASML supplies the equipment and supporting technologies to chipmakers; it does not manufacture finished NVIDIA GPUs.<a href="https://www.asml.com/en/products">[68]</a><a href="https://www.asml.com/en/technology/all-about-microchips/how-microchips-are-made">[77]</a></li>
<li><strong>Chip design and fabrication — NVIDIA and foundries such as TSMC.</strong> NVIDIA develops accelerator architectures and systems, while manufacturing partners fabricate the silicon. NVIDIA's Blackwell Ultra description, for example, identifies TSMC's 4NP manufacturing process.<a href="https://developer.nvidia.com/blog/inside-nvidia-blackwell-ultra-the-chip-powering-the-ai-factory-era">[69]</a></li>
<li><strong>Memory, packaging and testing.</strong> Compute dies need memory and connections. <strong>High-bandwidth memory (HBM)</strong> supplies data close to the accelerator; advanced packaging integrates components so they can communicate efficiently. A shortage of memory or packaging capacity can limit delivery even when the processor design is ready.<a href="https://developer.nvidia.com/blog/inside-nvidia-blackwell-ultra-the-chip-powering-the-ai-factory-era">[69]</a><a href="https://iea.blob.core.windows.net/assets/3179f7f8-01f6-4dd6-bffa-c9f7b73f1dc9/KeyQuestionsonEnergyandAI.pdf">[72]</a></li>
<li><strong>Servers, networks and cloud capacity.</strong> Components become server and rack systems, connected by high-speed networks and supported by power and cooling. Oracle and other cloud operators make such computing capacity available to customers. Oracle belongs at this infrastructure layer—not in the chip-fabrication box.<a href="https://www.oracle.com/cloud/compute/gpu">[70]</a></li>
<li><strong>Models and applications.</strong> AI labs use the infrastructure for training and serving models. Agent developers then build applications around those models, connecting them to tools and users.</li>
</ul>
<p>Two photographs make these layers tangible: the equipment used to pattern chips, and NVIDIA hardware presented on stage.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/12938465-b9b1-44a7-9c81-5325719421ee.jpg" alt="ASML TWINSCAN NXE:3800E EUV lithography system in a Veldhoven cleanroom, with a person in cleanroom clothing showing its scale." style="display:block;margin:0 auto" />

<p><em>ASML's TWINSCAN NXE:3800E EUV lithography system in Veldhoven. Photograph: Michel de Heer / ©ASML.</em><a href="https://ourbrand.asml.com/web/ffdedecebf4d8fe6/asml-com---our-technology/?viewType=list&amp;mediaId=CDDAC2C3-68EB-4991-96C1145FD8C660B6">[104]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/4c054db5-0ba8-4dc5-9efa-c7e1d2c6915d.jpg" alt="Jensen Huang presenting NVIDIA hardware in Taipei on 2 June 2024; photograph by Annabelle Chih, Bloomberg, via Getty Images." style="display:block;margin:0 auto" />

<p><em>Jensen Huang presenting NVIDIA hardware in Taipei on 2 June 2024. Photograph: Annabelle Chih / Bloomberg / Getty Images.</em><a href="https://www.cnn.com/2024/06/03/tech/nvidia-amd-ai-tech-computex-taiwan-intl-hnk/index.html">[140]</a></p>
<p>The supply chain explains how accelerators reach a data center. Their design determines how efficiently they turn that infrastructure into useful work. For an interactive agent, a particularly important question is how quickly a trained model can produce its next response. That is driving specialised inference architectures such as Cerebras' wafer-scale systems.</p>
<h3>Why can specialised chips make inference much faster?</h3>
<p>Inference can be limited by moving data, not just performing calculations. Specialised designs keep model weights close to compute, reduce communication overhead and organise execution around token generation. Their advantage depends on the model, workload and serving system—not a universal ranking of chips.</p>
<p>A model first processes the prompt, a stage called <strong>prefill</strong>, and then generates its response during <strong>decoding</strong>. In ordinary autoregressive decoding, each new token depends on what came before it. At low batch sizes, compute units can spend much of their time waiting for model data rather than doing arithmetic. Faster access to weights and intermediate state can therefore matter as much as more arithmetic units.<a href="https://developer.nvidia.com/blog/mastering-llm-techniques-inference-optimization">[137]</a></p>
<p><strong>Cerebras changes the physical scale of the processor.</strong> Instead of cutting a wafer into many separate processors, its Wafer-Scale Engine keeps a very large grid of compute cores and memory connected on the silicon. Cerebras describes its GPT-5.6 Sol implementation as using <strong>44 GB of on-chip static random-access memory (SRAM) per wafer</strong>, with weights kept on-chip and model layers pipelined across multiple wafers. SRAM is fast memory integrated with the compute.<a href="https://www.cerebras.ai/blog/accelerating-gpt-5-6-sol-ultrafast-with-openai">[130]</a></p>
<p>This reduces repeated movement from external memory and avoids some of the communication and coordination required between separate accelerator chips. It does not eliminate networking: when a model spans several wafers, activations still pass between them. Cerebras' Hot Chips 2026 explanation describes keeping high-volume tensor and expert communication on-wafer while transferring lower-volume activations between systems.<a href="https://www.cerebras.ai/blog/ultrafast-frontier-inference-cerebras-deep-dive-at-hot-chips-2026">[129]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/7dac6aab-7b38-43dc-9ca1-215d2c7c2148.jpg" alt="Cerebras wafer-scale processor, photographed to show the physical scale of the chip." style="display:block;margin:0 auto" />

<p><em>A Cerebras wafer-scale chip held in gloved hands, illustrating the scale of the silicon. Archival press photograph: © Cerebras Systems, Inc.; the photographed generation is not identified here.</em><a href="https://www.cerebras.ai/company/press-kit">[135]</a></p>
<p>Different architectures tackle the same bottleneck in different ways:</p>
<ul>
<li><strong>Cerebras:</strong> wafer-scale compute, on-chip SRAM and short on-wafer connections. Its CS-4 system uses the Nexus rack platform with three Wafer-Scale Engines. The roadmap also describes CS-5, targeted for 2027, and CS-6 with tightly integrated, 3D-stacked DRAM to add memory capacity. Those roadmap claims are plans, not measurements of deployed CS-5 or CS-6 services.<a href="https://www.cerebras.ai/blog/ultrafast-frontier-inference-cerebras-deep-dive-at-hot-chips-2026">[129]</a></li>
<li><strong>Groq's Language Processing Unit (LPU) approach:</strong> on-chip SRAM and compiler-controlled, deterministic execution. The compiler schedules computation and data movement to reduce unpredictable delays, rather than simply relying on a higher peak arithmetic specification.<a href="https://groq.com/blog/the-groq-lpu-explained">[136]</a></li>
<li><strong>NVIDIA GPUs:</strong> high-bandwidth memory, NVLink GPU interconnects and a programmable platform whose kernels and serving software can keep improving. GPUs can be reused across training and inference, and software optimisation can substantially change performance without replacing the entire hardware fleet.<a href="https://developer.nvidia.com/blog/inside-nvidia-blackwell-ultra-the-chip-powering-the-ai-factory-era">[69]</a><a href="https://blogs.nvidia.com/blog/gpus-openai-gpt-6-astra-ultrafast">[133]</a></li>
</ul>
<p>The term “fastest” therefore needs a workload attached. <strong>Time to first token</strong> measures the initial wait; <strong>output tokens per second</strong> measures generation once it starts; <strong>aggregate throughput</strong> measures how much a service can handle across requests. Comparisons need matched models, context lengths, precision and load; even tokenisation can differ between models. A low-latency system for one interactive session is not automatically the cheapest or highest-throughput choice for a large batch. For an agent, the final measure is task-completion time—including tool calls, tests and retries—not token speed alone.<a href="https://developer.nvidia.com/blog/mastering-llm-techniques-inference-optimization">[137]</a></p>
<h3>How does OpenAI use Fast and Ultrafast inference?</h3>
<p>OpenAI exposes faster serving through service tiers, including Fast and Ultrafast. These are delivery options for supported models, not names for one chip architecture. The hardware must be checked for each model and offering: a Cerebras-backed tier and a GPU-backed tier can share the Ultrafast label.</p>
<p>The distinction is concrete:</p>
<ul>
<li><strong>GPT-5.6 Sol Ultrafast on Cerebras.</strong> The August 2026 announcement described up to <strong>750 output tokens per second</strong>, or up to <strong>14 times</strong> Standard processing speed, initially in a limited preview. This is a specific model-and-service result, not a speed guarantee for every model served by Cerebras.<a href="https://openai.com/index/previewing-ultrafast">[138]</a><a href="https://www.cerebras.ai/blog/accelerating-gpt-5-6-sol-ultrafast-with-openai">[130]</a></li>
<li><strong>GPT-6 Astra Ultrafast on NVIDIA Blackwell.</strong> NVIDIA's October 2026 announcement explicitly identifies Blackwell GPUs and reports up to <strong>eight times faster token generation</strong> than Astra Standard. It credits improvements to inference software and kernels, including optimisation work assisted by OpenAI's own models. It would therefore be incorrect to attribute Astra Ultrafast's acceleration to Cerebras.<a href="https://blogs.nvidia.com/blog/gpus-openai-gpt-6-astra-ultrafast">[133]</a></li>
</ul>
<p>For API users, <strong>Fast</strong> is selected with <code>service_tier: "fast"</code>; the older <code>"priority"</code> value is also supported. <strong>Ultrafast</strong> uses <code>service_tier: "ultrafast"</code> and is currently documented for GPT-6 Astra and GPT-6.1 Sol. It has separate rate limits and higher costs. A faster service tier is also different from reducing reasoning effort: one changes how the model is served, while the other changes how much reasoning work it is asked to do.<a href="https://developers.openai.com/api/docs/guides/fast-mode">[131]</a><a href="https://developers.openai.com/api/docs/guides/ultrafast-mode">[132]</a></p>
<p>The surrounding application still matters. OpenAI recommends persistent WebSocket connections for rapid sequences of agent tool calls because repeated network overhead can erode the gains. Faster generation can shorten an edit–test–fix loop, but it does not make a slow test suite, external API or human approval instant.<a href="https://developers.openai.com/api/docs/guides/ultrafast-mode">[132]</a></p>
<p>These examples concern <strong>inference</strong>: using a trained model repeatedly. Training is a different workload with its own scaling story. To compare training runs across model generations, we first need a unit for that work.</p>
<h3>How much has training compute grown?</h3>
<p>Training compute is the total numerical work used to train a model. Estimates for selected large language models have increased by many orders of magnitude. These estimates describe individual training runs, not the entire computing fleet owned by a lab or its cloud partners.</p>
<p>A <strong>FLOP</strong> is a floating-point operation. <strong>FLOP/s</strong>, often written <strong>FLOPS</strong>, measures operations per second:</p>
<ul>
<li><strong>1 TFLOP/s</strong> = one trillion operations per second.</li>
<li><strong>1 PFLOP/s</strong> = one thousand TFLOP/s.</li>
<li><strong>1 EFLOP/s</strong> = one thousand PFLOP/s.</li>
</ul>
<p>The distinction matters: <strong>FLOP is an amount of work; FLOP/s is a rate</strong>. Hardware specifications usually give a theoretical peak rate at a stated numerical precision. Actual training throughput also depends on utilisation, memory movement, communication and interruptions. FP8, FP16 and other formats use different numerical representations, so their advertised throughput figures are not interchangeable.<a href="https://docs.nvidia.com/deeplearning/performance/dl-performance-gpu-background/index.html">[32]</a><a href="https://developer.nvidia.com/blog/inside-nvidia-blackwell-ultra-the-chip-powering-the-ai-factory-era">[69]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/25d1f722-3802-44b5-89e6-ff56466a1dab.png" alt="Line chart of estimated training compute for selected models by publication date, from GPT-1 in 2018 to GPT-6 Astra in 2026. The vertical axis is logarithmic and measures total FLOP, not FLOP per second." style="display:block;margin:0 auto" />

<p><em>Source: Epoch AI's model database, retrieved 26 October 2026. One illustrative model per publication year; not annual maxima, a complete industry series or vendor fleet totals. Points mix paper-supported values and indirect estimates. Hollow markers identify the indirect estimates selected here. Publication year is not necessarily the year the training occurred; connecting lines only guide the eye.</em></p>
<p>For scale, Epoch records approximately <strong>3.14 × 10²³ FLOP</strong> for GPT-3 and estimates <strong>9.4 × 10²⁶ FLOP</strong> for GPT-6 Astra. The latter is an indirect estimate, with a range of roughly <strong>5 × 10²⁶ to 2 × 10²⁷ FLOP</strong> in its estimation notes—not a disclosed meter reading from OpenAI. The difference between those selected points is about 3,000-fold in training work, not a claim of 3,000-fold intelligence.<a href="https://epoch.ai/data/notable_ai_models.csv">[58]</a></p>
<p>A deliberately hypothetical example makes the units tangible: 100,000 accelerators each sustaining 1 PFLOP/s would together deliver 100 EFLOP/s. Running continuously for 90 days would perform about <strong>7.8 × 10²⁶ FLOP</strong>. This is arithmetic illustrating scale, not an inventory or performance claim about any provider. It also does not tell us electricity use without a separate power measurement.</p>
<p>Compute measures the work done during training. The model that comes out of that process has another kind of scale: how many learned parameters it contains.</p>
<h3>Does a higher parameter count mean a better model?</h3>
<p>Parameter count measures the number of learned numerical values in a model, not its intelligence. Larger models can offer more capacity, but training data, architecture and training quality also matter. Newer models can be smaller and still perform better on important tasks.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/c84d7286-0d80-46b8-9a3d-1c70ee2e6df3.png" alt="Line chart of total parameter counts for selected disclosed model examples, including dense models and later mixture-of-experts models. The curve is not monotonic; the vertical axis uses a logarithmic scale." style="display:block;margin:0 auto" />

<p><em>Total parameter counts as recorded in Epoch AI's database. The examples are selected, not the largest model of each year. Kimi K2 and K2.5 use mixture-of-experts architectures; their total weights are not all active for each token. No undisclosed GPT-4, GPT-5 or GPT-6 parameter count has been filled in with speculation.</em></p>
<p>A <strong>dense model</strong> uses its main network throughout processing. A <strong>mixture-of-experts (MoE) model</strong> routes work through a subset of specialised parts. For example, Epoch records Kimi K2 as having one trillion parameters in total but about 32 billion active per forward pass. Comparing its total parameter count directly with the active computation of a dense model would be misleading.<a href="https://epoch.ai/data/notable_ai_models.csv">[58]</a></p>
<p>The dips reflect the selected examples, not changes in the largest available model. The Chinchilla research demonstrated that a smaller model trained on more data could outperform a larger model trained with the same compute budget. Scale matters, but so does how that scale is used.<a href="https://arxiv.org/abs/2203.15556">[5]</a></p>
<p>Neither training compute nor parameter count tells us which tasks a model can complete. For that, we need to look at changes in behaviour and performance.</p>
<h3>What has changed in the models' abilities over time?</h3>
<p>Capability has broadened from flexible text generation towards better instruction following, visual understanding and more demanding reasoning. These are overlapping advances, not a fixed ladder every model climbs. A model's performance should still be checked on the tasks and conditions that matter to its user.</p>
<p>The change becomes clearer when we look at a few milestones:</p>
<ul>
<li><strong>2020 — Learning from examples in a prompt.</strong> The GPT-3 paper demonstrated that one language model could attempt many tasks from written instructions and a few examples, without a separate parameter update for each task.<a href="https://arxiv.org/abs/2005.14165">[4]</a></li>
<li><strong>2022 — Becoming more useful as an assistant.</strong> InstructGPT research used demonstrations and human preferences to improve instruction following. This was a change in how models were trained to respond, not simply an increase in size.<a href="https://arxiv.org/abs/2203.02155">[44]</a></li>
<li><strong>2023 — Working with images as well as text.</strong> The GPT-4 technical report described a model that accepts image and text inputs and produces text outputs. A model could now be asked about visual material, rather than relying only on a typed description.<a href="https://arxiv.org/abs/2303.08774">[52]</a></li>
<li><strong>2024 — Spending more computation on difficult reasoning.</strong> OpenAI's o1 research described training models to work through harder problems and reported better performance with more training and more computation at answer time. A fast reply and a more deliberative reply became meaningful design choices.<a href="https://openai.com/index/learning-to-reason-with-llms">[53]</a></li>
<li><strong>2025 — Stronger problem solving and coding.</strong> OpenAI's GPT-5 developer evaluation reported gains over earlier models on difficult science questions, competition mathematics and coding tasks. These are OpenAI-reported benchmark results, not just more fluent conversation.<a href="https://openai.com/index/introducing-gpt-5-for-developers">[51]</a></li>
<li><strong>2026 — Coordinating agents on frontier research.</strong> OpenAI reports teams of agents using an internal model to investigate Millennium Prize Problems, including a reported Navier–Stokes proof. This extends the story from individual model responses to sustained, tool-assisted research.<a href="https://openai.com/index/navier-stokes-solution">[94]</a></li>
</ul>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/80d17476-7054-45b3-9042-1df4c0e3fc34.png" alt="Selected model-capability milestones from 2020 to 2026, ending with research at swarm scale: OpenAI reports approximately 10,000 concurrent agents in the group responsible for its Navier–Stokes result." style="display:block;margin:0 auto" />

<p><em>Selected milestones, not a complete history or claims that each capability was invented in that year. The examples mainly follow one research lineage to keep the progression readable; other labs contributed parallel advances. New releases do not improve every task equally.</em></p>
<h3>What does the 2026 milestone show?</h3>
<p>Frontier research systems are being used to coordinate many model-driven workers on open scientific problems. OpenAI's published Millennium Prize effort is a concrete example: the capability being tested is sustained, tool-assisted collaboration, not merely answering harder benchmark questions.<a href="https://openai.com/index/navier-stokes-solution">[94]</a></p>
<p>On 8 September 2026, OpenAI reported using an internal model in coordinated groups of agents to investigate open Millennium Prize Problems. The agents could read a cached version of the internet, run code and communicate within their groups. Researchers varied the prompts, redirected effort and consolidated intermediate findings across groups. This was an orchestrated research system, not an unattended chatbot receiving one question.<a href="https://openai.com/index/navier-stokes-solution">[94]</a></p>
<p>OpenAI reported a Navier–Stokes result concerning finite-time singularities in three-dimensional incompressible flow with a smooth external force, and published both a proof write-up and a formalization in <strong>Lean</strong>, a system for expressing and checking mathematical proofs. According to its account, the group that produced this result involved roughly <strong>10,000 concurrent agents</strong>. The internal model used was distinct from its publicly available model at the time.<a href="https://openai.com/index/navier-stokes-solution">[94]</a></p>
<p>Keep the claim's scope clear. This is OpenAI's published research report, not a claim here that a consumer chatbot can solve arbitrary open problems or that all Millennium Prize Problems have been solved. The Clay Mathematics Institute currently lists Navier–Stokes as <strong>Active</strong>, rather than among its solved problems; OpenAI also says it does not intend to claim the prize. A lab announcement, mathematical scrutiny and formal prize recognition are different things.<a href="https://openai.com/index/navier-stokes-solution">[94]</a><a href="https://www.claymath.org/millennium-problems/navier-stokes-equation">[95]</a></p>
<p>This example expands what researchers can attempt, but it does not provide a single measure of intelligence. To compare models more broadly, we need evaluations that go beyond one research result.</p>
<h2>What does “more intelligent” mean in practice?</h2>
<p>Here, intelligence refers to capabilities such as applying knowledge, solving unfamiliar problems and combining constraints. Benchmarks provide imperfect ways to measure those abilities. A useful historical comparison needs consistent methods; parameter counts, computing capacity and a model's confident tone are not substitutes for capability evidence.</p>
<p>The <strong>Epoch Capabilities Index (ECI)</strong> combines results across multiple benchmarks into a common statistical scale. This helps compare models as individual tests become too easy. The scale is arbitrary—not human IQ, a percentage or a measure on which twice the score means twice the intelligence.<a href="https://epoch.ai/benchmarks/eci">[61]</a><a href="https://epoch.ai/data/eci-documentation/methodology">[62]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/2fb0540d-65f6-40a0-b18b-b2eed0f6eb4e.png" alt="Line chart of the highest central Epoch Capabilities Index score among models released in each year from 2023 through 2026, using one fixed data snapshot and 90 percent bootstrap intervals. 2026 is year-to-date." style="display:block;margin:0 auto" />

<p><em>Derived from Epoch AI's 26 October 2026 snapshot. Each point is the highest central ECI score among covered models released that year; 2026 is incomplete. Error bars show the selected model's reported 90% bootstrap interval, not uncertainty in the whole year's frontier. Close or overlapping scores do not establish a decisive winner. The index combines results reported by benchmark creators, Epoch AI and model developers; historical scores can change as the dataset is refitted.</em></p>
<p>This snapshot places the selected annual points at approximately <strong>125.7 in 2023, 141.7 in 2024, 156.3 in 2025 and 168.8 in 2026 so far</strong>. It illustrates rising measured capability, not a universal annual growth rate. In the 2026 data, the central scores of Claude Opus 5.5 and GPT-6 Astra are almost identical and their intervals overlap; the chart is not evidence that one is meaningfully superior.<a href="https://epoch.ai/data/eci_scores.csv">[67]</a></p>
<p>A complementary view comes from <strong>Artificial Analysis</strong>, an independent source of model evaluations and inference-performance data. Its <strong>Intelligence Index v4.3.2</strong> combines ten evaluations across agentic work, coding, general capability and scientific reasoning. This gives readers another way to compare models rather than relying only on claims from their developers.<a href="https://artificialanalysis.ai/methodology/intelligence-benchmarking">[127]</a><a href="https://artificialanalysis.ai/evaluations/artificial-analysis-intelligence-index">[128]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/4940bedd-90eb-46ef-95f1-df3f06036760.png" alt="Original column chart with model configurations on the x-axis and Artificial Analysis Intelligence Index v4.3.2 on the y-axis; same ten models and rounded scores, 26 October 2026." style="display:block;margin:0 auto" />

<p><em>Original visualisation using Artificial Analysis Intelligence Index v4.3.2 data from 26 October 2026. The same ten leading entries from the site's default selection are shown, with the reported rounded scores and reasoning/fallback labels. † marks a model without a publicly available API in that snapshot. Data: Artificial Analysis.</em><a href="https://artificialanalysis.ai">[134]</a></p>
<p>The two charts answer different questions: the ECI view illustrates a historical trend, while this Artificial Analysis view compares selected models under one benchmark methodology. Their numerical scales are not interchangeable. The Intelligence Index is also primarily an English-language, text-based evaluation suite; it is not a complete measure of multimodal ability or performance on your own workload.<a href="https://artificialanalysis.ai/methodology/intelligence-benchmarking">[127]</a></p>
<p>For software development, stronger capability may help a model understand a codebase and diagnose a failing test. Whether a particular implementation is correct still depends on tests and review. Delivering those capabilities at scale also depends on the power supply behind the model.</p>
<h2>Why is electricity becoming an AI bottleneck?</h2>
<p>A computing cluster is useful only when it can receive enough reliable power and remove the resulting heat. AI capacity can expand faster than grid connections, substations, generation and equipment supply chains. The constraint is often getting electricity to the right place in time—not merely generating more worldwide.</p>
<p>The International Energy Agency's <strong>2026</strong> report estimates that global data-centre electricity consumption reached <strong>485 TWh in 2025</strong> and projects approximately <strong>950 TWh in 2030</strong> in its Base Case. These totals cover <strong>all data centres</strong>, not just AI. The report projects faster growth in AI-focused data centres and describes tightening constraints in grid access, transformers, generation equipment and high-bandwidth memory.<a href="https://iea.blob.core.windows.net/assets/3179f7f8-01f6-4dd6-bffa-c9f7b73f1dc9/KeyQuestionsonEnergyandAI.pdf">[72]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/c21f6418-b090-4d67-addd-adab4c44f1e9.png" alt="Dashed line joining the IEA's 2025 estimate of 485 TWh and 2030 Base Case projection of 950 TWh for global data-centre electricity demand. It is a forecast comparison, not observed annual data." style="display:block;margin:0 auto" />

<p><em>Source: IEA, Key Questions on Energy and AI, April 2026. The dashed line links the published 2025 estimate and 2030 Base Case projection; it does not represent annual observations.</em></p>
<p><strong>Power and energy are different measures.</strong> Megawatts (MW) describe an instantaneous power level; terawatt-hours (TWh) describe energy consumed over time. A hypothetical facility drawing 100 MW continuously for a 365-day year would consume 0.876 TWh. A model's FLOP count cannot be converted into electricity consumption using one universal multiplier.</p>
<p>There are several bottlenecks at once. Grid connections and substations take time to build. AI racks concentrate substantial power and heat in a small space. Rapidly changing workloads create swings in demand. Locating a data centre near existing capacity can help, but local planning, water, environmental and affordability concerns also matter. The IEA warns that these physical and social constraints can slow expansion even when capital and demand are available.<a href="https://iea.blob.core.windows.net/assets/3179f7f8-01f6-4dd6-bffa-c9f7b73f1dc9/KeyQuestionsonEnergyandAI.pdf">[72]</a></p>
<h3>What are hyperscalers doing about the energy constraint?</h3>
<p>Hyperscalers are combining long-term electricity procurement, new generation projects, grid partnerships, storage, more flexible workloads and more efficient infrastructure. These measures solve different problems. A signed power agreement does not immediately create a working grid connection, and a future reactor does not power a data centre today.</p>
<ul>
<li><strong>Contracting electricity and supporting new supply.</strong> Long-term <strong>power purchase agreements (PPAs)</strong> help finance generation. Renewable electricity remains important, but matching an annual energy total is not the same as having low-carbon electricity available at that location every hour. The IEA reports growing commitments to renewables, nuclear and geothermal alongside continuing grid constraints.<a href="https://iea.blob.core.windows.net/assets/3179f7f8-01f6-4dd6-bffa-c9f7b73f1dc9/KeyQuestionsonEnergyandAI.pdf">[72]</a></li>
<li><strong>Backing nuclear projects with long lead times.</strong> Microsoft's 2024 agreement with Constellation was a 20-year PPA supporting the planned restart of Three Mile Island Unit 1, announced as approximately 835 MW. Google's 2024 Kairos agreement targeted up to 500 MW from new small modular reactors, with the first reactor targeted by 2030 and further deployments through 2035. Amazon's Energy Northwest agreement supported a planned first phase of roughly 320 MW, with an option to expand to 960 MW. These are examples of announced commitments—not claims that those capacities are already operating.<a href="https://www.constellationenergy.com/news/2024/Constellation-to-Launch-Crane-Clean-Energy-Center-Restoring-Jobs-and-Carbon-Free-Power-to-The-Grid.html">[65]</a><a href="https://blog.google/company-news/outreach-and-initiatives/sustainability/google-kairos-power-nuclear-energy-agreement">[63]</a><a href="https://www.aboutamazon.com/news/sustainability/amazon-nuclear-small-modular-reactor-net-carbon-zero">[64]</a></li>
<li><strong>Making demand more flexible.</strong> Google announced agreements with Indiana Michigan Power and the Tennessee Valley Authority to shift or reduce selected data-centre demand when the grid needs it. Flexible work can be scheduled differently from a live conversation that needs an immediate answer.<a href="https://blog.google/innovation-and-ai/infrastructure-and-cloud/global-network/how-were-making-data-centers-more-flexible-to-benefit-power-grids">[66]</a></li>
<li><strong>Adding storage and considering onsite generation.</strong> Batteries can help manage rapid power swings and support reliability. The IEA also describes proposed onsite gas generation, particularly in the United States, while warning about turbine supply, emissions, costs and technical constraints. Onsite generation is not an automatic escape from infrastructure limits.<a href="https://iea.blob.core.windows.net/assets/3179f7f8-01f6-4dd6-bffa-c9f7b73f1dc9/KeyQuestionsonEnergyandAI.pdf">[72]</a></li>
<li><strong>Improving chips, software and cooling.</strong> Better utilisation and more efficient models reduce the resources needed for a given task. Cooling design also matters, but water and electricity savings are not identical: Microsoft's closed-loop cooling design avoids evaporating water, while its explanation acknowledges a nominal increase in energy use compared with its evaporative designs.<a href="https://www.microsoft.com/en-us/microsoft-cloud/blog/2024/12/09/sustainable-by-design-next-generation-datacenters-consume-zero-water-for-cooling">[80]</a></li>
</ul>
<p>Microsoft's agreement with Constellation connects this energy discussion to a specific place: Three Mile Island in Pennsylvania.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/707e4f26-28be-433b-be84-a0bf011890ec.jpg" alt="Wide photograph of the Three Mile Island site in Pennsylvania, showing cooling towers, water and wooded surroundings, published by Constellation for the Crane Clean Energy Center." style="display:block;margin:0 auto" />

<p><em>The Three Mile Island site, pictured on Constellation's Crane Clean Energy Center page. The restart project concerns Unit 1; Unit 2 is a separate facility. Photograph published by Constellation.</em><a href="https://www.constellationenergy.com/news/2024/Constellation-to-Launch-Crane-Clean-Energy-Center-Restoring-Jobs-and-Carbon-Free-Power-to-The-Grid.html">[65]</a><a href="https://www.constellationenergy.com/about/locations/crane-clean-energy-center.html">[106]</a></p>
<p>The important relationship is therefore <strong>research progress plus manufacturing capacity plus usable compute plus energy infrastructure</strong>. More efficient models can lower energy per task while total demand still grows as more people use them and agents perform more steps. That is why the development of AI is simultaneously a software, semiconductor and energy story.</p>
<p>Yet an assistant that writes a convincing answer still has a practical limitation. It may need a current document, a calculation, or confirmation that an operation actually succeeded. Generating text about those things is not the same as doing them.</p>
<p>Tool-using agents address this gap by bringing external observations into the process. The 2022 <em>ReAct</em> paper explored interleaving language-model reasoning and actions, allowing observations from an environment to influence subsequent steps.<a href="https://arxiv.org/abs/2210.03629">[6]</a></p>
<h2>What makes an AI system agentic?</h2>
<p>An agentic system lets a model help choose an action, use a tool—such as inspecting a project file or running a test—inspect the result and continue towards a goal. The important change is the feedback loop, not a chatbot’s personality or the number of models involved.</p>
<p>A conventional build pipeline follows a predefined sequence: install dependencies, run tests and build the application. An agent can adapt its next step: inspect a failing test, trace the relevant code, make a correction and run the test again. Anthropic’s architectural distinction is useful: workflows follow predefined code paths, while agents let models dynamically direct parts of the process. Many useful systems combine both.<a href="https://www.anthropic.com/engineering/building-effective-agents">[45]</a></p>
<p>Agency can be narrow. An agent might be allowed to inspect tests and propose a fix, while a person decides whether to merge it. The amount of autonomy should follow the task.</p>
<p>Consider this illustrative assignment: <strong>“Build a small online store with product pages, a basket and checkout. Use the payment provider’s test environment, and prepare the changes for review—not production deployment.”</strong></p>
<p>The work is familiar: connect the product pages, basket and checkout, then check that a customer can complete an order. Failed payments and repeated requests need to be handled too.</p>
<p>In this example, the agent works in a development workspace with test payments. It inspects the existing project, clarifies important choices that are still open, then edits the code and runs checks. A developer reviews the changes before they go live.</p>
<p>A language model can describe those changes in a reply. Carrying them out requires software that can work with files and tools, then return the results to the model.</p>
<h2>What software turns a model into an agent?</h2>
<p>A model's reply cannot edit a file or run a test on its own. An agent runtime, or harness, connects the model to tools, executes permitted requests and returns their results. That surrounding software makes an interactive working loop possible.</p>
<p>For the checkout, the model might request a file change followed by a test run. The runtime sends those requests to the development tools and brings the output back. A failing test then becomes information the model can use to choose its next step.</p>
<p><strong>Hermes Agent</strong> is one implementation of that runtime. It prepares the model's input, connects it to available tools and stores conversation state so the work can continue. The model supplies the reasoning; Hermes manages the surrounding loop.<a href="https://hermes-agent.nousresearch.com/docs/developer-guide/architecture">[9]</a></p>
<h3>Where should the agent run?</h3>
<p>An agent can run on a laptop, a server or a hosted platform. A laptop suits an interactive development session. Work that needs to remain reachable or start on a schedule benefits from an environment whose availability does not depend on that laptop.</p>
<p>When an agent is building software or handling another long-running task, you may want it to continue after you close your laptop. You may also want to pick up the work later from another device. That calls for a persistent, remotely accessible environment with the files, tools and task state kept together.</p>
<p>You can provide that environment yourself on a server. A managed agent platform brings together the operational pieces: running the harness, retaining its files, exposing interfaces and scheduling work.</p>
<p>One option is <strong>Agent37</strong>, an always-on agent platform with managed instances and templates for runtimes such as Hermes. In this example, Agent37 provides the host; Hermes continues to manage the agent loop, and the selected model supplies inference.<a href="https://www.agent37.com/docs/agents-api/concepts.md">[37]</a><a href="https://www.agent37.com/docs/agents-api/models.md">[38]</a></p>
<p>The architecture below separates the hosted runtime and its local tools from the model providers and connected services it calls.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/8c7da28b-07ae-4992-91fc-eb1054fa6782.png" alt="Logical Agent37 platform architecture: isolated Hermes instance, browser and development tools, persistent state, credential handling, external model inference, managed Composio integrations and website access." style="display:block;margin:0 auto" />

<p><em>An illustrative logical deployment, not a map of a private installation or a security audit. The default sandbox, optional desktop and external services have distinct boundaries; hardening does not make authorised account access harmless.</em></p>
<ul>
<li><strong>Execution and isolation.</strong> Agent37 describes its default instance type as gVisor-based, while full VM instances are a separate option. gVisor places an application-kernel boundary between sandboxed software and the host operating system, reducing exposure to the host kernel. That is a concrete isolation mechanism—not proof that every command, plugin or external action inside the instance is safe.<a href="https://www.agent37.com/docs/agents-api/vm-instances.md">[84]</a><a href="https://gvisor.dev/docs/">[85]</a></li>
<li><strong>Persistent state.</strong> Files, project state and saved configuration can outlive a conversation. Agent37 preserves the home data directory across image updates; the operating-system layer is reset on an update. Keep durable agent data in that persistent location and treat backups, retention and recovery as separate responsibilities.<a href="https://www.agent37.com/docs/agents-api/instance-lifecycle.md">[86]</a></li>
<li><strong>Browser and development tools.</strong> The stock Hermes template includes Chromium automation for opening pages, interacting with forms and inspecting results. A separate desktop-template recipe adds a visible browser that a person can watch and take over. For our example, those capabilities let the agent inspect a test checkout rather than infer its behaviour from source code alone.<a href="https://www.agent37.com/docs/agents-api/desktop.md">[87]</a></li>
<li><strong>Connected applications.</strong> Agent37's managed Composio service provides a route to supported external apps. <strong>OAuth</strong> lets a person authorise an application to access an account without handing that application their account password. Check the actual account and granted permissions: being able to discover a tool is not permission to execute every action it supports. Browser sessions and direct integrations are separate access paths, not automatically routed through Composio.<a href="https://www.agent37.com/docs/agents-api/managed-services.md">[88]</a></li>
</ul>
<p>Agent37 instances run continuously by default. With optional auto-sleep, an idle instance can pause and wake when a request arrives. Platform schedules can also wake it, unlike timers running inside a sleeping container. Durable task state belongs in files so it survives restarts.<a href="https://www.agent37.com/docs/agents-api/instance-auto-sleep.md">[92]</a><a href="https://www.agent37.com/docs/agents-api/crons.md">[93]</a></p>
<p>A hosted workspace solves the problem of keeping an agent available, but it leaves another choice: use an agent someone has already packaged for you, or choose the runtime, tools and operating rules yourself. Both approaches can support <strong>always-on agents</strong>, with different amounts of setup and control.</p>
<h3>Which always-on agents and platforms can you use?</h3>
<p>Ready-made agents combine models, memory, connected apps and background work in a product. Managed platforms host a runtime you configure; developer services provide building blocks for agents you build. Compare what continues between messages, what triggers new work and which actions still need approval.</p>
<p>Here, <strong>always-on means continuity</strong>, not that a model is generating tokens every second. A service may continue a long task, wake on a schedule or react to an event. Those behaviours differ from continuous monitoring, and persistent files do not imply an unlimited process lifetime.</p>
<p>The comparison below separates ready-made agents from managed hosts, agent builders and cloud runtimes. The latter can support an always-on application, but you still have to design its behaviour. Capabilities and access conditions are based on provider documentation checked on <strong>26 October 2026</strong>, not hands-on testing of every product.</p>
<table>
<thead>
<tr>
<th>Product / layer</th>
<th>Work over time</th>
<th>Tools / context</th>
<th>Con­trols / limits</th>
</tr>
</thead>
<tbody><tr>
<td><strong>OpenAI Dots</strong><br />ChatGPT agent</td>
<td>Ongoing goals, sched­uled checks and pro­active re­search.</td>
<td>Cloud com­puter, con­nected apps and ChatGPT memory; op­tional local access.</td>
<td>Custom rules, pause and take­over. Plan and region gates.<br /><a href="https://help.openai.com/en/articles/20001530-getting-started-with-your-dot">[117]</a></td>
</tr>
<tr>
<td><strong>Claude Duet</strong><br />Per­sonal agent</td>
<td>Morning briefs, account checks and longer tasks.</td>
<td>Cloud VM and browser; Claude memory, skills and apps.</td>
<td>Approve sensi­tive actions. US Pro/Max preview waitlist.<br /><a href="https://claude.com/resources/articles/claude-duet">[118]</a></td>
</tr>
<tr>
<td><strong>Meta Muse</strong><br />Per­sonal agent</td>
<td>Ongoing goals, errands and busi­ness tasks.</td>
<td>Cloud browser and con­nected apps; Muse app or WhatsApp.</td>
<td>Sentinel checks, ap­provals and activ­ity log. US / Canada rollout.<br /><a href="https://about.fb.com/news/2026/09/introducing-muse-personal-ai-agent">[119]</a><a href="https://about.fb.com/news/2026/09/introducing-muse-small-business">[120]</a></td>
</tr>
<tr>
<td><strong>Grok Bot</strong><br />Per­sonal / team agents</td>
<td>Named bots, parallel work and sched­uled routines.</td>
<td>Browser, terminal and files; your bots share a cloud com­puter and app logins.</td>
<td>Ap­proval re­quests; access and usage depend on plan.<br /><a href="https://docs.x.ai/grok-bot/overview.md">[121]</a></td>
</tr>
<tr>
<td><strong>Manus</strong><br />Task agent</td>
<td>Recurring work in tasks, Projects and built web apps.</td>
<td>Files, skills and app links; cloud-com­puter options.</td>
<td>Run history and sched­ule settings. Review the “skip confir­mations” setting.<br /><a href="https://manus.im/blog/manus-schedules">[122]</a></td>
</tr>
<tr>
<td><strong>Agent37</strong><br />Man­aged plat­form</td>
<td>Hosted harnesses, durable files and sched­ules that can wake sleep­ing in­stances.</td>
<td>Choice of runtimes and models; tools depend on the chosen tem­plate.</td>
<td>You config­ure agent access and work­flows. Optional auto-sleep.<br /><a href="https://www.agent37.com/docs/agents-api/concepts.md">[37]</a><a href="https://www.agent37.com/docs/agents-api/crons.md">[93]</a></td>
</tr>
<tr>
<td><strong>Claude Man­aged Agents</strong><br />Man­aged harness</td>
<td>Long-running, stateful sessions and sched­uled deploy­ments.</td>
<td>Bash, files, web tools, MCP and skills.</td>
<td>API beta; not eligible for zero data retention. You config­ure the environ­ment and tools. Separate from Duet.<br /><a href="https://platform.claude.com/docs/en/managed-agents/overview">[123]</a></td>
</tr>
<tr>
<td><strong>Micro­soft Copilot Studio</strong><br />Agent builder</td>
<td>Event and recur­rence triggers for busi­ness work­flows.</td>
<td>Connectors, busi­ness data, actions and flows.</td>
<td>These triggers use maker creden­tials; design access bound­aries carefully.<br /><a href="https://learn.microsoft.com/en-us/microsoft-copilot-studio/authoring-triggers-about">[124]</a></td>
</tr>
<tr>
<td><strong>AWS Bed­rock Agent­Core</strong><br />Cloud runtime</td>
<td>Asyn­chro­nous work; runtime sessions up to eight hours.</td>
<td>Your agent code and tool links, in an isolated microVM.</td>
<td>Runtime state is ephe­meral; use Agent­Core Memory or your own store for dura­bility. Design orches­tration sepa­rately.<br /><a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-how-it-works.html">[125]</a></td>
</tr>
<tr>
<td><strong>Google Agent Plat­form</strong><br />Cloud runtime</td>
<td>Man­aged agent runtime, sessions and long-term memory services.</td>
<td>Your agent appli­cation, code sandbox and observ­ability.</td>
<td>Deploy­ment and access design required; not a ready-made personal agent.<br /><a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/scale">[126]</a></td>
</tr>
</tbody></table>
<p><strong>Access is not global.</strong> OpenAI's Pro rollout excludes the European Economic Area, Switzerland and the UK; Business Premium and Enterprise have separate workspace eligibility rules. Claude Duet starts with a US Pro/Max waitlist. Meta's later small-business announcement describes Muse as available in the US and Canada. Check the exact plan and region before treating any row as available to you.<a href="https://help.openai.com/en/articles/20001530-getting-started-with-your-dot">[117]</a><a href="https://claude.com/resources/articles/claude-duet">[118]</a><a href="https://about.fb.com/news/2026/09/introducing-muse-small-business">[120]</a></p>
<p>The operating behaviour matters as much as the label. Anthropic says Duet checks connected accounts every few hours, rather than continuously. Agent37 schedules can wake a sleeping instance, while an explicitly stopped instance stays stopped. AWS documents a maximum runtime-session lifetime and idle timeouts; durable state must be stored separately. These are different ways to manage work over time.<a href="https://claude.com/resources/articles/claude-duet">[118]</a><a href="https://www.agent37.com/docs/agents-api/crons.md">[93]</a><a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-how-it-works.html">[125]</a></p>
<p>For a morning brief or routine administrative work, start by checking whether a ready-made agent already has the right connections and approval behaviour. If you need to choose the harness and model or retain a development workspace, a managed platform gives you more of those choices. For an agent embedded in your own business application, a builder or cloud runtime may be the better starting point. Test the actual task, including pauses, approvals and recovery, rather than choosing on the promise of autonomy alone.</p>
<p>Whichever option you choose, you still need a way to give the agent tasks and receive its results.</p>
<h2>How can you interact with your agent?</h2>
<p>You can interact with an agent through a terminal, an editor, a web or desktop app, a chat service or an application interface. These are different ways to give it tasks and receive results. The available surfaces depend on the runtime and integrations you enable.</p>
<p>For the store-building assignment, an engineer might start inside the code editor, inspect the diff in a web interface and receive a progress summary in a messaging app. That does not mean every interface automatically shares the same session or permissions.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/22fb9324-4542-46ac-b701-0c070e75516a.png" alt="Several interfaces connect to an agent runtime: terminal and IDE, web and desktop apps, messaging services such as WhatsApp or Slack, and application APIs." style="display:block;margin:0 auto" />

<ul>
<li><strong>Terminal or integrated development environment (IDE).</strong> Useful when the work centres on a repository, local tools, code changes and tests.</li>
<li><strong>Web or desktop app.</strong> A visual workspace for conversations, files, review and longer-running tasks.</li>
<li><strong>Messaging apps.</strong> WhatsApp, Telegram, Slack or another supported channel lets you ask questions, provide instructions and receive results in an existing communication habit.</li>
<li><strong>Application interfaces and automation.</strong> An API or event integration lets your own software submit work and consume results. The application still needs an explicit scope and permission model.</li>
</ul>
<p>Hermes's documented entry points include command-line, messaging and application interfaces; Claude Code similarly documents multiple terminal, editor, desktop and web surfaces. These are product capabilities to check, not a guarantee that every agent supports every channel.<a href="https://hermes-agent.nousresearch.com/docs/developer-guide/architecture">[9]</a><a href="https://code.claude.com/docs/en/overview">[16]</a></p>
<p>Once you have given the agent an assignment, it needs tools to inspect and change the project.</p>
<h2>How does the agent work with a real codebase?</h2>
<p>The model does not know the current state of your project just because it can discuss programming. It needs tools to inspect files, make permitted changes and run checks. The runtime executes those operations and returns their results so the model can choose its next step.</p>
<p>A <strong>tool call</strong> is a structured request with arguments—for example, a file path to inspect or a test command to run. The model proposes the call; the runtime carries it out. A response might contain source code, a test failure or a build result. A proposed call is not evidence that the operation succeeded.<a href="https://ai.google.dev/gemini-api/docs/function-calling">[42]</a></p>
<p>Local tools may be enough to inspect the store's files and run its tests. But suppose the checkout bug is described in an issue tracker, or the finished change needs to be submitted for code review. The agent now needs to work with systems outside its project directory.</p>
<p>A connector bridges that gap. It calls the service's <strong>application programming interface (API)</strong> and exposes useful operations to the agent, such as reading an issue or opening a review request. The service still has its own authentication requirements and permissions.</p>
<p>As the store project grows, the agent may need access to its code host, issue tracker and documentation. Each integration must tell the runtime which tools are available, what inputs they accept and how results are returned. If every integration does this differently, connecting the same service to another runtime means repeating part of the work.</p>
<p>A shared protocol lets runtimes and tool providers agree on that interaction instead of inventing a new connection for every pairing. The Model Context Protocol (MCP) is designed for this purpose.</p>
<h3>What is the Model Context Protocol (MCP)?</h3>
<p>The Model Context Protocol (MCP) gives an AI application a standard way to discover and call external tools. Each server handles its underlying service. The protocol standardises the connection, while the service’s operations, data and permissions remain its own.<a href="https://modelcontextprotocol.io/docs/getting-started/intro">[34]</a></p>
<p>For our store, a code-hosting connector could expose tools to read an issue and prepare a review request. The runtime discovers those tools through MCP, sends a permitted call and receives the result. The connector still translates the operation into the service's API; MCP does not replace that service or its access controls.<a href="https://modelcontextprotocol.io/docs/getting-started/intro">[34]</a></p>
<p>Local file operations can remain built-in tools. For external systems, the same MCP client can work with compatible servers instead of requiring a new connection mechanism for each service. Hermes supports local and remote MCP servers and lets the operator filter which tools are exposed.<a href="https://hermes-agent.nousresearch.com/docs/user-guide/features/mcp">[11]</a></p>
<p>Once those tools can reach external accounts, another question comes first: what information and authority should the agent be allowed to use?</p>
<h2>How should an agent handle sensitive data?</h2>
<p>Give an agent the information and authority needed for a specific task—not unrestricted access to your digital life. Keep credentials out of ordinary prompts and tool output, use scoped account connections, minimise sensitive task data and require explicit approval for consequential actions.</p>
<p>Once an agent can reach external accounts, connectivity becomes an access-control question. Building our checkout may require a test-mode API credential; it does not require real customer records or a production payment key. Use synthetic orders and a payment sandbox wherever possible. Separate <strong>credentials</strong>, which unlock an account, from <strong>task data</strong>, which the agent reads after gaining access. Protecting the password does not automatically protect everything behind it.</p>
<p>The location of the harness does not determine where all task data is processed. Relevant prompts and tool results may be sent to the selected model provider, while connected services handle their own requests.</p>
<h3>Where do 1Password and Hermes Vault fit?</h3>
<p>1Password stores and supplies credentials; Hermes Vault provides origin-bound browser filling using local or supported password-manager items. Composio account tools are a separate integration route and may return secret fields, so they need different safeguards.<a href="https://hermes-agent.nousresearch.com/docs/user-guide/features/credential-vault">[89]</a><a href="https://docs.composio.dev/toolkits/_1password">[99]</a></p>
<ul>
<li><strong>Agent37, Composio and 1Password.</strong> Agent37 offers managed Composio integrations, and Composio separately documents a 1Password toolkit. Confirm that the toolkit is exposed in the particular managed environment before relying on that route. Composio lists <strong>API Key authentication</strong> for its 1Password toolkit—not OAuth. Other Composio apps may use OAuth, but the method is connector-specific. This account-tool route is distinct from Hermes browser autofill: a normal item-retrieval action can return secret fields, so do not treat it as an automatic secret-hiding boundary or send those values through ordinary model-visible results.<a href="https://docs.composio.dev/toolkits/_1password">[99]</a></li>
<li><strong>1Password as a credential source.</strong> Keep approved agent credentials in a dedicated vault and grant a service account only the necessary vault access and operations. 1Password service accounts support vault-level access controls; read-only access to the vault does <strong>not</strong> make the underlying website or API read-only. A retrieved key still carries the permissions granted by that service.<a href="https://developer.1password.com/docs/service-accounts/">[91]</a></li>
<li><strong>Hermes Vault for browser sign-in.</strong> The documented browser-vault workflow exposes saved-item metadata and opaque handles to the agent, then fills the password directly into the browser on an exactly matching saved origin. The password is not returned as ordinary model-visible tool output. Existing 1Password logins can be used through the supported password-manager backend; local encrypted vault items are another option. Site origins, labels and login identifiers remain visible metadata. Origin checks do not protect against a compromised legitimate page or software running with the operator’s privileges.<a href="https://hermes-agent.nousresearch.com/docs/user-guide/features/credential-vault">[89]</a></li>
<li><strong>1Password-backed API credentials are a different path.</strong> Hermes can resolve <code>op://vault/item/field</code> references at process startup and put the resulting values into its runtime environment. That avoids copying the API key into a prompt, but the process still has the plaintext credential. The documented integration can also cache resolved values locally. Review that cache, the bootstrap credential and child-process access rather than assuming every 1Password integration has the same isolation properties as browser autofill.<a href="https://hermes-agent.nousresearch.com/docs/user-guide/secrets/onepassword">[90]</a></li>
</ul>
<p>For a browser task, the intended flow is <strong>authorised request → saved-item handle → exact-origin check → direct fill → authenticated task</strong>. Missing passwords or verification codes belong in the designated masked interface, not the conversation. Availability depends on the client and session: a headless job cannot answer an interactive unlock prompt. Passkeys and app approvals may still require the person to act on their device.<a href="https://hermes-agent.nousresearch.com/docs/user-guide/features/credential-vault">[89]</a></p>
<p>Access determines which information the agent may use. Context and memory determine which of that information is available as the task progresses.</p>
<h2>How does the agent keep track of the task?</h2>
<p>Context is the information available to the model for its current response. Memory is information retained for future use. The coding agent needs the current requirements, relevant files and test results in context. Longer-lived project conventions may come from memory, but should not replace inspecting the current repository.</p>
<p><strong>Context</strong> includes instructions, conversation history, selected documents and tool results. Models process this information as <strong>tokens</strong>: units of encoded input and output, often words or parts of words for text. A <strong>context window</strong> is the bounded capacity available to a request. A large advertised window is useful, but it is not a guarantee that every fact will be noticed or correctly reconciled.</p>
<p><strong>Memory</strong> is not the same as context. Stored information must be selected and made available before it can influence a response. Hermes, for example, documents bounded persistent memory and session search. Saving a preference or procedure changes what the harness can provide later; it does not, by itself, retrain the model’s underlying weights.<a href="https://hermes-agent.nousresearch.com/docs/user-guide/features/memory">[12]</a><a href="https://hermes-agent.nousresearch.com/docs/developer-guide/architecture">[9]</a></p>
<p>For our coding agent, useful memory might include the team’s preferred framework or review conventions. The current task’s context includes checkout requirements, the files under investigation and any failing test output. A remembered description of the project is not proof that the code or tests still behave that way.</p>
<h2>How can an agent build software?</h2>
<p>The agent first examines the project and clarifies the required customer journey. It then implements a bounded set of changes, runs the relevant checks and uses failures to guide corrections. The deliverable is a reviewable change set with evidence—not an unapproved production deployment.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/4f651096-fa6e-4465-9083-4b155267590c.png" alt="Illustrative coding loop: the model proposes a development step, the runtime checks permission, a tool inspects or edits files or runs tests, and the result informs the next step. A developer reviews the final changes." style="display:block;margin:0 auto" />

<p><em>An illustrative workflow, not a tested implementation supplied by this article. The application stays in a development or payment-test environment; merging, deploying and enabling real payments are separate decisions.</em></p>
<p><strong>1. Inspect before designing.</strong> The agent reads the existing files, project instructions and tests. Is there already a framework, database or payment integration? What should happen when stock changes or payment fails? It asks about missing requirements rather than silently replacing the stack or inventing production credentials.</p>
<p><strong>2. Make the customer journey concrete.</strong> The proposed flow is product page → basket → checkout → order result. The agent identifies which pages, server operations and stored order information are needed. It also clarifies the interfaces—the data each component sends and expects—so the frontend and backend agree.</p>
<p><strong>3. Implement a bounded change.</strong> The agent edits the relevant files, adds the basket and checkout behaviour and uses the selected payment provider’s test environment. Prices and order state need authoritative server-side handling rather than blindly trusting values sent by a browser. These are design requirements for this fictional assignment, not claims that a generated implementation automatically satisfies them.</p>
<p><strong>4. Test the behaviour, not just compilation.</strong> The agent runs appropriate unit, integration and browser checks where the environment supports them. Useful cases include an empty basket, an invalid quantity, a rejected payment and a repeated checkout request. A page that renders is not proof that the payment and order flow is correct.</p>
<p><strong>5. Use failures to decide what comes next.</strong> If a test reports that an order is created twice, the agent inspects that path, changes the implementation and reruns the relevant checks. That adaptable investigate–change–verify cycle is the agentic part. If it cannot run a required check, it reports the gap rather than inventing a passing result.</p>
<p><strong>6. Hand over a reviewable result.</strong> The agent presents the changed files, a clear explanation of behaviour and the tests actually run, with remaining limitations. Where authorised, it can prepare a pull request—a request to review and merge the code. A developer reviews the result before merge, deployment or enabling live payments. The agent does not turn “build this” into unlimited production access.</p>
<p>Building a checkout is one understandable assignment. The same pattern—understand a goal, gather the right information, act through tools and verify the result—can support many other kinds of work.</p>
<h2>How can agents act as a digital workforce?</h2>
<p>Agents can act as a flexible digital workforce: software workers that research, analyse, organise and carry out authorised tasks. One agent can handle a bounded assignment; a coordinated team can divide a larger challenge. Their usefulness is not limited to shopping or personal assistance.</p>
<p>The same pattern applies wherever work involves gathering information, making choices and taking permitted actions. A software project is one example; research, household planning and administration are others. With the appropriate services connected, that could include:</p>
<ul>
<li><strong>Shopping and household planning.</strong> Turn a meal plan into a grocery list, check available products, suggest substitutions and prepare a basket. You decide whether the substitutions, total and delivery slot are acceptable.</li>
<li><strong>Trips and days out.</strong> Compare transport, accommodation and opening hours against dates, budget and family needs. The agent can assemble a coherent itinerary instead of leaving you with unrelated search results; bookings remain separate commitments.</li>
<li><strong>Calendars and coordination.</strong> Find suitable times across the calendars you allow it to read, account for travel time, and prepare invitations or reminders. It can do the coordination work without deciding that it may move someone else's appointment.</li>
<li><strong>Personal administration.</strong> Sort documents, extract invoice details, match a receipt to an expense and prepare a reimbursement form. The useful result is an organised record or completed form—not merely a summary explaining what you still need to do.</li>
<li><strong>Learning and preparation.</strong> Gather relevant material, explain an unfamiliar topic at the right level, turn notes into a study plan, or prepare a meeting brief with sources and outstanding questions.</li>
</ul>
<p>The potential benefit is reduced <strong>coordination overhead</strong>: fewer repeated searches, copied details and forgotten follow-ups. You can state the outcome and constraints, let the agent handle the intermediate steps, and concentrate on choices that deserve your judgement. For recurring tasks, remembered preferences and reusable procedures can reduce repeated explanation; Hermes's memory is one documented implementation of that supporting layer.<a href="https://hermes-agent.nousresearch.com/docs/user-guide/features/memory">[12]</a></p>
<p>This can make people more productive, but the gain is task-dependent. A useful test is whether the agent reduces your active attention and finishes the task correctly after including review and corrections. Time spent supervising an unreliable agent can cancel out the time it appeared to save. For a simple action, a normal app or fixed automation may still be faster.</p>
<p>For a larger assignment, the next question is whether one agent should do everything or divide the work with others.</p>
<h2>What is an agent swarm?</h2>
<p>An agent swarm is a coordinated group working towards a shared goal. It can range from a few specialists to thousands of workers organised into groups. Useful swarms divide work, exchange results and check outcomes; size alone does not guarantee quality.</p>
<p>For the online store, a coordinator could ask one agent to build the product pages and basket, another to implement the checkout backend and test-mode payment integration, and a third to examine tests and failure cases. Work can proceed in parallel where the tasks are genuinely independent. The team first needs shared interface expectations and clear ownership of files or isolated work areas. Anthropic describes the broader coordinator-and-subagent approach, including its coordination challenges, in its multi-agent research system.<a href="https://www.anthropic.com/engineering/multi-agent-research-system">[54]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/2f658a69-2500-4530-a448-87b5e17bc0f9.png" alt="Illustrative agent swarm at three scales: a small specialist team, multiple working groups, and thousands of agents arranged in many coordinated groups. Nodes are representative, not literal counts." style="display:block;margin:0 auto" />

<p><em>Swarm size can range from a few agents to thousands. These are illustrative coordination patterns, not a reconstruction of any particular internal system. As a real large-scale example, OpenAI reports roughly 10,000 concurrent agents in the group responsible for its reported Navier–Stokes result.</em><a href="https://openai.com/index/navier-stokes-solution"><em>[94]</em></a></p>
<p><em>In the store-building example, the agents have bounded responsibilities and isolated work where appropriate. One integration owner brings the changes together and checks the combined result; developer review remains separate from merge and deployment. This is an illustrative design, not a benchmarked or deployed application.</em></p>
<p>The same pattern can help with a holiday plan: one agent investigates transport, another accommodation, and another activities. It can also help with a work brief: separate agents examine documentation, identify conflicting evidence and review the proposed conclusion. Specialists may use the same underlying model with different instructions and tools; a swarm does not necessarily mean several model vendors.</p>
<p><strong>More agents are not automatically better.</strong> They can duplicate searches, miss information another agent found, or return incompatible recommendations. Work that depends on the previous step may gain little from parallel execution. Anthropic also reports substantial token costs and coordination challenges for multi-agent systems, so the extra work must justify the expense.<a href="https://www.anthropic.com/engineering/multi-agent-research-system">[54]</a></p>
<p>For the store, the coordinator must notice if the frontend expects a different response than the checkout backend returns, or if a test passes only against a mock rather than the integrated application. Agreement between agents is not proof: they may share the same mistaken assumption. Clear interfaces, evidence, isolated work and one integration owner matter more than the size of the swarm.</p>
<p>The practical progression is therefore <strong>one useful agent first, a small coordinated team when the task benefits from it</strong>. The goal is to remove work from the person—not to create a second team that the person must constantly supervise. Adding more actions and participants also creates more ways for a task to go wrong, so the execution boundaries matter as much as the division of work.</p>
<h2>What can go wrong, and how should the system respond?</h2>
<p>An agent can misunderstand evidence, trust malicious content, repeat a write or spend too long pursuing an unproductive route. Good design limits the consequences, makes the work inspectable and gives a person a meaningful way to stop or correct it.</p>
<p><strong>Untrusted content can look like instructions.</strong> A retrieved page might contain “ignore previous instructions” or ask the assistant to send data elsewhere. This is <strong>prompt injection</strong>: content encountered during a task attempts to redirect the agent’s behaviour. In our example, an issue description, dependency document or repository file is information to evaluate, not authority to reveal secrets, disable safeguards or deploy code. Hermes documents multiple security layers, including command approvals, isolation options and checks on context files; these are controls to configure and understand, not a promise that arbitrary hostile content is harmless.<a href="https://hermes-agent.nousresearch.com/docs/user-guide/security">[10]</a></p>
<p><strong>Credentials create real authority.</strong> A credential is a key or token that gives software access to a service. <strong>Least privilege</strong> means providing only the authority needed for the task. An agent implementing checkout should use development access and test-mode payment credentials, not production payment keys or unrestricted deployment access. Tool filtering and approval controls should reinforce those boundaries. Keep secrets out of prompts, committed files and logs.</p>
<p><strong>Retries are not all equivalent.</strong> Running a test again is different from repeating a production deployment or payment operation. In the checkout being built, a repeated request must not silently create duplicate orders or charges. An <strong>idempotency key</strong>, where the service supports one, identifies the same logical operation across retries.<a href="https://docs.stripe.com/api/idempotent_requests">[139]</a> The agent should follow the chosen provider’s documented replay rules and test duplicate-request behaviour in the test environment, not assume a retry is harmless.</p>
<p><strong>A loop can be expensive without making useful progress.</strong> Budget the whole task: repeated model calls, input and output tokens, tool charges, retries and hosting. Set limits on steps, elapsed time and spending where the platform supports them. A model with a lower token price is not automatically cheaper if it repeatedly misses the evidence and needs more attempts.</p>
<p><strong>Logs should explain what happened.</strong> Retain the selected model and route, tool names, relevant arguments with secrets removed, source references, operation identifiers and outcomes. That is more useful for diagnosis than a confident final paragraph. Restrict log access and retention: even redacted records can contain sensitive task data. Inspectable actions and evidence matter; access to a model’s private internal reasoning is not required.</p>
<p><strong>Human approval must name a real action.</strong> “Continue?” is a weak gate when the person cannot see what will happen. “Merge this reviewed change set into this branch” is specific; deploying it to production or enabling real payments is a different action. Materially changed code should not inherit approval for an older revision. With behaviour and boundaries clear, choosing the underlying model becomes a practical engineering decision rather than a contest over impressive names.</p>
<h2>Which model providers should you compare?</h2>
<p>Compare models against the work you need done, through the route you will actually use. Tool-call reliability, evidence handling, supported inputs, context limits, latency and total task cost matter more than a universal ranking. The representative selection below is not exhaustive.</p>
<p>The current OpenAI, Anthropic and Google catalogues offer different combinations of reasoning, multimodal input, context capacity and specialised capabilities. Choosing a model increasingly means matching those abilities and costs to a task, rather than picking one universal winner.<a href="https://platform.openai.com/docs/models">[25]</a><a href="https://docs.anthropic.com/en/docs/about-claude/models/overview">[26]</a><a href="https://ai.google.dev/gemini-api/docs/models">[27]</a></p>
<p>A model can be accessed directly from a provider or through an intermediary. An <strong>inference gateway</strong> offers a common access point to models from different providers. OpenRouter, for example, documents access to many models through one API. It is a routing and access layer, not the developer of every model in its catalogue.<a href="https://openrouter.ai/docs/quickstart">[50]</a> This access route is separate from the model developer, and may change available features or terms.</p>
<p><em>Documentation checked on 26 October 2026. Model names, availability, context limits and prices change. No comparative benchmark was run for this article. “Open-weight” means model weights are available under stated terms; it does not automatically mean open training data, unrestricted licensing or free operation.</em></p>
<p>GitHub Copilot and OpenRouter are included as <strong>access routes</strong>, not additional model developers. Copilot packages model access into its coding products; OpenRouter provides a common API for reaching different model providers.<a href="https://docs.github.com/en/copilot/reference/ai-models/supported-models">[102]</a><a href="https://openrouter.ai/docs/quickstart">[50]</a></p>
<table>
<thead>
<tr>
<th>Provider / family</th>
<th>Inputs</th>
<th>Tool use</th>
<th>Access and choice</th>
</tr>
</thead>
<tbody><tr>
<td><strong>OpenAI</strong><br />GPT models</td>
<td>Text and images in the listed general models.</td>
<td>Functions and sup­ported server tools.</td>
<td>Hosted API; compare model tiers, effort and cost.<a href="https://platform.openai.com/docs/models">[25]</a></td>
</tr>
<tr>
<td><strong>Anthropic</strong><br />Claude</td>
<td>Text and images.</td>
<td>Tool use; features depend on route and account.</td>
<td>Direct and cloud routes; compare Fable, Opus, Sonnet and Haiku.<a href="https://docs.anthropic.com/en/docs/about-claude/models/overview">[26]</a></td>
</tr>
<tr>
<td><strong>Google</strong><br />Gemini</td>
<td>Text and images; audio and other media vary by model.</td>
<td>Function calls on sup­ported models.</td>
<td>Hosted API; general, live and special­ist endpoints differ.<a href="https://ai.google.dev/gemini-api/docs/models">[27]</a> <a href="https://ai.google.dev/gemini-api/docs/function-calling">[42]</a></td>
</tr>
<tr>
<td><strong>xAI</strong><br />Grok</td>
<td>Text and images in the docu­mented chat model.</td>
<td>Tool calls supported; enable search for realtime data.</td>
<td>Hosted API; include search and tool charges in total cost.<a href="https://docs.x.ai/docs/models">[28]</a></td>
</tr>
<tr>
<td><strong>Mistral AI</strong></td>
<td>Text, vision or other media, depend­ing on model.</td>
<td>Function calls on sup­ported models.</td>
<td>Hosted API and selected open-weight models; check each licence.<a href="https://docs.mistral.ai/getting-started/models">[29]</a> <a href="https://docs.mistral.ai/capabilities/function_calling">[43]</a></td>
</tr>
<tr>
<td><strong>GitHub Copilot</strong><br />Access route</td>
<td>Text and code; other inputs vary by model and client.</td>
<td>Tools depend on the Copilot client.</td>
<td>Models depend on plan, client and policy.<a href="https://docs.github.com/en/copilot/reference/ai-models/supported-models">[102]</a> <a href="https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli">[100]</a></td>
</tr>
<tr>
<td><strong>Open­Router</strong><br />API gateway</td>
<td>Inputs vary by model and endpoint.</td>
<td>Tool calls where the chosen route supports them.</td>
<td>One API; choice of model, provider and fallback rules.<a href="https://openrouter.ai/docs/quickstart">[50]</a> <a href="https://openrouter.ai/docs/guides/routing/provider-selection">[103]</a></td>
</tr>
</tbody></table>
<p>The model-developer rows describe selected current product families, not identical feature sets across every release. The cited catalogues list roughly million-token context windows for GPT-6 Astra, current Claude models and Gemini 4 Argon. A large window does not mean every route exposes the same limit or every fact will be used correctly.<a href="https://platform.openai.com/docs/models">[25]</a><a href="https://docs.anthropic.com/en/docs/about-claude/models/overview">[26]</a><a href="https://ai.google.dev/gemini-api/docs/models">[27]</a></p>
<p>Grok 4.7 is listed with a 500,000-token context window.<a href="https://docs.x.ai/docs/models">[28]</a> Mistral's catalogue includes different licences—for example, Small 4 is labelled Apache 2.0 and Medium 3.5 Modified MIT. Do not generalise one model's context, licence or supported inputs to the whole provider.<a href="https://docs.mistral.ai/getting-started/models">[29]</a></p>
<p>Hosted access and downloadable weights are different choices: a hosted catalogue is not a promise that its models' weights are available, and open weights still carry model-specific terms.</p>
<p>This table deliberately mixes closed hosted offerings with a provider that also releases open weights. Self-hosting can offer more control, but shifts model-serving capacity, updates and performance tuning to the operator. Managed inference shifts much of that work to a provider; it does not remove the need to check terms, retention settings and task suitability.</p>
<p>A useful evaluation for our example is simple: give candidate models the same small test repository, checkout requirements and permitted tools. Include a failing test or an incomplete interface. Compare whether they identify the problem, make a correct change, verify the result and respect the review boundary. Count corrections, tool calls and total cost—not just the confidence of the explanation. Use test data and a payment sandbox, not real transactions.</p>
<p>Choosing the model and choosing its runtime are connected decisions: the runtime determines which tools, interfaces and controls are available.</p>
<h2>Which harness could run an agent?</h2>
<p>A runnable harness provides an application you can use, not just a library for building one. Choose it for the environment, integrations and control model you need. Frameworks and software development kits (SDKs) are a different layer: components developers use when constructing their own applications.<a href="https://www.anthropic.com/engineering/building-effective-agents">[45]</a></p>
<p><em>This comparison concerns the named runnable products and their public documentation checked on 26 October 2026. Software licensing is separate from the terms and cost of the model service.</em></p>
<table>
<thead>
<tr>
<th>Harness</th>
<th>Interface and role</th>
<th>Models / tools</th>
<th>Controls / licence</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Hermes</strong></td>
<td>General agent; CLI, web and messaging.</td>
<td>Multi­ple pro­viders; skills, memory and MCP tools.</td>
<td>Tool rules and iso­lation options.<br /><strong>MIT</strong>.<a href="https://hermes-agent.nousresearch.com/docs/developer-guide/architecture">[9]</a> <a href="https://hermes-agent.nousresearch.com/docs/user-guide/security">[10]</a> <a href="https://raw.githubusercontent.com/NousResearch/hermes-agent/main/LICENSE">[13]</a></td>
</tr>
<tr>
<td><strong>OpenClaw</strong></td>
<td>Mess­aging gateway with a web UI.</td>
<td>Provider choice; skills, plugins and channels.</td>
<td>Sender and tool rules; one gateway trust boundary.<br /><strong>MIT</strong>.<a href="https://docs.openclaw.ai">[14]</a> <a href="https://docs.openclaw.ai/gateway/security">[40]</a> <a href="https://raw.githubusercontent.com/openclaw/openclaw/main/LICENSE">[15]</a></td>
</tr>
<tr>
<td><strong>Claude Code</strong></td>
<td>Coding in CLI, IDE, desktop and web.</td>
<td>Claude-centred; sup­ported access routes and tool links.</td>
<td>Fine-grained rules and managed policies.<br /><strong>Com­mercial terms</strong>.<a href="https://code.claude.com/docs/en/overview">[16]</a> <a href="https://code.claude.com/docs/en/permissions">[17]</a> <a href="https://raw.githubusercontent.com/anthropics/claude-code/main/LICENSE.md">[39]</a></td>
</tr>
<tr>
<td><strong>Codex CLI</strong></td>
<td>Terminal coding, reviews and scripted work.</td>
<td>Model selection and MCP tools.</td>
<td>Sandbox, network and approval controls.<br /><strong>Apache 2.0</strong>.<a href="https://developers.openai.com/codex/cli">[19]</a> <a href="https://developers.openai.com/codex/agent-approvals-security">[46]</a> <a href="https://raw.githubusercontent.com/openai/codex/main/LICENSE">[21]</a></td>
</tr>
<tr>
<td><strong>GitHub Copilot CLI</strong></td>
<td>Terminal coding and GitHub work­flows.</td>
<td>Model choice; local and MCP tools.</td>
<td>Tool and path ap­provals.<br /><strong>Pro­prietary licence</strong>.<br /><a href="https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli">[100]</a> <a href="https://github.com/github/copilot-cli/blob/main/LICENSE.md">[101]</a><a href="https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/configure-copilot-cli">[141]</a></td>
</tr>
<tr>
<td><strong>OpenCode 2</strong></td>
<td>Coding in CLI, desktop and web.</td>
<td>Multi­ple pro­viders, plugins and MCP tools.</td>
<td>Action rules; not an OS sandbox.<br /><strong>MIT</strong> reposi­tory.<a href="https://opencode.ai/v2/docs">[36]</a> <a href="https://opencode.ai/v2/docs/permissions">[48]</a> <a href="https://raw.githubusercontent.com/anomalyco/opencode/dev/LICENSE">[24]</a></td>
</tr>
</tbody></table>
<p>Compare the configured execution boundary, not just the presence of an approval dialog. OpenClaw's gateway is not an isolation boundary for mutually adversarial users. OpenCode 2's action rules are not an operating-system sandbox, and V1 uses different permission settings. Claude Code's documented routes do not imply arbitrary model interchangeability. An open-source harness also does not make a connected model or paid service open source.<a href="https://docs.openclaw.ai/gateway/security">[40]</a><a href="https://opencode.ai/v2/docs/permissions">[48]</a><a href="https://code.claude.com/docs/en/overview">[16]</a></p>
<p><strong>Hermes</strong> is used throughout this article to show how model access, tools, memory and runtime controls fit together. A repository-focused task may suit a coding CLI; a conversational assistant may benefit from a messaging gateway. Agent37 can provide the hosting environment for a harness, while the harness retains its own permissions and controls.<a href="https://www.agent37.com/docs/agents-api/models.md">[38]</a></p>
<h2>Where should you start?</h2>
<p>Start with a task whose result you can inspect and whose mistakes you can contain. For the online store, choose a bounded checkout change in a development branch. Give the agent requirements and tests, keep production credentials unavailable, and review the resulting code and evidence before expanding its authority.</p>
<p>Use an ordinary workflow when the sequence is predictable. Introduce model-selected actions only where adaptation adds value. Keep the first permissions narrow, measure the complete task rather than a single response, and expand access only after observing how the system handles uncertainty and failure.</p>
<p>The model helps choose the next step; the surrounding software turns that choice into an action and checks what happened. That is the core of agentic AI, whether it powers one coding assistant or a coordinated group.</p>
<h2>Frequently asked questions</h2>
<h3>Is an agent just a chatbot with tools?</h3>
<p>A chatbot with tools can be agentic if it uses results to decide subsequent actions towards a goal. The interface does not determine the architecture. A fixed tool sequence is closer to a workflow; an adaptive loop gives the model more control over the next step.<a href="https://www.anthropic.com/engineering/building-effective-agents">[45]</a></p>
<h3>Do I need a powerful GPU to run Hermes?</h3>
<p>Not necessarily. When inference is provided remotely, the host runs the harness and its tools rather than the model’s numerical workload. Resource needs depend on those tools. Running a model locally introduces separate requirements for model size, memory and inference performance.<a href="https://hermes-agent.nousresearch.com/docs/developer-guide/architecture">[9]</a><a href="https://docs.nvidia.com/deeplearning/performance/dl-performance-gpu-background/index.html">[32]</a></p>
<h3>Does persistent memory mean the model is learning permanently?</h3>
<p>Not in the training sense. Saving notes or procedures lets a harness retrieve information for future requests. It does not automatically update model weights. Hermes’s documented persistent-memory mechanism is a concrete example of stored information being supplied to later sessions.<a href="https://hermes-agent.nousresearch.com/docs/user-guide/features/memory">[12]</a></p>
<h3>Can I trust an agent more because several models agree?</h3>
<p>Agreement can help identify questions worth checking, but it is not independent evidence. Models may share a mistaken premise or rely on the same incorrect source. Verify the original material and the actual operation; keep the final decision with the responsible person.</p>
]]></content:encoded></item><item><title><![CDATA[Site Reliability Engineering: A Practical Introduction for Engineers]]></title><description><![CDATA[Follow a fictional checkout service through SRE design, ownership, monitoring, incidents and toil reduction. A practical introduction for engineers.]]></description><link>https://blog.turingts.com/site-reliability-engineering-a-practical-introduction-for-engineers</link><guid isPermaLink="true">https://blog.turingts.com/site-reliability-engineering-a-practical-introduction-for-engineers</guid><category><![CDATA[SRE]]></category><category><![CDATA[Devops]]></category><category><![CDATA[automation]]></category><category><![CDATA[monitoring]]></category><category><![CDATA[Software Engineering]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Fri, 23 Oct 2026 10:58:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/2feab2ec-a3e9-4814-8fac-e12342f27af1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In 2003, Benjamin Treynor Sloss joined Google to lead a production team of seven engineers. He approached the job as a software engineer: instead of relying on people to repeat operational tasks, build software to do that work. That team became Google’s Site Reliability Engineering organization, applying engineering to the practical problem of keeping services running reliably.</p>
<p>Sloss also coined the name. As <a href="https://sre.google/sre-book/preface/">Google’s SRE book explains</a>, <strong>“site” originally meant the</strong> <a href="http://google.com"><strong>google.com</strong></a> <strong>website</strong> that the team helped keep running. The discipline now extends beyond websites to services such as storage and cloud infrastructure. <strong>Reliability</strong> is the focus: keeping those services dependable for their users. <strong>Engineering</strong> is the approach: designing and building software and systems to achieve that, rather than relying on repeated manual intervention.</p>
<p>The problem behind that approach is familiar: as a service grows, its operational workload can grow with it. Hiring more people to handle the same recurring tasks does not remove that work. SRE makes improving the system part of running it—automating repeatable operations, addressing recurring failures and protecting time for engineering. Sloss captures the idea in <a href="https://sre.google/sre-book/introduction/">Google’s SRE book</a>: “SRE is what happens when you ask a software engineer to design an operations team.”</p>
<p>Consider a fictional online store. A customer submits an order through its website; the website calls a checkout API, which records order state and contacts a payment provider. If the response disappears, the customer may not know whether to try again. The business needs more than a running server: it needs a trustworthy outcome and a team able to recover when things go wrong.</p>
<p>We will follow that service from design through launch, an incident, and the engineering work afterwards. The outcome is a small service/reliability map connecting user expectations, technical decisions, signals and ownership. You need basic familiarity with HTTP services and software releases, but no particular cloud or monitoring platform.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/37fdeb55-3463-49f1-a007-47a54ec6496c.png" alt="Illustrative checkout service and reliability responsibilities across design, launch, observation, response and improvement." style="display:block;margin:0 auto" />

<p><em>Illustrative service: customer → website → observed entry point → checkout API → order database and payment provider. The API observation includes the effects of downstream dependencies, but not failures before the entry point or the complete shopping journey.</em></p>
<h2>What is site reliability engineering?</h2>
<p>Site reliability engineering (SRE) applies software engineering to running reliable services. It combines production responsibility with work that changes the system itself, so reliability and operational effort do not depend on continually adding people to perform the same tasks. This is central to Google's description of SRE.<a href="https://sre.google/sre-book/introduction">1</a></p>
<p>For checkout, answering an urgent page is necessary operational work. Changing the payment integration so a known failure no longer requires repeated manual intervention is engineering work. Both belong in the picture; the second must not disappear beneath the first.</p>
<p>SRE is therefore not a new label for a ticket queue or a team that receives finished software and absorbs every production problem. The Google model explicitly protects engineering time and uses production experience to improve the service.<a href="https://sre.google/sre-book/introduction">1</a> This is not a claim that operations engineers cannot write software or improve systems. The distinction is the operating model, incentives and protected capacity—not professional status.</p>
<p>There is overlap with DevOps: Google's introduction describes compatible principles, including collaboration across development and operations, automation and engineering practices applied to operations.<a href="https://sre.google/sre-book/introduction">1</a> For this article, think of SRE as a concrete way to organize reliability work, not as a replacement name for all development or operations.</p>
<h2>What does this service need to promise?</h2>
<p>Start with the customer's action and its consequences, then choose measurable objectives. For checkout, “the servers are available” is too weak: the customer needs a correct, timely response and an order state that remains understandable if communication fails.</p>
<p>In our hypothetical design, a valid checkout result is an accepted-order confirmation or a legitimate business decline. A payment-provider timeout is neither: the outcome remains uncertain until reconciliation establishes what happened. We also require the design to prevent duplicate processing of the same logical order, rather than asking customers or operators to resolve ambiguity by repeatedly submitting it.</p>
<p>An <strong>SLI</strong>, or service level indicator, measures a service outcome; an <strong>SLO</strong>, or service level objective, sets a target for that measure. An <strong>error budget</strong> expresses the permitted shortfall and helps prioritize reliability work against other changes. Google's workbook treats these as decision-making tools, not merely reporting metrics.<a href="https://sre.google/workbook/implementing-slos">7</a></p>
<p>For a first checkout objective, the team could measure the proportion of eligible API attempts receiving a valid result within an agreed time, over an agreed window. Product and engineering must choose the target together. Here, we leave its exact percentage and measurement rules to a separate design exercise rather than pretend one number suits every store.</p>
<p>The existing <a href="https://blog.turingts.com/sre-fundamentals-designing-slis-slos-and-error-budgets">SRE fundamentals article</a> works through checkout measurement definitions, Prometheus queries and error-budget decisions in detail.<a href="https://blog.turingts.com/sre-fundamentals-designing-slis-slos-and-error-budgets">8</a> Use it as optional further reading on measurement, not as a prerequisite for this lifecycle introduction.</p>
<p>Our boundary matters. An edge-observed API result can include a failure caused by the database or payment provider, but cannot describe every browser, DNS or shopping-flow failure. Google's workbook explicitly distinguishes an SLI specification from its implementation, with different coverage and cost trade-offs.<a href="https://sre.google/workbook/implementing-slos">7</a> Nor would a good availability percentage excuse lost orders or duplicate charges; those require separate correctness checks in this design.</p>
<h2>How does reliability change the design?</h2>
<p>Turn each failure concern into an explicit design decision before launch. In this example, reliable checkout requires defined dependency behaviour, durable order state, safe change controls and a named owner—not simply more replicas of the API.</p>
<p>Use the following map as a working agreement. Every row is a proposed choice for this fictional service, not a deployed system or a universal checklist.</p>
<table>
<thead>
<tr>
<th>User or team need</th>
<th>Engineering decision</th>
<th>Evidence to inspect</th>
<th>Accountable owner in this example</th>
</tr>
</thead>
<tbody><tr>
<td>Receive a usable checkout result</td>
<td>Define outcomes and a request deadline; bound dependency calls</td>
<td>Valid-result rate, response times, timeouts</td>
<td>Checkout team</td>
</tr>
<tr>
<td>Avoid duplicate order processing</td>
<td>Persist a logical-order identifier and state; reconcile uncertain payment outcomes</td>
<td>Duplicate-prevention tests and reconciliation exceptions</td>
<td>Checkout team with payment-integration maintainer</td>
</tr>
<tr>
<td>Release without exposing every customer at once</td>
<td>Use staged rollout and a compatible rollback path</td>
<td>Outcome changes by release; rollback rehearsal</td>
<td>Release owner in checkout team</td>
</tr>
<tr>
<td>Recover without improvising</td>
<td>Maintain a short runbook and escalation route</td>
<td>Response exercise and incident timeline</td>
<td>On-call lead</td>
</tr>
<tr>
<td>Keep operational work sustainable</td>
<td>Measure recurring reconciliation effort; engineer away repeatable cases</td>
<td>Human interventions and unresolved cases</td>
<td>Checkout engineering lead</td>
</tr>
</tbody></table>
<p>Take the uncertain-payment row. Suppose the provider processes a request but its response never reaches checkout. A blind retry is not our recovery design. We propose storing the operation identifier and an explicit unresolved state, then checking the outcome only through mechanisms supported by the provider's actual contract. Any retry must respect that provider's actual idempotency contract; an identifier in our database alone cannot establish its behaviour.</p>
<p>This is a design requirement to implement and test, not working payment code. It exposes a useful question early: what evidence lets us tell the customer what happened without creating another charge?</p>
<p>Google's engagement model explains why SRE involvement can start during design and implementation, rather than only when a service is handed over after launch.<a href="https://sre.google/sre-book/evolving-sre-engagement-model">6</a> The concrete benefit here is the opportunity to resolve that question while the state model and API are still being designed.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/ef0f20cc-81a1-41d0-a775-e792e86435ba.png" alt="Illustrative SRE involvement across architecture and design, active development, limited availability, general availability and deprecation." style="display:block;margin:0 auto" />

<p><em>Conceptual engagement pattern based on Google’s SRE Workbook.</em><a href="https://sre.google/workbook/engagement-model/"><em>11</em></a> <em>SRE can become involved at any stage. Curve height and phase lengths are illustrative—not measured effort or a mandatory staffing schedule. The chapter also describes the later abandoned and unsupported states.</em></p>
<h2>What should be ready before launch?</h2>
<p>Before exposing customers to checkout, make sure someone can detect user harm, take a safe recovery action, and explain who owns the next decision. Production readiness is a service-specific engineering review, not a document that transfers every risk to an operations team.</p>
<p>For this service, the developers and reliability engineer would review dependency failure tests, rollback compatibility, capacity assumptions and recovery access together. They would rehearse a payment timeout and ask whether the operator can distinguish a failed request from an uncertain payment. They would also check that restoring order data is an exercised procedure rather than merely a claim that backups exist.</p>
<p>Google describes production readiness reviews, training and progressive transfer of production responsibilities, with continued development-team support.<a href="https://sre.google/sre-book/evolving-sre-engagement-model">6</a> That is useful guidance, not a requirement to copy Google's team structure. Our checkout team retains application ownership; an SRE may advise it or share production responsibility under an explicit agreement.</p>
<p>Before a sales or marketing promotion increases demand, revisit expected traffic and test the relevant limits. Google's introduction includes demand forecasting, load testing and capacity planning in reliability work.<a href="https://sre.google/sre-book/introduction">1</a> A reasonable checkout question is whether database connections or payment-provider limits will constrain the service before API compute does. Adding API instances is not our default answer to an unidentified bottleneck.</p>
<h2>How do you know customers are being affected?</h2>
<p>Observe the checkout outcome first, then collect enough internal evidence to explain it. Google's monitoring guidance separates symptoms from causes and identifies four useful signals: latency, traffic, errors and saturation.<a href="https://sre.google/sre-book/monitoring-distributed-systems">3</a></p>
<p>For checkout, that means watching how many eligible requests arrive, whether they receive valid results, how long those results take, and whether constrained resources are approaching their limits. A fast error must not make the successful-response picture look healthier. Google's guidance specifically distinguishes successful and failed latency, and notes that an HTTP success code can still carry incorrect content.<a href="https://sre.google/sre-book/monitoring-distributed-systems">3</a></p>
<p>Our proposed instrumentation would record outcome metrics, diagnostic events for order-state transitions, and request traces showing time spent in dependency calls. These would summarize outcomes, explain state changes and connect the work of individual requests. We would collect evidence to answer those questions, not everything a tool supports. Payment credentials and customer details do not belong in these diagnostic records.</p>
<p>The operational question is not “which dashboard should someone watch all day?” For this design, sustained customer-visible checkout failures should reach the on-call engineer with the affected operation, a diagnostic starting point and the runbook. A gradual capacity concern might become planned work instead. Google's monitoring chapters distinguish urgent alerts from tickets and emphasize understandable, low-noise paging; immediate action may be needed for a current or imminent problem.<a href="https://sre.google/sre-book/introduction">1</a><a href="https://sre.google/sre-book/monitoring-distributed-systems">3</a></p>
<p>Also check the observer. A silent stream of outcome data cannot establish that checkout is healthy. In our design, telemetry freshness and an independent synthetic check help distinguish quiet traffic from missing visibility; synthetic results remain separate from real customer outcomes.</p>
<h2>What happens during a checkout incident?</h2>
<p>During an incident, reduce customer harm, coordinate changes and preserve evidence. Google's incident guidance separates command, operational work and communication, and recommends preparing and practising the response before an emergency.<a href="https://sre.google/sre-book/managing-incidents">4</a></p>
<p>Imagine a new checkout release coincides with increased payment timeouts. This is a fictional incident, not a report of an observed deployment. The on-call engineer sees degraded API outcomes, while dependency timing and release information suggest where to investigate. Correlation with a release does not establish the cause.</p>
<p>A useful first runbook is short:</p>
<ol>
<li><strong>Confirm impact:</strong> inspect checkout outcomes and telemetry freshness; record what is known and unknown.</li>
<li><strong>Stop expansion:</strong> pause the rollout and identify its owner. Keep changes coordinated in one incident channel.</li>
<li><strong>Choose a safe mitigation:</strong> consider rollback only after checking schema and payment-state compatibility. Escalate when that safety is uncertain.</li>
<li><strong>Protect unresolved orders:</strong> do not replay payment requests indiscriminately. Preserve identifiers and hand ambiguous cases to the reconciliation owner.</li>
<li><strong>Verify recovery:</strong> inspect customer-facing outcomes and unresolved work, then communicate the remaining impact.</li>
</ol>
<p>The incident lead coordinates decisions; a responder performs agreed changes; someone keeps stakeholders informed and maintains a timeline. A small team may combine roles, but it should still make the responsibilities explicit. The person investigating a dependency should not also have to answer every status request.</p>
<p>A rollback can restore new requests without resolving payments already in an uncertain state. In our scenario, recovery therefore has two parts: restore usable checkout and account for affected orders. “The graph is green” is not sufficient closure.</p>
<h2>How does an incident become engineering work?</h2>
<p>A postmortem should explain impact, contributing conditions, response and preventive actions without blaming the person who happened to deploy or respond. Google's guidance treats this as a learning process and stresses reviewing whether the action plan is appropriate.<a href="https://sre.google/sre-book/postmortem-culture">5</a></p>
<p>For our fictional incident, the investigation might find that a changed dependency timeout escaped testing, the rollout lacked an effective stop condition, and the runbook did not explain unresolved payments. Those are hypotheses to investigate, not conclusions supplied by the incident narrative.</p>
<p>Useful follow-up work could include a test where payment processing succeeds but the response is lost, a rollout check for worsening checkout outcomes, and a documented reconciliation path. Give each accepted action an owner and a way to demonstrate completion. “Be more careful” changes neither the software nor the information available to the next responder.</p>
<p>This also exposes <strong>toil</strong>. Google defines toil as production work that tends to be manual, repetitive, automatable, tactical, without enduring value, and growing with the service.<a href="https://sre.google/sre-book/eliminating-toil">2</a> Suppose an operator repeatedly checks uncertain orders in two systems and copies outcomes into a spreadsheet. Resolving one case may be necessary, but doing the same work again does not improve the system.</p>
<h3>Why automate repetitive operational work?</h3>
<p>Automation matters when it removes a recurring dependency on human effort. Resolving one case helps one customer; improving how that class of cases is handled can reduce future work. Google's SRE model protects engineering time precisely to avoid operational effort growing with the service.<a href="https://sre.google/sre-book/introduction">1</a></p>
<p>For our checkout example, more orders could mean more manual payment checks. Adding people to repeat those checks leaves the underlying work intact. Automating the repeatable evidence gathering—or changing the integration so fewer outcomes become uncertain—would address the source of the workload. These are proposed improvements, not measured savings.</p>
<p>The engineering response could be a reconciliation tool that gathers evidence, proposes safe transitions and leaves ambiguous cases for review. It needs tests, bounded permissions, an audit trail and a stop mechanism. Automating an unsafe decision would be a worse outcome than retaining the manual step.</p>
<p>Automation also takes effort to build, test and maintain. For this team, prioritize recurring work whose removal justifies that investment; do not automate a poorly understood decision simply because it is manual. Investigating a novel failure or judging an ambiguous payment can require human expertise. Google's toil definition explicitly distinguishes work requiring judgment from automatable repetition.<a href="https://sre.google/sre-book/eliminating-toil">2</a></p>
<p>Measure the change using recurring human interventions, time spent and unresolved cases—not merely whether a script exists. Google's toil chapter explicitly notes that repeatedly launching a script can still be toil.<a href="https://sre.google/sre-book/eliminating-toil">2</a> Reducing unnecessary work, rather than accumulating automation, is the objective.</p>
<h3>What is a healthy balance between operations and engineering?</h3>
<p>Protect engineering time rather than letting operational work consume the entire schedule. Google's benchmark caps aggregate operational work at 50%, reserving at least the other half for development. Treat that as a useful reference, not a universal staffing formula.<a href="https://sre.google/sre-book/introduction">1</a></p>
<p>The cap is a ceiling, not a quota to fill with manual work. It is also <strong>not “50% automation and 50% manual work”</strong>: engineering includes design, reliability features and lasting systems improvements. Google's toil chapter separately sets a goal of keeping toil below 50% of each SRE's time, with at least half spent on engineering projects.<a href="https://sre.google/sre-book/eliminating-toil">2</a></p>
<p>Look at the trend, not one incident-heavy week: Google's guidance assesses engineering time over several quarters or a year.<a href="https://sre.google/sre-book/eliminating-toil">2</a> For checkout, record recurring checks and interruptions alongside engineering work. If operations repeatedly crowds out improvements, agree protected capacity and choose a recurring cause to remove. Keep necessary human judgment and production experience; the goal is sustainable operations, not zero manual activity.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/ed2ca78d-8cc3-49fd-95a7-3e31e2e87b41.png" alt="Illustrative comparison of repetitive manual checkout checks with engineering improvements, plus Google’s reference for protecting engineering time." style="display:block;margin:0 auto" />

<p><em>Illustrative design, not measured savings: automate repeatable work while retaining human judgment. The time-allocation reference is Google’s operational-work ceiling and protected engineering capacity—not a universal staffing rule or a split between automation and manual work.</em><a href="https://sre.google/sre-book/introduction"><em>1</em></a><a href="https://sre.google/sre-book/eliminating-toil"><em>2</em></a></p>
<h2>Where should you start?</h2>
<p>Start with one service and one important user action. Write its promise, dependencies, failure signals, recovery action and accountable owner on a single page. Then walk through a failure with someone who did not write the page and use the gaps to choose the next engineering task.</p>
<p>For checkout, try the lost-payment-response scenario as a tabletop exercise. Can your colleague identify the uncertain order, explain which actions are unsafe, find the escalation contact and describe the evidence required before closing the incident? No production fault injection is necessary to discover an unclear recovery contract.</p>
<p>This is where design, development and operations meet. SRE makes reliability a continuing engineering responsibility: define the outcome, build for failure, observe actual behaviour, recover deliberately, and improve the service so the next shift has less avoidable work.</p>
<h2>Frequently asked questions</h2>
<h3>Do you need a separate SRE team?</h3>
<p>Not to use the practices in this example. Keep service ownership explicit and dedicate engineering capacity to reliability. Google's engagement guidance itself describes consultation and documentation as alternatives to full SRE support.<a href="https://sre.google/sre-book/evolving-sre-engagement-model">6</a></p>
<h3>Is SRE mainly about monitoring and being on call?</h3>
<p>No. Those provide operational visibility and response, but Google's SRE model also covers engineering, change management, capacity and efficiency.<a href="https://sre.google/sre-book/introduction">1</a> For checkout, improving payment-state handling can matter as much as adding an alert.</p>
<h3>Should you automate every operational task?</h3>
<p>No. Prioritize repeated work whose removal creates durable value. Some toil is unavoidable, and Google's guidance does not define all manual work as toil.<a href="https://sre.google/sre-book/eliminating-toil">2</a> In our checkout example, ambiguous payment decisions stay under human review until safe behaviour is established.</p>
<h2>Sources</h2>
<ul>
<li><a href="https://sre.google/sre-book/introduction">1</a> — Introduction</li>
<li><a href="https://sre.google/sre-book/eliminating-toil">2</a> — Eliminating Toil</li>
<li><a href="https://sre.google/sre-book/monitoring-distributed-systems">3</a> — Monitoring Distributed Systems</li>
<li><a href="https://sre.google/sre-book/managing-incidents">4</a> — Managing Incidents</li>
<li><a href="https://sre.google/sre-book/postmortem-culture">5</a> — Postmortem Culture: Learning from Failure</li>
<li><a href="https://sre.google/sre-book/evolving-sre-engagement-model">6</a> — The Evolving SRE Engagement Model</li>
<li><a href="https://sre.google/workbook/implementing-slos">7</a> — Implementing SLOs</li>
<li><a href="https://blog.turingts.com/sre-fundamentals-designing-slis-slos-and-error-budgets">8</a> — SRE Fundamentals: Designing SLIs, SLOs, and Error Budgets</li>
<li><a href="https://sre.google/sre-book/introduction/">9</a> — Introduction: byline and origin of SRE</li>
<li><a href="https://sre.google/sre-book/preface/">10</a> — Preface: SRE name and site meaning</li>
<li><a href="https://sre.google/workbook/engagement-model/">11</a> — SRE Engagement Model (The Site Reliability Workbook, chapter 18)</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[SRE Fundamentals: Designing SLIs, SLOs and Error Budgets]]></title><description><![CDATA[A practical checkout example: define SLIs, query SLOs in Prometheus, calculate error budgets and turn the results into release decisions.]]></description><link>https://blog.turingts.com/sre-fundamentals-designing-slis-slos-and-error-budgets</link><guid isPermaLink="true">https://blog.turingts.com/sre-fundamentals-designing-slis-slos-and-error-budgets</guid><category><![CDATA[SRE]]></category><category><![CDATA[Site Reliability Engineering]]></category><category><![CDATA[#prometheus]]></category><category><![CDATA[observability]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Thu, 22 Oct 2026 16:37:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/3069ea9c-d7a2-4da6-894e-81528db84e56.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A green dashboard cannot tell you whether an online store's checkout is usable or whether the next sprint should fund features or reliability fixes. SLIs, SLOs and error budgets make that decision concrete. This guide defines one checkout attempt, measures availability and timely success, then turns the same traffic into an engineering policy.</p>
<p>Our example is a fictional online store. When a customer submits an order at checkout, the website calls a checkout API and waits for a result. We measure that API interaction—not the entire shopping journey, browser experience or every step of payment processing.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/d4dce75d-a226-4806-aceb-8d977a844127.png" alt="Illustrative online store: a customer submits an order through the edge to the checkout API, which uses a payment provider and an orders database." style="display:block;margin:0 auto" />

<p><em>An illustrative online store. The edge observer measures the checkout request and its result, including the effects of downstream dependencies.</em></p>
<h2>What do SLIs, SLOs and error budgets tell you?</h2>
<p>An SLI (service level indicator) measures behaviour; an SLO (service level objective) sets its target over a window. An error budget quantifies the bad events that target allows, helping a team prioritize reliability work over discretionary changes.</p>
<p>CPU usage can explain why checkout struggles. It does not establish whether a customer received a usable response. Start with the user-facing operation, then choose a measurement that represents it. Google's <a href="https://sre.google/sre-book/service-level-objectives/">service-level objectives chapter</a> distinguishes these indicators and objectives from an SLA (service level agreement): an agreement with users that specifies consequences for meeting or missing its objectives.</p>
<p>For the hypothetical checkout API below, we will use two objectives:</p>
<ul>
<li><strong>Availability:</strong> at least 99.9% of eligible attempts return a valid result.</li>
<li><strong>Timely success:</strong> at least 99.0% of eligible attempts return a valid result within 300 milliseconds.</li>
</ul>
<p>Both use the same rolling 28-day window. These are teaching choices, not industry-standard targets. Product and engineering should choose real targets together, using user expectations and the cost of improving reliability.</p>
<p>The practical outcome is a measurement contract, two PromQL queries and a policy that changes engineering priorities. You need basic HTTP knowledge; the local exercise also requires <code>promtool</code>, the command-line tool distributed with Prometheus. It needs neither a running Prometheus server nor a deployed checkout service.</p>
<h2>What counts as one checkout attempt?</h2>
<p>Count one eligible external submission to <code>POST /checkout</code>, once, when it reaches a terminal outcome. An internal retry does not create another attempt. A new client submission does, even if it repeats an idempotency key. This measures attempts, not unique purchases or customers.</p>
<p>Define eligibility before classifying the outcome. Here, eligible attempts come from real production users with valid input and authorization. Exclude health probes, synthetic tests, staff or load-test traffic, malformed input and genuine authorization denials.</p>
<p>Keep authentication-infrastructure failures, capacity rejections of otherwise eligible requests, dependency failures and planned maintenance in scope. Filtering out every 4xx response would remove some real service failures. Changing exclusions after an incident would change the question instead of answering it.</p>
<p>Our hypothetical observer sits at the edge, where requests enter the service. It starts a timer on receipt and records exactly one terminal event at response completion, interruption or a two-second deadline. It must recognize eligible attempts even when the backend is unavailable. If it cannot establish eligibility or loses observations, investigate data coverage rather than silently removing those attempts.</p>
<p>A <strong>valid result</strong> is a semantically correct response delivered by the deadline: either an accepted checkout confirmation or a correctly handled business decline. A legitimate payment decline can therefore count as a service success, whereas a plausible-looking decline caused by a bug or dependency fault is a failed outcome under the contract. This SLI measures usable API handling, not sales conversion.</p>
<p>An infrastructure rejection is not a business decline; it counts as failed. Timeouts, interrupted responses or client disconnects, incorrect payloads and dependency failures also count as failed. Counting disconnects as failures is a conservative choice for this example. A response arriving after the deadline cannot convert the recorded failure into success.</p>
<p>Classify every eligible terminal event into exactly one category:</p>
<table>
<thead>
<tr>
<th>Outcome</th>
<th>Meaning</th>
</tr>
</thead>
<tbody><tr>
<td><code>good</code></td>
<td>Valid success completed in at most 300 ms</td>
</tr>
<tr>
<td><code>slow</code></td>
<td>Valid success completed after 300 ms, but by the two-second deadline</td>
</tr>
<tr>
<td><code>failed</code></td>
<td>Every other eligible terminal outcome</td>
</tr>
</tbody></table>
<p>Both measurements share <code>total = good + slow + failed</code>. Availability is <code>(good + slow) / total</code>; timely success is <code>good / total</code>. An attempt spanning the window boundary belongs to the window containing its terminal event.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/1e346384-a7ed-4b6d-abf5-1fdc6c9b2721.png" alt="An eligible checkout attempt receives one good, slow or failed outcome; availability and timely success use the same total." style="display:block;margin:0 auto" />

<p><em>One hypothetical measurement contract, two objectives, one shared population.</em></p>
<p>That distinction prevents a fast error from improving the timely-success result. Google's <a href="https://sre.google/sre-book/monitoring-distributed-systems/">monitoring chapter</a> explains why successful and failed request latency need separate treatment, and why an HTTP success status can still carry incorrect content.</p>
<p>The observer therefore needs application outcome signals; transport status alone cannot establish semantic correctness, and an undetected buggy decline that looks well-formed at the transport layer is a measurement limitation that can overstate the SLI rather than a valid success. This is a proposed custom instrumentation contract, not a built-in gateway feature or existing metric. It also misses failures before the observed edge, such as DNS problems, and cannot report its own unobserved disappearance. It is an attempt-weighted proxy for part of the checkout journey, not a complete browser-to-purchase SLO.</p>
<h2>How do you query both objectives in Prometheus?</h2>
<p>Export one counter family with <code>good</code>, <code>slow</code> and <code>failed</code> outcome series, then divide each objective's good-event count by their shared total. Apply <code>increase</code> to each counter before summing across observers. Return a ratio only when the observed total is positive.</p>
<p>In the stored series we query, the proposed metric is <code>checkout_operations_total</code>, with labels such as <code>service="checkout"</code>, <code>instance="edge-a"</code> and <code>outcome="good"</code>. Here <code>instance="edge-a"</code> represents a hypothetical scrape-target identity in stored data, not a label the checkout exporter has to set itself. When Prometheus scrapes a target, it <a href="https://prometheus.io/docs/concepts/jobs_instances/">automatically attaches <code>job</code> and <code>instance</code> labels to identify the scraped target</a>. Initialize all three outcome counters to zero on every expected observer. Each terminal event increments only one counter. Do not put user IDs or operation IDs in metric labels.</p>
<p>With that contract implemented and scraped, these complete expressions need no recording-rule setup. The availability ratio over the last 28 days is:</p>
<pre><code class="language-promql">(
  sum(increase(checkout_operations_total{service="checkout",outcome=~"good|slow"}[28d]))
  /
  sum(increase(checkout_operations_total{service="checkout"}[28d]))
)
and
(sum(increase(checkout_operations_total{service="checkout"}[28d])) &gt; 0)
</code></pre>
<p>Timely success uses only <code>good</code> in the numerator:</p>
<pre><code class="language-promql">(
  sum(increase(checkout_operations_total{service="checkout",outcome="good"}[28d]))
  /
  sum(increase(checkout_operations_total{service="checkout"}[28d]))
)
and
(sum(increase(checkout_operations_total{service="checkout"}[28d])) &gt; 0)
</code></pre>
<p>These return fractions; display them as percentages. In PromQL, <a href="https://prometheus.io/docs/prometheus/latest/querying/operators/">comparison operators filter out false elements by default, and <code>and</code> keeps left-hand elements, with their values, whose label sets exactly match an element on the right</a>. The final <code>and</code> guard therefore filters out a ratio when the observed total is not positive, though it does not certify that all observers reported correctly.</p>
<p>Prometheus documents that <a href="https://prometheus.io/docs/prometheus/latest/querying/functions/"><code>increase</code> adjusts for observed counter resets and extrapolates across the range</a>, which can produce non-integer results even for integer counters. That makes the result an estimate rather than an exact event ledger. Calculate each series' increase before aggregation so independent resets remain visible to the function.</p>
<p>Retain at least 28 days of underlying samples with boundary coverage, and check scrape and ingestion freshness. A newly installed counter does not acquire a full history because the query says <code>[28d]</code>. Long-range raw queries may also be expensive; evaluate recording rules when query cost warrants them, without changing the measurement definition.</p>
<p>For a current five-minute dashboard, use sums of per-series <code>rate(...[5m])</code>, but do not average five-minute ratios or multiply today's rate by 28 days to calculate budget spend.</p>
<p>Sampled counters can miss events during gaps or unseen resets. If exact accounting is required, reconcile against durable, deduplicated terminal-event records; building that system is outside this guide.</p>
<h2>How much error budget is left?</h2>
<p>For a request-based objective, allowed bad events equal <code>total × (1 − target)</code>. Subtract observed bad events to find the remaining budget. Calculate each objective separately, using the same eligible population and window; failures can consume both budgets at once.</p>
<p>Google's <a href="https://sre.google/workbook/implementing-slos/">SLO implementation guidance</a> recommends good-event ratios and explains how their targets translate into error budgets. Apply that approach to this hypothetical 28-day population:</p>
<ul>
<li>990,500 <code>good</code> attempts</li>
<li>8,900 <code>slow</code> attempts</li>
<li>600 <code>failed</code> attempts</li>
<li>1,000,000 eligible attempts in total</li>
</ul>
<table>
<thead>
<tr>
<th>Calculation</th>
<th>Availability</th>
<th>Timely success</th>
</tr>
</thead>
<tbody><tr>
<td>Successful events for this objective</td>
<td>999,400</td>
<td>990,500</td>
</tr>
<tr>
<td>Measured SLI</td>
<td>99.94%</td>
<td>99.05%</td>
</tr>
<tr>
<td>SLO target</td>
<td>99.9%</td>
<td>99.0%</td>
</tr>
<tr>
<td>Allowed bad events</td>
<td>1,000</td>
<td>10,000</td>
</tr>
<tr>
<td>Observed bad events</td>
<td>600</td>
<td>9,500</td>
</tr>
<tr>
<td>Remaining budget</td>
<td>400</td>
<td>500</td>
</tr>
<tr>
<td>Fraction of budget remaining</td>
<td>40%</td>
<td>5%</td>
</tr>
</tbody></table>
<p>For availability, the allowed fraction is 0.1%, giving <code>1,000,000 × 0.001 = 1,000</code> failures. Subtracting 600 leaves 400, or 40% of that budget.</p>
<p>For timely success, both slow and failed attempts are bad events. The allowance is <code>1,000,000 × 0.01 = 10,000</code>; subtracting <code>8,900 + 600 = 9,500</code> leaves 500, or 5%.</p>
<p>Both objectives pass, but the engineering decision should not be an unconditional green light. Timely success has little margin left, and slow responses dominate its bad events. Investigating that latency is more relevant to this budget than treating every problem as an availability incident.</p>
<p>Do not add the remaining budgets together: a failed attempt consumes both. Nor are these counts minutes of permitted downtime. Traffic volume determines the impact of an interruption, and a rolling window changes as new events arrive and old events expire. The current allowance is not a fixed monthly allocation.</p>
<h2>What should the team do with the result?</h2>
<p>Agree on a policy before an incident: normal releases while budgets are healthy, closer review when little remains, and a pause on discretionary feature releases when a budget is exhausted. Assign a service owner and explicit recovery conditions so the numbers lead to decisions.</p>
<p>Google's <a href="https://sre.google/workbook/error-budget-policy/">example error-budget policy</a> uses release restrictions to make space for reliability work, rather than punish teams. The following thresholds are proposed for this example, not universal Google rules:</p>
<table>
<thead>
<tr>
<th>State</th>
<th>Engineering action</th>
</tr>
</thead>
<tbody><tr>
<td>Both objectives met, neither budget below 25%, coverage sound</td>
<td>Permit ordinary releases with normal rollout and rollback controls.</td>
</tr>
<tr>
<td>Either budget positive but below 25% remaining</td>
<td>Prioritize the dominant failure class; require service-owner review of high-risk changes.</td>
</tr>
<tr>
<td>Either budget at or below zero</td>
<td>Pause discretionary feature releases, allow incident mitigations and security fixes, and assign a dated reliability action to the service owner.</td>
</tr>
</tbody></table>
<p>Our baseline is already in the caution state because timely success has only 5% remaining. That calls for investigating the slow responses and reviewing risky changes, not automatically freezing every deployment.</p>
<p>Resume paused feature releases when both rolling-window budgets are positive, telemetry coverage is sound, and the owner records remediation and rollout checks. A positive budget below 25% still requires caution. Unknown coverage, no traffic or insufficient history cannot establish the healthy state; the service owner must assess the missing evidence before using this policy to permit normal releases.</p>
<p>Review the policy weekly with product and engineering. Revisit targets when user needs change, but do not rewrite them retroactively to erase a failure.</p>
<p>Budget status never excuses a security incident or data loss. Those require action regardless of the aggregate percentage.</p>
<h2>What do zero traffic and missing telemetry mean?</h2>
<p>Zero eligible events means there is no request-based SLI for that interval. Missing telemetry means coverage is unknown. Neither means 100% success. Show traffic volume and data-health status alongside the ratio so readers can distinguish an idle service from an unobserved one.</p>
<p>One successful attempt gives 100%, but little evidence. Two attempts with one failure give 50%. Keep those real attempts in long-window accounting; dropping quiet periods would also drop their failures.</p>
<p>The query's traffic guard suppresses an empty or zero denominator. It cannot detect partial loss. If only the <code>good</code> series survives, the ratio can look perfect while failures go unreported. Check every expected observer and outcome series, together with scrape and ingestion freshness. A service-wide <code>absent_over_time</code> check detects total absence, not that kind of partial loss.</p>
<p>Synthetic checks can provide a separate signal during quiet periods. Keep their successes out of the real-user denominator. Google's <a href="https://sre.google/workbook/alerting-on-slos/">SLO alerting guidance</a> discusses low-traffic limitations and how artificial traffic can conceal real-user failures.</p>
<h2>How can you test the ratio without deploying anything?</h2>
<p>Use <code>promtool</code> to evaluate synthetic counters against explicit expected results. The self-contained fixture below tests the timely-success expression for normal traffic, zero traffic and missing telemetry. It checks query behaviour, not the correctness of an observer or a live service.</p>
<p>Save this as <code>checkout-test.yml</code>. In the <a href="https://prometheus.io/docs/prometheus/latest/configuration/unit_testing_rules/">documented Prometheus test format</a>, expanding notation <code>a+bxn</code> represents a series starting at <code>a</code> followed by <code>n</code> further samples incrementing by <code>b</code>. Here <code>0+90x28</code> means a starting value of zero followed by 28 samples increasing by 90. Daily samples keep this artificial example small, not realistic for production scraping.</p>
<pre><code class="language-yaml">rule_files: []
evaluation_interval: 1d
fuzzy_compare: true
tests:
  - name: normal-traffic
    interval: 1d
    input_series:
      - series: 'checkout_operations_total{service="checkout",instance="edge-a",outcome="good"}'
        values: '0+90x28'
      - series: 'checkout_operations_total{service="checkout",instance="edge-a",outcome="slow"}'
        values: '0+9x28'
      - series: 'checkout_operations_total{service="checkout",instance="edge-a",outcome="failed"}'
        values: '0+1x28'
    promql_expr_test:
      - expr: &amp;timely |
          (
            sum(increase(checkout_operations_total{service="checkout",outcome="good"}[28d]))
            /
            sum(increase(checkout_operations_total{service="checkout"}[28d]))
          )
          and
          (sum(increase(checkout_operations_total{service="checkout"}[28d])) &gt; 0)
        eval_time: 28d
        exp_samples:
          - labels: '{}'
            value: 0.9
  - name: zero-traffic
    interval: 1d
    input_series:
      - series: 'checkout_operations_total{service="checkout",instance="edge-a",outcome="good"}'
        values: '0+0x28'
      - series: 'checkout_operations_total{service="checkout",instance="edge-a",outcome="slow"}'
        values: '0+0x28'
      - series: 'checkout_operations_total{service="checkout",instance="edge-a",outcome="failed"}'
        values: '0+0x28'
    promql_expr_test:
      - expr: *timely
        eval_time: 28d
        exp_samples: []
  - name: missing-telemetry
    interval: 1d
    input_series: []
    promql_expr_test:
      - expr: *timely
        eval_time: 28d
        exp_samples: []
</code></pre>
<p>The YAML anchor <code>&amp;timely</code> names the expression so <code>*timely</code> can reuse it without recording rules. With <code>promtool</code> on your PATH, run:</p>
<pre><code class="language-shell">promtool test rules checkout-test.yml
</code></pre>
<p>This exact fixture passed with Prometheus <code>promtool</code> 3.5.0 and returned <code>SUCCESS</code>. The normal case returns <code>0.9</code>; the other cases return no samples. If your edited fixture fails, inspect the reported expression and expected value rather than replacing empty results with a success default.</p>
<h2>Frequently asked questions</h2>
<h3>Can a latency percentile replace the timely-success ratio?</h3>
<p>No. A percentile reports a latency threshold for a distribution; this objective needs the fraction of all eligible attempts that succeeded within 300 ms. Preserve both the success condition and the shared denominator.</p>
<p>A classic histogram ingested and queried as classic buckets can support threshold ratios only when it has an <a href="https://prometheus.io/docs/practices/histograms/">explicit matching bucket boundary</a>, because Prometheus does not interpolate missing classic buckets and returns an incomplete result without warning if only some histograms have that bucket. Counting every fast response would also incorrectly include fast failures.</p>
<h3>Should a planned maintenance window be excluded?</h3>
<p>Not in this example. If maintenance affects eligible user attempts, those outcomes remain in the denominator and consume budget when bad. Any different eligibility policy must be agreed in advance and describe the service promise honestly.</p>
<h3>Does meeting the 28-day SLO mean nobody needs to respond now?</h3>
<p>No. An ongoing outage can harm users while the historical ratio still meets its target. Use current operational signals for incident response; the rolling budget informs release risk and sustained reliability priorities, rather than replacing immediate response.</p>
]]></content:encoded></item><item><title><![CDATA[Observability on Amazon EKS: Metrics, Logs and Traces]]></title><description><![CDATA[Add OpenTelemetry, AMP, Fluent Bit and Grafana to existing EKS with Terraform and Helm, then diagnose failures across metrics, logs and traces.]]></description><link>https://blog.turingts.com/observability-on-amazon-eks-metrics-logs-and-traces</link><guid isPermaLink="true">https://blog.turingts.com/observability-on-amazon-eks-metrics-logs-and-traces</guid><category><![CDATA[AWS]]></category><category><![CDATA[Kubernetes]]></category><category><![CDATA[OpenTelemetry]]></category><category><![CDATA[observability]]></category><category><![CDATA[Terraform]]></category><category><![CDATA[#prometheus]]></category><category><![CDATA[Grafana]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Wed, 21 Oct 2026 17:45:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/1bc63d4b-8b91-444e-85cf-f2b63a79815e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A running application is not necessarily a healthy application. This guide adds observability to an existing Amazon EKS cluster: metrics to spot patterns, logs to explain events and traces to follow requests. We will introduce each component, connect the three signals and investigate a deliberately failed request.</p>
<h2>Why do we need more than a running cluster?</h2>
<p>A running container does not tell us whether users receive errors or slow responses. <strong>Observability</strong> helps us understand application behaviour through <strong>telemetry</strong>: metrics reveal patterns, logs describe events, and traces show the operations involved in a request.</p>
<p>Imagine an API suddenly starts returning errors. We want to answer three different questions:</p>
<ul>
<li><p><strong>Metrics — how often is this happening?</strong> Metrics are numerical measurements over time, such as request counts, error rates and response durations. They help us spot trends and decide where to investigate.</p>
</li>
<li><p><strong>Logs — what happened?</strong> Logs record individual events, ideally with useful fields such as a timestamp, an error message and a request identifier. They provide detail about a particular failure.</p>
</li>
<li><p><strong>Traces — where did the request spend its time or fail?</strong> A trace describes the work performed for a request. It contains <strong>spans</strong>, each representing an operation with its timing and context. In a distributed application, a trace can connect operations across services when those services propagate the trace context.</p>
</li>
</ul>
<p>These signals complement each other. A metric can reveal an increase in errors, a log can describe one of those errors, and a trace can identify the operation involved. Here we use <strong>Podinfo</strong>, an upstream demo service, rather than build a second application project. With tracing enabled and debug logging selected, its request-start log includes a <strong>trace ID</strong> that we can look up manually in the span store. Collecting all three signals does not automatically link them; the application and collection configuration must preserve that connection.</p>
<h2>What does each component do?</h2>
<p>OpenTelemetry instruments applications; the Collector forwards metrics and traces. AMP stores metrics, while Fluent Bit sends container logs to CloudWatch. X-Ray receives spans for Transaction Search. Grafana queries metrics and logs; Terraform and Helm deploy the tooling.</p>
<ul>
<li><strong>Amazon EKS</strong> runs the application, collectors and Grafana on your existing Kubernetes cluster. We do not create a cluster or rebuild its networking.</li>
<li><strong>OpenTelemetry (OTel)</strong> provides vendor-neutral instrumentation and transport, not a database or dashboard. Podinfo already uses it to produce spans; <strong>OTLP</strong> is the protocol that carries them. <a href="https://opentelemetry.io/docs/what-is-opentelemetry/">OpenTelemetry overview</a></li>
<li><strong>The OpenTelemetry Collector</strong> receives, processes and forwards telemetry. Here it scrapes Podinfo's Prometheus endpoint and sends metrics to AMP; it also receives OTLP/gRPC spans and exports them to X-Ray over OTLP/HTTP. It does not collect application logs or provide long-term storage. <a href="https://opentelemetry.io/docs/collector/">Collector documentation</a></li>
<li><strong>Prometheus and AMP</strong> provide the metrics model and managed storage. Scraping means periodically reading an HTTP metrics endpoint; Podinfo already exposes <code>/metrics</code>, so no custom exporter is needed. The Collector uses remote write to send samples to <strong>Amazon Managed Service for Prometheus (AMP)</strong>. Grafana queries them with <strong>PromQL</strong>, the Prometheus query language.</li>
<li><strong>AWS for Fluent Bit and CloudWatch Logs</strong> handle application events. Fluent Bit tails container logs from stdout/stderr and forwards them to the application log group. Podinfo writes JSON to stderr; debug request-start events include a trace ID, but no completion status or duration. Existing EKS control-plane logging is a separate path.</li>
<li><strong>X-Ray and Transaction Search</strong> handle spans. The Collector sends them to AWS's X-Ray OTLP ingestion endpoint. With the prerequisite <strong>CloudWatch Transaction Search</strong> enabled, spans are stored in CloudWatch Logs under <code>aws/spans</code>, separately from application logs. Transaction Search is the trace-investigation interface. <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Transaction-Search.html">Transaction Search documentation</a></li>
<li><strong>Grafana</strong> queries AMP metrics and CloudWatch application logs. It does not replace those stores; this example uses Transaction Search separately, not a Grafana trace datasource.</li>
<li><strong>Terraform and Helm</strong> configure AWS resources, workload permissions and tooling charts through your existing CI/CD pipeline. <strong>kubectl</strong> installs Podinfo separately. IAM roles give collectors ingestion permissions and Grafana query permissions; they are distinct from the pipeline's deployment identity.</li>
</ul>
<h2>What will we build and verify?</h2>
<p>We will add a Collector, AMP workspace, application log group, workload permissions and Grafana to existing EKS. Using Podinfo, we will generate an HTTP 500, identify its metric signal, find its request-start log and locate the server span using the same trace ID.</p>
<p>This is a focused learning implementation, not a claim of production high availability. We assume that EKS, Terraform state and CI/CD already work, and that the account owner has enabled Transaction Search. The prerequisites below make those assumptions explicit before we deploy anything.</p>
<h2>Architecture: how the signals travel</h2>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/e5ea1cb6-3e1c-4fd0-bfe2-ef8a6b87d419.png" alt="Podinfo on EKS: metrics through the Collector to AMP, stderr through Fluent Bit to CloudWatch Logs, and OTLP/gRPC spans through the Collector and X-Ray to Transaction Search." /></p>
<p>The diagram separates collection from storage and investigation. Terraform and Helm configure the tooling through the existing pipeline; <code>kubectl</code> installs Podinfo. Neither deployment path carries telemetry. Account-level Transaction Search configuration remains with its existing owner.</p>
<h2>1. What needs to exist before I deploy this stack?</h2>
<p>You need an existing EKS cluster, Terraform CI/CD, authorized Kubernetes access and the cluster's existing IAM OIDC provider. Prepare the Grafana admin Secret, confirm workload egress, and have the account owner enable Transaction Search before applying observability resources.</p>
<p>Use <code>us-east-1</code>, Linux amd64 nodes, tooling in <code>observability</code>, one Podinfo replica in <code>demo</code>, and <code>/aws/eks/observability-lab/application</code> for application logs. Confirm:</p>
<ul>
<li>Your runner/operator can reach the EKS API and is authorized for these resources, including Fluent Bit's cluster-scoped RBAC. A private API needs VPC or connected-network access. <a href="https://docs.aws.amazon.com/eks/latest/userguide/cluster-endpoint.html">EKS networking</a></li>
<li>The owner supplies the cluster name, endpoint, <strong>decoded PEM</strong> CA, exact OIDC issuer URL and existing provider ARN. Do not recreate or import the cluster's OIDC provider here.</li>
<li>Workloads can reach regional STS, APS, X-Ray and CloudWatch Logs; nodes can pull images, including Podinfo from GHCR. Grafana startup also needs <code>grafana.com</code> for its AMP plugin. No application build toolchain or private registry is required.</li>
<li>The existing Terraform process provides credentials, backend, approvals and provider locks. Use Terraform <code>&gt;= 1.10.0, &lt; 2.0.0</code>, AWS CLI for EKS token generation, and Helm/kubectl for inspection.</li>
<li>The account owner has enabled Transaction Search, approved span costs/retention and granted the investigator access to <code>aws/spans</code>. Its account-level configuration is outside this lab. <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-OTLPSimplesetup.html">AWS setup</a></li>
</ul>
<p>Explicit example pins: AWS provider <code>6.69.1</code>; Helm provider <code>3.3.0</code>; Collector chart <code>0.176.1</code> / contrib <code>0.162.0</code>; Fluent Bit chart <code>0.2.0</code> / AWS image <code>3.2.1</code>; Grafana chart <code>14.0.1</code> / image <code>13.2.4-distroless</code> / AMP plugin <code>3.2.0</code>; Podinfo <code>6.9.2</code> plus digest. These are not claims of latest versions or upgrade advice.</p>
<h3>Prepare the namespace and Grafana Secret</h3>
<p>Check ownership and name collisions first: fixed release names and IAM role names must not replace existing installations. Use your approved operator context, and create the Secret only if it does not already exist:</p>
<pre><code class="language-shell">kubectl config current-context
kubectl create namespace observability --dry-run=client -o yaml | kubectl apply -f -
# Supply private files through your approved secret-handling process.
: "${ADMIN_USER_FILE:?required}" "${ADMIN_PASSWORD_FILE:?required}"
kubectl -n observability create secret generic grafana-admin \
  --from-file=admin-user="$ADMIN_USER_FILE" \
  --from-file=admin-password="$ADMIN_PASSWORD_FILE"
</code></pre>
<p>The namespace and Secret are operator-managed. Keep credentials outside Terraform state and job output; rotate existing credentials through the owner's approved process. The Secret must contain both <code>admin-user</code> and <code>admin-password</code>.</p>
<p>Use this layout; all handwritten deployment files appear below. There is no separate application project:</p>
<pre><code class="language-text">observability/
  versions.tf
  telemetry.tf
  permissions.tf
  helm.tf
  values/{otel-collector,fluent-bit,grafana}.yaml.tftpl
podinfo/
  podinfo.yaml
</code></pre>
<p>Use a separately owned Terraform root with your established backend, or integrate after reviewing resource ownership. Supply <code>cluster</code> through the existing pipeline's variable mechanism.</p>
<h2>2. Create the observability resources and workload roles</h2>
<p>The input identifies the existing cluster and its existing IAM OIDC provider; <code>ca_pem</code> must already be decoded. The region is consistently <code>us-east-1</code>.</p>
<p><code>observability/versions.tf</code>:</p>
<pre><code class="language-json">terraform {
  required_version = "&gt;= 1.10.0, &lt; 2.0.0"
  required_providers {
    aws  = { source = "hashicorp/aws", version = "6.69.1" }
    helm = { source = "hashicorp/helm", version = "3.3.0" }
  }
  # Use the backend configuration already owned by your Terraform pipeline.
}
provider "aws" { region = "us-east-1" }
variable "cluster" {
  description = "Existing us-east-1 cluster and its existing IAM OIDC provider; CA is decoded PEM, not base64."
  type = object({
    name              = string
    endpoint          = string
    ca_pem            = string
    oidc_issuer_url   = string
    oidc_provider_arn = string
  })
  validation {
    condition     = startswith(var.cluster.endpoint, "https://") &amp;&amp; startswith(var.cluster.oidc_issuer_url, "https://") &amp;&amp; !endswith(var.cluster.oidc_issuer_url, "/")
    error_message = "Supply HTTPS cluster and issuer URLs; the issuer must not end with a slash."
  }
}
</code></pre>
<p>IRSA allows a Kubernetes workload to assume an AWS role with its service-account token. The trust below matches the existing OIDC provider, STS audience and exact service-account subject. It creates three roles, an AMP workspace and a seven-day application log group. <a href="https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html">AWS IRSA</a></p>
<p><code>observability/telemetry.tf</code>:</p>
<pre><code class="language-json">locals {
  oidc_key = trimprefix(var.cluster.oidc_issuer_url, "https://")
}
resource "aws_iam_role" "workload" {
  for_each = toset(["otel-collector", "fluent-bit", "grafana"])
  name     = "lab-${each.key}"
  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect    = "Allow", Action = "sts:AssumeRoleWithWebIdentity"
      Principal = { Federated = var.cluster.oidc_provider_arn }
      Condition = { StringEquals = {
        "${local.oidc_key}:aud" = "sts.amazonaws.com"
        "${local.oidc_key}:sub" = "system:serviceaccount:observability:${each.key}"
      } }
    }]
  })
}
resource "aws_prometheus_workspace" "lab" { alias = "observability-lab" }
resource "aws_cloudwatch_log_group" "app" {
  name              = "/aws/eks/observability-lab/application"
  retention_in_days = 7
}
locals {
  amp_base        = trimsuffix(trimsuffix(aws_prometheus_workspace.lab.prometheus_endpoint, "/"), "/api/v1")
  app_streams_arn = "${aws_cloudwatch_log_group.app.arn}:log-stream:*"
}
locals {
  tool_values = {
    region               = "us-east-1"
    cluster_name         = var.cluster.name
    endpoint             = var.cluster.endpoint
    ca_pem               = var.cluster.ca_pem
    collector_role_arn   = aws_iam_role.workload["otel-collector"].arn
    fluent_bit_role_arn  = aws_iam_role.workload["fluent-bit"].arn
    grafana_role_arn     = aws_iam_role.workload["grafana"].arn
    amp_base_url         = local.amp_base
    amp_remote_write_url = "${local.amp_base}/api/v1/remote_write"
    app_log_group        = aws_cloudwatch_log_group.app.name
    xray_traces_url      = "https://xray.us-east-1.amazonaws.com/v1/traces"
  }
}
output "amp_base_url" {
  value = local.amp_base
  precondition {
    condition     = can(regex("^https://[^/]+/workspaces/[^/?#]+$", local.amp_base))
    error_message = "Unexpected AMP endpoint shape; inspect before deployment."
  }
}
output "amp_remote_write_url" { value = local.tool_values.amp_remote_write_url }
</code></pre>
<p>Normalize the AMP endpoint's trailing slash and known <code>/api/v1</code> suffix before appending <code>/api/v1/remote_write</code>. Grafana receives the workspace base. The output precondition catches unexpected shapes. The pinned provider passes through the workspace endpoint and removes the log-group ARN's trailing <code>:*</code>. <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/v6.69.1/internal/service/amp/workspace.go">AMP provider source</a> · <a href="https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/v6.69.1/website/docs/r/cloudwatch_log_group.html.markdown">Log-group ARN</a></p>
<h3>Attach permissions, not shared credentials</h3>
<table>
<thead>
<tr>
<th>Role</th>
<th>Scope</th>
</tr>
</thead>
<tbody><tr>
<td>Collector</td>
<td><code>aps:RemoteWrite</code> on this workspace; <code>xray:PutSpans</code> on <code>*</code></td>
</tr>
<tr>
<td>Fluent Bit</td>
<td>Create streams and write events in the precreated application group</td>
</tr>
<tr>
<td>Grafana</td>
<td>Query AMP and application logs; separate global discovery/stop actions</td>
</tr>
</tbody></table>
<p><code>xray:PutSpans</code> authorizes OTLP span uploads, not the separate <code>PutTraceSegments</code> action; it has no resource-level ARN. <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_xray.html">X-Ray authorization</a></p>
<p><code>observability/permissions.tf</code>:</p>
<pre><code class="language-json">resource "aws_iam_role_policy" "collector" {
  name = "telemetry-write"
  role = aws_iam_role.workload["otel-collector"].id
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      { Effect = "Allow", Action = ["aps:RemoteWrite"], Resource = aws_prometheus_workspace.lab.arn },
      { Effect = "Allow", Action = ["xray:PutSpans"], Resource = "*" }
    ]
  })
}
resource "aws_iam_role_policy" "fluent_bit" {
  name = "application-log-write"
  role = aws_iam_role.workload["fluent-bit"].id
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect   = "Allow"
      Action   = ["logs:CreateLogStream", "logs:PutLogEvents"]
      Resource = local.app_streams_arn
    }]
  })
}
resource "aws_iam_role_policy" "grafana" {
  name = "telemetry-read"
  role = aws_iam_role.workload["grafana"].id
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Effect   = "Allow"
        Action   = ["aps:QueryMetrics", "aps:GetLabels", "aps:GetSeries", "aps:GetMetricMetadata"]
        Resource = aws_prometheus_workspace.lab.arn
      },
      {
        Effect   = "Allow"
        Action   = ["logs:StartQuery", "logs:GetQueryResults"]
        Resource = [aws_cloudwatch_log_group.app.arn, "${aws_cloudwatch_log_group.app.arn}:*"]
      },
      {
        Effect   = "Allow"
        Action   = ["logs:DescribeLogGroups", "logs:StopQuery"]
        Resource = "*"
      }
    ]
  })
}
</code></pre>
<p>The Logs query policy includes the application's bare group ARN and <code>:*</code> form. Verify the form accepted by each action, then tighten it if appropriate. <code>DescribeLogGroups</code> can enumerate names but does not authorize event reads. Optional Grafana editor features may need separate permissions; give the human trace investigator access to <code>aws/spans</code> rather than widening this application-log role. <a href="https://grafana.com/docs/grafana/latest/datasources/aws-cloudwatch/configure/">Grafana permissions</a></p>
<p>AWS for Fluent Bit <code>3.2.1</code> packages upstream <code>4.2.2</code>. With log-group auto-creation disabled and no retention change, this configuration needs only stream creation and event writes. <a href="https://api.github.com/repos/aws/aws-for-fluent-bit/releases/tags/v3.2.1">Release</a> · <a href="https://raw.githubusercontent.com/fluent/fluent-bit/v4.2.2/plugins/out_cloudwatch_logs/cloudwatch_api.c">Pinned implementation</a></p>
<h2>3. Install tooling with the existing Terraform process</h2>
<p>The Helm provider connects to the existing EKS API. Only the three tooling releases belong to Terraform; Podinfo is installed later with kubectl. Provider <code>3.3.0</code> uses object-valued <code>kubernetes</code> and <code>exec</code> settings. <a href="https://github.com/hashicorp/terraform-provider-helm/tree/v3.3.0/docs">Provider documentation</a></p>
<p><code>observability/helm.tf</code>:</p>
<pre><code class="language-json">locals {
  charts = {
    otel-collector = {
      repository = "https://open-telemetry.github.io/opentelemetry-helm-charts"
      chart      = "opentelemetry-collector"
      version    = "0.176.1"
    }
    fluent-bit = {
      repository = "https://aws.github.io/eks-charts"
      chart      = "aws-for-fluent-bit"
      version    = "0.2.0"
    }
    grafana = {
      repository = "https://grafana-community.github.io/helm-charts"
      chart      = "grafana"
      version    = "14.0.1"
    }
  }
}
provider "helm" {
  kubernetes = {
    host                   = var.cluster.endpoint
    cluster_ca_certificate = var.cluster.ca_pem
    exec = {
      api_version = "client.authentication.k8s.io/v1beta1"
      command     = "aws"
      args = ["eks", "get-token", "--cluster-name", var.cluster.name,
      "--region", "us-east-1"]
    }
  }
}
resource "helm_release" "tools" {
  for_each         = local.charts
  name             = each.key
  namespace        = "observability"
  create_namespace = false
  repository       = each.value.repository
  chart            = each.value.chart
  version          = each.value.version
  values           = [templatefile("${path.module}/values/${each.key}.yaml.tftpl", local.tool_values)]
  wait             = true
  timeout          = 600
  depends_on       = [aws_iam_role_policy.collector, aws_iam_role_policy.fluent_bit, aws_iam_role_policy.grafana]
}
</code></pre>
<p>Terraform downloads each chart directly from its repository at the pinned version and supplies our values. No manual chart download, extraction or local vendor directory is needed. The existing pipeline must be able to reach these repositories and their chart download hosts.</p>
<p>For production environments with additional supply-chain requirements, an approved internal chart mirror and provenance verification can be added separately; they are not prerequisites for following this guide.</p>
<p>The <code>.yaml.tftpl</code> files below are Terraform templates, not direct Helm values. <code>templatefile</code> renders each complete document before Helm consumes it. Keep <code>$${env:MY_POD_IP}</code> escaped so Terraform leaves environment expansion to the Collector. <a href="https://developer.hashicorp.com/terraform/language/expressions/strings">Terraform string syntax</a></p>
<p>Confirm the operator-managed namespace and Secret exist, then use the existing pipeline's reviewed plan/apply. Afterward:</p>
<pre><code class="language-shell">kubectl -n observability rollout status deployment/otel-collector --timeout=180s
kubectl -n observability rollout status daemonset/fluent-bit --timeout=180s
kubectl -n observability rollout status deployment/grafana --timeout=180s
</code></pre>
<p>A successful rollout is not proof of telemetry ingestion.</p>
<h2>4. Give the Collector one scrape owner</h2>
<p>The pinned remote-write exporter supports nested <code>http</code> settings, while the OTLP HTTP exporter accepts an explicit <code>traces_endpoint</code> and top-level HTTP client settings. <a href="https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector-contrib/v0.162.0/exporter/prometheusremotewriteexporter/config.go">Remote-write configuration</a> · <a href="https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector/v0.162.0/exporter/otlphttpexporter/config.go">OTLP HTTP configuration</a></p>
<p>Use this complete Collector template: a Recreate singleton, one static application target, separate <code>aps</code> and <code>xray</code> signers, finite in-memory queues and retries, and no log pipeline. Expose only OTLP/gRPC on port <code>4317</code> for Podinfo; retain the chart’s internal health check. The Collector still exports traces to AWS over OTLP/HTTP with SigV4.</p>
<p><code>observability/values/otel-collector.yaml.tftpl</code>:</p>
<pre><code class="language-yaml">fullnameOverride: otel-collector
mode: deployment
replicaCount: 1
rollout: {strategy: Recreate, rollingUpdate: {}}
autoscaling: {enabled: false}
image: {repository: otel/opentelemetry-collector-contrib, tag: '0.162.0'}
command: {name: otelcol-contrib}
serviceAccount:
  create: true
  name: otel-collector
  automountServiceAccountToken: true
  annotations: {eks.amazonaws.com/role-arn: '${collector_role_arn}'}
clusterRole: {create: false}
presets:
  logsCollection: {enabled: false}
  hostMetrics: {enabled: false}
  kubernetesAttributes: {enabled: false}
  kubeletMetrics: {enabled: false}
  kubernetesEvents: {enabled: false}
  kubernetesObjects: {enabled: false}
  clusterMetrics: {enabled: false}
  annotationDiscovery: {logs: {enabled: false}, metrics: {enabled: false}}
  profiling: {enabled: false}
  resourceDetection: {enabled: false}
resources:
  requests: {cpu: 100m, memory: 256Mi}
  limits: {memory: 512Mi}
extraEnvs: [{name: AWS_EC2_METADATA_DISABLED, value: 'true'}]
ports:
  otlp: {enabled: true, containerPort: 4317, servicePort: 4317, hostPort: null}
  otlp-http: {enabled: false}
  jaeger-compact: {enabled: false}
  jaeger-thrift: {enabled: false}
  jaeger-grpc: {enabled: false}
  zipkin: {enabled: false}
  metrics: {enabled: false}
service: {enabled: true, type: ClusterIP}
config:
  extensions:
    sigv4auth/amp: {region: us-east-1, service: aps}
    sigv4auth/xray: {region: us-east-1, service: xray}
  receivers:
    jaeger: null
    zipkin: null
    otlp:
      protocols:
        grpc: {endpoint: '$${env:MY_POD_IP}:4317'}
        http: null
    prometheus:
      config:
        scrape_configs:
          - job_name: podinfo
            scrape_interval: 15s
            scrape_timeout: 10s
            static_configs: [{targets: [podinfo.demo.svc.cluster.local:9898]}]
  processors:
    memory_limiter: {check_interval: 1s, limit_percentage: 75, spike_limit_percentage: 15}
    batch: {timeout: 5s, send_batch_size: 1024, send_batch_max_size: 1024}
  exporters:
    debug: null
    prometheus_remote_write/amp:
      http:
        endpoint: '${amp_remote_write_url}'
        auth: {authenticator: sigv4auth/amp}
      remote_write_queue: {enabled: true, queue_size: 100, num_consumers: 1}
      max_batch_request_parallelism: 1
      retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 60s}
    otlp_http/xray:
      traces_endpoint: '${xray_traces_url}'
      auth: {authenticator: sigv4auth/xray}
      compression: gzip
      sending_queue: {enabled: true, queue_size: 100, num_consumers: 1}
      retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 60s}
  service:
    extensions: [health_check, sigv4auth/amp, sigv4auth/xray]
    pipelines:
      logs: null
      metrics: {receivers: [prometheus], processors: [memory_limiter, batch], exporters: [prometheus_remote_write/amp]}
      traces: {receivers: [otlp], processors: [memory_limiter, batch], exporters: [otlp_http/xray]}
</code></pre>
<p>The chart requires <code>health_check</code> for its probes. Multiple Collector replicas with identical Prometheus configurations scrape the same targets repeatedly. <a href="https://github.com/open-telemetry/opentelemetry-helm-charts/tree/opentelemetry-collector-0.176.1/charts/opentelemetry-collector">Chart defaults</a> · <a href="https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.162.0">Component documentation</a></p>
<p>Accept a scrape interruption during replacement rather than overlapping owners. This Service target is deliberately limited to one application replica; introduce per-pod discovery and explicit scrape ownership before scaling. No WAL or outage-delivery guarantee is configured.</p>
<p>Keep the nested <code>http</code> settings, one queue consumer and <code>max_batch_request_parallelism: 1</code>; these avoid the deprecated client configuration and parallel metric-batch delivery. They do not provide durable queues or make duplicate scrapers safe.</p>
<h2>5. Keep container logs on one path</h2>
<p>Fluent Bit’s Kubernetes filter can put parsed application JSON under <code>Merge_Log_Key</code>; its CloudWatch output sends the entire record unless <code>log_key</code> selects only one value. <a href="https://docs.fluentbit.io/manual/4.2/data-pipeline/filters/kubernetes.md">Kubernetes filter</a> · <a href="https://docs.fluentbit.io/manual/4.2/data-pipeline/outputs/cloudwatch.md">CloudWatch output</a></p>
<p>Use <code>data</code> as that key, disable annotation-driven parsing/exclusion, and leave <code>logKey</code> unset. Tail only this application, avoiding collection of Fluent Bit’s own diagnostics. The following is the complete <code>fluent-bit.yaml.tftpl</code>.</p>
<p><code>observability/values/fluent-bit.yaml.tftpl</code>:</p>
<pre><code class="language-yaml">fullnameOverride: fluent-bit
image:
  repository: public.ecr.aws/aws-observability/aws-for-fluent-bit
  tag: "3.2.1"
serviceAccount:
  create: true
  name: fluent-bit
  annotations:
    eks.amazonaws.com/role-arn: ${fluent_bit_role_arn}
nodeSelector:
  kubernetes.io/os: linux
hostNetwork: false
env:
  - name: AWS_EC2_METADATA_DISABLED
    value: "true"
service:
  parsersFiles:
    - /fluent-bit/parsers/parsers.conf
  extraService: |
    Flush 5
    Grace 30
    Log_Level info
    HTTP_Server On
    HTTP_Listen 0.0.0.0
    HTTP_Port 2020
    Health_Check On
    storage.path /buffers/chunks
    storage.sync normal
    storage.checksum On
    storage.max_chunks_up 64
    storage.backlog.mem_limit 16M
input:
  enabled: true
  tag: kube.*
  path: /var/log/containers/podinfo-*_demo_podinfo-*.log
  db: /buffers/tail.db
  multilineParser: docker, cri
  memBufLimit: 5MB
  skipLongLines: "On"
  refreshInterval: 5
  extraInputs: |
    Read_from_Head On
    storage.type filesystem
    DB.Sync Normal
filter:
  enabled: true
  match: kube.*
  mergeLog: "On"
  mergeLogKey: data
  keepLog: "Off"
  k8sLoggingParser: "Off"
  k8sLoggingExclude: "Off"
  bufferSize: 32k
cloudWatchLogs:
  enabled: true
  match: kube.*
  region: us-east-1
  logGroupName: ${app_log_group}
  logStreamPrefix: fluentbit-
  autoCreateGroup: "false"
  autoRetryRequests: "false"
  extraOutputs: |
    Retry_Limit 5
    storage.total_limit_size 100M
cloudWatch:
  enabled: false
firehose:
  enabled: false
kinesis:
  enabled: false
kinesis_streams:
  enabled: false
elasticsearch:
  enabled: false
s3:
  enabled: false
opensearch:
  enabled: false
additionalInputs: ""
additionalFilters: ""
additionalOutputs: ""
volumes:
  - name: varlog
    hostPath:
      path: /var/log
      type: Directory
  - name: buffers
    emptyDir:
      sizeLimit: 256Mi
volumeMounts:
  - name: varlog
    mountPath: /var/log
    readOnly: true
  - name: buffers
    mountPath: /buffers
resources:
  requests:
    cpu: 50m
    memory: 128Mi
    ephemeral-storage: 128Mi
  limits:
    memory: 256Mi
    ephemeral-storage: 512Mi
serviceMonitor:
  enabled: false
</code></pre>
<p>Keep the quoted <code>"false"</code> settings: the pinned chart otherwise omits these options. The configuration sends only Podinfo container logs, merges application JSON under <code>data</code>, and has exactly one CloudWatch output. The precreated group needs no log-group creation or retention-update permissions. <a href="https://aws.github.io/eks-charts/aws-for-fluent-bit-0.2.0.tgz">Pinned chart</a></p>
<p>The filesystem buffer requires the service storage path, input storage type, writable volume and output limit together. Retries are finite; a full output queue can evict its oldest chunks. <code>emptyDir</code> and the tail database survive a container restart, not Pod replacement or node loss. Replacement can also reread files with <code>Read_from_Head On</code>. This is bounded buffering, not durable delivery. <a href="https://docs.fluentbit.io/manual/4.2/administration/buffering-and-storage.md">Storage behavior</a></p>
<p><code>AWS_EC2_METADATA_DISABLED</code> is not by itself proof of the binary's credential choice: check that Fluent Bit uses its intended service-account role, not node credentials. Leave existing EKS control-plane logging with its owner; do not add Collector logs, CloudWatch metrics, EMF or Container Insights to this application-log path.</p>
<h2>6. Provision Grafana without role hopping</h2>
<p>Grafana 13 deprecates SigV4 on the core Prometheus datasource in favor of dedicated plugins. Chart <code>14.0.1</code> maps its plugin list to <code>GF_PLUGINS_PREINSTALL_SYNC</code>. <a href="https://grafana.com/docs/plugins/grafana-amazonprometheus-datasource/latest/configure/">AMP configuration</a> · <a href="https://raw.githubusercontent.com/grafana-community/helm-charts/grafana-14.0.1/charts/grafana/templates/_pod.tpl">Chart pod template</a></p>
<p>Use the pinned amd64 AMP package and retain the bundled CloudWatch plugin. Configure Grafana with an explicit STS-audience projection, ordinary API-token automount disabled, no IRSA webhook annotation, and no static AWS credentials.</p>
<p><code>observability/values/grafana.yaml.tftpl</code>:</p>
<pre><code class="language-yaml">fullnameOverride: grafana
replicas: 1
image:
  registry: docker.io
  repository: grafana/grafana
  tag: 13.2.4-distroless
nodeSelector:
  kubernetes.io/os: linux
  kubernetes.io/arch: amd64
serviceAccount:
  create: true
  name: grafana
  automountServiceAccountToken: false
  annotations: {}
automountServiceAccountToken: false
rbac:
  create: false
admin:
  existingSecret: grafana-admin
  userKey: admin-user
  passwordKey: admin-password
service:
  type: ClusterIP
ingress:
  enabled: false
persistence:
  enabled: false
testFramework:
  enabled: false
securityContext:
  runAsNonRoot: true
  runAsUser: 472
  runAsGroup: 472
  fsGroup: 472
env:
  AWS_REGION: us-east-1
  AWS_DEFAULT_REGION: us-east-1
  AWS_STS_REGIONAL_ENDPOINTS: regional
  AWS_EC2_METADATA_DISABLED: "true"
  AWS_ROLE_ARN: ${grafana_role_arn}
  AWS_WEB_IDENTITY_TOKEN_FILE: /var/run/secrets/eks.amazonaws.com/serviceaccount/token
extraSecretMounts:
  - name: aws-iam-token
    mountPath: /var/run/secrets/eks.amazonaws.com/serviceaccount
    readOnly: true
    projected:
      defaultMode: 420
      sources:
        - serviceAccountToken:
            audience: sts.amazonaws.com
            expirationSeconds: 86400
            path: token
plugins:
  - grafana-amazonprometheus-datasource@3.2.0@https://grafana.com/api/plugins/grafana-amazonprometheus-datasource/versions/3.2.0/download?os=linux&amp;arch=amd64
shadowBundledPlugins: false
datasources:
  datasources.yaml:
    apiVersion: 1
    datasources:
      - name: AMP
        uid: amp
        type: grafana-amazonprometheus-datasource
        access: proxy
        isDefault: true
        editable: false
        url: ${amp_base_url}
        jsonData:
          httpMethod: POST
          sigV4Auth: true
          sigV4AuthType: default
          sigV4Region: us-east-1
          sigv4Service: aps
          manageAlerts: false
      - name: CloudWatch Logs
        uid: cloudwatch
        type: cloudwatch
        access: proxy
        editable: false
        jsonData:
          authType: default
          defaultRegion: us-east-1
</code></pre>
<p>The explicit STS-audience token projection is separate from ordinary API-token automounting. Grafana uses <code>AWS_WEB_IDENTITY_TOKEN_FILE</code> and <code>AWS_ROLE_ARN</code> through the SDK default credential chain; <code>fsGroup: 472</code> makes the token accessible. Leave datasource Assume Role fields unset to avoid a second role hop. <a href="https://grafana.com/docs/grafana/latest/datasources/aws-cloudwatch/aws-authentication/">Grafana AWS authentication</a></p>
<p>The Secret and projected token keep static AWS credentials out of these values. Plugin installation and real web-identity/query access still need live verification. Keep dashboards reproducible: persistence is disabled, so UI-only changes are disposable.</p>
<h2>7. Install upstream Podinfo with kubectl</h2>
<p>Podinfo supplies the workload without a Dockerfile, dependency lock or application chart. Use release <strong>6.9.2</strong>, source commit <code>e86405a8674ecab990d0a389824c7ebbd82973b5</code>; the manifest pins the public image by digest as well as version. This is an explicit teaching pin, not a claim that it is the latest release. <a href="https://github.com/stefanprodan/podinfo/blob/e86405a8674ecab990d0a389824c7ebbd82973b5/kustomize/deployment.yaml">Pinned upstream deployment</a></p>
<p>This small manifest adapts the upstream workload to the lab: one replica, one HTTP port, a ClusterIP Service and no public ingress. It enables tracing with <code>PODINFO_OTEL_SERVICE_NAME=podinfo</code> and sets <code>OTEL_EXPORTER_OTLP_ENDPOINT</code> to the Collector's <strong>gRPC</strong> endpoint. This Podinfo version constructs a gRPC exporter: changing an environment variable to say HTTP does not turn it into an OTLP/HTTP client. The <code>http://</code> scheme selects plaintext gRPC inside this lab; do <strong>not</strong> append <code>/v1/traces</code>. <a href="https://github.com/stefanprodan/podinfo/blob/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/tracer.go">Tracing implementation</a></p>
<p>The dedicated <code>demo</code> namespace separates ownership from tooling in <code>observability</code>; a namespace alone is <strong>not</strong> a network-security boundary. Podinfo has environment/configuration inspection and fault-injection endpoints. Do not give it AWS credentials, application secrets or a Kubernetes API token, and do not put sensitive values in its environment or configuration. Keep it private and use authorized port-forwarding. Review existing namespace ownership before applying. <a href="https://github.com/stefanprodan/podinfo/blob/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/server.go">Pinned routes</a></p>
<p><code>podinfo/podinfo.yaml</code>:</p>
<pre><code class="language-yaml">apiVersion: v1
kind: Namespace
metadata: {name: demo}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: podinfo, namespace: demo}
spec:
  replicas: 1
  strategy: {type: Recreate}
  selector: {matchLabels: {app: podinfo}}
  template:
    metadata: {labels: {app: podinfo}}
    spec:
      automountServiceAccountToken: false
      enableServiceLinks: false
      nodeSelector: {kubernetes.io/os: linux, kubernetes.io/arch: amd64}
      securityContext: {runAsNonRoot: true, runAsUser: 10001, runAsGroup: 10001, fsGroup: 10001}
      containers:
        - name: podinfo
          image: ghcr.io/stefanprodan/podinfo:6.9.2@sha256:cab90e04829cdae73199a8402882a4e3ccaf251b8a0d50bdefede0ab3f6371e7
          command: [./podinfo]
          args: [--port=9898, --level=debug, --random-delay=false, --random-error=false]
          env:
            - {name: PODINFO_OTEL_SERVICE_NAME, value: podinfo}
            - name: OTEL_EXPORTER_OTLP_ENDPOINT
              value: http://otel-collector.observability.svc.cluster.local:4317
          ports: [{name: http, containerPort: 9898}]
          readinessProbe: {httpGet: {path: /readyz, port: http}}
          livenessProbe: {httpGet: {path: /healthz, port: http}, initialDelaySeconds: 5}
          resources:
            requests: {cpu: 100m, memory: 64Mi}
            limits: {cpu: 500m, memory: 128Mi}
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities: {drop: [ALL]}
          volumeMounts: [{name: data, mountPath: /data}]
      volumes: [{name: data, emptyDir: {sizeLimit: 16Mi}}]
---
apiVersion: v1
kind: Service
metadata: {name: podinfo, namespace: demo}
spec:
  type: ClusterIP
  selector: {app: podinfo}
  ports: [{name: http, port: 9898, targetPort: http}]
</code></pre>
<p>After the observability tooling is ready, inspect and apply these resources through your approved operator context. The namespace is part of this manifest; do not reuse a shared <code>demo</code> namespace without reviewing ownership.</p>
<pre><code class="language-shell">kubectl config current-context
kubectl apply -f podinfo/podinfo.yaml
kubectl -n demo rollout status deployment/podinfo --timeout=180s
kubectl -n demo get pods -l app=podinfo
</code></pre>
<p>Both application HTTP and <code>/metrics</code> use port <code>9898</code>. The Collector scrapes <code>podinfo.demo.svc.cluster.local:9898</code>; its AWS role, not Podinfo, authorizes remote write and span ingestion. Keep one Podinfo replica with this Service-based scrape target. Scaling requires per-pod discovery and explicit scrape ownership, not just a higher replica count.</p>
<p>Debug logging is intentional for this exercise. Podinfo's JSON <strong>request-start</strong> event contains <code>uri</code>, <code>method</code> and <code>trace_id</code>; it does not contain a response status or duration. Its logger can sample repeated messages at high volume, so it is not an exhaustive access audit. Enable suitable correlation in your real service rather than assuming all applications produce this contract. <a href="https://github.com/stefanprodan/podinfo/blob/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/logging.go">Logging middleware</a> · <a href="https://github.com/stefanprodan/podinfo/blob/e86405a8674ecab990d0a389824c7ebbd82973b5/cmd/podinfo/main.go">Logger configuration</a></p>
<h2>8. Investigate a deliberate HTTP failure</h2>
<p>Check the three signals independently, then connect them. Metrics identify the affected route and time window; the request-start log supplies a trace ID; the matching server span shows the response outcome. No automatic Grafana log-to-trace link is configured.</p>
<p>Before deployment, have the account owner verify <code>aws xray get-trace-segment-destination --region us-east-1</code>: the documented active configuration is <code>Destination: CloudWatchLogs</code> and <code>Status: ACTIVE</code>. <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Enable-TransactionSearch.html">Transaction Search verification</a></p>
<h3>Generate bounded traffic</h3>
<p>Use separate terminals for the two port forwards and a third for requests:</p>
<pre><code class="language-shell">kubectl -n demo port-forward service/podinfo 9898:9898
</code></pre>
<pre><code class="language-shell">kubectl -n observability port-forward service/grafana 3000:80
</code></pre>
<p>The default port-forward bind is local. Leave the forwards running while investigating and stop them with Ctrl-C afterward. Send known successful and failing requests for about a minute so multiple 15-second scrapes can observe them:</p>
<pre><code class="language-shell">for i in $(seq 1 30); do
  curl --fail --silent --show-error http://localhost:9898/status/200
  curl --silent --show-error --output /dev/null --write-out 'HTTP %{http_code}\n' \
    http://localhost:9898/status/500
  sleep 2
done
curl --fail --silent --show-error http://localhost:9898/delay/1
curl --fail --silent --show-error http://localhost:9898/metrics
</code></pre>
<p>Expect <code>HTTP 500</code> from the failing request; it deliberately omits <code>--fail</code>. <code>/delay/1</code> waits one second before responding; it is optional latency traffic, not an extra service. <a href="https://github.com/stefanprodan/podinfo/blob/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/status.go">Status handler</a> · <a href="https://github.com/stefanprodan/podinfo/blob/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/delay.go">Delay handler</a></p>
<h3>Find the metric signal in Grafana</h3>
<p>Select AMP and a time window covering your requests. Run these queries one at a time: scrape health, missing scrape samples, request rate by status, then error fraction:</p>
<pre><code class="language-promql">up{job="podinfo"}
absent_over_time(up{job="podinfo"}[5m])
sum by (status) (rate(http_request_duration_seconds_count{job="podinfo",path="status"}[5m]))
(
  sum(rate(http_request_duration_seconds_count{job="podinfo",path="status",status=~"5.."}[5m]))
  / sum(rate(http_request_duration_seconds_count{job="podinfo",path="status"}[5m]))
)
and (sum(rate(http_request_duration_seconds_count{job="podinfo",path="status"}[5m])) &gt; 0)
</code></pre>
<p>The pinned implementation exposes <code>http_requests_total</code> with <strong>only <code>status</code></strong> as an application label. Its <code>http_request_duration_seconds</code> histogram has <code>method</code>, <code>path</code> and <code>status</code>; the named status route is <code>path="status"</code>, not <code>/status/500</code>. Using the histogram count lets us exclude probes and metrics scrapes from the exercise's error fraction. <code>job</code> is added by scraping. Confirm the final names and labels in AMP before saving panels. <a href="https://github.com/stefanprodan/podinfo/blob/e86405a8674ecab990d0a389824c7ebbd82973b5/pkg/api/http/metrics.go">Pinned metric implementation</a></p>
<p><code>up=1</code> means the scrape worked, not that application requests succeeded. <code>rate</code> needs multiple observations and accounts for counter resets. The ratio hides idle traffic rather than inventing a zero error rate; newly created series need time to appear. Do not blanket-fill missing data with <code>or vector(0)</code>. <a href="https://prometheus.io/docs/prometheus/latest/querying/functions/">Prometheus functions</a> · <a href="https://prometheus.io/docs/prometheus/latest/querying/operators/">Operators</a></p>
<p>If <code>up</code> is zero, check the Podinfo Service and Collector reachability. If it is absent, check Collector remote-write errors, the AMP endpoint and role permissions. After several scrapes, the status queries should show successful and failing requests and a nonzero error fraction.</p>
<h3>Find the request-start log</h3>
<p>In Grafana's CloudWatch Logs datasource, choose <code>/aws/eks/observability-lab/application</code> and the same time window. The intended Fluent Bit envelope places parsed Podinfo fields under <code>data</code>:</p>
<pre><code class="language-text">fields @timestamp, kubernetes.pod_name, data.uri, data.method, data.trace_id
| filter kubernetes.namespace_name = "demo"
| filter kubernetes.container_name = "podinfo"
| filter data.msg = "request started" and data.uri = "/status/500"
| sort @timestamp desc
| limit 20
</code></pre>
<p>Expect request-start events with <code>data.trace_id</code>. If none appear, check <code>kubectl -n demo logs deployment/podinfo</code> first, then Fluent Bit’s file glob, buffer and CloudWatch write permissions. If events arrive but the query misses them, inspect their envelope. If automatic field discovery is unavailable, use <code>fields jsonParse(@message) as record</code> and access <code>record.data.uri</code>, <code>record.data.trace_id</code> and <code>record.kubernetes.namespace_name</code> instead. <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax-operations-functions.html">Logs Insights functions</a></p>
<p>The following <strong>local binary observation</strong>, shown with only selected fields, demonstrates what Podinfo itself emitted. It is not an observed CloudWatch event:</p>
<pre><code class="language-json">{
  "level": "debug",
  "ts": "2026-10-21T15:48:34.513Z",
  "msg": "request started",
  "uri": "/status/500",
  "method": "GET",
  "trace_id": "497072ba60def9880894539d1e8c27fa"
}
</code></pre>
<p>This records the request starting, not its successful completion. For this controlled endpoint we know the requested outcome; confirm the actual HTTP result in the client and server span. Copy the log's unchanged <code>data.trace_id</code> for the next lookup. If it is missing, check both <code>--level=debug</code> and <code>PODINFO_OTEL_SERVICE_NAME</code> before changing the log query.</p>
<h3>Look up the matching server span</h3>
<p>Select <code>aws/spans</code> in the same AWS account, region and time window, using your investigator permissions rather than Grafana's application-log role:</p>
<pre><code class="language-text">fields @timestamp, traceId, spanId, name
| filter traceId = "&lt;32-lowercase-hex-id-from-data.trace_id&gt;"
| sort @timestamp asc
| limit 100
</code></pre>
<p>Replace the placeholder with your own logged trace ID, without angle brackets. Transaction Search supports Logs Insights analysis. Verify the stored fields and returned ID in the account, then open the trace to inspect its spans. <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Transaction-Search-search-analyze-spans.html">Span analysis</a></p>
<p>In the local OTLP capture, <code>GET /status/{code:[0-9]+}</code> was the <strong>server span</strong>, with <code>http.response.status_code=500</code> and error status. Its child <code>statusHandler</code> span shared the trace ID but had unset status. Do not require every child span to be marked as an error, or invent an exception event for this deliberate status response. The resource contained <code>service.name=podinfo</code> and <code>service.version=6.9.2</code>.</p>
<p>Use the unchanged 32-hex W3C trace ID for this lookup. Do not rewrite it into an X-Ray-format ID or add a timestamp to make a query match. A successful metrics scrape cannot prove that span export or search worked. Transaction Search may take about ten minutes to become searchable after initial activation; its trace-summary indexing is distinct from collecting spans. <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Enable-TransactionSearch.html">Transaction Search setup</a></p>
<h2>9. Know the limits and clean up</h2>
<p>Validation was local only, including Podinfo’s metrics, request-start logs and captured spans. The AWS deployment and end-to-end ingestion and queries have not been tested.</p>
<h3>Before broader use</h3>
<p>The Collector's OTLP receiver is an unauthenticated ClusterIP endpoint. Other reachable clients can submit telemetry that it signs with its AWS role. Before broader use, enforce NetworkPolicies limiting port <code>4317</code> to the intended Podinfo workload and application access to approved clients; review TLS/authentication and confirm the cluster's policy enforcement. Namespace separation and ClusterIP alone do not provide these controls.</p>
<p>Budget for workload capacity, egress, AMP ingestion/storage/querying, CloudWatch ingestion/retention/scans and trace collection/indexing. This example sets seven-day application-log retention; AMP and shared span-store retention remain owner decisions. It deliberately omits HA, durable Collector queues and public Grafana access.</p>
<h3>Clean up without deleting shared infrastructure</h3>
<p>Stop the port forwards and remove only this application's Deployment and Service first:</p>
<pre><code class="language-shell">kubectl -n demo delete deployment/podinfo service/podinfo
</code></pre>
<p>Then remove the tooling releases through the established Terraform workflow while cluster access and workload roles still work. After deciding what data to retain, remove this example's IAM policies/roles, AMP workspace and application log group. Delete <code>demo</code> only if you created it solely for this exercise and have confirmed it is empty of other owned resources. Keep <code>observability</code> and its externally managed Grafana Secret under their owner's cleanup process.</p>
<p>Do not destroy the existing EKS cluster, OIDC provider, state backend, pipeline or account-level Transaction Search configuration. The useful result is a tested investigation path: metrics narrow the search, a request log gives context and a trace shows the response outcome. Podinfo keeps that lesson about observability, not about maintaining a bespoke demo application.</p>
<h2>Frequently asked questions</h2>
<h3>Why choose these tools rather than an all-in-one platform?</h3>
<p>We combine vendor-neutral instrumentation and the Prometheus ecosystem with AWS-managed storage. This lets us explore the individual components without operating every backend ourselves. It is a practical AWS-oriented choice, not a universal industry standard or the best fit for every team.</p>
<ul>
<li><strong>OpenTelemetry</strong> provides vendor-neutral instrumentation and a common telemetry protocol, reducing dependence on backend-specific application integrations. <a href="https://opentelemetry.io/docs/what-is-opentelemetry/">OpenTelemetry overview</a></li>
<li><strong>Prometheus and AMP</strong> let us use the Prometheus metrics ecosystem and PromQL while AWS operates the metrics backend. <a href="https://aws.amazon.com/documentation-overview/prometheus/">AMP overview</a></li>
<li><strong>Fluent Bit</strong> gives container logs a dedicated collection path; <strong>Grafana</strong> lets us investigate AMP metrics and CloudWatch logs from one interface.</li>
<li><strong>CloudWatch and X-Ray ingestion</strong> fit the existing AWS environment, while <strong>Terraform and Helm</strong> reuse our deployment tools instead of introducing another management workflow.</li>
</ul>
<p>The trade-off is integration work and AWS-specific permissions, queries and costs. Open telemetry formats improve portability; they do not make the entire solution cloud-independent. An all-in-one platform may suit teams that prefer fewer integrations to manage.</p>
<h3>Can I add this beside an existing monitoring installation?</h3>
<p>Treat this as a separately owned example, not a second copy of your collectors. Check release names, service accounts, IAM roles, namespaces and log-group ownership. Choose one owner for each scrape target and container-log path before combining configurations.</p>
<h3>Does Podinfo automatically connect its logs and traces?</h3>
<p>This pinned version includes a trace ID in debug request-start logs when tracing is enabled. We verified that ID against captured spans locally. The article uses a manual lookup, not an automatic Grafana link; those logs do not report response status or duration.</p>
<h3>What if metrics arrive but the matching trace does not?</h3>
<p>Check <code>PODINFO_OTEL_SERVICE_NAME</code>, the gRPC endpoint on port 4317, the Collector trace pipeline, <code>xray</code> signing, permissions and Transaction Search activation. Search the same account, region and time window with the unchanged logged trace ID. Metrics and traces have separate delivery paths.</p>
<h3>Can I keep the tooling and remove Podinfo?</h3>
<p>Yes. Delete Podinfo's Deployment and Service, then replace its scrape target, instrumentation assumptions and queries with your service's contract. Keep dashboards as reproducible configuration. Missing <code>podinfo</code> series after removal are not evidence that the replacement service is healthy.</p>
]]></content:encoded></item><item><title><![CDATA[Platform Engineering: A Practical Introduction]]></title><description><![CDATA[Why it emerged, what problems it solves, and how internal developer platforms support development teams.]]></description><link>https://blog.turingts.com/platform-engineering-a-practical-introduction</link><guid isPermaLink="true">https://blog.turingts.com/platform-engineering-a-practical-introduction</guid><category><![CDATA[Platform Engineering ]]></category><category><![CDATA[Devops]]></category><category><![CDATA[developer experience]]></category><category><![CDATA[internal developer platforms]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Tue, 08 Sep 2026 08:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/e54c437d-e41c-4ece-8d3c-02b069ef9a7b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>For many software teams, development and operations used to be separate worlds. Developers wrote the application, then handed it over to an operations team to deploy and maintain. Changes had to cross that boundary, often through tickets, queues and repeated explanations.</p>
<p>DevOps emerged to improve that relationship. The <a href="https://devopsdays.org/about">first DevOpsDays</a>, organised by Patrick Debois in 2009, became an important milestone in a movement towards closer collaboration, automation and shared responsibility for software in production.</p>
<p>Meanwhile, cloud computing gave teams more control over the infrastructure their applications needed. But that freedom also brought more decisions: how to build and deploy software, manage access, collect logs, monitor services and recover when something went wrong. In organisations with many development teams, the same supporting work could be repeated across projects.</p>
<p><strong>Platform engineering addresses that duplication and complexity.</strong> Instead of every team assembling and maintaining its own delivery setup, a platform team provides shared, supported capabilities that developers can use themselves. Application teams retain responsibility for their software, but do not have to build every underlying capability from scratch.</p>
<p>This approach developed across organisations rather than being invented by one person. <a href="https://martinfowler.com/articles/talk-about-platforms.html">Evan Bottcher’s 2018 description of platforms as compelling internal products</a>, followed by Matthew Skelton and Manuel Pais’s <a href="https://teamtopologies.com/book"><em>Team Topologies</em></a> in 2019, helped articulate the idea: <a href="https://teamtopologies.com/key-concepts">reduce the technical burden on application teams</a> so they can focus on the software their users need.</p>
<p>Platform engineering therefore builds on DevOps rather than replacing it. <strong>DevOps encourages teams to build and run software together; a well-designed platform makes that easier to do in practice.</strong></p>
<p>Consider a fictional online store. A customer submits an order through its website; an orders API accepts the request and records the order in an existing database. Payment processing is outside this example. The application team wants to change that API safely, not rediscover deployment, identity and diagnostic conventions for every release.</p>
<p>We will use this service to explain how a shared platform can help, then look at concrete tools and company examples at the end. This is an introduction to the ideas and responsibilities, not a guide to building an internal developer platform. Detailed implementation belongs in a separate article.</p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/4c76459f-89e2-46f4-b6df-3c07d8057bc8.png" alt="Fictional customer request path through the website and orders API to the existing database" /></p>
<p><em>Figure 1 — The fictional customer request path through the website and orders API to the existing database.</em></p>
<h2>What is platform engineering?</h2>
<p>Platform engineering is the discipline of providing shared capabilities as an internal product that helps teams deliver and operate software. It includes people, processes and policies as well as technology. CNCF explicitly frames it around the needs of internal users and the business outcomes those capabilities support.<a href="https://tag-app-delivery.cncf.io/whitepapers/platforms">[1]</a><a href="https://tag-app-delivery.cncf.io/whitepapers/platform-eng-maturity-model">[2]</a></p>
<p>An <strong>internal developer platform</strong>, or IDP, is the usable combination of those capabilities: supported workflows, interfaces, documentation and operational support. Its purpose is not to conceal all infrastructure knowledge. It is to make common work consistent while keeping necessary controls and failure information accessible.</p>
<p>A <strong>developer portal</strong> is one possible interface to that platform. A portal might help engineers discover services, identify owners or start a workflow. It is not the deployment capability, identity policy or support agreement behind the screen. CNCF describes platforms with web, API, CLI and template interfaces; it does not require a particular front end.<a href="https://tag-app-delivery.cncf.io/whitepapers/platforms">[1]</a></p>
<p>The distinction matters when comparing products: a portal can be the front door, but the platform also includes the delivery, identity and operational capabilities behind it. Installing a portal does not automatically provide a complete internal developer platform.</p>
<p>How do developers actually use those capabilities day to day? Usually through a small number of supported routes for common tasks, often called golden paths.</p>
<h2>What is a golden path?</h2>
<p>A <strong>golden path</strong> is a supported, documented way to complete a common engineering task, such as creating a service or releasing a change. CNCF describes it as a reusable workflow combined with a project template and documentation.<a href="https://tag-app-delivery.cncf.io/whitepapers/platforms">[1]</a> Teams can follow it instead of assembling those steps themselves.</p>
<p>For our orders API, the path should cover creating the service repository, validating and building a change, promoting it, and finding the evidence needed to operate it—not just generating starter files.</p>
<p>For this fictional store, the supported path is for stateless HTTP services on an existing runtime. The API instances can be replaced; the orders stored in the database must be preserved.</p>
<p>The path would provide a maintained build workflow, reusable deployment configuration, runtime identity integration, telemetry conventions and a runbook starting point. It would also return useful status: which revision was built, which artifact is proposed for production, whether deployment converged, and where to investigate a failure.</p>
<p>This is <strong>self-service</strong> when engineers can complete supported work through the interface without a platform engineer manually fulfilling each request.<a href="https://tag-app-delivery.cncf.io/whitepapers/platforms">[1]</a> It does not mean every developer can approve their own production access. A workflow can be self-service while retaining an explicit authorization or approval step for a risky change. The distinction is between an intentional control and an accidental dependency on someone remembering a command.</p>
<h2>Who owns the service, and who owns the path?</h2>
<p>The application team owns the orders service; the platform team owns the supported capability used to deliver it. Shared ownership means named responsibilities at their boundary, not that everyone is accountable for everything. The following division is a proposed design for this example.</p>
<table>
<thead>
<tr>
<th>Concern</th>
<th>Application team</th>
<th>Platform team</th>
</tr>
</thead>
<tbody><tr>
<td>Service behaviour</td>
<td>API code, business rules, tests and data correctness</td>
<td>Supported runtime interface and documented constraints</td>
</tr>
<tr>
<td>Delivery</td>
<td>Application tests, release intent and promotion decisions</td>
<td>Reusable workflow, deployment integration and actionable failure status</td>
</tr>
<tr>
<td>Identity</td>
<td>Describe required application access</td>
<td>Integrate scoped identities and access policy with the responsible security and infrastructure teams</td>
</tr>
<tr>
<td>Observability</td>
<td>Instrument meaningful outcomes; maintain service diagnostics</td>
<td>Supported collection/export path, shared conventions and access</td>
</tr>
<tr>
<td>Incidents</td>
<td>First response to customer-facing orders failures; application recovery decisions</td>
<td>Respond to failures of shared delivery, runtime integration or telemetry capabilities</td>
</tr>
<tr>
<td>Evolution</td>
<td>Adopt supported versions; raise missing use cases</td>
<td>Compatibility policy, migration guidance and support lifecycle</td>
</tr>
</tbody></table>
<p>The platform team need not operate every underlying service. CNCF recommends keeping the platform a thin, consistent layer over capabilities that may be maintained by managed providers or other internal teams.<a href="https://tag-app-delivery.cncf.io/whitepapers/platforms">[1]</a> In this design, an infrastructure team can operate the cluster while the platform team remains responsible for the developer-facing deployment experience. The escalation route must reflect that arrangement.</p>
<h2>What does a platform contract mean in practice?</h2>
<p>A <strong>platform contract</strong> is the agreement about what a platform supports and what it expects from application teams. It explains the available capabilities, access restrictions, support responsibilities and how changes to the supported path are introduced.</p>
<p>For example, the orders team chooses a supported service template, identifies the owning team and selects an allowed environment. The platform provides maintained delivery defaults, deployment status and diagnostic links. The agreement need not start with a custom configuration format.</p>
<h2>How does a repository become a production service?</h2>
<p>For the fictional orders API, the supported path connects four activities: starting from maintained defaults, testing and building a change, deploying an approved release, and checking its behaviour. This is an illustrative delivery flow, not a prescribed tool stack.</p>
<ol>
<li><strong>Start from maintained defaults.</strong> A service template supplies an initial repository and documentation. Reusable pipelines keep common build logic shared rather than permanently copied into every project. GitHub Actions reusable workflows are one concrete mechanism for this.<a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusable-workflows">[5]</a> The application team still writes the tests for order behaviour.</li>
<li><strong>Test and build an identifiable release.</strong> The pipeline runs the relevant checks and records which source revision produced the release artifact. A failed application test goes to the orders team; a broken shared pipeline has a platform support route.</li>
<li><strong>Deploy through a supported workflow.</strong> The team selects an allowed environment and follows its approval requirements. A GitOps approach is one option: versioned desired state is reconciled with the runtime.<a href="https://opengitops.dev">[10]</a> Argo CD can support that approach by automatically synchronising changes from Git.<a href="https://argo-cd.readthedocs.io/en/stable/user-guide/auto_sync">[7]</a> In this design, review and approval controls sit in the surrounding delivery workflow. A successful build is not the same as a successful deployment.</li>
<li><strong>Keep access and status clear.</strong> The developer, build job, deployment system and running application are different actors with different permissions. A portal login must not become unrestricted production or database access. The path should show whether a release is waiting for approval, has failed to deploy, or has deployed but is behaving incorrectly.</li>
</ol>
<h2>How will the team know what happened after deployment?</h2>
<p>The path should make operational evidence accessible, while the application team remains responsible for its meaning. OpenTelemetry distinguishes traces, metrics and logs: a request's path, runtime measurements and recorded events.<a href="https://opentelemetry.io/docs/concepts/signals">[8]</a> In our design, shared service, release and environment identifiers help connect those signals to a deployment.</p>
<p>For orders, useful questions include: are submissions succeeding, how long do they take, and is the database interaction failing? The application team instruments those outcomes and avoids putting sensitive order payloads into diagnostics. The platform supplies the supported collection and export path; instrumentation and business correctness do not appear automatically because that path exists.</p>
<p>The service runbook should identify the first responder, show the diagnostic starting points, explain a safe mitigation and name the escalation route. For example, customer-facing order errors first reach the orders team; a broken shared reconciler reaches the platform team. During an incident, those teams collaborate rather than forwarding the ticket indefinitely.</p>
<p>Recovery also needs a supported procedure. Returning to an earlier application release may help, but the team must check compatibility with stored data and verify customer outcomes afterwards. Reverting application code cannot undo data changes.</p>
<p>Turing's introduction to SRE explores service readiness, incident response and engineering follow-up in more detail.<a href="https://blog.turingts.com/site-reliability-engineering-a-practical-introduction-for-engineers">[9]</a> That is complementary reading, not a requirement to build a separate SRE organisation for this example.</p>
<h2>How do you avoid turning the golden path into a cage?</h2>
<p>Provide a supported default and an explicit <strong>escape hatch</strong>: a documented way to deviate when the common path does not fit. CNCF describes platforms as optional and composable, including the ability for product teams to operate capabilities outside the platform's offerings.<a href="https://tag-app-delivery.cncf.io/whitepapers/platforms">[1]</a></p>
<p>Suppose orders needs a deployment strategy the supported service template does not cover. In our design, the teams record the reason, the application-owned implementation, the security and operational requirements that still apply, the support boundary, and a review date. An exception is not permission to disable mandatory controls or an unspoken promise that the platform team will support unknown configuration forever.</p>
<p>Repeated exceptions are product feedback. If several teams need the same capability, consider making it part of the supported path. If one unusual service needs it, an explicitly owned deviation may be cheaper and clearer than expanding every service's interface.</p>
<h2>Where should a platform team start?</h2>
<p>Start with one frequent journey and a willing application team. DORA recommends a minimum viable platform that makes the most common workflow demonstrably better, then evolves through feedback.<a href="https://dora.dev/capabilities/platform-engineering">[3]</a> For this store, that journey is taking one orders API change from a repository to an observable, recoverable deployment.</p>
<p>Observe the work before replacing it: where does the team wait, repeat configuration or ask another person for help? Build the smallest supported path that removes those frictions. Have a second engineer use it without the platform author beside them. Their first confusing failure is useful evidence for the next improvement.</p>
<p>Measure the journey, not the number of tools installed. In this example, track time to the first supported deployment, waiting time, in-scope tasks completed without platform tickets, repeat adoption by eligible teams, and application delivery/reliability signals. Compare like-for-like workflows and combine those observations with interviews. These are proposed measures, not benchmark targets or claims of achieved savings.</p>
<p>CNCF recommends both quantitative and qualitative feedback; its maturity model also warns that reaching the highest level is not an objective in itself.<a href="https://tag-app-delivery.cncf.io/whitepapers/platforms">[1]</a><a href="https://tag-app-delivery.cncf.io/whitepapers/platform-eng-maturity-model">[2]</a> Shared capabilities require maintenance and can concentrate failures across teams. Expanding the platform is worthwhile only when the benefit justifies that added responsibility.</p>
<p>A practical IDP starts when an application team can use a supported capability, understand its result and know who owns the next action. The portal can wait. The dependable path cannot.</p>
<h2>What are concrete examples of developer platforms and portals?</h2>
<p>Backstage, Cortex and Red Hat Developer Hub illustrate different ways to provide a developer-facing entry point. Backstage is an open-source framework; Cortex is a commercial product; Red Hat Developer Hub packages a Backstage-based portal with enterprise support. They are not interchangeable with the whole platform behind them.</p>
<h3>Backstage: an open-source portal framework, built at Spotify</h3>
<p><a href="https://backstage.io/docs/overview/what-is-backstage">Backstage</a> provides a software catalog, Software Templates and TechDocs for technical documentation. Its catalog helps developers discover software and ownership; templates provide a consistent starting point for new projects. It is a framework that a platform team integrates with its own tools, rather than a ready-made deployment environment.<a href="https://backstage.io/docs/overview/what-is-backstage">[11]</a></p>
<p>Spotify's engineering account describes how its internal Backstage grew from a service catalog into a shared place to create, manage and monitor projects, and how it was open-sourced in March 2020.<a href="https://engineering.atspotify.com/2021/03/happy-birthday-backstage-spotifys-biggest-open-source-project-grows-up-fast">[18]</a> Spotify also explains that its backend, frontend and data-pipeline templates are maintained by experts in those disciplines and form part of its supported golden paths.<a href="https://backstage.spotify.com/learn/onboarding-software-to-backstage/setting-up-software-templates/11-spotify-templates">[12]</a></p>
<p>A concrete developer journey is choosing a supported backend-service template instead of assembling a project from scratch. Backstage's template feature can generate the initial code and publish it to a repository such as GitHub or GitLab.<a href="https://backstage.io/docs/features/software-templates">[4]</a> The useful combination is a discoverable starting point, maintained defaults and a team responsible for keeping that path usable—not simply a catalog page.</p>
<h3>Cortex: a commercial product, with Xero as a documented example</h3>
<p><a href="https://www.cortex.io/products/cortex-idp">Cortex</a> is a commercial, proprietary product, not an open-source alternative to Backstage.<a href="https://www.cortex.io/post/avoiding-vendor-lock-in-with-your-idp">[13]</a><a href="https://www.cortex.io/legal/terms-of-service">[19]</a> It now describes itself as an <strong>Engineering Operations Platform</strong>, evolved from an internal developer portal. Its capabilities include a catalog of services and owners, scorecards for checking agreed standards, and self-service workflows.<a href="https://www.cortex.io/products/cortex-idp">[14]</a></p>
<p>In Cortex's customer case study, <strong>Xero</strong> is described as moving from a homegrown portal to Cortex to centralise information about services, dependencies and ownership.<a href="https://cortex.io/case-studies/xero">[15]</a> This illustrates a practical use case: helping an engineer find the responsible team and relevant service information instead of tracing it through spreadsheets and disconnected tools. The adoption account comes from the vendor; it is not an independent assessment of business results.</p>
<h3>Red Hat Developer Hub: a supported Backstage-based option</h3>
<p><a href="https://www.redhat.com/en/technologies/cloud-computing/developer-hub">Red Hat Developer Hub</a> is an enterprise developer portal based on Backstage, with supported plugins and integrations, including with OpenShift.<a href="https://www.redhat.com/en/technologies/cloud-computing/developer-hub">[16]</a> Its project code is available under the Apache 2.0 licence.<a href="https://raw.githubusercontent.com/redhat-developer/rhdh/main/LICENSE">[17]</a> That open-source code and Red Hat's supported product offering are distinct choices.<a href="https://www.redhat.com/en/technologies/cloud-computing/developer-hub">[16]</a> It is relevant when a team wants a Backstage-based portal with a vendor-supported package rather than assembling the upstream framework entirely itself.</p>
<h3>Open-source and commercial approaches</h3>
<p>Open-source options extend beyond Backstage, but they solve different problems. Compare portals with portals, and orchestration or delivery components with the corresponding platform layer. Kratix, KubeVela and Crossplane are not drop-in replacements for Backstage's catalog and portal experience; they can complement a portal. The suggested fit and trade-offs below are editorial guidance, not benchmarks or claims of equal maturity.</p>
<table>
<thead>
<tr>
<th>Product / approach</th>
<th>Layer &amp; licensing</th>
<th>Useful when and trade-off</th>
</tr>
</thead>
<tbody><tr>
<td><a href="https://backstage.io/docs/overview/what-is-backstage">Backstage</a></td>
<td>Portal framework; <a href="https://backstage.io/docs/faq/product">Apache 2.0</a>.</td>
<td><strong>Useful when:</strong> You want a custom catalog, templates and documentation experience, with a team to build it.<br /><br /><strong>Trade-off:</strong> You own integration, hosting and ongoing maintenance.</td>
</tr>
<tr>
<td><a href="https://www.redhat.com/en/technologies/cloud-computing/developer-hub">Red Hat Developer Hub</a></td>
<td>Backstage-based portal distribution; <a href="https://raw.githubusercontent.com/redhat-developer/rhdh/main/LICENSE">Apache-2.0 project</a> with commercial support.</td>
<td><strong>Useful when:</strong> You want a supported Backstage package, particularly alongside OpenShift.<br /><br /><strong>Trade-off:</strong> It is a Backstage distribution, not an independent alternative; you still own deployment and integrations.</td>
</tr>
<tr>
<td><a href="https://www.cortex.io/products/cortex-idp">Cortex</a></td>
<td><a href="https://www.cortex.io/legal/terms-of-service">Commercial, proprietary</a> engineering-operations product with portal capabilities.</td>
<td><strong>Useful when:</strong> Service ownership, scorecards and self-service workflows are the main gaps.<br /><br /><strong>Trade-off:</strong> You still need to define standards and maintain the underlying integrations.</td>
</tr>
<tr>
<td><a href="https://kratix.io">Kratix</a></td>
<td>Platform orchestration framework; <a href="https://github.com/syntasso/kratix">Apache 2.0</a>. Not a portal.</td>
<td><strong>Useful when:</strong> You want reusable platform APIs (Promises) and workflows for provisioning and lifecycle operations.<br /><br /><strong>Trade-off:</strong> Your team defines and maintains the Promises, workflows and integrations.</td>
</tr>
<tr>
<td><a href="https://kubevela.io/docs/">KubeVela</a></td>
<td>Application-delivery platform; <a href="https://github.com/kubevela/kubevela">Apache 2.0</a>.</td>
<td><strong>Useful when:</strong> You want application abstractions and delivery workflows across clusters or cloud environments.<br /><br /><strong>Trade-off:</strong> You adopt its application model and maintain the delivery definitions and control plane.</td>
</tr>
<tr>
<td><a href="https://www.cncf.io/projects/crossplane/">Crossplane</a></td>
<td>Platform control-plane framework; <a href="https://github.com/crossplane/crossplane">Apache 2.0</a>. Not a portal.</td>
<td><strong>Useful when:</strong> You want declarative platform APIs to compose and manage infrastructure and applications.<br /><br /><strong>Trade-off:</strong> You own API design, compositions, providers and control-plane operations.</td>
</tr>
<tr>
<td><strong>Custom Kubernetes-based IDP</strong></td>
<td>Architecture approach using open-source components; not a single product or licence.</td>
<td><strong>Useful when:</strong> You need tailored platform APIs and workflows, and can staff a platform team.<br /><br /><strong>Trade-off:</strong> Your team owns composition, integration, upgrades and operational support.</td>
</tr>
</tbody></table>
<p><a href="https://www.cncf.io/projects/kubevela/">KubeVela is a CNCF Incubating project</a>; <a href="https://www.cncf.io/projects/crossplane/">Crossplane is Graduated</a>. These are CNCF maturity levels, not a feature ranking or proof that a particular integration fits your organisation. Open-source licensing also does not mean that every vendor extension or support offering is free.</p>
<p><em>Project documentation, licences and release activity checked in October 2026. These are components and approaches, not substitutes for owning the developer experience.</em></p>
<h3>Can you build an IDP from CNCF projects?</h3>
<p>Yes. <a href="https://www.cncf.io/projects/backstage/">Backstage</a> and <a href="https://www.cncf.io/projects/crossplane/">Crossplane</a> are CNCF projects. So are <a href="https://www.cncf.io/projects/argo/">Argo</a> and <a href="https://www.cncf.io/projects/kubernetes/">Kubernetes</a>. They offer building blocks for a custom platform, rather than one packaged “CNCF IDP”.</p>
<p>For our fictional store, an illustrative combination is Backstage as the portal, <a href="https://docs.crossplane.io/latest/get-started/get-started-with-composition/">Crossplane</a> for platform APIs and resource provisioning, <a href="https://argo-cd.readthedocs.io/en/stable/">Argo CD</a> for GitOps deployment, and <a href="https://kubernetes.io/docs/concepts/overview/">Kubernetes</a> to run the orders API. Kubernetes alone is not an IDP: the platform team still builds and supports the integrations, policies and golden paths that make those components usable together.</p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/bdb3ba14-5e57-4930-89f2-37c811a1c1b2.png" alt="Illustrative CNCF IDP architecture: Backstage, Git, Argo CD, Kubernetes and Crossplane, with separate runtime API-to-database traffic" /></p>
<p><em>Figure 2 — One illustrative IDP: Backstage proposes a Git change for review, Argo CD syncs the merged application and platform resources, and Crossplane provisions a database. Runtime data flows directly from the orders API to the database. CI and supporting services are omitted. This variant illustrates provisioning a database; an existing database could instead be integrated.</em></p>
<p>These examples are starting points, not a product ranking. First identify what developers struggle to do: find a service owner, start a supported project, request an environment or understand a failed release. Then choose the capabilities and interface that address that problem.</p>
<h2>Frequently asked questions</h2>
<h3>Does platform engineering require Kubernetes or a developer portal?</h3>
<p>Not for the definition of a platform. CNCF describes capabilities offered through multiple interfaces and backed by different providers.<a href="https://tag-app-delivery.cncf.io/whitepapers/platforms">[1]</a> A useful platform can start with shared delivery workflows and documentation; its interface need not be a portal, and its runtime need not be Kubernetes.</p>
<h3>Does self-service remove production approvals?</h3>
<p>Not in this design. Self-service removes routine manual fulfilment while retaining the authorization required for the requested action. A developer can initiate and inspect a workflow without having permission to approve every production change or grant arbitrary access.</p>
<h3>Does the platform team take over application operations?</h3>
<p>Not here. The orders team owns application behaviour, data correctness and recovery decisions. The platform team supports the shared delivery capability and its integrations. Both teams need a clear escalation agreement so a cross-boundary incident does not become an ownership dispute.</p>
<h2>Sources</h2>
<p>[1] <a href="https://tag-app-delivery.cncf.io/whitepapers/platforms">https://tag-app-delivery.cncf.io/whitepapers/platforms</a> — CNCF Platforms White Paper</p>
<p>[2] <a href="https://tag-app-delivery.cncf.io/whitepapers/platform-eng-maturity-model">https://tag-app-delivery.cncf.io/whitepapers/platform-eng-maturity-model</a> — CNCF Platform Engineering Maturity Model</p>
<p>[3] <a href="https://dora.dev/capabilities/platform-engineering">https://dora.dev/capabilities/platform-engineering</a> — DORA: Platform engineering</p>
<p>[4] <a href="https://backstage.io/docs/features/software-templates">https://backstage.io/docs/features/software-templates</a> — Backstage Software Templates</p>
<p>[5] <a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusable-workflows">https://docs.github.com/en/actions/concepts/workflows-and-actions/reusable-workflows</a> — GitHub Actions reusable workflows</p>
<p>[7] <a href="https://argo-cd.readthedocs.io/en/stable/user-guide/auto_sync">https://argo-cd.readthedocs.io/en/stable/user-guide/auto_sync</a> — Argo CD automated sync policy</p>
<p>[8] <a href="https://opentelemetry.io/docs/concepts/signals">https://opentelemetry.io/docs/concepts/signals</a> — OpenTelemetry signals</p>
<p>[9] <a href="https://blog.turingts.com/site-reliability-engineering-a-practical-introduction-for-engineers">https://blog.turingts.com/site-reliability-engineering-a-practical-introduction-for-engineers</a> — Turing: Site Reliability Engineering</p>
<p>[10] <a href="https://opengitops.dev">https://opengitops.dev</a> — OpenGitOps principles</p>
<p>[11] <a href="https://backstage.io/docs/overview/what-is-backstage">https://backstage.io/docs/overview/what-is-backstage</a> — What is Backstage? | Backstage Software Catalog and Developer Platform</p>
<p>[12] <a href="https://backstage.spotify.com/learn/onboarding-software-to-backstage/setting-up-software-templates/11-spotify-templates">https://backstage.spotify.com/learn/onboarding-software-to-backstage/setting-up-software-templates/11-spotify-templates</a> — Onboarding Software to Backstage | Spotify for Backstage</p>
<p>[13] <a href="https://www.cortex.io/post/avoiding-vendor-lock-in-with-your-idp">https://www.cortex.io/post/avoiding-vendor-lock-in-with-your-idp</a> — Avoiding vendor lock-in with your IDP | Cortex</p>
<p>[14] <a href="https://www.cortex.io/products/cortex-idp">https://www.cortex.io/products/cortex-idp</a> — Cortex: IDP to EngOps Platform | Cortex</p>
<p>[15] <a href="https://cortex.io/case-studies/xero">https://cortex.io/case-studies/xero</a> — How Xero Scaled Engineering Excellence with Cortex | Cortex</p>
<p>[16] <a href="https://www.redhat.com/en/technologies/cloud-computing/developer-hub">https://www.redhat.com/en/technologies/cloud-computing/developer-hub</a> — Red Hat Developer Hub</p>
<p>[17] <a href="https://raw.githubusercontent.com/redhat-developer/rhdh/main/LICENSE">https://raw.githubusercontent.com/redhat-developer/rhdh/main/LICENSE</a> — Red Hat Developer Hub project licence (Apache 2.0)</p>
<p>[18] <a href="https://engineering.atspotify.com/2021/03/happy-birthday-backstage-spotifys-biggest-open-source-project-grows-up-fast">https://engineering.atspotify.com/2021/03/happy-birthday-backstage-spotifys-biggest-open-source-project-grows-up-fast</a> — Happy Birthday, Backstage: Spotify’s Biggest Open Source Project Grows Up Fast | Spotify Engineering</p>
<p>[19] <a href="https://www.cortex.io/legal/terms-of-service">https://www.cortex.io/legal/terms-of-service</a> — Cortex Terms of Service</p>
]]></content:encoded></item><item><title><![CDATA[GitHub Actions: An Introduction to Workflows and Reusable Workflows]]></title><description><![CDATA[Learn GitHub Actions basics, then turn a CI workflow into a reusable workflow with inputs, outputs, secrets and deployment security boundaries.]]></description><link>https://blog.turingts.com/github-actions-an-introduction-to-workflows-and-reusable-workflows</link><guid isPermaLink="true">https://blog.turingts.com/github-actions-an-introduction-to-workflows-and-reusable-workflows</guid><category><![CDATA[GitHub Actions]]></category><category><![CDATA[ci-cd]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Continuous Integration]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Wed, 12 Aug 2026 10:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/c4c1d57f-353d-4253-b7b2-dc9414781e28.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Software teams have not always merged their work continuously. In the 1990s, integrating everyone's changes shortly before a release was still the norm. That late integration was hard to estimate and hard to predict: Martin Fowler describes projects stuck in "integration hell", where every time they fixed an integration bug, two more popped up.<a href="https://martinfowler.com/articles/continuousIntegration.html">[1]</a></p>
<p>Continuous integration (CI) changed that habit. Kent Beck developed it as a practice within Extreme Programming in the 1990s. Teams integrate their changes into the shared main branch (the mainline) at least daily, and a CI service verifies every commit to it with a full build in an integration environment. Fowler describes CruiseControl as the first CI service; Jenkins and GitHub Actions are among the services teams use today.<a href="https://martinfowler.com/articles/continuousIntegration.html">[1]</a></p>
<p>GitHub introduced Actions in 2018. In August 2019, it announced built-in CI/CD in beta, with support for Linux, macOS and Windows, and planned general availability for 13 November that year.<a href="https://github.blog/news-insights/product-news/github-actions-now-supports-ci-cd/">[2]</a> Because the automation lives in the repository, teams can describe their build, test and deployment steps next to the code.</p>
<p><strong>That convenience creates a new problem as an organisation grows.</strong> Imagine that the first service gets a carefully written workflow and the next ten copy it. Over time, each copy can drift: different action versions, different permissions, slightly different secret handling. Fixing one security issue then means editing every repository. GitHub's answer is to reuse workflows rather than copy and paste them.<a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusing-workflow-configurations">[6]</a></p>
<p>This article explains the core concepts of GitHub Actions, writes one CI workflow for a small service, and then turns it into a <strong>reusable workflow</strong> that many repositories can call. It then adds a reusable deployment workflow and covers the security boundaries that matter when you share automation.</p>
<h2>What is GitHub Actions?</h2>
<p><strong>GitHub Actions is a CI/CD platform built into GitHub. It runs workflows, defined as YAML files in a repository, when events such as a push or pull request occur, so you can build, test and deploy code automatically.</strong><a href="https://docs.github.com/en/actions/get-started/understand-github-actions">[3]</a></p>
<p>Six terms cover most of what you need:<a href="https://docs.github.com/en/actions/get-started/understand-github-actions">[3]</a></p>
<ul>
<li>An <strong>event</strong> is something that happens, such as a pull request being opened or a commit being pushed. Workflows can also run on a schedule or be started manually.</li>
<li>A <strong>workflow</strong> is an automated process defined in a YAML file in the repository's <code>.github/workflows</code> directory. A repository can have several.</li>
<li>A <strong>job</strong> is a set of steps that run on the same runner. By default, jobs run in parallel; a job can wait for another job by declaring a dependency.</li>
<li>A <strong>step</strong> either runs a shell command or uses an action. Steps in the same job run in order and can share files.</li>
<li>An <strong>action</strong> is a reusable extension, such as one that checks out your repository or installs a language toolchain.</li>
<li>A <strong>runner</strong> is the machine that executes a job. GitHub provides hosted Linux, Windows and macOS runners, and you can also host your own.</li>
</ul>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/a9e1997b-0602-4e3c-8405-f615bb283313.png" alt="GitHub Actions concepts: an event starts a workflow; the workflow contains jobs; each job runs its steps on a runner" /></p>
<p><em>Figure 1 — Conceptual view: an event starts a workflow. Each job runs on its own runner, and its steps run in order on that runner.</em></p>
<h2>What will we build?</h2>
<p><strong>We will build CI for a small fictional service, first as one workflow inside the service repository and then as a shared reusable workflow in a central repository. A final step adds a reusable deployment workflow.</strong></p>
<p>The example is the orders API of a fictional online store. A customer submits an order through the website; the orders API calculates the total and records the order. To keep the focus on the workflow, the service is two short Python files: <code>orders.py</code> and its unit tests in <code>test_orders.py</code>. The tests use only Python's standard library:</p>
<pre><code class="language-python">"""Order arithmetic for the fictional online store."""


def order_total(lines):
    """Return the order total in cents for (quantity, unit_price_cents) pairs."""
    total = 0
    for quantity, unit_price_cents in lines:
        if quantity &lt;= 0:
            raise ValueError("quantity must be positive")
        if unit_price_cents &lt; 0:
            raise ValueError("unit price cannot be negative")
        total += quantity * unit_price_cents
    return total
</code></pre>
<pre><code class="language-python">import unittest

from orders import order_total


class OrderTotalTest(unittest.TestCase):
    def test_adds_line_totals(self):
        self.assertEqual(order_total([(2, 1250), (1, 499)]), 2999)

    def test_rejects_zero_quantity(self):
        with self.assertRaises(ValueError):
            order_total([(0, 1250)])


if __name__ == "__main__":
    unittest.main()
</code></pre>
<p>The repository layout is:</p>
<pre><code class="language-text">orders-api/
├── orders.py
├── test_orders.py
└── .github/
    └── workflows/
        └── ci.yml
</code></pre>
<p><strong>Prerequisites:</strong> basic Git and YAML familiarity and permission to add files under <code>.github/workflows</code>. The first stage needs one GitHub repository; the shared stages need a second repository in the same organisation for the reusable workflows, and admin access to the service repository to configure its deployment environment. No cloud account is needed for the CI part.</p>
<p><strong>How the examples were checked:</strong> we validated every workflow file statically with actionlint and ran the unit tests locally, but did not run the workflows on GitHub. The action versions were pinned on 24 October 2026 and will age; check for newer releases before you copy them, and verify that a SHA comes from the action's own repository rather than a fork.<a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a> The details are in the section on checking workflows.</p>
<h2>How do you write a first CI workflow?</h2>
<p><strong>Create a YAML file under <code>.github/workflows</code>, choose the events that trigger it, and define a job with steps that check out the code, install the toolchain and run the tests.</strong><a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/workflows">[4]</a></p>
<p>Here is the complete workflow for the orders API, saved as <code>.github/workflows/ci.yml</code>:</p>
<pre><code class="language-yaml">name: CI

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - name: Check out the repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Set up Python
        uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
        with:
          python-version: "3.13"

      - name: Run unit tests
        run: python -m unittest discover --verbose
</code></pre>
<p>Most lines are deliberate choices rather than boilerplate:</p>
<ul>
<li><strong><code>on</code></strong> runs the workflow for every pull request and for every push to <code>main</code>. Pull requests get feedback before merging; the push run checks what actually landed.</li>
<li><strong><code>permissions: contents: read</code></strong> limits the automatically created <code>GITHUB_TOKEN</code>. GitHub creates this token for each job, and its permissions are limited to the repository.<a href="https://docs.github.com/en/actions/concepts/security/github_token">[9]</a> Once you specify any permission, every permission you do not list is set to <code>none</code>.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax">[5]</a> GitHub recommends read-only access to repository contents as the default, increased only for jobs that need more.<a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a></li>
<li><strong><code>timeout-minutes: 10</code></strong> stops a stuck job early. Without it, the default is 360 minutes.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax">[5]</a></li>
<li><strong>The actions are pinned to full commit SHAs</strong>, with the release tag as a comment. A tag can be moved or deleted if an attacker gains access to the action's repository. To replace the code behind a full-length commit SHA, an attacker would need a SHA-1 collision.<a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a> GitHub also offers workflow dependency lockfiles, currently in public preview, as an alternative to pinning in each file.<a href="https://docs.github.com/en/actions/concepts/security/workflow-dependency-lockfiles">[14]</a></li>
<li><strong><code>persist-credentials: false</code></strong> stops <code>actions/checkout</code> from leaving credentials configured for subsequent Git commands.<a href="https://github.com/actions/checkout/blob/3d3c42e5aac5ba805825da76410c181273ba90b1/action.yml">[18]</a><a href="https://github.com/actions/checkout/blob/3d3c42e5aac5ba805825da76410c181273ba90b1/README.md">[22]</a> This job never pushes, so it does not need the token afterwards.</li>
<li><strong><code>"3.13"</code> is quoted.</strong> In YAML, an unquoted <code>3.10</code> is the number 3.1, not the version string <code>3.10</code>. Quoting version numbers avoids that surprise.</li>
</ul>
<p>This single workflow is a good starting point. The trouble starts when the second, third and twentieth service copy it.</p>
<h2>What is a reusable workflow?</h2>
<p><strong>A reusable workflow is a workflow that other workflows can call, as if it were part of them. You define it once, give it explicit inputs, secrets and outputs, and callers reference that one centrally maintained file by version instead of copying it.</strong><a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusing-workflow-configurations">[6]</a><a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a></p>
<p>GitHub calls the workflow that uses another workflow the <strong>caller</strong>, and the reused workflow the <strong>called</strong> workflow. One line in the caller can run an entire called workflow, including all of its jobs.<a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusing-workflow-configurations">[6]</a> Reusable workflows became generally available in November 2021, with support for outputs and environment secrets.<a href="https://github.blog/news-insights/product-news/github-actions-reusable-workflows-is-generally-available/">[17]</a></p>
<p>A workflow becomes reusable when its <code>on</code> section includes <code>workflow_call</code>. Like any workflow, it lives in a repository's <code>.github/workflows</code> directory; subdirectories are not supported.<a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a></p>
<p><img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/7856b7a9-4898-4a4e-a097-4e29c3f9f702.png" alt="A central ci-workflows repository holds python-ci.yml and deploy.yml; orders-api, catalogue-api and payments-ui call python-ci.yml, and orders-api also calls deploy.yml" /></p>
<p><em>Figure 2 — Several service repositories call shared reusable workflows maintained in a central repository.</em></p>
<h2>How do you turn the CI workflow into a reusable workflow?</h2>
<p><strong>Move the job into a central repository, add <code>on: workflow_call</code> with typed inputs and outputs, and replace each service's job with a short job that calls it by path and version.</strong><a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a></p>
<p>In this example, the platform or developer-experience team keeps shared workflows in a repository called <code>example-org/ci-workflows</code>:</p>
<pre><code class="language-text">ci-workflows/
└── .github/
    └── workflows/
        ├── python-ci.yml
        └── deploy.yml
</code></pre>
<p>The reusable version of the test job is <code>python-ci.yml</code>:</p>
<pre><code class="language-yaml">name: Python CI

on:
  workflow_call:
    inputs:
      python-version:
        description: Python version to install
        required: false
        type: string
        default: "3.13"
    outputs:
      python-version:
        description: The Python version that was installed
        value: ${{ jobs.test.outputs.python-version }}

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    outputs:
      python-version: ${{ steps.setup-python.outputs.python-version }}
    steps:
      - name: Check out the calling repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Set up Python
        id: setup-python
        uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
        with:
          python-version: ${{ inputs.python-version }}

      - name: Run unit tests
        run: python -m unittest discover --verbose
</code></pre>
<p>Three parts form the workflow's interface:</p>
<ul>
<li><strong>Inputs</strong> must declare a <code>type</code>: <code>boolean</code>, <code>number</code> or <code>string</code>.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax">[5]</a> The caller's value must match that type.<a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a> Here the Python version is optional, with a default. Changing that default later changes what every caller that relies on it gets, so it is not a free change.</li>
<li><strong>Outputs</strong> pass data back. A step output must first be mapped to a job output, and the job output to a workflow output.<a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a> This example returns the version that <code>actions/setup-python</code> reports as installed.<a href="https://github.com/actions/setup-python/blob/6d4fd22b20465ccc0f7354476588e8df7c9ca0e0/action.yml">[19]</a></li>
<li><strong>Secrets</strong> are also declared under <code>workflow_call</code>. The deployment example later in this article uses one.</li>
</ul>
<p>The checkout step deserves attention. In a called workflow from another repository, actions run as if they were part of the caller. <code>actions/checkout</code> therefore checks out the <strong>calling</strong> repository, <code>orders-api</code>, not <code>ci-workflows</code>.<a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusing-workflow-configurations">[6]</a> That is exactly what a shared test workflow needs.</p>
<p>In the orders API's own <code>ci.yml</code>, the test job shrinks to six lines:</p>
<pre><code class="language-yaml">name: CI

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  test:
    permissions:
      contents: read
    uses: example-org/ci-workflows/.github/workflows/python-ci.yml@v1
    with:
      python-version: "3.13"

  summary:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - name: Report the tested Python version
        env:
          PYTHON_VERSION: ${{ needs.test.outputs.python-version }}
        run: echo "Tests passed on Python $PYTHON_VERSION"
</code></pre>
<p>The <code>test</code> job no longer has <code>runs-on</code> or <code>steps</code>. A reusable workflow is called directly at job level, not from a step.<a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a> A calling job can use only a small set of keywords, including <code>uses</code>, <code>with</code>, <code>secrets</code>, <code>needs</code>, <code>if</code>, <code>strategy</code>, <code>concurrency</code> and <code>permissions</code>.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a> The <code>summary</code> job shows how a later job reads the reusable workflow's output through <code>needs</code>. The orders API also passes <code>"3.13"</code> explicitly, even though it equals the default, so a future change to the default does not silently change its build.</p>
<p>Before this works, the central team must create and push the <code>v1</code> tag in <code>ci-workflows</code>. The service repository's Actions settings must allow actions and reusable workflows, and if <code>ci-workflows</code> is private, its own Actions settings must allow access from the service repositories.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a></p>
<p>A shared workflow also encodes conventions. This one assumes that tests run with <code>python -m unittest discover</code> and need no extra dependencies. Every caller must follow that convention, or it must become an input.</p>
<h2>How should callers reference a reusable workflow?</h2>
<p><strong>Use <code>{owner}/{repo}/.github/workflows/{file}@{ref}</code>, where the ref is a commit SHA, release tag or branch. GitHub calls the commit SHA the safest option for stability and security.</strong><a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a> <strong>For a repository you control and trust, a release tag is easier to maintain.</strong></p>
<p>The example uses <code>@v1</code>, a release tag in the organisation's own <code>ci-workflows</code> repository. That is a common internal trade-off: the central team can ship compatible fixes behind <code>v1</code>, and every caller picks them up. The cost is that a moved tag changes what runs. For third-party workflows, apply the same caution as for third-party actions.<a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a></p>
<p>Two details are useful when you choose:</p>
<ul>
<li><strong>Re-runs behave differently.</strong> If the reference is not a SHA, re-running all jobs uses whatever the reference points to now. Re-running failed jobs, or one specific job, uses the same commit as the first attempt.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a></li>
<li><strong>Access depends on visibility.</strong> A caller can use a reusable workflow in the same repository, in a public repository if the organisation allows it, or in a private repository whose settings explicitly allow access.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a></li>
</ul>
<p>Treat a shared workflow like a small internal product with a versioned interface. Adding an optional input with a default is compatible. Renaming or removing an input, secret or output, adding a required input or secret, or changing an input's type breaks callers, so release that as <code>v2</code> and keep <code>v1</code> working until callers have moved.</p>
<h2>What crosses the boundary between caller and called workflow?</h2>
<p><strong>Workflow-level <code>env</code> variables do not cross in either direction, and secrets other than <code>GITHUB_TOKEN</code> reach the called workflow only when the caller passes them. The <code>github</code> context, GitHub-hosted runners and billing stay with the caller, and the called workflow can reduce but never increase the caller's <code>GITHUB_TOKEN</code> permissions.</strong><a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a><a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a></p>
<p>These boundaries surprise people the first time:</p>
<ul>
<li><strong>Environment variables:</strong> <code>env</code> set at workflow level in the caller is not available in the called workflow, and the reverse is also true. Use inputs and outputs, or organisation, repository or environment variables through the <code>vars</code> context.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a></li>
<li><strong>Secrets:</strong> the called workflow receives <code>GITHUB_TOKEN</code> automatically.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a> Other secrets are passed only to a directly called workflow, by name or with <code>secrets: inherit</code>.<a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a></li>
<li><strong>Permissions:</strong> if the calling job does not set <code>permissions</code>, it inherits the caller’s workflow-level permissions, or the enterprise, organisation or repository defaults if no workflow-level permissions are set. The called workflow can only downgrade what it is given.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a><a href="https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax">[5]</a> Setting <code>permissions</code> on the calling job makes the token scope explicit at the call site and keeps it there if the workflow-level block is later changed.</li>
<li><strong>Context:</strong> the <code>github</code> context in a called workflow always belongs to the caller, so values such as the triggering event and ref come from the service repository.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a></li>
<li><strong>Runners and billing:</strong> GitHub-hosted runners are assigned and billed in the caller's context.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a></li>
<li><strong>Nesting limits:</strong> you can chain up to ten levels of workflows and call at most 50 unique reusable workflows from one workflow file.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a></li>
</ul>
<h2>How do you add a reusable deployment workflow?</h2>
<p><strong>Create a second reusable workflow that takes the target environment as an input and requires a deployment secret. Put the <code>environment</code> on the job inside the reusable workflow, and let the caller decide when to call it.</strong><a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a></p>
<p>Deployment is a strong candidate for sharing, because every deployment should go through a protected environment, receive only the secrets it names and never overlap with another deployment of the same service. This is <code>.github/workflows/deploy.yml</code> in <code>ci-workflows</code>:</p>
<pre><code class="language-yaml">name: Deploy

on:
  workflow_call:
    inputs:
      environment:
        description: Target deployment environment
        required: true
        type: string
    secrets:
      deploy_token:
        required: true

permissions:
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    environment: ${{ inputs.environment }}
    concurrency:
      group: deploy-${{ inputs.environment }}
    steps:
      - name: Check out the calling repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Deploy
        env:
          DEPLOY_TOKEN: ${{ secrets.deploy_token }}
          TARGET_ENVIRONMENT: ${{ inputs.environment }}
        run: ./scripts/deploy.sh "$TARGET_ENVIRONMENT"
</code></pre>
<p>The <code>scripts/deploy.sh</code> script and the <code>PRODUCTION_DEPLOY_TOKEN</code> secret are placeholders for whatever your service uses to deploy; the workflow structure is the lesson here. The script must be executable in the calling repository. In the orders API's <code>ci.yml</code>, a <code>deploy</code> job now replaces the <code>summary</code> job:</p>
<pre><code class="language-yaml">name: CI

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  test:
    permissions:
      contents: read
    uses: example-org/ci-workflows/.github/workflows/python-ci.yml@v1
    with:
      python-version: "3.13"

  deploy:
    needs: test
    if: github.event_name == 'push' &amp;&amp; github.ref == 'refs/heads/main'
    permissions:
      contents: read
    uses: example-org/ci-workflows/.github/workflows/deploy.yml@v1
    with:
      environment: production
    secrets:
      deploy_token: ${{ secrets.PRODUCTION_DEPLOY_TOKEN }}
</code></pre>
<p>Each part has a specific purpose:</p>
<ul>
<li><strong>The reusable workflow references the environment; it does not configure it.</strong> To use environment secrets, the job in the reusable workflow sets <code>environment</code>; the calling job cannot use that keyword.<a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a> An environment can require approval and limit access to secrets. Its protection rules must pass before the job is sent to a runner, and only then can the job read the environment's secrets.<a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/deployment-environments">[12]</a></li>
<li><strong>The caller passes the secret explicitly.</strong> Even for an environment secret, the caller must pass it, either by name or with <code>secrets: inherit</code>. It can pass a secret by name even if the secret exists only in the environment.<a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a> <code>inherit</code> passes all the secrets the caller can access.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax">[5]</a> Naming the one secret a workflow needs applies the same least-privilege idea that GitHub recommends for credentials.<a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a></li>
<li><strong><code>required: true</code> turns a silent mistake into a failure.</strong> If the caller does not pass an environment secret, it resolves to an empty string without an error. <code>required: true</code> makes the run fail instead, although it does not check that the secret has a value.<a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a> A deployment script should therefore fail fast when its token is empty.</li>
<li><strong>The <code>if</code> condition limits deployment to pushes on <code>main</code>.</strong> Pull requests still run the tests but never reach the deploy job. This is workflow logic, not access control: someone with write access can change it, and anyone with write access to a repository can read all its repository secrets.<a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a></li>
<li><strong><code>concurrency</code> prevents overlapping deployments of this service.</strong> Within the orders API repository, at most one job in the group <code>deploy-production</code> runs at a time. By default, a newer pending deploy job cancels and replaces an older pending one, so queued intermediate deployments are dropped rather than kept.<a href="https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency">[13]</a> The group applies within the repository, so other services that call <code>deploy.yml</code> are not blocked by it. Do not reuse the same group name in caller and called workflow with <code>cancel-in-progress: true</code>, or one can cancel the other.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">[8]</a></li>
<li><strong>Inputs reach the shell through <code>env</code>, not by expanding <code>${{ }}</code> inside the script.</strong> Passing values through an intermediate environment variable is GitHub's recommended defence against script injection in inline scripts.<a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a></li>
</ul>
<p><strong>The real protection for production is the environment.</strong> Store <code>PRODUCTION_DEPLOY_TOKEN</code> as a secret of the <code>production</code> environment rather than as a repository secret, and configure the environment's protection rules, such as required reviewers and the branches allowed to deploy. Environment secrets are available only to jobs that use the environment, and only after its rules pass.<a href="https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments">[20]</a> Create the environment before the first deployment: a workflow that references an environment that does not exist creates it without any protection rules, and only repository admins can configure it.<a href="https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments">[20]</a> Because the reusable workflow runs as part of the caller, the environment and its secret belong to each calling repository, here <code>orders-api</code>, not to <code>ci-workflows</code>; a caller's secrets include its own environment secrets.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax">[5]</a><a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusing-workflow-configurations">[6]</a> So <code>deploy.yml</code> cannot impose approvals centrally: every service repository that calls it must create and protect its own <code>production</code> environment and store its token there. A rule that allows deployments only from <code>main</code> is only as strong as the protection on that branch; required reviewers are the stronger control. We did not verify these settings on GitHub.</p>
<p>A long-lived deployment token is the simplest example, not the strongest design. If you deploy to a cloud provider that supports OpenID Connect, a workflow can request short-lived credentials directly from the provider instead of storing cloud credentials as GitHub secrets.<a href="https://docs.github.com/en/actions/concepts/security/openid-connect">[15]</a> That set-up deserves its own article.</p>
<h2>Which security risks matter most in shared workflows?</h2>
<p><strong>A shared workflow spreads both good and bad practice to every caller. Keep token permissions minimal, pin actions, never expand untrusted input inside scripts, and be careful with workflows that run with privileges on pull request content.</strong><a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a></p>
<ul>
<li><strong>Pull requests from forks:</strong> with the exception of <code>GITHUB_TOKEN</code>, secrets are not passed to workflows triggered from a forked repository, and the token is read-only there.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows">[11]</a> That limits what fork code can reach by default.</li>
<li><strong><code>pull_request_target</code> and <code>workflow_run</code>:</strong> these triggers run in a privileged context. GitHub warns against using them to check out untrusted pull request code.<a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a> Avoid them unless a workflow genuinely needs that context.</li>
<li><strong>Untrusted text in scripts:</strong> a pull request title written directly into a <code>run</code> script with <code>${{ }}</code> can inject shell commands. Pass such values through <code>env</code> instead.<a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a></li>
<li><strong>Third-party code:</strong> a compromised action could access the repository's secrets and may be able to write to the repository with the <code>GITHUB_TOKEN</code>. Review what you depend on and pin it. Pinning fixes the action's own code, not the actions it uses in turn; lockfiles also cover those transitive dependencies.<a href="https://docs.github.com/en/actions/concepts/security/workflow-dependency-lockfiles">[14]</a><a href="https://docs.github.com/en/actions/reference/security/secure-use">[10]</a></li>
</ul>
<p>Because many repositories call it, the <code>ci-workflows</code> repository becomes part of your delivery supply chain. Protect its main branch, require reviews for changes, and restrict who can create, move or delete release tags such as <code>v1</code>.</p>
<h2>When should you use a composite action instead?</h2>
<p><strong>Use a composite action to share a few steps inside a job, such as installing tools. Use a reusable workflow to share whole jobs, including their runner choice, environments and secrets.</strong><a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusing-workflow-configurations">[6]</a><a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a></p>
<p>GitHub's documentation summarises the main differences:<a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusing-workflow-configurations">[6]</a></p>
<table>
<thead>
<tr>
<th></th>
<th>Reusable workflow</th>
<th>Composite action</th>
</tr>
</thead>
<tbody><tr>
<td>Contains</td>
<td>One or more jobs</td>
<td>Steps only</td>
</tr>
<tr>
<td>Called from</td>
<td>A job</td>
<td>A step</td>
</tr>
<tr>
<td>Runner</td>
<td>Chosen by its jobs</td>
<td>The caller's job</td>
</tr>
<tr>
<td>Logs</td>
<td>Every job and step</td>
<td>One step</td>
</tr>
<tr>
<td>Secrets</td>
<td>Can use them</td>
<td>Must receive them explicitly as inputs</td>
</tr>
<tr>
<td>Marketplace</td>
<td>Cannot be published</td>
<td>Can be published</td>
</tr>
</tbody></table>
<p>Composite actions cannot access the <code>secrets</code> context directly. The calling workflow can pass a secret explicitly as an input.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/contexts">[21]</a></p>
<p>The two work well together. A reusable deployment workflow might call a composite action that installs a deployment tool, so the tool set-up is shared too.</p>
<h2>How can you check workflows before pushing them?</h2>
<p><strong>Run a workflow linter such as actionlint locally or in CI. It checks syntax, expressions, reusable workflow inputs, outputs and secrets, and common script-injection risks before GitHub ever runs the file.</strong><a href="https://github.com/rhysd/actionlint">[16]</a></p>
<p><a href="https://github.com/rhysd/actionlint">actionlint</a> is a static checker for workflow files, distributed under the MIT licence. It can also run ShellCheck on <code>run</code> scripts.<a href="https://github.com/rhysd/actionlint">[16]</a> We ran actionlint 1.7.12 with ShellCheck 0.11.0 on every workflow in this article; it reported no errors. To check the caller–called contract offline, we used modified copies: the caller and the reusable workflows in one local repository, with the <code>example-org/...@v1</code> references rewritten to local <code>./.github/workflows/...</code> paths. Again, no errors.</p>
<p>We then introduced deliberate mistakes, and actionlint reported each one:</p>
<ul>
<li>a misspelt input name;</li>
<li>a reference to an output that the reusable workflow does not define;</li>
<li>a missing or misspelt required secret;</li>
<li><code>steps</code> or <code>environment</code> on a job that calls a reusable workflow;</li>
<li>a pull request title expanded directly inside a <code>run</code> script.</li>
</ul>
<p>A linter does not replace a real run. We did not run these workflows on GitHub: runner behaviour, repository access settings, environment protection rules and the token's effective permissions can only be confirmed there. The application's unit tests did run locally on Python 3.11 and 3.13.</p>
<h2>Frequently asked questions</h2>
<h3>Can a reusable workflow live in the same repository as its caller?</h3>
<p>Yes. Reference it as <code>./.github/workflows/{file}</code>; the called workflow then comes from the same commit as the caller.<a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">[7]</a> This is a good way to remove duplication inside one repository before you share a workflow across many.</p>
<h3>Can I add steps before or after a reusable workflow in the same job?</h3>
<p>No. A reusable workflow replaces the whole job, so you cannot add steps to that job.<a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusing-workflow-configurations">[6]</a> Put extra work in a separate job that uses <code>needs</code>, and pass data through the reusable workflow's outputs, as the <code>summary</code> job in this article does.</p>
<h3>Should I use <code>secrets: inherit</code>?</h3>
<p>It is convenient within one organisation or enterprise, but it passes every secret the caller can access.<a href="https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax">[5]</a> For shared deployment workflows, declare the secrets you need and pass them by name. The workflow's interface then documents exactly what it uses.</p>
<h2>Sources</h2>
<p>[1] <a href="https://martinfowler.com/articles/continuousIntegration.html">https://martinfowler.com/articles/continuousIntegration.html</a> — Martin Fowler: Continuous Integration</p>
<p>[2] <a href="https://github.blog/news-insights/product-news/github-actions-now-supports-ci-cd/">https://github.blog/news-insights/product-news/github-actions-now-supports-ci-cd/</a> — GitHub Actions now supports CI/CD, free for public repositories</p>
<p>[3] <a href="https://docs.github.com/en/actions/get-started/understand-github-actions">https://docs.github.com/en/actions/get-started/understand-github-actions</a> — Understanding GitHub Actions</p>
<p>[4] <a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/workflows">https://docs.github.com/en/actions/concepts/workflows-and-actions/workflows</a> — Workflows</p>
<p>[5] <a href="https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax">https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax</a> — Workflow syntax for GitHub Actions</p>
<p>[6] <a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/reusing-workflow-configurations">https://docs.github.com/en/actions/concepts/workflows-and-actions/reusing-workflow-configurations</a> — Reusing workflow configurations</p>
<p>[7] <a href="https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows">https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows</a> — Reuse workflows</p>
<p>[8] <a href="https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations">https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations</a> — Reusing workflow configurations reference</p>
<p>[9] <a href="https://docs.github.com/en/actions/concepts/security/github_token">https://docs.github.com/en/actions/concepts/security/github_token</a> — GITHUB_TOKEN</p>
<p>[10] <a href="https://docs.github.com/en/actions/reference/security/secure-use">https://docs.github.com/en/actions/reference/security/secure-use</a> — Secure use reference</p>
<p>[11] <a href="https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows">https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows</a> — Events that trigger workflows</p>
<p>[12] <a href="https://docs.github.com/en/actions/concepts/workflows-and-actions/deployment-environments">https://docs.github.com/en/actions/concepts/workflows-and-actions/deployment-environments</a> — Deployment environments</p>
<p>[13] <a href="https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency">https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency</a> — Control the concurrency of workflows and jobs</p>
<p>[14] <a href="https://docs.github.com/en/actions/concepts/security/workflow-dependency-lockfiles">https://docs.github.com/en/actions/concepts/security/workflow-dependency-lockfiles</a> — Workflow dependency lockfiles</p>
<p>[15] <a href="https://docs.github.com/en/actions/concepts/security/openid-connect">https://docs.github.com/en/actions/concepts/security/openid-connect</a> — OpenID Connect</p>
<p>[16] <a href="https://github.com/rhysd/actionlint">https://github.com/rhysd/actionlint</a> — actionlint</p>
<p>[17] <a href="https://github.blog/news-insights/product-news/github-actions-reusable-workflows-is-generally-available/">https://github.blog/news-insights/product-news/github-actions-reusable-workflows-is-generally-available/</a> — GitHub Actions: reusable workflows is generally available</p>
<p>[18] <a href="https://github.com/actions/checkout/blob/3d3c42e5aac5ba805825da76410c181273ba90b1/action.yml">https://github.com/actions/checkout/blob/3d3c42e5aac5ba805825da76410c181273ba90b1/action.yml</a> — actions/checkout v7.0.1 action.yml</p>
<p>[19] <a href="https://github.com/actions/setup-python/blob/6d4fd22b20465ccc0f7354476588e8df7c9ca0e0/action.yml">https://github.com/actions/setup-python/blob/6d4fd22b20465ccc0f7354476588e8df7c9ca0e0/action.yml</a> — actions/setup-python v7.1.0 action.yml</p>
<p>[20] <a href="https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments">https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments</a> — Managing environments for deployment</p>
<p>[21] <a href="https://docs.github.com/en/actions/reference/workflows-and-actions/contexts">https://docs.github.com/en/actions/reference/workflows-and-actions/contexts</a> — GitHub Actions contexts</p>
<p>[22] <a href="https://github.com/actions/checkout/blob/3d3c42e5aac5ba805825da76410c181273ba90b1/README.md">https://github.com/actions/checkout/blob/3d3c42e5aac5ba805825da76410c181273ba90b1/README.md</a> — actions/checkout v7.0.1 README</p>
]]></content:encoded></item><item><title><![CDATA[Understanding TCP/IP: Packets, Connections and Reliability]]></title><description><![CDATA[Explore how TCP/IP moves everyday data, from addressing and routing to reliable byte streams, congestion control and a real local experiment.]]></description><link>https://blog.turingts.com/tcp-ip-how-networks-move-data</link><guid isPermaLink="true">https://blog.turingts.com/tcp-ip-how-networks-move-data</guid><category><![CDATA[networking]]></category><category><![CDATA[TCP]]></category><category><![CDATA[internet]]></category><category><![CDATA[tcp/ip-model]]></category><category><![CDATA[TCP Handshake]]></category><category><![CDATA[TCP/IP]]></category><category><![CDATA[IPv4]]></category><category><![CDATA[ipv6]]></category><category><![CDATA[network]]></category><dc:creator><![CDATA[Ferhat Yildiz]]></dc:creator><pubDate>Sat, 01 Aug 2026 08:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/0fb6bec7-c9e1-4ff7-b4e2-012c40f7a580.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Computers need to exchange data even when they use different hardware, sit on different networks and encounter lost packets. TCP/IP separates those problems into manageable responsibilities. Following one request from an application to a server reveals how addressing, routing and reliable transport work together—and where their guarantees stop.</p>
<p>Opening a website, checking out a repository and calling an API all depend on mechanisms that are usually invisible when everything works. An application produces bytes. Somehow those bytes must reach the right application on another computer, across links with different capacities, packet sizes and failure modes. A fast connection is not enough: both ends also need to agree about what arrived, what is missing and whether either side can accept more.</p>
<p>That problem predates the web. ARPANET connected its first nodes in 1969, but interconnecting independently designed networks introduced a further challenge: how could they communicate without all adopting the same internal technology? Work on packet switching, open-network architecture and internetworking involved many researchers and institutions. Robert Kahn and Vinton Cerf's collaboration led to a published protocol design in 1974; the design evolved, and ARPANET's planned transition from NCP to TCP/IP took place on 1 January 1983.<a href="https://www.internetsociety.org/internet/history-internet/brief-history-internet">[1]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/98af5a15-7fb1-4ec9-a75f-21168d675af9.png" alt="Map of the four ARPANET sites in December 1969: UCLA, Stanford Research Institute, UC Santa Barbara and the University of Utah. Network links connect SRI to the other three sites, plus UCLA to UC Santa Barbara." />

<p><em>ARPANET in December 1969. Our visualization of the four-site network, based on</em> <a href="https://www.darpa.mil/news/features/arpanet"><em>DARPA’s historical diagram</em></a><em>, with a</em> <a href="https://www.naturalearthdata.com/"><em>Natural Earth</em></a> <em>basemap.</em></p>
<p>The enduring idea is separation. Networks can forward packets without understanding every application, while communicating endpoints can reconstruct a useful conversation from an imperfect packet service. This article develops that idea through one request, then uses a small real loopback experiment to make the application-facing behaviour visible.</p>
<p>In our <em>Foundation</em> series, we take a closer look at the technologies we rely on every day, explaining how they work and why they were designed that way. TCP/IP is something we use whenever systems exchange data; looking beneath that familiar surface reveals the mechanisms, design choices and trade-offs that make it work. The aim is to turn everyday familiarity into a deeper understanding of the technology itself.</p>
<h2>What does TCP/IP actually provide?</h2>
<p>TCP/IP is a family of protocols with complementary responsibilities. IP provides addressing and packet delivery across networks. TCP adds a reliable, ordered byte stream between endpoints. Applications still define what those bytes mean and what counts as a successful operation.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a><a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<h3>Why did networks need IP addresses?</h3>
<p>IP addresses give separate networks a shared way to identify destinations. They let senders address data beyond their own network and let routers forward it toward the right network without needing to understand the application.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/e087f9ae-ae96-41ad-b72f-fbb3e5f9f1ce.png" alt="Three separate networks share IP addressing. A sender on network A reaches a destination interface on network B through a router; connected network C is not on the highlighted path." style="display:block;margin:0 auto" />

<p><em>Conceptual example: the destination IP address guides forwarding toward network B, then delivery to the destination interface.</em></p>
<p>Before a network can deliver data, it needs a way to say where that data is going. Connecting several networks makes the problem harder: a destination must make sense beyond the sender's own network.</p>
<p>The early ARPANET had its own addressing arrangements; the four-site network in the 1969 map was not running IPv4. Its later NCP host protocol assumed communication through ARPANET and could not address networks beyond a destination Interface Message Processor, or IMP—the packet-switching computer connecting hosts to ARPANET. Internetworking required a scheme that could span independently operated networks. Cerf and Kahn's 1974 paper combined transport and forwarding in a protocol called TCP; the design subsequently separated into IP for addressing and forwarding, and TCP for reliable transport.<a href="https://www.internetsociety.org/internet/history-internet/brief-history-internet">[1]</a></p>
<p>The IPv4 specification published as RFC 791 in September 1981 describes addresses with a network part and a part identifying a destination within that network. That structure lets routers work with groups of destinations rather than an unrelated label for every computer. The boundaries and allocation practices have evolved, but this combination of an endpoint address and a routable network prefix remains central.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a><a href="https://www.rfc-editor.org/rfc/rfc4632.txt">[5]</a></p>
<h3>What does an IP address identify?</h3>
<p>An IP address is a numerical address used by the Internet Protocol. In an ordinary one-to-one exchange, it identifies a network interface: the point where a system connects to a network.</p>
<p>An IP packet carries a source address and a destination address, allowing the network layer to distinguish where it came from and where it should go.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a><a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a><a href="https://www.rfc-editor.org/rfc/rfc4291.txt">[24]</a></p>
<p>A laptop's Wi-Fi and Ethernet connections can have different addresses, and one interface can have more than one address. A router has interfaces on different networks. Addresses can also be reassigned as systems move or their configuration changes. An address therefore describes a network attachment in a particular context; it is not a permanent serial number for a device or proof of the identity of its user.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a><a href="https://www.rfc-editor.org/rfc/rfc4291.txt">[24]</a><a href="https://www.rfc-editor.org/rfc/rfc2131.txt">[29]</a></p>
<h3>How do you read an IPv4 address and its prefix?</h3>
<p>An IPv4 address contains 32 bits, written as four decimal numbers separated by dots. Each number represents eight bits and ranges from <code>0</code> to <code>255</code>. A suffix such as <code>/24</code> tells you how many leading bits form the network prefix.</p>
<p>A bit is a binary digit, either <code>0</code> or <code>1</code>; an octet is a group of eight bits. For example, <code>192.168.1.10</code> represents the bit pattern <code>11000000.10101000.00000001.00001010</code>. The dots make the written address easier to read; the address itself is a single 32-bit value.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a></p>
<p>The address alone does not tell a host which destinations are on its local network. For that, it also needs network configuration. Consider a home or small-office LAN—a local area network—with a laptop configured as <code>192.168.1.10/24</code> and a router whose LAN interface is <code>192.168.1.1</code>. The <code>/24</code> is a prefix length: the first 24 bits identify the subnet, leaving eight bits for addresses within it. Here the subnet is <code>192.168.1.0/24</code>, covering <code>192.168.1.0</code> through <code>192.168.1.255</code>. The equivalent subnet mask is <code>255.255.255.0</code>; its set bits mark the prefix.<a href="https://www.rfc-editor.org/rfc/rfc4632.txt">[5]</a></p>
<p>That range contains 256 addresses, not 256 ordinary device assignments. In this conventional IPv4 <code>/24</code>, <code>192.168.1.0</code> identifies the subnet and <code>192.168.1.255</code> is its broadcast address, used to address all hosts on that subnet. This leaves <code>192.168.1.1</code> through <code>192.168.1.254</code> for interface addresses, including the router. The network/broadcast convention should not be generalized into a rule for every possible IPv4 prefix or for IPv6.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a></p>
<p>Suppose the laptop has a connected route for this subnet and a default route through <code>192.168.1.1</code>. A printer at <code>192.168.1.50</code> is on-link, so the laptop can send to it without asking the router to forward the packet. A destination outside that subnet requires another route; with only these two routes, traffic goes to the default gateway. A gateway is the next router, not the final destination. The destination address still identifies the remote server. Later we will follow the actual route lookup and the link-layer delivery to that next hop.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a></p>
<p>The prefix is what makes the grouping explicit. Historically, IPv4's class A, B and C formats imposed fixed network/host boundaries, which fit growing networks poorly and contributed to inefficient allocation and large routing tables. Classless Inter-Domain Routing, or CIDR, replaced those classes with explicit, variable-length prefixes and allowed routes to be aggregated. It improved address use and routing scale; it did not enlarge the 32-bit address space. An address beginning with <code>192</code> does not by itself tell you that its present-day subnet is <code>/24</code>.<a href="https://www.rfc-editor.org/rfc/rfc4632.txt">[5]</a></p>
<h3>How are public, private and LAN addresses different?</h3>
<p>Public addresses come from globally coordinated address space intended for Internet routing. Private addresses can be reused within different organizations or homes. A LAN is a local network, not an address category: it can use private or public addresses.</p>
<p>The laptop's <code>192.168.1.10</code> belongs to private IPv4 address space. Private ranges can be reused without each network obtaining a globally unique allocation. This distinction concerns address scope, not whether the device is physically nearby.<a href="https://www.rfc-editor.org/rfc/rfc1918.txt">[25]</a></p>
<p>RFC 1918 reserves exactly these three IPv4 ranges for private use:</p>
<table>
<thead>
<tr>
<th>Private prefix</th>
<th>Full address range</th>
</tr>
</thead>
<tbody><tr>
<td><code>10.0.0.0/8</code></td>
<td><code>10.0.0.0</code>–<code>10.255.255.255</code></td>
</tr>
<tr>
<td><code>172.16.0.0/12</code></td>
<td><code>172.16.0.0</code>–<code>172.31.255.255</code></td>
</tr>
<tr>
<td><code>192.168.0.0/16</code></td>
<td><code>192.168.0.0</code>–<code>192.168.255.255</code></td>
</tr>
</tbody></table>
<p>Only the listed portion of <code>172</code> is private under RFC 1918. These ranges can be routed within an organization and between cooperating private networks, but they are not globally unique destinations to advertise across the public Internet. Two homes can both use <code>192.168.1.10</code>; joining overlapping private networks through a VPN can therefore require renumbering or translation.<a href="https://www.rfc-editor.org/rfc/rfc1918.txt">[25]</a></p>
<p>A LAN is the local network itself, not an address category. It can use private IPv4, appropriately allocated public IPv4, or IPv6 addresses. Likewise, a public address does not guarantee that an application is reachable: there must be working routes in both directions, traffic must be permitted by policy, and a service must be listening. Address scope and access control answer different questions.<a href="https://www.rfc-editor.org/rfc/rfc1918.txt">[25]</a><a href="https://www.rfc-editor.org/rfc/rfc4864.txt">[32]</a></p>
<p>How, then, does the privately addressed laptop reach a public service? A common IPv4 gateway uses Network Address Translation, or NAT. With the port-sharing form—Network Address Port Translation (NAPT), also called PAT—it translates outgoing source addresses and transport ports, allowing several private clients to share a public IPv4 address. It keeps mappings so replies can be translated back to the appropriate internal endpoint. Routing chooses the next hop; translation changes the addressing seen on the other side.<a href="https://www.rfc-editor.org/rfc/rfc3022.txt">[20]</a></p>
<p>This is a response to scarcity: 32 bits allow 4,294,967,296 distinct IPv4 values in total, and reserved uses mean fewer are available for public host addressing. Sharing public addresses stretches that resource, but translation alone is not a security guarantee. Stateful filtering and firewall policy can restrict incoming traffic, including on networks that use public addresses without NAT.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a><a href="https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml">[27]</a><a href="https://www.rfc-editor.org/rfc/rfc4864.txt">[32]</a></p>
<p>The translation may also happen inside an Internet provider. Carrier-grade NAT can place multiple customers behind shared public addresses. Its designated shared range, <code>100.64.0.0/10</code>, runs from <code>100.64.0.0</code> to <code>100.127.255.255</code>; it is a separate special-purpose allocation, not a fourth RFC 1918 range. If a router receives an address from this range on its upstream interface, that address is not a globally reachable public IPv4 address.<a href="https://www.rfc-editor.org/rfc/rfc6598.txt">[33]</a></p>
<h3>What changes with IPv6?</h3>
<p>IPv6 expands addresses from 32 to 128 bits and uses a different packet format. It provides a much larger address space, with addressing scopes and configuration mechanisms described below. A system can support both versions, with separate addresses and routing information.</p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/d5ef58be-b024-469d-b00f-8a1338db5cdb.png" alt="IPv4 has four 8-bit decimal octets, illustrated by 192.0.2.10. IPv6 has eight 16-bit hexadecimal groups: 2001:0db8:1234:0001:0000:0000:0000:0010 shortens to 2001:db8:1234:1::10. Amber highlights the three zero groups represented by the double colon. Address-length bars are scaled 1 to 4; dual-stack keeps separate addresses." style="display:block;margin:0 auto" />

<p><em>IPv4 and IPv6 address notation. Both examples use documentation-only addresses. The two IPv6 forms represent the same value: leading zeros are omitted, and the amber zero groups become</em> <code>::</code><em>. The bars compare address length, not address-space size; the counts show possible bit patterns, not usable public hosts. Dual-stack allows both versions to coexist with separate addresses.</em></p>
<p>Its first specification appeared as RFC 1883 in December 1995; the current base specification is RFC 8200. IPv6 is a distinct IP version, not just longer text for an IPv4 address.<a href="https://www.rfc-editor.org/rfc/rfc1883.txt">[23]</a><a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<p>Writing 128 binary digits would be unwieldy, so IPv6 normally uses eight colon-separated groups of hexadecimal digits. Hexadecimal is base 16: the symbols <code>0</code>–<code>9</code> and <code>a</code>–<code>f</code> represent values zero through fifteen, and each digit represents four bits. Each full group contains four digits, or 16 bits. For example, <code>2001:0db8:1234:0001:0000:0000:0000:0010</code> can be shortened to <code>2001:db8:1234:1::10</code>. Leading zeros within a group may be omitted, and one consecutive run of zero groups may be compressed to <code>::</code>; using it twice would make the missing groups ambiguous. The final <code>10</code> here is hexadecimal, equal to sixteen in decimal.<a href="https://www.rfc-editor.org/rfc/rfc4291.txt">[24]</a></p>
<p>IPv6 also uses prefixes: in <code>2001:db8:1234:1::/64</code>, the first 64 bits are fixed and the other 64 bits vary. The addresses beginning with <code>2001:db8</code> in this article are reserved for documentation, so they illustrate the notation without identifying a public service to contact.<a href="https://www.rfc-editor.org/rfc/rfc4291.txt">[24]</a><a href="https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml">[28]</a></p>
<p>On an IPv6 LAN, an interface can have several useful addresses at once. A global unicast address is intended for communication beyond the local network and can be routed on the public Internet; it still needs routes and permission to be reachable. A unique-local address (ULA) is intended for local communications, potentially across several internal networks, rather than the public Internet. ULAs occupy <code>fc00::/7</code>; the locally assigned form uses <code>fd00::/8</code>, with a generated prefix to reduce the chance of clashes between sites. A link-local address, from <code>fe80::/10</code>, is narrower in scope: routers do not forward packets with link-local source or destination addresses to another link. Link-local addresses support functions such as discovering neighbours and routers.<a href="https://www.rfc-editor.org/rfc/rfc4291.txt">[24]</a><a href="https://www.rfc-editor.org/rfc/rfc4193.txt">[26]</a></p>
<p>This makes the LAN/private distinction especially visible: the same laptop interface can have both a link-local address and a global address. IPv6 also has no broadcast addresses. Where communication needs to reach a group of interfaces, multicast serves that role rather than IPv4-style broadcasting.<a href="https://www.rfc-editor.org/rfc/rfc4291.txt">[24]</a></p>
<h3>How does a system get its address, and where does DNS fit?</h3>
<p>A system can have a statically configured address or obtain one automatically through DHCP or IPv6 autoconfiguration. DNS lets applications look up addresses associated with names. Address assignment configures an interface; name resolution helps an application find a destination.</p>
<p>DHCP—the Dynamic Host Configuration Protocol—commonly supplies an IPv4 address as a renewable lease, together with network configuration. It can also convey a deliberately fixed assignment. Both public and private addresses can be assigned automatically; “dynamic” does not mean “private.”<a href="https://www.rfc-editor.org/rfc/rfc2131.txt">[29]</a></p>
<p>IPv6 supports manual configuration and DHCPv6, as well as Stateless Address Autoconfiguration (SLAAC). With SLAAC, a host can form addresses using suitable prefixes advertised by a router rather than receiving each complete address from a DHCP server. Router Advertisements also support learning default routers; obtaining an address and learning how to leave the link are related but distinct functions. Whether an IPv6 destination is on-link follows advertised or configured information, not merely a visual resemblance between addresses.<a href="https://www.rfc-editor.org/rfc/rfc4862.txt">[30]</a><a href="https://www.rfc-editor.org/rfc/rfc4861.txt">[7]</a></p>
<p>A few special addresses explain what we will see later. The IPv4 loopback range is <code>127.0.0.0/8</code>, with <code>127.0.0.1</code> commonly used; IPv6 uses <code>::1</code>. They let applications communicate within the same host, without sending their traffic through the LAN router. The unspecified addresses <code>0.0.0.0</code> and <code>::</code> instead represent the absence of a specified address in relevant protocol contexts. They are not ordinary addresses for a remote service. Also distinguish <code>0.0.0.0</code> from the route prefix <code>0.0.0.0/0</code>: the latter matches every IPv4 destination and is used for the default route.<a href="https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml">[27]</a><a href="https://www.rfc-editor.org/rfc/rfc4291.txt">[24]</a><a href="https://www.rfc-editor.org/rfc/rfc4632.txt">[5]</a></p>
<p>People usually choose a service by name rather than by its current numerical address. The Domain Name System (DNS) lets applications look up information associated with a name, including addresses. A name can have several addresses, and its records can change without the name changing. DNS supplies information used to choose a destination; it does not assign an interface its address, select the packet's route or establish the TCP connection.<a href="https://www.rfc-editor.org/rfc/rfc1034.txt">[31]</a></p>
<h3>How does an addressed request become a connection?</h3>
<p>Once the application has selected a server address, it can ask TCP to establish a connection to the server's port. IP routes the handshake packets toward that address; TCP establishes the connection state before ordinary application data is exchanged.</p>
<p>The next diagram uses the same subnet and gateway principles as the home-network example, but deliberately leaves out NAT so we can see routing and transport without translation changing the endpoints.</p>
<p>Imagine a client requesting a document from a server. We will use an illustrative client at <code>192.0.2.10</code>, a router at <code>192.0.2.1</code> on the client's link, and a server at <code>198.51.100.20</code>. These addresses come from the documentation-only ranges <code>192.0.2.0/24</code> and <code>198.51.100.0/24</code>; they are neither RFC 1918 private ranges nor real public destinations to contact. The drawing models routing between these example networks, omitting NAT, proxies and additional routers to keep the original IP endpoints visible.<a href="https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml">[27]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/632b1cdb-66c6-4008-ae95-cea0f9e3d494.png" alt="Client 192.0.2.10 port 53000 sends through a router to server 198.51.100.20 port 443; return arrows point back to the client. IP endpoints span two links; frames reach local next hops." style="display:block;margin:0 auto" />

<p><em>Figure 1. A request crosses two links through a router. The response travels back toward the client; a real return path need not use the same routers. This topology is illustrative, separate from the loopback experiment.</em></p>
<p>With the server address selected, the application can open a connection. For a conventional HTTPS connection using HTTP/1.1 or HTTP/2, TCP carries the TLS-protected application traffic. TLS provides the secure channel; HTTP describes the request and response. Not every web request uses TCP: HTTP/3 maps HTTP onto QUIC instead.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a><a href="https://www.rfc-editor.org/rfc/rfc9114.txt">[4]</a></p>
<p>For the main journey, suppose the client opens a TCP connection from local port <code>53000</code> to server port <code>443</code>. Port <code>53000</code> is an illustrative ephemeral port chosen for this connection. The server has a listening socket associated with its service address and port. After accepting a connection, the server application communicates through a connected socket; the listening socket can continue accepting others.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>A connection is distinguished by its local and remote IP addresses and TCP ports. The response reverses those endpoints: its source port is <code>443</code>, and its destination port is <code>53000</code>. A port is not an independent network destination, and <code>443</code> does not uniquely identify one connection. Many clients can reach the same listener because their endpoint combinations differ. Operating systems additionally scope sockets within their networking contexts; the four endpoint fields identify a connection within that context.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<h2>Why split the work into layers?</h2>
<p>Layers separate responsibilities that change at different rates. An application can keep its protocol while a link changes from Ethernet to Wi-Fi; TCP can preserve its stream service while IP routes packets across different networks. The boundaries help explain behaviour without requiring every component to understand the whole conversation.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a><a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>The Internet architecture is commonly described with four layers: application, transport, Internet and link. A five-layer teaching model separates the physical medium from the link layer. The OSI model offers another useful vocabulary. TLS, tunnels and hardware offload illustrate where the boundaries between these models overlap or differ.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a></p>
<p>For our request, IP offers best-effort packet delivery, not guaranteed arrival, order or freedom from duplicates. TCP supplies the stronger stream service above it; it does not make individual IP packets infallible.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a><a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>The important distinction is between the data an application handles and the units carried between networking components:</p>
<ul>
<li><strong>Application bytes:</strong> the contents of the conversation, with meaning defined by HTTP or another application protocol.</li>
<li><strong>TCP segment:</strong> a TCP header plus a portion of the stream, or control information such as a SYN or ACK.</li>
<li><strong>IP packet:</strong> an IP header and its payload, which here contains a TCP segment, before any IP fragmentation.</li>
<li><strong>Link frame:</strong> the unit carried across a particular link, such as an Ethernet frame carrying that IP packet.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a><a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></li>
</ul>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/a199d5c2-61ab-41b3-a456-55c37599ff03.png" alt="Application data gains a TCP header, an IP header and link framing. The diagram shows one segment in one unfragmented packet, not a write-to-packet guarantee." style="display:block;margin:0 auto" />

<p><em>Figure 2. Encapsulation adds headers around data. This simplified view shows one TCP segment in one unfragmented IP packet; it does not imply one application write becomes one segment. Ethernet also has a trailer, omitted here.</em></p>
<h2>What is actually inside an IP packet and a TCP segment?</h2>
<p>An IP packet contains an IP header and a payload. For TCP traffic, that payload contains a TCP segment: its header and any application data. IP fields describe addressing and forwarding; TCP fields describe ports, byte positions and connection control.</p>
<p>Reading their layouts makes it easier to understand where the payload begins, what changes at a router and what an acknowledgement describes.</p>
<h3>How do you read a header diagram?</h3>
<p>Read left to right, then continue on the next row. Each full row represents <strong>32 bits, or four bytes</strong>. Field widths show their bit counts, and byte offsets locate them within the header. Multi-byte numeric fields use <strong>network byte order</strong>, with the most significant byte first.</p>
<p>The bit positions restart at zero on each row; the byte offsets at the left count from the beginning of that particular header. These are drawings of a continuous sequence of bytes, not separate records transmitted row by row. For example, the two-byte value <code>0x1234</code> appears as <code>12</code> followed by <code>34</code>. The leftmost bit of each byte is its most significant bit.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a><a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>Field widths in the fixed-header grids are proportional to their bit counts. A 16-bit field occupies half a row; a 128-bit IPv6 address occupies four full rows. Variable-length options and payload are shown as separate bands, <strong>not to scale</strong>. The right edge marked <code>32</code> is the boundary after bit <code>31</code>, not an additional bit.</p>
<p>A <strong>header</strong> holds protocol information; a <strong>payload</strong> is what that protocol carries. Those terms are relative to a layer. In our unfragmented TCP-over-IPv4 example, the IP payload is the complete TCP segment—TCP header plus any TCP data. The TCP payload is only the bytes after its own header. A segment can also carry control information without application data, as with a pure ACK. This is why the informal expression “TCP packet” usually refers to an IP packet containing a TCP <strong>segment</strong>.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<h3>What does each IPv4 header field do?</h3>
<p>IPv4 header fields identify the source and destination, describe packet and header lengths, limit forwarding, identify the carried protocol, control fragmentation and check header integrity. The header occupies 20–60 bytes; its length tells the receiver where the payload begins.</p>
<p>The IPv4 header starts with a fixed 20-byte portion and can grow to 60 bytes when options and padding are present. Its total-length field describes the entire IP packet. These measurements determine how much application data fits under an MTU.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/20bb6b5d-8004-4598-baf8-47598e0e633b.png" alt="IPv4 header with five 32-bit rows: version, IHL, DSCP and ECN, total length, identification, fragmentation flags and offset, TTL, protocol, checksum, source and destination addresses; optional header bytes and payload follow." style="display:block;margin:0 auto" />

<p><em>IPv4 header anatomy. Fixed fields are drawn to their bit widths. E marks the two ECN bits; F marks the three fragmentation flags. Options, padding and payload have variable lengths and are not drawn to scale.</em></p>
<p><strong>Version and Internet Header Length (IHL), four bits each.</strong> Version is <code>4</code>. IHL counts 32-bit words in the IPv4 header, including options and padding: <code>5</code> means 20 bytes, while the largest four-bit value, <code>15</code>, means 60 bytes. For an ordinary unfragmented TCP packet, the TCP header begins immediately after those IP-header bytes. IHL describes the IP header, not the TCP header or the entire packet.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a></p>
<p><strong>DSCP, six bits, and ECN, two bits.</strong> Older drawings label this whole byte “Type of Service” or “TOS.” Its modern interpretation separates the Differentiated Services Code Point, used to select configured per-hop traffic treatment, from Explicit Congestion Notification. DSCP can influence queueing or forwarding treatment under a network's policy; setting it does not reserve end-to-end bandwidth. ECN distinguishes non-ECN-capable traffic (<code>00</code>), the two ECN-capable codepoints (<code>01</code> and <code>10</code>), and Congestion Experienced (<code>11</code>). A participating congested router can mark suitable ECN-capable traffic rather than signal congestion solely through loss. TCP's feedback for that mark appears in its own header, described below.<a href="https://www.rfc-editor.org/rfc/rfc2474.txt">[34]</a><a href="https://www.rfc-editor.org/rfc/rfc3168.txt">[35]</a></p>
<p><strong>Total Length, 16 bits.</strong> This is the number of bytes in the IPv4 header <strong>plus</strong> its payload. A value of <code>1500</code> with IHL <code>5</code> leaves 1,480 bytes after the IP header; that space must accommodate both the TCP header and TCP data. The field's maximum value is 65,535 bytes, although the path's usable packet size is usually much smaller. Each IPv4 fragment has its own header and Total Length.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a></p>
<p><strong>Identification, 16 bits; Flags, three bits; Fragment Offset, 13 bits.</strong> These fields describe IP fragmentation, not TCP's ordering of application bytes. Identification helps associate fragments of one original datagram, together with its source, destination and protocol. It is not a TCP sequence number or a universal counter of all packets. Modern rules do not require a unique Identification value for an atomic IPv4 datagram—one with DF set, MF clear and offset zero.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a><a href="https://www.rfc-editor.org/rfc/rfc6864.txt">[36]</a></p>
<p>The three flag bits, in order, are reserved (zero), <strong>DF</strong> (Don't Fragment) and <strong>MF</strong> (More Fragments). DF tells a router not to fragment the packet. MF means more fragments follow; the final fragment has MF clear. The offset gives this fragment's position in the original IP payload in <strong>eight-byte units</strong>. Thus offset <code>185</code> places its data at byte <code>1480</code> of that payload. A nonzero offset can identify a later fragment even when MF is clear. The destination reassembles the IP payload before TCP processes the complete segment; later fragments do not each acquire a new TCP header.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a></p>
<p><strong>Time to Live (TTL), eight bits, and Protocol, eight bits.</strong> TTL limits how long a packet can keep being forwarded; routers decrement it, preventing a routing loop from circulating the same packet forever. Protocol identifies the protocol carried in the reassembled IP payload: <code>6</code> means TCP, while <code>17</code> means UDP. It does not identify the application port. Our request therefore has IP Protocol <code>6</code> and TCP destination port <code>443</code>, in different headers.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a><a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc768.txt">[18]</a></p>
<p><strong>Header Checksum, 16 bits.</strong> IPv4 checks its header, including any options, but not the IP payload. A router changing TTL must also update this checksum. The one's-complement checksum detects many accidental corruptions; it is not cryptographic authentication and cannot establish that an address or packet is trustworthy. TCP applies its own checksum to a different scope.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a><a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p><strong>Source and Destination Address, 32 bits each.</strong> These are the binary addresses introduced earlier: in our outgoing example, <code>192.0.2.10</code> and <code>198.51.100.20</code>. The ordinary header does not contain the client's subnet mask or its default gateway. Those belong to the host's configuration and routing information. The router uses the destination to make its own next-hop decision.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a><a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a></p>
<p><strong>Options and padding, zero to 40 bytes together.</strong> IPv4 options can carry additional network-layer information, such as record-route or timestamp information. Padding brings the header to a whole number of four-byte words. Both are included in IHL and the IPv4 header checksum. The payload begins only after them, so assuming every IPv4 header is exactly 20 bytes can put a decoder at the wrong location.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a></p>
<h3>How is the IPv6 base header different?</h3>
<p>IPv6 uses a fixed <strong>40-byte base header</strong>. Longer addresses occupy most of it, while optional network-layer information goes into separate extension headers after the base. It has no IHL field, no base-header fragmentation fields and no IPv4-style header checksum.<a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/80c35bc4-90ce-4069-b4ad-b12151b86c1a.png" alt="IPv6 base header: version 4 bits, traffic class 8, flow label 20, payload length 16, next header 8, hop limit 8, then 128-bit source and destination addresses spanning four rows each. An extension-header chain follows the fixed 40-byte header." style="display:block;margin:0 auto" />

<p><em>IPv6 header anatomy. The ten four-byte rows total 40 bytes. The example below the grid shows how Next Header links a base header, an optional Destination Options header and TCP; that chain is schematic, not to scale.</em></p>
<p><strong>Version, four bits; Traffic Class, eight bits; Flow Label, 20 bits.</strong> Version is <code>6</code>. Traffic Class provides the same six-bit DSCP and two-bit ECN split discussed for IPv4. The Flow Label lets a source label a flow of packets for flow-specific handling; it is neither a TCP port nor a byte sequence number. It does not itself reserve bandwidth or make IP delivery reliable.<a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a><a href="https://www.rfc-editor.org/rfc/rfc2474.txt">[34]</a><a href="https://www.rfc-editor.org/rfc/rfc3168.txt">[35]</a></p>
<p><strong>Payload Length, 16 bits.</strong> Unlike IPv4's Total Length, this counts everything <strong>after</strong> the fixed base header. That includes any extension headers as well as the transport header and transport data. An ordinary 1,500-byte IPv6 packet therefore has Payload Length <code>1460</code>; adding the 40-byte base header recovers its total size. The specialized IPv6 jumbogram mechanism is outside this example.<a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<p><strong>Next Header, eight bits.</strong> This identifies the header immediately following the current one. If the base header says <code>6</code>, TCP follows directly. If it identifies an extension header, that header's Next Header value continues the chain. For example, base Next Header <code>60</code> can identify Destination Options, whose Next Header <code>6</code> then identifies TCP. Consequently, “the TCP header starts 40 bytes into IPv6” is true only when no intervening extension headers are present.<a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<p><strong>Hop Limit, eight bits.</strong> Each forwarding node decrements this limit by one and discards the packet if forwarding exhausts it. It serves the loop-limiting role discussed for IPv4 TTL. Because IPv6 has no base-header checksum, changing Hop Limit does not require an IPv4-style header-checksum update.<a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<p><strong>Source and Destination Address, 128 bits each.</strong> Each occupies sixteen bytes—four rows in the drawing. They carry the full binary addresses, irrespective of how many characters their compressed textual forms use. In the ordinary case they identify the originating and receiving interfaces; a Routing extension header can affect which destination is currently named in the base header.<a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<p><strong>Extension headers and the upper-layer payload.</strong> Extensions are outside the fixed base header but inside its payload-length count. A Fragment header, when needed, carries IPv6's fragmentation information. Only the source fragments IPv6 packets; a forwarding router that cannot carry the packet sends Packet Too Big feedback instead. The larger base header, any extensions and the actual TCP header all consume space under the MTU.<a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<h3>What does the TCP header add?</h3>
<p>The TCP header adds source and destination ports, sequence and acknowledgement numbers, control flags, a receive window and integrity checking. It occupies 20–60 bytes, including any options and padding, and describes one segment in a bidirectional byte-stream conversation.</p>
<p>The same basic TCP layout works over IPv4 and IPv6; IP addresses remain in the IP layer rather than being repeated as transmitted fields inside TCP.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/33dc37a4-1295-4dac-bdc2-fd0fd346b069.png" alt="TCP header in five 32-bit rows: two 16-bit ports, sequence and acknowledgement numbers, data offset, baseline reserved bits and eight flags, receive window, checksum and urgent pointer. An expanded flag legend explains CWR, ECE, URG, ACK, PSH, RST, SYN and FIN, with the newer AE and ACE interpretation distinguished below." style="display:block;margin:0 auto" />

<p><em>TCP header anatomy. The main grid shows the RFC 9293 baseline: four reserved bits and eight named flags. The inset expands those flags for readability. The note distinguishes the newer Accurate ECN allocation; it does not add bytes to the header.</em></p>
<p><strong>Source and Destination Port, 16 bits each.</strong> For our client-to-server segment these are <code>53000</code> and <code>443</code>. Together with the IP addresses, they identify the communicating endpoints. Reply segments reverse the ports. A port number says where TCP delivers the bytes, not what those bytes mean or whether TLS has authenticated the peer.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p><strong>Sequence Number and Acknowledgment Number, 32 bits each.</strong> The sequence number identifies the first data byte carried by this segment, except that a SYN uses the initial sequence number and the first data byte follows it. The acknowledgement field, when ACK is set, identifies the <strong>next sequence number expected from the other direction</strong>. Each direction has its own numbering. SYN and FIN each consume one sequence position; a pure ACK consumes none. The handshake example below will apply these fields to concrete byte positions, including the ten-byte request.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p><strong>Data Offset, four bits.</strong> This counts four-byte words in the TCP header. A value of <code>5</code> means data begins after 20 bytes; <code>8</code> means after 32 bytes; <code>15</code> allows 60 bytes. Unlike IPv4's Total Length, it does not describe the whole segment. TCP has no separate total-segment-length field: the enclosing IP information determines the segment's extent after reassembly and any intervening headers are accounted for.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<p><strong>Reserved bits and flags.</strong> The baseline layout in RFC 9293 assigns four reserved bits followed by eight one-bit flags. Reserved bits are sent as zero when their corresponding future features are not implemented. The flags can be combined: SYN-ACK means both SYN and ACK are set in the same segment. Read the baseline flag region from left to right:<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<table>
<thead>
<tr>
<th>Flag</th>
<th>Meaning in the baseline or Classic ECN interpretation</th>
</tr>
</thead>
<tbody><tr>
<td><strong>CWR</strong></td>
<td>Congestion Window Reduced: part of TCP's Classic ECN feedback exchange, including acknowledging a response to congestion feedback.</td>
</tr>
<tr>
<td><strong>ECE</strong></td>
<td>ECN-Echo: supports Classic ECN negotiation and, during data transfer, reports congestion marking back to the sender.</td>
</tr>
<tr>
<td><strong>URG</strong></td>
<td>The Urgent Pointer field is significant.</td>
</tr>
<tr>
<td><strong>ACK</strong></td>
<td>The Acknowledgment Number field is significant.</td>
</tr>
<tr>
<td><strong>PSH</strong></td>
<td>Requests the push function, making received data available promptly rather than waiting for more data; it does not define an application-message boundary.</td>
</tr>
<tr>
<td><strong>RST</strong></td>
<td>Resets or aborts the connection.</td>
</tr>
<tr>
<td><strong>SYN</strong></td>
<td>Synchronizes initial sequence numbers when establishing a connection.</td>
</tr>
<tr>
<td><strong>FIN</strong></td>
<td>Indicates no more data will be sent in this direction.</td>
</tr>
</tbody></table>
<p>Classic ECN uses ECE and CWR during the handshake to establish support, then to return congestion feedback and acknowledge the sender's response. That connects IP's two ECN bits to TCP's congestion-control behaviour; an IP congestion mark and a TCP ECE flag are different fields travelling in the data and feedback directions.<a href="https://www.rfc-editor.org/rfc/rfc3168.txt">[35]</a></p>
<p>There is a newer interpretation worth recognizing in packet analyzers. The current IANA registry assigns the last of the baseline reserved bits to <strong>AE (Accurate ECN)</strong> under RFC 9768, leaving three reserved bits. Some older drawings call that position <strong>NS</strong>, from the now-historic ECN Nonce experiment. Accurate ECN is negotiated during the handshake: the client requests it by setting AE, CWR and ECE in its SYN, and the server's SYN-ACK indicates whether it is supported. After successful negotiation, on segments with SYN clear, those three positions form the <strong>ACE</strong> field for more detailed ECN feedback. It normally carries the low three bits of a counter of CE-marked packets; a pure final handshake ACK without SACK blocks has a special encoding. Without the negotiated mode, those positions must not simply be decoded as an ACE counter. The bit positions change meaning, not the header's byte length.<a href="https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml">[37]</a><a href="https://www.rfc-editor.org/rfc/rfc9768.txt">[38]</a></p>
<p><strong>Window, 16 bits.</strong> This advertises how much data the sender of this segment is currently willing to receive, starting at the byte identified by its acknowledgement. In a server-to-client ACK, it therefore constrains how much the client may send. Window scaling, negotiated in the SYN exchange, lets this field represent larger receive windows. The congestion window, <code>cwnd</code>, is separate sender-side state and is not another transmitted TCP-header field. We will use that distinction in the flow-control example later.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc7323.txt">[39]</a></p>
<p><strong>Checksum, 16 bits.</strong> TCP checks its complete header, including options, and its data, plus a <strong>pseudo-header</strong> built from IP-layer information. That pseudo-header is input to the checksum calculation, not an extra header transmitted before TCP. For IPv4 it contains the 32-bit source and destination addresses, eight zero bits, the eight-bit protocol value <code>6</code>, and a 16-bit TCP length covering TCP header plus data. For IPv6 it contains the 128-bit source and destination addresses, a 32-bit upper-layer length, 24 zero bits and the eight-bit upper-layer Next Header value <code>6</code>. IPv6 extension headers are excluded from that TCP length; if a Routing header is present, the pseudo-header uses the final destination address.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<p>The TCP checksum is required over both IP versions. It helps detect accidental corruption and misdelivery, but provides no cryptographic authentication or resistance to deliberate modification. TLS supplies a different kind of protection above TCP. Ordinary router changes to TTL or Hop Limit do not alter the TCP checksum's inputs, whereas translation of an address or TCP port does affect them.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc3022.txt">[20]</a></p>
<p><strong>Urgent Pointer, 16 bits.</strong> When URG is set, this is an offset from the segment's sequence number to the sequence position immediately after the urgent data. It does not create a separate high-priority packet queue or replace application framing. It matters only under the urgent-data mechanism; ordinary request/response data need not use it.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<h3>How do TCP options affect the handshake and payload?</h3>
<p>TCP options can advertise or negotiate capabilities such as maximum segment size, window scaling, selective acknowledgements and timestamps. They extend the header before its payload, consuming space under the packet-size limit. Data Offset identifies where TCP data begins.</p>
<p>Options occupy the space between the fixed 20 bytes and the start indicated by Data Offset. Most options encode a kind, a length and option data; the one-byte No-Operation and End of Option List forms are exceptions. Padding completes a four-byte boundary, and these bytes count as header, not application data.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>Four commonly encountered options explain why a real SYN has more detail than a minimal handshake drawing:</p>
<ul>
<li><strong>Maximum Segment Size (MSS)</strong> advertises the largest TCP data segment the endpoint can receive, with the fixed IP and TCP headers excluded. It is sent on SYN-bearing segments. Each endpoint advertises its own receive limit, which constrains the other endpoint's sending; it is not a single shared size chosen by the client.</li>
<li><strong>Window Scale</strong> announces a shift count for interpreting that endpoint's later receive-window advertisements. Both sides must offer the option in their SYN-bearing segments to enable scaling. Each direction can use a different count, and the Window field in SYN and SYN-ACK is never scaled.</li>
<li><strong>SACK Permitted</strong> advertises support during the SYN exchange. Later SACK options can report received byte ranges beyond a gap, supplementing the ordinary cumulative acknowledgement.</li>
<li><strong>Timestamps</strong> carry a timestamp value and an echoed value. Negotiation starts in SYN/SYN-ACK; subsequent timestamp exchanges support RTT measurement and protection against old duplicates when sequence numbers wrap. These are protocol clock values, not necessarily wall-clock times.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc2018.txt">[14]</a><a href="https://www.rfc-editor.org/rfc/rfc7323.txt">[39]</a></li>
</ul>
<p>For example, if the server advertises MSS <code>1460</code> in its SYN-ACK, that informs the client's sending direction. If both sides also negotiate window scaling and the server announces a shift of <code>7</code>, a later server Window field of <code>512</code> represents 65,536 bytes of receive space. That is the receive-window value used later in Figure 4; the server's initial SYN-ACK window remains unscaled. These are illustrative negotiated values, not observations from the loopback test.<a href="https://www.rfc-editor.org/rfc/rfc7323.txt">[39]</a></p>
<p>Options also consume real packet space. With a 1,500-byte IPv4 MTU, a 20-byte IP header and a 32-byte TCP header, only 1,448 bytes remain for TCP data. The no-options example later has 1,460 bytes because its TCP header is twelve bytes shorter. This is why a decoder must follow IHL, extension headers and Data Offset rather than assume every packet has the same header lengths.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>We can now connect the header fields to the journey: IP supplies the addresses and forwarding limits, TCP identifies the application endpoints and byte positions, and each layer's length rules locate what it carries.</p>
<p>At the router, the incoming link frame is not forwarded intact across every subsequent network. The router processes the IP packet and sends it using the next link's framing. In our no-NAT example, the source and destination IP addresses still identify the client and server, while the link-layer addresses identify the participants on each individual link.<a href="https://www.rfc-editor.org/rfc/rfc1122.txt">[2]</a></p>
<p>This distinction answers an otherwise puzzling question: a client can send a frame to its local router while the IP packet inside is addressed to a server elsewhere. To do that, it first has to decide which destination is local and which requires a next hop.</p>
<h2>How does a host choose the next hop?</h2>
<p>A host consults its routing information to choose an outgoing interface and, when needed, a next-hop router. IP prefixes describe address ranges. Within the selected routing table, a more-specific matching route wins over a less-specific one; the default route is the least-specific fallback.<a href="https://www.rfc-editor.org/rfc/rfc4632.txt">[5]</a></p>
<p>In our routed example, <code>192.0.2.0/24</code> has the same prefix structure as the home LAN introduced earlier: the first 24 bits identify the subnet. We can now make the next-hop decision explicit with a routing table.</p>
<p>Suppose our client has <code>192.0.2.10/24</code> on an Ethernet interface, an on-link route for <code>192.0.2.0/24</code>, and a default route through <code>192.0.2.1</code>:</p>
<pre><code class="language-text">192.0.2.0/24       directly connected
0.0.0.0/0         via 192.0.2.1
</code></pre>
<p>A destination such as <code>192.0.2.20</code> matches the on-link route. The server at <code>198.51.100.20</code> does not, so this table sends its traffic to the default router. The default gateway is a next hop, not a replacement destination address in the original IP packet.</p>
<p>Now add a route for <code>198.51.100.0/24</code> through another reachable next hop. That route is more specific than <code>/0</code>, so it takes precedence for the server. Add a <code>/32</code> route for that one server and it is more specific again. This is <strong>longest-prefix matching</strong>. Policy routing can select different tables, and equal-prefix alternatives need further selection rules.<a href="https://www.rfc-editor.org/rfc/rfc4632.txt">[5]</a></p>
<p>The client now knows the next hop's IP address, but an Ethernet interface needs a link-layer destination. For IPv4 over Ethernet, Address Resolution Protocol (ARP) resolves that local IP address to an Ethernet address. For our remote server, the client resolves the router's local address—not the server's distant Ethernet address. ARP requests remain on the local link.<a href="https://www.rfc-editor.org/rfc/rfc826.txt">[6]</a></p>
<p>IPv6 resolves the local next hop through Neighbor Discovery rather than ARP. Carried in ICMPv6, Neighbor Discovery provides address resolution, router discovery and neighbour-reachability functions, using the on-link and router information introduced earlier.<a href="https://www.rfc-editor.org/rfc/rfc4861.txt">[7]</a><a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<p>Each forwarding router repeats a next-hop decision using its own information. A path is therefore a series of local forwarding decisions, not a complete route encoded in every ordinary packet. The IPv4 Time to Live (TTL) and IPv6 Hop Limit prevent packets from circulating indefinitely: forwarding consumes the limit, and an exhausted packet is discarded. Despite the IPv4 field's historical name, it is not an application timeout or a measurement of remaining seconds.<a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a><a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a></p>
<h2>What happens when a packet is too large?</h2>
<p>A link's maximum transmission unit, or MTU, limits the IP packet size it can carry without IP fragmentation. TCP must account for the smallest MTU along the path—the path MTU—when forming segments. A large application write is not a demand for one large packet.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a></p>
<p>A familiar worked example assumes a 1,500-byte IP MTU, a 20-byte IPv4 header and a 20-byte TCP header, with no options. That leaves 1,460 bytes for TCP data. With IPv6's 40-byte base header and the same TCP header, it leaves 1,440 bytes. Options, extension headers and encapsulation can change the space available in these examples.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a></p>
<p>The MSS exchange described above sets a receive constraint for each direction. The sender also has to respect the path and subtract any actual option or extension-header overhead from the payload it sends. An MSS exchange does not by itself discover every bottleneck MTU between the endpoints.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>There are two different kinds of splitting here:</p>
<ul>
<li><strong>TCP segmentation</strong> divides the byte stream into independently sequenced transport segments. TCP at the receiver reconstructs the ordered stream.</li>
<li><strong>IP fragmentation</strong> divides one IP datagram into fragments. IP must reassemble that datagram at the destination before passing its complete payload upward.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a><a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a></li>
</ul>
<p>IPv4 routers can fragment eligible packets when the Don't Fragment (DF) flag is clear. With DF set, an oversized packet is discarded and the router can return an ICMP “fragmentation needed” message. Classical IPv4 Path MTU Discovery uses that feedback to reduce the sender's packet size.<a href="https://www.rfc-editor.org/rfc/rfc791.txt">[9]</a><a href="https://www.rfc-editor.org/rfc/rfc1191.txt">[10]</a></p>
<p>IPv6 routers do not fragment packets in transit. They return ICMPv6 Packet Too Big feedback; if fragmentation is used, it is performed by the source. IPv6 Path MTU Discovery uses that feedback to adapt to the path.<a href="https://www.rfc-editor.org/rfc/rfc8200.txt">[8]</a><a href="https://www.rfc-editor.org/rfc/rfc8201.txt">[11]</a></p>
<p>This explains a specific failure pattern: a small handshake succeeds, but a larger transfer stalls. If required ICMP feedback is filtered or lost, the sender may not learn that its packets are too large. Packetization Layer Path MTU Discovery can instead use transport-level probes and delivery feedback to discover usable sizes. Recovery depends on the implementation supporting and using that mechanism.<a href="https://www.rfc-editor.org/rfc/rfc8201.txt">[11]</a><a href="https://www.rfc-editor.org/rfc/rfc4821.txt">[12]</a></p>
<p>A successful connection establishes that some packets made the round trip; larger packets, sustained traffic and application operations may encounter different constraints.</p>
<h2>How does TCP establish a conversation?</h2>
<p>TCP's usual three-way handshake synchronizes the two directions' sequence spaces and establishes connection state. The client sends SYN, the server replies with SYN-ACK, and the client acknowledges it. That creates a transport connection; it does not authenticate the server or confirm that a request has been processed.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>Each direction has its own sequence numbers. They count bytes in the stream, not application messages or packet numbers. SYN and FIN each consume one position in sequence space, even though they are not application-data bytes. An ordinary acknowledgement without data does not.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/5150cb92-1b92-49d5-9ae2-b4f83be654d4.png" alt="Client SYN sequence 1000; server SYN-ACK sequence 5000 acknowledgement 1001; client ACK 5001; client sends ten bytes from sequence 1001; server acknowledges 1011." style="display:block;margin:0 auto" />

<p><em>Figure 3. Illustrative sequence numbers, not a packet capture. The client starts at 1000 and the server at 5000. After the SYN, ten client data bytes occupy positions 1001 through 1010; ACK 1011 identifies the next expected byte. Options and possible ACK combinations are omitted.</em></p>
<p>The server's <code>ACK 1001</code> acknowledges the client's SYN. The client's <code>ACK 5001</code> acknowledges the server's SYN. If the client then sends ten bytes starting at sequence number <code>1001</code>, the server can acknowledge through them with <code>ACK 1011</code>. The acknowledgement identifies the next expected byte in the stream.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>That acknowledgement means the receiving TCP has accepted the bytes, not that the server application has read them, validated the request or committed a database transaction. A transport connection can remain established while its application is stuck. TCP itself also provides neither encryption nor cryptographic peer authentication; those are additional responsibilities.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>Even before considering losses, this byte-stream model has a direct consequence for ordinary application code: the receiver must decide where messages begin and end.</p>
<h2>Why can one write require several reads?</h2>
<p>TCP preserves byte order, not the boundaries of application writes. One write may be split across reads; bytes from several writes may be returned together. A receiver must use the application's framing rules rather than assume that one <code>recv()</code> returns one complete message.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>HTTP has its own framing rules. A smaller custom protocol might use a fixed length, a delimiter or a length prefix. These choices belong to the application protocol, not to TCP. A length-prefixed protocol must still read the entire prefix and body, bound the permitted length and decide how to handle an incomplete message.</p>
<p>Here is a deliberately small fixed-length exchange that you can run with Python 3. It binds only to <code>127.0.0.1</code>, asks the operating system for an available port and exits after one connection. It needs no external service, elevated privileges or extra packages. Save it as <code>stream.py</code>:</p>
<pre><code class="language-python">import socket
from concurrent.futures import ThreadPoolExecutor


def read_exact(sock, count):
    data = bytearray()
    while len(data) &lt; count:
        chunk = sock.recv(count - len(data))
        if not chunk:
            raise EOFError("connection ended before the frame was complete")
        data.extend(chunk)
    return bytes(data)


def server(listener):
    conn, _ = listener.accept()
    with conn:
        conn.settimeout(5)
        first = conn.recv(3)
        print("First read:", first)
        rest = read_exact(conn, 10 - len(first))
        print("Complete request:", first + rest)
        assert first + rest == b"HELLOWORLD"
        assert conn.recv(1) == b""  # Client has finished sending.
        conn.sendall(b"OK")         # The other direction still works.


with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as listener:
    listener.settimeout(5)
    listener.bind(("127.0.0.1", 0))  # Ask the OS for an unused local port.
    listener.listen(1)
    with ThreadPoolExecutor(max_workers=1) as pool:
        task = pool.submit(server, listener)
        with socket.create_connection(listener.getsockname(), timeout=5) as client:
            client.sendall(b"HELLOWORLD")
            client.shutdown(socket.SHUT_WR)
            print("Reply:", read_exact(client, 2))
        task.result()
</code></pre>
<p>Run it:</p>
<pre><code class="language-shell">python3 stream.py
</code></pre>
<p>This local execution returned:</p>
<pre><code class="language-text">First read: b'HEL'
Complete request: b'HELLOWORLD'
Reply: b'OK'
</code></pre>
<p>The client made one <code>sendall()</code> call with ten bytes, but the server's first read asked for at most three. It could not return the entire request. On another run, that first read could return fewer than three bytes; the loop still reconstructs the exact ten-byte message. This demonstrates application read boundaries; determining the transmitted segment count would require packet-level observation.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://docs.python.org/3/library/socket.html">[13]</a></p>
<p><code>sendall()</code> handles partial sends for the caller, continuing until it has sent the supplied bytes or encounters an error. It does not wait for an application-level acknowledgement. The <code>read_exact()</code> loop handles partial reads and rejects EOF before the frame is complete. The five-second socket timeout bounds an individual blocking operation here; a larger application may also need an overall request deadline.<a href="https://docs.python.org/3/library/socket.html">[13]</a></p>
<p>The final two lines of the exchange reveal something else. The client calls <code>shutdown(SHUT_WR)</code>, ending its sending direction, but then receives <code>OK</code>. TCP is bidirectional: finishing one direction does not inherently prevent data flowing in the other.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://docs.python.org/3/library/socket.html">[13]</a></p>
<p>The transport still has more work than this quiet loopback exchange reveals. Across a real path, a segment can arrive late, twice, out of order or not at all.</p>
<h2>How does TCP recover missing data?</h2>
<p>TCP tracks bytes sent and acknowledged, detects missing data and retransmits when needed. The receiver can buffer out-of-order data, but the ordinary stream interface delivers bytes in order. Data beyond a gap does not become a separate complete message merely because it has already reached the host.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>Suppose the receiver expects byte <code>2001</code>. It receives bytes <code>3001–4000</code> first because the earlier range is delayed or lost. Its cumulative acknowledgement can remain at <code>2001</code>: that is still the start of the missing contiguous range. Repeated acknowledgements can give the sender evidence of a gap, but reordering also produces this pattern. A duplicate ACK is not, by itself, proof of a physical packet drop.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>When Selective Acknowledgment (SACK) has been negotiated, the receiver can additionally report ranges it has received beyond that gap. The sender can use that information to avoid resending data unnecessarily. SACK supplements the cumulative acknowledgement; it does not redefine its meaning or turn the application interface into unordered messages.<a href="https://www.rfc-editor.org/rfc/rfc2018.txt">[14]</a></p>
<p>Waiting forever for acknowledgements would not provide a useful failure mechanism. TCP therefore maintains a retransmission timeout (RTO) using an estimate of round-trip time (RTT) and its variation. A timeout can trigger retransmission, and repeated timeouts back off. The calculation avoids ambiguous RTT samples from retransmitted data unless information such as timestamps resolves the ambiguity.<a href="https://www.rfc-editor.org/rfc/rfc6298.txt">[15]</a></p>
<p>Loss recovery is not identical in every implementation. The classic fast-retransmit algorithm uses three duplicate ACKs as a loss signal, while other recovery mechanisms can use additional timing and SACK information. A retransmission timer is also necessary, including when a small transfer cannot generate three duplicate ACKs.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc5681.txt">[16]</a></p>
<p>The cost of ordered delivery is visible here. Later bytes may have arrived, but the application waits for the gap to be repaired. If several logical requests share one TCP stream, that gap can delay all of them at the transport boundary. TCP solves reconstruction of the stream; it does not know which application message is more urgent.</p>
<p>Reliability is also bounded by failure. A permanently broken path may eventually produce an error; an application deadline can bound the wait even when TCP does not detect the failure. If the client loses the response, it may be unable to tell whether the server acted on the request before the connection failed. Safe retries and duplicate-operation handling require application semantics beyond TCP's sequence numbers.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<h2>What stops a sender from overwhelming the receiver or network?</h2>
<p>TCP uses two different constraints. The receiver's advertised window protects receiving capacity. The sender's congestion window limits data in flight according to its congestion-control algorithm. A sender can be limited by either, even when the other would permit more traffic.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc5681.txt">[16]</a></p>
<p><strong>Flow control</strong> asks how much more data the receiving TCP can accept. If the application reads slowly, the receive buffer can fill and the advertised receive window, <code>rwnd</code>, can shrink. A zero window means “not ready for more data,” not “the network has no bandwidth.” TCP has mechanisms for probing so that a lost window update does not leave the connection stuck indefinitely.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p><strong>Congestion control</strong> asks how much traffic the sender should put into the path. The sender maintains <code>cwnd</code>; it is not a field advertised by the receiver in each TCP header. In a simplified window-limited model, outstanding unacknowledged data must fit within the smaller of <code>rwnd</code> and <code>cwnd</code>. Pacing, available application data and implementation details add further constraints.<a href="https://www.rfc-editor.org/rfc/rfc5681.txt">[16]</a></p>
<img src="https://cdn.hashnode.com/uploads/gql/6ad858beca6b1f0a715e21e0/625c9489-3b02-4f41-8b0f-e020eb219182.png" alt="Receive window 65536 bytes and congestion window 32768 bytes constrain outstanding data to 32768. With 16384 in flight, the simplified remaining allowance is 16384 bytes." style="display:block;margin:0 auto" />

<p><em>Figure 4. Two independent constraints on one sender. The receive window comes from the receiver; the congestion window is maintained at the sender. Values are illustrative, not measurements.</em></p>
<p>For example, suppose <code>rwnd</code> is 65,536 bytes, <code>cwnd</code> is 32,768 bytes and 16,384 bytes are already in flight. The simplified model leaves room for another 16,384 bytes. Increasing the receive buffer would not remove the current congestion-window limit. Large advertised receive windows use TCP's window-scaling extension, which allows the header's 16-bit window field to represent a larger value.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>Classic slow start increases the congestion window rapidly as acknowledgements arrive, rather than assuming the full path capacity is available immediately. Congestion avoidance then probes more cautiously, and loss or congestion indications change sending behaviour. The exact growth and reduction rules depend on the algorithm: CUBIC, for example, uses a cubic growth function rather than merely reproducing Reno's linear congestion-avoidance behaviour.<a href="https://www.rfc-editor.org/rfc/rfc5681.txt">[16]</a><a href="https://www.rfc-editor.org/rfc/rfc9438.txt">[17]</a></p>
<p>Loss is evidence an algorithm reacts to, not an infallible diagnosis of congestion. Reordering, link problems and other failures also matter. Conversely, a path can suffer long queues and high latency without dropping every burst. Looking only at packet loss misses part of the performance story.<a href="https://www.rfc-editor.org/rfc/rfc5681.txt">[16]</a><a href="https://www.rfc-editor.org/rfc/rfc9438.txt">[17]</a></p>
<p>RTT makes the feedback loop tangible. At an illustrative 100 megabits per second and 40 milliseconds round-trip time, roughly 500,000 bytes must be in flight to sustain that rate in an idealized steady state. This bandwidth-delay product describes an idealized steady state; application limits, headers, congestion, loss and competing traffic can all reduce useful throughput. A fast link with a small effective window can still deliver a slow transfer.</p>
<h2>Why use UDP if TCP handles reliability?</h2>
<p>UDP provides datagrams rather than an ordered byte stream. It preserves the datagram abstraction but does not itself provide TCP's retransmission, ordering, duplicate protection or congestion-control machinery. Applications can choose different trade-offs or build a richer transport on top; UDP does not mean the complete application must be unreliable.<a href="https://www.rfc-editor.org/rfc/rfc768.txt">[18]</a></p>
<p>For some communication, a late result is less useful than a current one. For other protocols, independently framed messages are a better starting point than a single ordered stream. These trade-offs concern message delivery as well as speed. A UDP-based application still needs appropriate behaviour under loss and congestion.</p>
<p>QUIC is the important web example. It runs over UDP and provides reliable ordered streams, flow control, connection management and integrated security, with loss recovery and congestion control specified as part of the transport design. HTTP/3 uses these capabilities rather than assuming a TCP connection underneath.<a href="https://www.rfc-editor.org/rfc/rfc9000.txt">[19]</a><a href="https://www.rfc-editor.org/rfc/rfc9114.txt">[4]</a></p>
<p>QUIC's independent streams avoid TCP's transport-level head-of-line blocking <strong>between</strong> streams: a gap in one stream need not prevent delivery on another. A stream still has its own ordering requirements, a lost packet can contain data from several streams, and the connection still shares network constraints.<a href="https://www.rfc-editor.org/rfc/rfc9000.txt">[19]</a></p>
<h2>What do NAT, firewalls and proxies change?</h2>
<p>Routing chooses where a packet goes next. Network Address Translation changes addresses and sometimes ports. A firewall applies traffic policy. A transport-terminating proxy creates separate transport conversations. These functions can live on one device while serving distinct roles.</p>
<p>The IPv4 gateway translation introduced earlier changes what each endpoint observes. If we add NAPT to the original path, the server sees the translated source address and port rather than the client's original pair. Replies depend on the gateway retaining the matching translation state.<a href="https://www.rfc-editor.org/rfc/rfc3022.txt">[20]</a></p>
<p>That distinction matters when comparing observations. A client-side socket, a NAT mapping and a server-side socket can describe the same conversation with different endpoint values. A NAT-related resource limit can prevent new connections even while existing ones continue. But a translation table is not, by itself, a complete description of firewall policy: permitting or denying traffic is a separate decision.</p>
<p>A proxy that terminates TCP goes further. The client talks to the proxy's TCP endpoint, and the proxy opens or reuses another connection toward a backend. Each connection has its own sequence numbers, windows and lifecycle. An ACK from the proxy's client-facing TCP therefore does not establish that the backend has received the request. The acknowledgement covers the client-to-proxy connection.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>Addresses and packets now have context. The remaining question is how to use that context when the visible symptom is simply “the request failed.”</p>
<h2>What can local observations actually tell us?</h2>
<p>Observe the boundary that matches the symptom. Name resolution, route selection, connection establishment, TLS negotiation and application processing are different stages. A successful check at one stage narrows the investigation; it does not establish that every later stage succeeded.</p>
<p>On Linux, <code>ss</code> can show TCP sockets and, where the networking environment exposes them, internal TCP information. Use a filter for your own test's port rather than collecting unrelated connections.<a href="https://man7.org/linux/man-pages/man8/ss.8.html">[21]</a></p>
<p>In a separate bounded loopback check, the server listened on port <code>49419</code> and the client used port <code>26460</code>. While both sockets were open, this command was run in the same networking environment:</p>
<pre><code class="language-shell">ss -tin '( sport = :49419 or dport = :49419 )'
</code></pre>
<p>The relevant rows were:</p>
<pre><code class="language-text">ESTAB 0      0          127.0.0.1:26460    127.0.0.1:49419 reordering:0
ESTAB 0      0          127.0.0.1:49419    127.0.0.1:26460 reordering:0
</code></pre>
<p>These are two endpoint views of one connection, not two connections initiated independently. The local and peer addresses reverse. Substitute your own test's current port: these particular sockets were closed after inspection. The short <code>stream.py</code> example finishes too quickly to reliably inspect interactively.</p>
<p>The available TCP diagnostics depend on the host and networking environment; some environments expose basic socket rows without the richer information requested by <code>-i</code>.</p>
<p>A route lookup asks a different question:</p>
<pre><code class="language-shell">ip route get 127.0.0.1
</code></pre>
<p>The observed output was:</p>
<pre><code class="language-text">127.0.0.1 dev lo src 127.0.0.1
    cache
</code></pre>
<p><code>ip route get</code> performs a route lookup without sending a packet. Here the selected device is the loopback interface, <code>lo</code>. It does not exercise Ethernet, ARP, an external router or the path in Figure 1.<a href="https://man7.org/linux/man-pages/man8/ip-route.8.html">[22]</a></p>
<p>For a request to a real service, the same layered reasoning gives more useful questions than “is the network working?”:</p>
<ul>
<li><strong>Name resolution fails:</strong> was an address obtained at all? No TCP connection to that resolved destination has yet been established.</li>
<li><strong>Connection is refused:</strong> the attempt was rejected, commonly because no listener accepts that address and port or policy actively rejects it. That is different from receiving no response.</li>
<li><strong>Connection times out:</strong> investigate the selected destination, routes, filtering and return traffic; silence does not identify which device dropped a packet.</li>
<li><strong>TLS fails after TCP connects:</strong> examine the secure-channel negotiation and identity checks rather than treating an established TCP connection as proof of a valid TLS session.</li>
<li><strong>The server returns an HTTP error:</strong> transport carried a response. The error's meaning belongs to HTTP and the application; it is not equivalent to a failed handshake.</li>
</ul>
<p>Local socket limits, ephemeral-port availability and application deadlines also affect connection attempts. Some <code>connect()</code> failures occur locally, before any packet is sent.</p>
<h2>How does a TCP connection end?</h2>
<p>An orderly close finishes each direction separately using FIN and acknowledgements. A reset, RST, aborts a connection instead. TIME_WAIT retains state after an active close to handle delayed traffic and final-acknowledgement reliability; it is not, by itself, evidence of a leak.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>FIN follows the bytes already sent in that direction. The receiver can read those bytes before observing end-of-stream. The other direction can continue, as the Python example demonstrated. An application expecting a response can keep receiving after it has finished sending.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://docs.python.org/3/library/socket.html">[13]</a></p>
<p>The familiar drawing with four separate close packets is only one arrangement. Acknowledgements and FINs can be combined, and simultaneous close is possible. Applications also have different close and abort behaviour. A reset aborts the connection rather than completing the application exchange.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>The endpoint performing the active close normally enters TIME_WAIT. Its purpose includes keeping old duplicate segments from being confused with a later incarnation of the connection and allowing the final acknowledgement to be sent again if needed. TIME_WAIT duration and safe reuse behaviour have implementation-specific details. Tuning these values requires accounting for connection lifetimes and delayed segments to preserve safe reuse.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<p>This returns us to the original request. Delivering packets, reconstructing bytes, accepting an application request and committing its effects are distinct events. Understanding those boundaries explains both why everyday communication works so well and why no single “connection successful” signal can prove the whole operation succeeded.</p>
<h2>Frequently asked questions</h2>
<h3>Does a TCP acknowledgement mean the request succeeded?</h3>
<p>No. It acknowledges bytes at the receiving TCP endpoint, not application processing or durable effects. The application needs its own response semantics. If the response is lost, retrying safely may require idempotency or another way to determine the original operation's outcome.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<h3>Can TCP deliver the same application operation twice?</h3>
<p>TCP uses sequence numbers to prevent retransmitted bytes from appearing twice in one delivered stream. An application can nevertheless submit the same operation again, for example on a new connection after a timeout. Transport-level duplicate handling does not provide exactly-once business operations.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a></p>
<h3>Why can a small request work while a larger transfer stalls?</h3>
<p>An MTU problem is one possibility: small packets pass, larger ones do not, and required feedback fails to reach the sender. Receive-window limits, congestion and application behaviour are other possibilities. A larger transfer can expose constraints that a small request does not encounter.<a href="https://www.rfc-editor.org/rfc/rfc9293.txt">[3]</a><a href="https://www.rfc-editor.org/rfc/rfc8201.txt">[11]</a><a href="https://www.rfc-editor.org/rfc/rfc4821.txt">[12]</a></p>
<h3>Is this networking knowledge only useful for infrastructure work?</h3>
<p>No. Stream framing affects application code; acknowledgement boundaries affect API retries; latency and windows affect perceived responsiveness. Infrastructure operations are one use of the model, alongside software design, performance analysis and understanding the technologies behind everyday tools.</p>
<h2>Sources</h2>
<ol>
<li><a href="https://www.internetsociety.org/internet/history-internet/brief-history-internet">Internet Society: A Brief History of the Internet</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc1122.txt">RFC 1122: Requirements for Internet Hosts — Communication Layers</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc9293.txt">RFC 9293: Transmission Control Protocol</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc9114.txt">RFC 9114: HTTP/3</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc4632.txt">RFC 4632: Classless Inter-domain Routing</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc826.txt">RFC 826: Ethernet Address Resolution Protocol</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc4861.txt">RFC 4861: Neighbor Discovery for IP version 6</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc8200.txt">RFC 8200: Internet Protocol, Version 6 Specification</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc791.txt">RFC 791: Internet Protocol</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc1191.txt">RFC 1191: Path MTU Discovery</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc8201.txt">RFC 8201: Path MTU Discovery for IP version 6</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc4821.txt">RFC 4821: Packetization Layer Path MTU Discovery</a></li>
<li><a href="https://docs.python.org/3/library/socket.html">Python documentation: socket — Low-level networking interface</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc2018.txt">RFC 2018: TCP Selective Acknowledgment Options</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc6298.txt">RFC 6298: Computing TCP’s Retransmission Timer</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc5681.txt">RFC 5681: TCP Congestion Control</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc9438.txt">RFC 9438: CUBIC for Fast and Long-Distance Networks</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc768.txt">RFC 768: User Datagram Protocol</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc9000.txt">RFC 9000: QUIC — A UDP-Based Multiplexed and Secure Transport</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc3022.txt">RFC 3022: Traditional IP Network Address Translator</a></li>
<li><a href="https://man7.org/linux/man-pages/man8/ss.8.html">ss(8): investigate sockets</a></li>
<li><a href="https://man7.org/linux/man-pages/man8/ip-route.8.html">ip-route(8): routing table management</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc1883.txt">RFC 1883: Internet Protocol, Version 6 (1995)</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc4291.txt">RFC 4291: IPv6 Addressing Architecture</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc1918.txt">RFC 1918: Address Allocation for Private Internets</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc4193.txt">RFC 4193: Unique Local IPv6 Unicast Addresses</a></li>
<li><a href="https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml">IANA: IPv4 Special-Purpose Address Registry</a></li>
<li><a href="https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml">IANA: IPv6 Special-Purpose Address Registry</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc2131.txt">RFC 2131: Dynamic Host Configuration Protocol</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc4862.txt">RFC 4862: IPv6 Stateless Address Autoconfiguration</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc1034.txt">RFC 1034: Domain Names — Concepts and Facilities</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc4864.txt">RFC 4864: Local Network Protection for IPv6</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc6598.txt">RFC 6598: Shared Address Space for Service Providers</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc2474.txt">RFC 2474: Differentiated Services Field</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc3168.txt">RFC 3168: Explicit Congestion Notification to IP</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc6864.txt">RFC 6864: Updated Specification of the IPv4 ID Field</a></li>
<li><a href="https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml">IANA: TCP Parameters — TCP Header Flags</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc9768.txt">RFC 9768: More Accurate Explicit Congestion Notification Feedback in TCP</a></li>
<li><a href="https://www.rfc-editor.org/rfc/rfc7323.txt">RFC 7323: TCP Extensions for High Performance</a></li>
</ol>
]]></content:encoded></item></channel></rss>