<?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[DevOps Job Updates]]></title><description><![CDATA[DevOps Job Updates]]></description><link>https://devopsjobupdates.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 23:24:52 GMT</lastBuildDate><atom:link href="https://devopsjobupdates.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Ansible vs Terraform: Differences, When to Use Each, and How They Work Together]]></title><description><![CDATA[Ansible vs Terraform is the comparison every DevOps engineer is asked about, and it is mostly not a contest. The two tools answer different questions…]]></description><link>https://devopsjobupdates.hashnode.dev/ansible-vs-terraform-differences-when-to-use-each-and-how-they-work-together</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/ansible-vs-terraform-differences-when-to-use-each-and-how-they-work-together</guid><category><![CDATA[ansible]]></category><category><![CDATA[Terraform]]></category><category><![CDATA[Devops]]></category><category><![CDATA[#IaC]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:57:40 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>Ansible vs Terraform is the comparison every DevOps engineer is asked about, and it is mostly not a contest. The two tools answer different questions. Terraform builds infrastructure and remembers what it built. Ansible configures machines and network devices that already exist, and remembers nothing. A team that treats them as rivals will pick one and then fight its limitations; a team that treats them as complementary will use both, each for the job it is good at, and hand off between them cleanly.</p>
<p>This guide compares the two tools as they stand on 30 November 2026: ansible-core 2.22.0, released 2 November 2026, with the Ansible 14.6.0 community package on ansible-core 2.21 and Ansible 15 in pre-release; and Terraform 1.17.2, released 11 November 2026. It covers what each tool actually does, how they differ on language, state, workflow and licensing, when to use each one, and how they work together in a real pipeline — including the handoff pattern and the tooling that connects them. If you are new to either tool, our <a href="https://devopsjobupdates.com/ansible-tutorial-beginners/">Ansible Tutorial for Beginners</a> and our <a href="https://devopsjobupdates.com/terraform-tutorial-beginners/">Terraform Tutorial for Beginners</a> are the starting points; if you are choosing between infrastructure-as-code tools more broadly, our <a href="https://devopsjobupdates.com/terraform-vs-pulumi-vs-opentofu/">Terraform vs Pulumi vs OpenTofu</a> covers the other side of the decision.</p>
<p>The short answer: Terraform provisions cloud infrastructure declaratively, with state. Ansible configures what runs inside it, procedurally, over SSH, with no state. Learn Terraform first for cloud infrastructure, Ansible first for managing servers, and both if you want to be hireable — the job that asks for one usually expects the other as well.</p>
<h2>What Each Tool Actually Does</h2>
<p>Terraform is a provisioning tool. You declare the end state of cloud objects in HCL — a VPC, a subnet, a database, a load balancer — and Terraform compares that desired state with the state file it keeps, works out the difference, and creates, changes or destroys whatever is needed to close the gap. Run it twice with no code change and the second run does nothing, because the desired state and the real state already agree. That property, convergence against recorded state, is the whole value of the tool. Terraform talks to provider APIs: it does not log into machines, it calls the AWS, Azure or Google Cloud API and asks for an object to exist.</p>
<p>Ansible is a configuration and orchestration tool. It connects to machines that already exist — over SSH for Linux, WinRM for Windows, or vendor APIs for network gear — with no agent installed on the target, runs tasks in order, and each module is written to be safe to rerun. A playbook is a list of plays, each mapping a group of hosts to a list of tasks, and each task calls a module: install a package, write a configuration file from a template, restart a service, create a user. Ansible's control node pushes small Python modules to the target, runs them, and collects the results as JSON. The target needs Python for Linux hosts, and nothing else — there is no agent to install, upgrade or secure.</p>
<p>The overlap that confuses people is that Ansible ships cloud modules, so you can create an EC2 instance from a playbook. You can. But Ansible keeps no state file, so it has no memory of what it built, and deletion, drift detection and dependency ordering all become your problem. Creating an instance is easy; knowing it exists, knowing what has changed since, and deleting it cleanly a month later are the hard parts, and they are the parts Terraform's state file exists to solve. The same is true in reverse: Terraform has provisioners that can run commands on a machine after creating it, but they are a last resort, not a configuration management system, and HashiCorp's own guidance is to use a dedicated tool for configuration instead.</p>
<p>The sentence that settles most arguments is this: Terraform answers "what infrastructure should exist?", and Ansible answers "what state should this machine be in?". They are different questions, and a team that asks both needs both tools.</p>
<h2>Language — Declarative HCL vs Procedural YAML</h2>
<p>The language difference is the first thing a new user feels, and it follows from the job difference. Terraform's language is HCL, the HashiCorp Configuration Language: declarative, describing an intended goal rather than the steps to reach it. A resource block says what you want — a virtual machine of a given size in a given subnet — and Terraform works out the order, the dependencies and the API calls. HCL is a small language by design: it describes infrastructure and little else, so a configuration file is readable by anyone on the team, including people who do not program. Its limits are a feature: there is no way to write a loop that nobody understands, because the language does not offer one in the general-purpose sense. Repetition is handled by <code>for_each</code> and <code>count</code>, and by modules, which are folders of configuration with inputs and outputs.</p>
<p>Ansible's language is YAML plus Jinja2 templating. A playbook is a list of tasks that run in the order you wrote them, top to bottom, and each task is a module call with arguments. That makes Ansible procedural in feel even though its modules are idempotent — each module checks the current state and changes it only if needed, so running the playbook twice is safe, but the order of operations is yours to decide. The procedural style is a strength for orchestration: a rolling deploy that updates one server, waits for the health check, updates the next, and rolls back if the check fails is a sequence of steps, and YAML expresses a sequence naturally. It is also the source of Ansible's most common failure mode: a playbook that depends on the order of its tasks is fragile when someone reorders them, and a playbook with complex conditionals and loops in Jinja2 becomes a program written in a templating language, which is nobody's idea of a good time.</p>
<p>The choice follows the author. If the authors are infrastructure engineers, HCL's limits are a feature — the configuration is readable, reviewable and hard to misuse. If they are developers who already write YAML and Jinja2, Ansible's playbooks feel natural. Neither language is better in the abstract; the question is which one the maintaining team already reads fluently.</p>
<h2>State — The Difference That Decides Most Arguments</h2>
<p>State is the difference that matters most, and it is the one teams underestimate when they choose. Terraform keeps a state file: a record of every resource it manages, mapping your configuration to real resource IDs. The state file is what makes the plan possible — Terraform compares the desired configuration against the state, and against the real infrastructure, and shows you the difference before anything changes. It is what makes deletion possible — Terraform knows what it created, so it can destroy exactly those things and nothing else. And it is what makes drift detection possible — when someone changes a resource outside Terraform, the next plan notices. State must be stored remotely, locked during applies so two engineers cannot change the same infrastructure at once, and treated as sensitive, because it can contain secrets in plain text. Our <a href="https://devopsjobupdates.com/terraform-tutorial-beginners/">Terraform Tutorial for Beginners</a> covers the workflow, and the Terraform State Explained guide covers backends, locking and state surgery in detail.</p>
<p>Ansible has no state file. It queries the live system on every run: it checks whether the package is installed, whether the file has the right content, whether the service is running, and it changes what does not match. That is why Ansible is stateless, and it is both its strength and its weakness. The strength is simplicity: there is no state to store, lock, back up or lose, and there is no state file to go stale. The weakness is that Ansible cannot tell you what it built, what has changed since, or what to delete. If a playbook creates an EC2 instance and the playbook is deleted, the instance remains, and nothing in Ansible knows it exists. If a server is changed by hand, Ansible will put it back on the next run — which is good for configuration drift — but it cannot show you a plan of the change before it happens, the way <code>terraform plan</code> can.</p>
<p>The practical consequence is that Terraform is the tool for things with a lifecycle — create, change, destroy — and Ansible is the tool for things with a desired state — installed, configured, running. Cloud resources have a lifecycle, so they belong to Terraform. Machine configuration has a desired state, so it belongs to Ansible. A team that tries to manage a lifecycle with Ansible ends up writing its own state tracking, badly. A team that tries to configure machines with Terraform ends up fighting provisioners, which HashiCorp itself describes as a last resort.</p>
<h2>Workflow, Preview and Idempotency</h2>
<p>The two tools also differ in how you preview a change before making it, and that difference shapes how teams review each other's work. Terraform's preview is <code>terraform plan</code>: a complete diff showing what will be created, changed and destroyed, with the exact attribute changes for each resource. In a team, the plan is the artifact that gets reviewed like a code change — attached to a pull request, read by a second engineer, approved before the apply runs. It is the single best feature of the Terraform workflow for reliability, because it makes infrastructure changes reviewable in the same way code changes are.</p>
<p>Ansible's preview is <code>--check</code> mode, run with <code>--diff</code> to show what would change. It is useful, and it should be part of every playbook run in a pipeline, but it is weaker than a plan: whether a module can predict its change depends on the module, and some modules cannot know what they would do without doing it. A template module can show the diff of a file it would write; a command module cannot predict the effect of the command it would run. The practical result is that Ansible changes are reviewed as code — the playbook diff — rather than as a preview of the effect, and the effect is verified after the run, not before it.</p>
<p>Both tools are idempotent in the sense that matters: running the same configuration twice should produce the same result. Terraform achieves it through state and the plan; Ansible achieves it through modules that check the current state before acting. The difference is what happens when the world has changed since the last run. Terraform detects the drift and proposes to correct it, showing you the difference first. Ansible corrects the drift silently on the next run, which is convenient for configuration and dangerous for anything where the change deserves a review. That is another way of saying the same thing: Terraform is for changes you want to review, Ansible is for changes you want to converge.</p>
<p>The execution model differs too. Terraform runs from a single binary and plans fast, because it works from state and API calls. Ansible runs over SSH, one host at a time by default, with five parallel forks — slow for a large fleet, and the first setting every Ansible user learns to raise. The agentless model is a real advantage for adoption, but SSH round-trips cost at scale, and a fleet of hundreds needs the parallelism tuned and the playbooks written efficiently.</p>
<h2>Head-to-Head Comparison</h2>
<p>The table below puts the comparison in one place. Read it as a summary of the sections above, not as a scorecard — no tool wins every row, and the row that matters most depends on your team.</p>
<table>
<thead>
<tr>
<th>Factor</th>
<th>Ansible</th>
<th>Terraform</th>
</tr>
</thead>
<tbody><tr>
<td>Primary job</td>
<td>Configuration management and orchestration</td>
<td>Infrastructure provisioning</td>
</tr>
<tr>
<td>Paradigm</td>
<td>Procedural tasks with idempotent modules</td>
<td>Declarative desired state</td>
</tr>
<tr>
<td>Language</td>
<td>YAML playbooks with Jinja2</td>
<td>HCL</td>
</tr>
<tr>
<td>State management</td>
<td>Stateless — queries live systems</td>
<td>State file, local or remote backend</td>
</tr>
<tr>
<td>Change preview</td>
<td>--check / --diff mode, module-dependent</td>
<td>terraform plan, full diff</td>
</tr>
<tr>
<td>Agent on targets</td>
<td>None — SSH, WinRM, vendor APIs</td>
<td>None — provider APIs</td>
</tr>
<tr>
<td>Python on targets</td>
<td>Needed for Linux targets</td>
<td>Not needed</td>
</tr>
<tr>
<td>Control node on Windows</td>
<td>Needs WSL</td>
<td>Native Windows builds</td>
</tr>
<tr>
<td>Licence</td>
<td>GPLv3 (ansible-core open source)</td>
<td>Business Source License 1.1 (OpenTofu fork: MPL-2.0)</td>
</tr>
<tr>
<td>Maintainer</td>
<td>Red Hat (IBM)</td>
<td>HashiCorp (IBM)</td>
</tr>
<tr>
<td>Managed offering</td>
<td>Ansible Automation Platform, priced per managed node</td>
<td>HCP Terraform, free tier up to 500 managed resources</td>
</tr>
<tr>
<td>Current version (30 Nov 2026)</td>
<td>ansible-core 2.22.0; Ansible 14.6.0</td>
<td>Terraform 1.17.2</td>
</tr>
<tr>
<td>Certification</td>
<td>Red Hat Certified Engineer in Ansible</td>
<td>HashiCorp Certified: Terraform Associate (004)</td>
</tr>
<tr>
<td>Best for</td>
<td>Configuring servers, network devices, ad-hoc orchestration</td>
<td>Provisioning cloud resources with reviewable plans</td>
</tr>
</tbody></table>
<p>Licensing deserves a paragraph, because it is a legal question, not a technical one. Ansible-core is GPLv3 open source, and Red Hat's commercial product is the Automation Platform, which adds a web UI, role-based access control, execution environments and support, priced per managed node through sales quotes. Terraform has been under the Business Source License 1.1 since version 1.6.0: it is free to use, but the licence restricts competing commercial offerings built on it. OpenTofu is the MPL-2.0 fork under the Linux Foundation, for organisations whose open-source policy rules out BUSL-licensed software — our <a href="https://devopsjobupdates.com/terraform-vs-pulumi-vs-opentofu/">Terraform vs Pulumi vs OpenTofu</a> covers that fork in detail. If your organisation has a licensing policy, involve your legal or procurement team before committing, because this is a decision that is expensive to revisit.</p>
<p>Cost is simpler than it looks. Both tools are free in their open-source forms — <code>ansible-core</code> and the Terraform CLI cost nothing — and both vendors earn from a managed service. HCP Terraform's free tier covers up to 500 managed resources; beyond that it bills per resource. Ansible Automation Platform is quoted per managed node, with no public list price. For a team starting out, the cost that matters is the team's time, which is why the hiring and familiarity rows matter more than the price rows.</p>
<h2>When to Use Each — and When to Use Neither Alone</h2>
<p>The choice is a team decision, and it follows from the workload. Work through the questions below in order, and the answer usually emerges on its own.</p>
<p>Are you creating cloud resources — VPCs, subnets, databases, load balancers, Kubernetes clusters? Use Terraform. It is the tool for provisioning, it has the provider ecosystem for every cloud platform, it shows you a plan before it changes anything, and it remembers what it created so it can delete it. Ansible can create a cloud resource, but it cannot manage its lifecycle, and a cloud estate managed by playbooks is an estate nobody can delete cleanly.</p>
<p>Are you configuring machines that already exist — installing packages, writing configuration files, managing users and services? Use Ansible. It is the tool for configuration, it needs no agent, it runs over SSH, and its playbooks express a sequence of steps naturally. Terraform's provisioners can run a command on a machine, but they are a last resort, and a configuration managed by provisioners is a configuration nobody can review or rerun safely.</p>
<p>Are you managing network devices — switches, routers, firewalls? Use Ansible. Its network collections speak the devices' own interfaces — CLI over SSH, or NETCONF — and its resource modules describe the desired state of a VLAN or an interface and work out the commands themselves. Terraform has providers for network devices too, but the Ansible ecosystem for network automation is deeper, and the operational pattern — change a device, verify it, move to the next — is Ansible's natural shape.</p>
<p>Are you orchestrating a multi-step process across many machines — a rolling deploy, a failover, a patching window? Use Ansible. Playbooks are ordered lists of plays, and orchestration is ordering. Terraform's graph model is excellent for dependencies between resources and poor for sequences of human-judged steps, which is why the handoff pattern below puts orchestration on the Ansible side.</p>
<p>Are you doing ad-hoc work — running one command on fifty servers, or restarting a service everywhere? Use Ansible's ad-hoc mode: <code>ansible all -m ping</code>, <code>ansible webservers -a "systemctl restart nginx"</code>. There is no Terraform equivalent, which is reason enough to learn Ansible even if Terraform provisions everything.</p>
<p>The honest answer to "which one should I learn first" depends on the job you want. If you are aiming at cloud and platform roles, learn Terraform first: it owns the provisioning layer most cloud roles hire for, and the HashiCorp Certified: Terraform Associate (004) is the entry credential. If you are aiming at systems and network roles, learn Ansible first: it is the tool those teams use daily, and the Red Hat Certified Engineer path is the credential. If you can learn both — and you should, because the two together are the standard stack — learn Terraform's workflow first and Ansible's playbooks second, because the provisioning decision shapes the architecture and the configuration fills it in.</p>
<h2>How They Work Together — the Handoff Pattern</h2>
<p>In practice, the two tools meet at a handoff: Terraform builds the machines and emits outputs, Ansible reads those outputs and configures them. The pattern is simple, it is the industry standard, and it is worth setting up properly rather than improvising.</p>
<p>Terraform's side of the handoff is its outputs. After the apply, Terraform knows the IP addresses, the hostnames and the IDs of everything it created, and it exposes them as outputs:</p>
<pre><code class="language-hcl">output "web_server_ips" {
  description = "IP addresses of the web servers"
  value       = aws_instance.web[*].public_ip
}
</code></pre>
<p>Ansible's side is its inventory, and the clean way to connect the two is a dynamic inventory that reads Terraform's state. Red Hat publishes a certified collection for exactly this, installed with <code>ansible-galaxy collection install cloud.terraform</code>. It carries the <code>cloud.terraform.terraform_provider</code> inventory plugin, which builds an Ansible inventory straight from a Terraform state file, plus a <code>terraform</code> module for running Terraform from a playbook and a <code>tf_output</code> lookup for reading outputs. With that in place, the pipeline is: Terraform applies and writes state, Ansible reads the state as its inventory, and the playbook configures the machines Terraform just created — no hand-maintained inventory file, no copy-pasting IP addresses, no drift between the two tools' view of the world.</p>
<p>There is a second integration worth knowing: the Terraform Ansible provider (<code>ansible/ansible</code>), which lets Terraform call Ansible playbooks as part of an apply. It closes the gap in the other direction, for teams that want a single entry point. The general advice is to keep the boundary clean — Terraform provisions, Ansible configures, and the state file is the contract between them — rather than blurring it by embedding one tool inside the other. A blurred boundary is harder to debug: when a deploy fails, you want to know immediately whether the provisioning or the configuration failed, and a clean handoff gives you that answer.</p>
<p>A complete pipeline, then, looks like this. Code is committed to Git. A CI job runs <code>terraform plan</code> and attaches the plan to the pull request; on merge, it runs <code>terraform apply</code> against the remote backend. A second job runs the Ansible playbook against the dynamic inventory from Terraform state, with <code>--check</code> and <code>--diff</code> first in staging, then the real run in production. That pipeline is the answer most teams actually live with: not one or the other, but both, each doing the job it is good at, with a defined handoff between them.</p>
<h2>FAQ</h2>
<p><strong>Should I learn Ansible or Terraform first?</strong></p>
<p>Learn Terraform first if you are building cloud infrastructure, because it owns the provisioning layer most cloud roles hire for. Learn Ansible first if you are managing servers or network devices. Learn both if you can — the two together are the standard stack, and the job that asks for one usually expects the other as well.</p>
<p><strong>Can Ansible replace Terraform?</strong></p>
<p>Not for provisioning. Ansible can create a cloud resource through its cloud modules, but it keeps no state, so it cannot show you a plan, detect drift, or delete cleanly what it created. Use Ansible for configuration and Terraform for provisioning, and hand off between them.</p>
<p><strong>Can Terraform replace Ansible?</strong></p>
<p>Not for configuration. Terraform's provisioners can run commands on a machine, but they are a last resort, not a configuration management system, and HashiCorp's own guidance is to use a dedicated tool for configuration. Terraform is for things with a lifecycle; Ansible is for things with a desired state.</p>
<p><strong>What are the current versions of Ansible and Terraform?</strong></p>
<p>As of 30 November 2026, ansible-core 2.22.0 was released on 2 November 2026, with the Ansible 14.6.0 community package on ansible-core 2.21 and Ansible 15 in pre-release; Terraform 1.17.2 was released on 11 November 2026. Both projects ship frequently, so re-check the version before citing one.</p>
<p><strong>How do Ansible and Terraform work together?</strong></p>
<p>Terraform builds the infrastructure and emits outputs; Ansible reads those outputs and configures the machines. Red Hat's certified <code>cloud.terraform</code> collection provides an inventory plugin that builds an Ansible inventory from Terraform state, so the handoff needs no hand-maintained inventory file.</p>
<h2>Conclusion</h2>
<p>Ansible vs Terraform is not a contest, because the two tools answer different questions. Terraform provisions cloud infrastructure declaratively, with a state file, a reviewable plan and a provider ecosystem that covers every cloud platform. Ansible configures machines and network devices procedurally, over SSH, with no agent and no state, and it orchestrates multi-step processes that Terraform's graph model cannot express. The comparison that matters is not which tool is better but which job you are doing: lifecycle means Terraform, desired state means Ansible, and most real systems need both.</p>
<p>Learn Terraform first for cloud roles and Ansible first for systems roles, and learn both as soon as you can. Then set up the handoff properly: Terraform applies, Ansible reads the state as its inventory, and the playbook configures what Terraform built. Start with our <a href="https://devopsjobupdates.com/ansible-tutorial-beginners/">Ansible Tutorial for Beginners</a> and our <a href="https://devopsjobupdates.com/terraform-tutorial-beginners/">Terraform Tutorial for Beginners</a> for the hands-on foundations, and our <a href="https://devopsjobupdates.com/terraform-vs-pulumi-vs-opentofu/">Terraform vs Pulumi vs OpenTofu</a> when you are ready to choose between the infrastructure-as-code tools themselves.</p>
<p>Sources checked 30 Nov 2026: Ansible documentation, Getting Started (inventory, SSH transport, module transfer to targets, ad-hoc ping, first playbook, playbook execution order, <code>ansible-playbook</code> command, PLAY RECAP); Ansible version and comparison guides checked 30 Nov 2026 (ansible-core 2.22.0 released 2 Nov 2026; Ansible 14.6.0 on ansible-core 2.21; Ansible 15 in pre-release; Terraform 1.17.2, 11 Nov 2026, per the Batch 8 GitHub release check); HashiCorp Developer, Terraform language documentation (declarative language, blocks, arguments, expressions, resource declaration as the main purpose); Red Hat <code>cloud.terraform</code> collection documentation via comparison guides (inventory plugin from Terraform state, terraform module, <code>tf_output</code> lookup, requires ansible-core 2.15 or later); Terraform Ansible provider (<code>ansible/ansible</code>) version 1.5.0 via comparison guide. NOT VERIFIED on an official page and therefore not stated as fact above: HCP Terraform per-resource pricing beyond the free tier (guides cite $0.10 per managed resource per month on Essentials, but the pricing page was not checked directly — re-check on HashiCorp's pricing page); Ansible Automation Platform pricing (Red Hat quotes per managed node, no public list price — no figure stated); the Terraform 1.17.2 release date beyond the Batch 8 check (re-check on GitHub at publication). External references: <a href="https://docs.ansible.com/projects/ansible/7/getting_started/get_started_playbook.html">Ansible documentation — Getting Started</a> · <a href="https://developer.hashicorp.com/terraform/language">HashiCorp Developer — Terraform language documentation</a>.</p>
]]></content:encoded></item><item><title><![CDATA[SRE Interview Questions and Answers: 50 Questions for Site Reliability Engineers]]></title><description><![CDATA[Site reliability engineering interviews test two things at once: whether you can keep a production system running, and whether you can think about…]]></description><link>https://devopsjobupdates.hashnode.dev/sre-interview-questions-and-answers-50-questions-for-site-reliability-engineers</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/sre-interview-questions-and-answers-50-questions-for-site-reliability-engineers</guid><category><![CDATA[SRE]]></category><category><![CDATA[interview]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Career]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:54:34 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>Site reliability engineering interviews test two things at once: whether you can keep a production system running, and whether you can think about reliability as an engineering problem rather than a firefighting one. The fifty questions below cover both halves — the hands-on skills of Linux, Kubernetes, monitoring and incident response, and the judgement calls of SLIs, error budgets, toil and blameless postmortems.</p>
<p>The questions are grouped into seven sections by topic, so you can study one area at a time or run the whole set as a mock interview. If you are still deciding whether SRE is for you, our <a href="https://devopsjobupdates.com/site-reliability-engineer-career-guide/">Site Reliability Engineer Career Guide</a> covers the career path; for the broader DevOps set, see our <a href="https://devopsjobupdates.com/devops-interview-questions-answers/">DevOps Interview Questions and Answers</a>. If monitoring is your weakest area, our <a href="https://devopsjobupdates.com/prometheus-grafana-monitoring-tutorial/">Prometheus and Grafana Monitoring Tutorial</a> is the hands-on companion.</p>
<h2>Linux and Networking Fundamentals (Questions 1–8)</h2>
<p><strong>Q1. How do you check what is using CPU and memory on a Linux server?</strong></p>
<p>Use <code>top</code> or <code>htop</code> for a live view by process, and <code>free -h</code> for overall memory. <code>ps aux --sort=-%mem</code> ranks processes by memory use; in a container, <code>kubectl top pod</code> shows use against limits.</p>
<p><strong>Q2. A server is slow but CPU looks idle. What do you check next?</strong></p>
<p>Check I/O wait and disk: <code>iostat -x</code> shows disk saturation, and high <code>%iowait</code> means processes are waiting on disk. Then check memory pressure with <code>vmstat</code> — swapping makes everything slow — and the network, since a service waiting on a slow dependency looks like a slow server.</p>
<p><strong>Q3. What is the difference between a process and a thread, and why does it matter for reliability?</strong></p>
<p>A process has its own memory space; threads in a process share memory. A crashed process takes down only itself, but a crashed thread can corrupt the whole process's shared state.</p>
<p><strong>Q4. Explain what happens when you type a URL into a browser and press Enter.</strong></p>
<p>DNS resolves the hostname, the browser opens a TCP connection on port 443, and a TLS handshake encrypts the session before the HTTP request. The failure points matter most: DNS failure gives a name error, a failed TCP connection gives a timeout, a TLS failure gives a certificate error.</p>
<p><strong>Q5. What is the difference between TCP and UDP, and when would you use each?</strong></p>
<p>TCP is connection-oriented, reliable and ordered: it retransmits lost packets and delivers them in order. UDP is connectionless and unreliable: it sends packets without confirmation, ordering or retransmission. Use TCP where correctness matters — HTTP, databases, file transfers. Use UDP where speed and tolerance for loss matter more — DNS, video streaming, metrics.</p>
<p><strong>Q6. How do you find which process is listening on a port?</strong></p>
<p>Run <code>ss -tlnp</code> for TCP or <code>ss -ulnp</code> for UDP, which shows the port, state and process ID. <code>lsof -i :8080</code> shows what is using a specific port.</p>
<p><strong>Q7. What is a file descriptor, and what happens when a process runs out of them?</strong></p>
<p>A file descriptor is a handle for an open file, socket or pipe. Every open connection consumes one, so a busy server can exhaust its limit, often 1024 by default. At the limit, the process cannot open files or accept connections, and fails with "too many open files".</p>
<p><strong>Q8. How does DNS resolution work, and what is a TTL?</strong></p>
<p>A resolver asks a recursive DNS server, which walks the hierarchy — root, top-level domain, authoritative server — and returns the record. The TTL, time to live, is how long the answer may be cached, in seconds. A long TTL means faster lookups and slower propagation when the record changes; a short TTL means the opposite.</p>
<h2>Kubernetes and Containers (Questions 9–16)</h2>
<p><strong>Q9. What is a Pod, and how is it different from a container?</strong></p>
<p>A Pod is the smallest deployable unit in Kubernetes, and it can hold one or more containers that share a network namespace, an IP address and storage volumes. Containers in the same Pod can reach each other on localhost and share files through a volume. Kubernetes schedules, restarts and scales Pods, not containers.</p>
<p><strong>Q10. What is the difference between a Deployment, a StatefulSet and a DaemonSet?</strong></p>
<p>A Deployment manages stateless, interchangeable replicas — the normal case for web services — with rolling updates and rollbacks. A StatefulSet manages stateful replicas that need stable identities, stable storage and ordered startup, such as databases. A DaemonSet runs one Pod on every node for node-level work such as log collection.</p>
<p><strong>Q11. Your Pod is in CrashLoopBackOff. How do you diagnose it?</strong></p>
<p>Run <code>kubectl get pods</code> for the restart count, <code>kubectl describe pod</code> for the exit code in the Last State block, and <code>kubectl logs &lt;pod&gt; --previous</code> for the crashed run's output. The exit code is the map: 0 means the process finished (use a Job), 1 means an application error, 126 or 127 mean a command problem, and 137 means OOMKilled.</p>
<p><strong>Q12. What is the difference between a liveness probe and a readiness probe?</strong></p>
<p>A liveness probe asks whether the container is still alive: if it fails, the kubelet kills the container and restarts it. A readiness probe asks whether the container is ready to receive traffic: if it fails, the Pod is removed from the Service's endpoints but is not restarted. A startup probe disables the other two while it runs, protecting slow starters.</p>
<p><strong>Q13. How do resource requests and limits work, and what happens if you set them wrong?</strong></p>
<p>Requests are what the scheduler uses to place the Pod — a node must have at least the requested CPU and memory free. Limits are the ceiling the container may use. A container that exceeds its memory limit is killed with OOMKilled; one that exceeds its CPU limit is throttled, not killed.</p>
<p><strong>Q14. What is a ConfigMap and how is it different from a Secret?</strong></p>
<p>A ConfigMap holds non-sensitive configuration — environment variables, configuration files, flags — as key-value pairs. A Secret holds sensitive data such as passwords, tokens and keys. Secrets are base64-encoded, not encrypted, by default, and should come from an external secrets manager rather than etcd in plain text.</p>
<p><strong>Q15. How does a rolling update work, and how do you roll back?</strong></p>
<p>A Deployment's rolling update replaces Pods gradually, respecting <code>maxSurge</code> (how many extra Pods may exist) and <code>maxUnavailable</code> (how many may be down at once). With <code>maxUnavailable: 0</code> and <code>maxSurge: 1</code>, the update never reduces capacity. To roll back, <code>kubectl rollout undo deployment/&lt;name&gt;</code> returns to the previous revision.</p>
<p><strong>Q16. What is the difference between a Service and an Ingress?</strong></p>
<p>A Service gives a stable network endpoint for a set of Pods — ClusterIP for internal access, NodePort for a port on each node, LoadBalancer for a cloud load balancer. An Ingress sits above Services and routes external HTTP traffic by host and path, with TLS termination, to the right Service.</p>
<h2>Monitoring and Observability (Questions 17–24)</h2>
<p><strong>Q17. What is the difference between monitoring and observability?</strong></p>
<p>Monitoring asks known questions — is it up, is it fast, are errors rising — using metrics, dashboards and alerts defined in advance. Observability is asking new questions you did not anticipate, using telemetry — metrics, logs, traces — to understand why the system behaves as it does. Monitoring tells you something is wrong; observability tells you what is wrong.</p>
<p><strong>Q18. What are the four golden signals, and why are they golden?</strong></p>
<p>The four golden signals, from Google's SRE book, are latency, traffic, errors and saturation. Latency is how long requests take, traffic is how much demand the system faces, errors are the rate of failed requests, and saturation is how full the system's resources are. They are golden because they describe a service from the user's point of view.</p>
<p><strong>Q19. Explain SLI, SLO and SLA, and how they relate.</strong></p>
<p>An SLI, service level indicator, measures some aspect of service — for example, the fraction of requests served successfully. An SLO, service level objective, is a target for an SLI over a window, such as 99.9% of requests succeeding over 30 days. An SLA, service level agreement, is a contract with users that attaches consequences to missing the SLO.</p>
<p><strong>Q20. What is an error budget, and what do you do when it is exhausted?</strong></p>
<p>The error budget is 100% minus the SLO: at a 99.9% SLO over 30 days, the budget is 0.1% of the time, or about 43 minutes of downtime. While budget remains, the team ships features; when it is spent, releases stop and the team works on reliability until the budget recovers.</p>
<p><strong>Q21. How do you write a good alert?</strong></p>
<p>A good alert is actionable, specific and tied to a symptom users feel. It names the service, the symptom and the impact — "checkout error rate above 5% for 5 minutes" — not the cause, which is what you investigate after the page. It has a runbook link, a severity matching the impact, and a threshold that fires before users notice but not on noise.</p>
<p><strong>Q22. What is alert fatigue, and how do you fix it?</strong></p>
<p>Alert fatigue is when a team is paged so often — usually by noisy, non-actionable alerts — that they start ignoring pages, including the real ones. The fix is to reduce the noise: delete alerts that never require action, convert pages to tickets where the response can wait, and tune thresholds to the symptom.</p>
<p><strong>Q23. What is the difference between metrics, logs and traces?</strong></p>
<p>Metrics are numbers over time — request counts, latencies, error rates — cheap to store and good for alerting. Logs are discrete events with context — a single request, a single error — good for investigating one failure. Traces follow one request across services, showing where time went and where it failed. Metrics tell you something is wrong, traces tell you where, and logs tell you why.</p>
<p><strong>Q24. What is Prometheus, and how does it collect metrics?</strong></p>
<p>Prometheus is an open-source monitoring system that collects metrics by scraping HTTP endpoints on a schedule — the pull model — rather than receiving pushed data. Services expose metrics in Prometheus format, usually through a client library or an exporter, and Prometheus stores them as time series you query with PromQL.</p>
<h2>Incident Response and On-Call (Questions 25–31)</h2>
<p><strong>Q25. Walk me through how you handle a production incident.</strong></p>
<p>Declare the incident and its severity, gather the right people, and assign roles: incident commander, communications lead, responders. Mitigate first — roll back, fail over or shed load — and diagnose second, because users care about restoration, not root cause.</p>
<p><strong>Q26. What is a blameless postmortem, and why does it matter?</strong></p>
<p>A blameless postmortem asks what went wrong with the system, not who went wrong. It assumes people acted reasonably, and looks for systemic causes — the missing alert, the confusing runbook, the unsafe default. It matters because blame stops people reporting problems, and a team that hides mistakes cannot learn from them.</p>
<p><strong>Q27. How do you decide the severity of an incident?</strong></p>
<p>Severity follows user impact, not technical drama. A total outage of a user-facing service is the highest severity; a partial degradation is lower; an internal tool failure with a workaround is lower still. The scale should be defined in advance — most teams use four or five levels — with each level naming the response it triggers.</p>
<p><strong>Q28. What do you do when you are paged at 3 a.m. and you do not know what is wrong?</strong></p>
<p>Start with the symptom, not the cause: confirm the user impact, check the dashboard for the golden signals, and look at what changed recently — deploys, configuration changes, traffic spikes — because most incidents follow a change. Follow the runbook if one exists, and if it does not, narrow the scope: one service or many, one region or all.</p>
<p><strong>Q29. What is the difference between mitigation and resolution?</strong></p>
<p>Mitigation restores service; resolution fixes the underlying cause. Rolling back a bad deploy is mitigation — users are unblocked, but the bug still exists in the code. Fixing the bug and redeploying is resolution. In an incident, mitigation comes first and resolution comes after, because the order that serves users is the one that restores service fastest.</p>
<p><strong>Q30. How do you prevent the same incident from happening twice?</strong></p>
<p>Write the postmortem, extract the systemic causes, and turn each one into an action item with an owner and a date — a missing alert becomes an alert, a confusing runbook becomes a rewritten runbook, a manual step becomes automation. Then verify the fix: run the scenario again, or run a game day that reproduces it.</p>
<p><strong>Q31. What is an on-call rotation, and how do you make it sustainable?</strong></p>
<p>An on-call rotation shares page response across a team, usually in weekly shifts with a primary and a secondary responder. It is sustainable when the page rate is low — a few pages a week at most — when on-call work counts as real work, not extra load, and when shifts hand over properly.</p>
<h2>CI/CD and Automation (Questions 32–38)</h2>
<p><strong>Q32. What is the difference between continuous integration, continuous delivery and continuous deployment?</strong></p>
<p>Continuous integration means merging code to the main branch frequently and running automated tests on every merge. Continuous delivery means the code is always in a deployable state, with the release itself a manual decision. Continuous deployment releases every passing change to production automatically.</p>
<p><strong>Q33. How do you roll out a change safely to production?</strong></p>
<p>Roll out gradually and watch the signals at each step. Use a canary — a small share of traffic on the new version — or a blue-green deployment, where traffic switches over once the new version is healthy. Watch the golden signals and the error budget, and have the rollback ready before you start.</p>
<p><strong>Q34. What is infrastructure as code, and why does it matter for reliability?</strong></p>
<p>Infrastructure as code means defining infrastructure — servers, networks, databases — in version-controlled files, not by hand in a console. It makes infrastructure reviewable, repeatable and recoverable: changes are reviewed like code, the same configuration produces the same environment, and a broken environment can be rebuilt from the files.</p>
<p><strong>Q35. What is the difference between declarative and imperative configuration?</strong></p>
<p>Declarative configuration describes the desired end state — "three replicas" — and the tool works out how to get there. Imperative configuration describes the steps — "create one, create another, create a third" — and the tool executes them in order. Declarative is the Terraform and Kubernetes model, and it is better for reliability because it is idempotent and the tool can detect drift.</p>
<p><strong>Q36. How do you test infrastructure code?</strong></p>
<p>At three levels. Static checks catch syntax and style — <code>terraform validate</code> and <code>terraform fmt</code> for Terraform, a linter for YAML. Unit tests check the logic — <code>terraform test</code> with assertions on the plan, or policy checks that a configuration meets the rules. Integration tests check the real thing — apply in a test environment, verify the resources, then destroy it.</p>
<p><strong>Q37. What is toil, and how do you reduce it?</strong></p>
<p>Toil is manual, repetitive, automatable operational work with no enduring value — the same ticket handled by hand for the tenth time, the same manual deploy. It is manual, repetitive, automatable, and it does not improve the system. Reduce it by automating the task, or by eliminating the need for it — fixing the bug that generates the tickets.</p>
<p><strong>Q38. What is a runbook, and what makes a good one?</strong></p>
<p>A runbook is a written procedure for a specific alert or incident — the steps to take, in order, with the commands and expected results. A good one is written for a tired person at 3 a.m.: how to confirm the problem, the exact commands to run, what the output should look like, and when to escalate.</p>
<h2>System Design and Reliability (Questions 39–45)</h2>
<p><strong>Q39. How would you design a service to survive the failure of one availability zone?</strong></p>
<p>Run it in at least two availability zones, with the load balancer spreading traffic across both, the database replicated, and no single-zone dependency in the path. The application must be stateless or store state in the replicated database, so any instance can serve any request.</p>
<p><strong>Q40. What is a circuit breaker, and when would you use one?</strong></p>
<p>A circuit breaker stops calling a failing dependency. After a threshold of failures, the breaker opens and requests fail fast; after a cooling-off period it half-opens, lets one request through, and closes again if it succeeds. Use it when a slow downstream service would otherwise consume all your threads waiting for timeouts.</p>
<p><strong>Q41. What is the difference between horizontal and vertical scaling, and which is better?</strong></p>
<p>Horizontal scaling adds more instances; vertical scaling makes the existing instance bigger. Horizontal is better for most services, because it removes the single point of failure, scales beyond the largest available machine, and lets you roll out changes gradually. Vertical is simpler and sometimes necessary — a database that cannot shard — but it has a hard ceiling.</p>
<p><strong>Q42. What is a single point of failure, and how do you find one?</strong></p>
<p>A single point of failure is a component whose failure takes down the whole system — one database, one load balancer, one region, one DNS provider. You find them by drawing the request path and asking, for each component, what happens if it disappears.</p>
<p><strong>Q43. How do you choose an SLO for a service?</strong></p>
<p>Ask what users actually need, not what sounds impressive. A 99.99% target the service cannot meet is worse than a 99.9% target it can, because an SLO that is always breached is ignored. Look at current performance as a floor, not a target, and agree the target with the product team — the SLO is a contract between engineering and the business.</p>
<p><strong>Q44. What is graceful degradation, and why does it matter?</strong></p>
<p>Graceful degradation is a service continuing to work, with reduced functionality, when a dependency fails — cached results instead of fresh ones, or a simplified page instead of the full one. It matters because users prefer a slower service to no service, and because it contains the blast radius: one dependency's outage degrades one feature, not the whole product.</p>
<p><strong>Q45. How do you handle a database that is running out of disk?</strong></p>
<p>First, mitigate: find what is using the space and free what is safe — old logs, expired backups, unneeded indexes. Then stop the growth: find the process writing the most and slow it or move it. Then fix the cause: add storage, archive old data, or partition the table that is growing.</p>
<h2>SRE Concepts and Culture (Questions 46–50)</h2>
<p><strong>Q46. What is SRE, and how is it different from DevOps?</strong></p>
<p>SRE is what happens when you ask a software engineer to design an operations team: software engineering applied to operations, with measurable reliability targets, automation, and a cap on manual work. DevOps is a broader philosophy about breaking down the wall between development and operations, with shared ownership and continuous delivery. SRE is a specific role with specific practices; DevOps is a way of working.</p>
<p><strong>Q47. Why is 100% reliability the wrong target?</strong></p>
<p>Because users cannot tell 100% from 99.999%, and each additional nine costs steeply more — in effort, redundancy and slower releases. The SRE book's point: reliability is a continuum, and the right target is the one users need, not the highest number imaginable. The gap between the target and 100% is the error budget, and it is what lets the team ship features.</p>
<p><strong>Q48. How do you balance feature work against reliability work?</strong></p>
<p>With the error budget. While budget remains, the team ships features; when it is spent, releases stop and the team works on reliability until the budget recovers. It replaces an argument — product wants features, engineering wants reliability — with a shared number both sides agreed in advance.</p>
<p><strong>Q49. What makes a good SRE?</strong></p>
<p>Curiosity about failure, comfort with ambiguity, and a habit of automating the boring parts. A good SRE reads the postmortem before the dashboard, asks what the system should have done, and writes the runbook they wish they had during the last incident.</p>
<p><strong>Q50. Tell me about a time you handled a production incident.</strong></p>
<p>Use the structure: what broke, what the impact was, what you did first, and what changed afterwards. A strong answer names the symptom and impact first, describes the mitigation before the diagnosis, names the tool that found the cause, and ends with the systemic fix that prevents a repeat.</p>
<h2>FAQ</h2>
<p><strong>How many questions are in this SRE interview guide?</strong></p>
<p>Fifty, grouped into seven sections: Linux and networking, Kubernetes and containers, monitoring, incident response, CI/CD and automation, system design, and SRE concepts and culture.</p>
<p><strong>Should I memorise these answers?</strong></p>
<p>No. Read each answer until you understand the reasoning, then practise saying it in your own words, with an example from your own experience. Interviewers notice memorised answers.</p>
<p><strong>What is the most important SRE concept to understand before an interview?</strong></p>
<p>The error budget: SLIs and SLOs define it, monitoring measures it, incident response spends it, and the balance between feature work and reliability work is decided by it. If you can explain it clearly — 99.9% over 30 days leaves about 43 minutes — you can anchor most other answers to it.</p>
<p><strong>How do I prepare for the hands-on part of an SRE interview?</strong></p>
<p>Practise the commands, not just the concepts. Run <code>kubectl describe pod</code> and <code>kubectl logs --previous</code> on a broken pod, write a Prometheus query, and debug a slow Linux server with <code>top</code>, <code>iostat</code> and <code>ss</code>. Interviewers trust candidates who have done the thing.</p>
<p><strong>What if I have no production experience yet?</strong></p>
<p>Use a lab or a personal project, and say so plainly. Break a Kubernetes pod on purpose and diagnose it, or set up Prometheus and Grafana for a home service. Honesty about the scale is better than exaggeration.</p>
<h2>Conclusion</h2>
<p>Fifty questions, seven topics, one pattern: SRE interviews test whether you can keep a system running and whether you can think about reliability as an engineering problem. The technical half — Linux, Kubernetes, monitoring, CI/CD — is the price of entry. The judgement half — SLIs and error budgets, blameless postmortems, toil and the balance between shipping and reliability — is what separates a good SRE from a good operator. Study both halves, and bring an example from your own experience to every question you can.</p>
<p>Then go deeper with our <a href="https://devopsjobupdates.com/site-reliability-engineer-career-guide/">Site Reliability Engineer Career Guide</a> for the career path behind these questions, our <a href="https://devopsjobupdates.com/devops-interview-questions-answers/">DevOps Interview Questions and Answers</a> for the broader interview set, and our <a href="https://devopsjobupdates.com/prometheus-grafana-monitoring-tutorial/">Prometheus and Grafana Monitoring Tutorial</a> for the hands-on monitoring work that underpins the whole discipline.</p>
<p>Sources checked 30 Nov 2026: Google SRE book (sre.google), chapters 1, 3–6, 10, 11, 14, 15 (SRE definition, risk, SLIs/SLOs/SLAs, toil, monitoring and the four golden signals, alerting, on-call, incidents, blameless postmortems); Google SRE Workbook (sre.google) (SLI as good events divided by total events, error budget as 100% minus the SLO, SLO document and error budget policy examples); ClickHouse engineering guide on SLOs, SLIs and SLAs checked 30 Nov 2026 (99.9% over 30 days leaves 43.2 minutes of downtime). NOT VERIFIED and therefore not stated as fact above: any claim about how frequently a specific company asks any particular question. External references: <a href="https://sre.google/sre-book/table-of-contents/?hl=ja">Google SRE — Site Reliability Engineering book</a> · <a href="https://sre.google/workbook/index/">Google SRE — Site Reliability Workbook</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Kubernetes CrashLoopBackOff: Find the Cause and Fix It]]></title><description><![CDATA[CrashLoopBackOff is the Kubernetes status every engineer meets sooner or later, and the name explains almost nothing. It is not an error. It is not a…]]></description><link>https://devopsjobupdates.hashnode.dev/kubernetes-crashloopbackoff-find-the-cause-and-fix-it</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/kubernetes-crashloopbackoff-find-the-cause-and-fix-it</guid><category><![CDATA[Kubernetes]]></category><category><![CDATA[troubleshooting]]></category><category><![CDATA[Devops]]></category><category><![CDATA[SRE]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:52:09 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p><code>CrashLoopBackOff</code> is the Kubernetes status every engineer meets sooner or later, and the name explains almost nothing. It is not an error. It is not a cause. It is Kubernetes telling you that a container keeps starting and exiting, and that the kubelet is now waiting before it tries again. The actual error is somewhere else — in the application, in the configuration, in the image, in a probe or in a resource limit — and the status column gives you three words for it, one of which is sometimes Running.</p>
<p>This guide shows you how to find the real cause and fix it, using the method that works in every case: read the pod's last state, read the previous container's logs, and read the events, in that order. It covers what the back-off actually does, the six common causes with their fixes, and how to stop the loop happening again. Every command below is a standard kubectl command, and every output pattern shown is the shape that output takes in real clusters — the describe blocks, the event messages and the exit codes are the ones the official docs record, not invented examples. If you are new to Kubernetes itself, start with our <a href="https://devopsjobupdates.com/kubernetes-tutorial-beginners/">Kubernetes Tutorial for Beginners</a>; if you write the manifests, our <a href="https://devopsjobupdates.com/kubernetes-deployment-yaml-tutorial/">Kubernetes Deployment YAML Tutorial</a> is the companion for this one.</p>
<p>The short version: run <code>kubectl describe pod</code> and read the Last State block for the exit code, run <code>kubectl logs --previous</code> for what the crashed run printed, and check the Events section for what the kubelet did. The exit code tells you which of the six causes to look at.</p>
<h2>What CrashLoopBackOff Actually Means</h2>
<p>A pod's containers run under a <code>restartPolicy</code>, and the default for a Deployment is <code>Always</code>. When a container exits — for any reason and with any exit code — the kubelet starts it again. If it keeps exiting, the kubelet waits longer each time before the next attempt: 10 seconds, then 20, then 40, doubling up to a cap of five minutes. If a container then runs for ten minutes without problems, the delay resets. <code>CrashLoopBackOff</code> is the name of that waiting period, and the pod's status flips between Error, Running and <code>CrashLoopBackOff</code> while the RESTARTS counter grows.</p>
<p>Two consequences catch people out. First, the status column is not reliable on its own: a crash-looping pod can show Running and 1/1 between restarts, because the container is briefly up when you look. Trust RESTARTS instead — a count climbing over minutes means a crash loop, whatever the status word says. Second, the back-off is protective: it stops a broken container consuming the node's CPU in a tight restart loop, and gives you time to read the logs before the next attempt overwrites them.</p>
<p>The cause is always inside the container or in what it needs: the application crashes, is killed, or is told to exit. Kubernetes only reports it. That distinction is the whole method: do not debug Kubernetes, debug the container. The evidence is in the three places this guide covers next.</p>
<p>One timing detail changed in recent versions. Two feature gates touch the back-off: <code>KubeletCrashLoopBackOffMax</code> arrived as alpha in 1.32 and has been beta, on by default, since 1.35; <code>ReduceDefaultCrashLoopBackOffDecay</code> is still alpha in 1.37 and off by default, and with it on, delays start at 1 second and stop growing at 60. You do not need to change either gate to fix a crash loop — the 10-seconds-doubling-to-five-minutes behaviour above is the default on a current cluster.</p>
<h2>The Three Commands That Find the Cause</h2>
<p>Every <code>CrashLoopBackOff</code> diagnosis starts the same way, and the order matters. Work from the least invasive tool to the most invasive, and stop as soon as you have the cause — most cases are solved by the first two commands.</p>
<p>Command 1: spot the pod. <code>kubectl get pods</code> shows the status and the restart count. Narrow it to a namespace when you know it, and add <code>-o wide</code> when you need the node:</p>
<pre><code class="language-bash">kubectl get pods -n shop
kubectl get pods -n shop -o wide
</code></pre>
<p>The output has the shape every Kubernetes engineer recognises:</p>
<pre><code>NAME                      READY   STATUS             RESTARTS   AGE
my-app-6f4d5c7b8-x9kmn    0/1     CrashLoopBackOff   5          10m
</code></pre>
<p>READY of 0/1 means the container is not ready, RESTARTS of 5 means it has been restarted five times, and AGE of 10m tells you how long this has been going on. A restart count that grows between two runs of this command, a minute apart, confirms the loop is live rather than historical.</p>
<p>Command 2: read the pod's last state. <code>kubectl describe pod</code> is the single most useful thing to read, and the part that matters sits under <code>Containers:</code>. Skip the top of the output and find the state block:</p>
<pre><code class="language-bash">kubectl describe pod my-app-6f4d5c7b8-x9kmn -n shop
</code></pre>
<p>The block looks like this:</p>
<pre><code>    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Wed, 07 Oct 2026 10:12:01 +0200
      Finished:     Wed, 07 Oct 2026 10:12:02 +0200
    Ready:          False
    Restart Count:  6
</code></pre>
<p>State tells you only what is happening now — usually Waiting with reason <code>CrashLoopBackOff</code>, which tells you nothing new. Last State is the run that died, and it carries the two facts you came for: a Reason and an Exit Code, plus the start and finish times. How long the container lived is itself a diagnosis: one that died within a second of starting has a startup problem — a bad command, a bad configuration, a missing file. One that ran for several minutes and only then died points somewhere else — memory, a probe, or a dependency that went away while it was running. The Events section at the bottom of the same output is the third place to look: it is where the kubelet writes down what it did to your container and why, and a line like <code>Back-off restarting failed container</code> with a count confirms the loop, while a <code>Liveness probe failed</code> or <code>Failed to pull image</code> line points at the cause directly.</p>
<p>Command 3: read the previous container's logs. Plain <code>kubectl logs</code> shows the current container, which in a crash loop is often brand new or not started yet. Add <code>--previous</code> — short form <code>-p</code> — to get the instance that exited:</p>
<pre><code class="language-bash">kubectl logs my-app-6f4d5c7b8-x9kmn -n shop --previous
</code></pre>
<p>For a pod with several containers, add <code>-c &lt;container-name&gt;</code>. The previous logs are the application's own account of what happened: a stack trace, a missing-module error, a connection failure, a panic message. If they are empty, that is a finding in itself — the process exited before it wrote a line, which points at a command problem rather than an application error. Two limits: <code>--previous</code> goes back one container instance only, and if the pod has been deleted, its logs are gone — so read them before you delete anything.</p>
<p>If those three commands have not found the cause, the next steps are <code>kubectl get events -n &lt;namespace&gt; --sort-by='.lastTimestamp'</code> for the cluster-wide picture, and <code>kubectl debug</code> with an ephemeral container where the image has no shell — the technique for distroless images, where <code>kubectl exec</code> has nothing to run.</p>
<h2>Reading the Exit Code — the Map from Code to Cause</h2>
<p>The exit code in the Last State block is the fastest route from symptom to cause, because each code narrows the search to one family of problems. The table below is the map to use, and the sections after it work through each family in turn.</p>
<table>
<thead>
<tr>
<th>Exit code / reason</th>
<th>What it means</th>
<th>Look at</th>
</tr>
</thead>
<tbody><tr>
<td>0, reason Completed</td>
<td>The process finished successfully</td>
<td>The workload type — a one-shot task in a Deployment</td>
</tr>
<tr>
<td>1</td>
<td>Generic application error</td>
<td>The previous logs: exception, bad config, missing dependency</td>
</tr>
<tr>
<td>2</td>
<td>Shell or CLI argument error</td>
<td>The command and args in the manifest</td>
</tr>
<tr>
<td>126</td>
<td>Command cannot execute</td>
<td>Binary not executable, or wrong architecture for the node</td>
</tr>
<tr>
<td>127</td>
<td>Command not found</td>
<td>The command or entrypoint path in the manifest</td>
</tr>
<tr>
<td>137, reason OOMKilled</td>
<td>Container killed for exceeding its memory limit</td>
<td>Resource limits and actual memory use</td>
</tr>
<tr>
<td>143, SIGTERM</td>
<td>Container terminated by a signal</td>
<td>A liveness probe killing a slow starter, or a shutdown problem</td>
</tr>
</tbody></table>
<p>Exit code 0 confuses everyone the first time. A container that exits with code 0 has succeeded — its process finished its job and stopped. But a Deployment expects a long-running process, and its <code>restartPolicy</code> is <code>Always</code>, the only option for Deployments. So Kubernetes restarts the successful container, it succeeds again, and the pod enters <code>CrashLoopBackOff</code>. That is not a bug: it is a workload in the wrong controller. A one-shot task belongs in a Job, a recurring task in a CronJob — change the workload type, do not make the process hang artificially.</p>
<p>Exit code 1 is the most common and the least specific: it means the application failed, and the previous logs will say how — an unhandled exception, a missing environment variable, a bad configuration value, a database that refused the connection. Exit code 2 usually means a shell or CLI argument problem: a flag the binary does not recognise, or an argument in the wrong position. Codes 126 and 127 are command problems: 126 means the binary is present but cannot be executed — a missing executable bit, or an image built for the wrong CPU architecture, such as an arm64 image on an amd64 node; 127 means the command was not found at all, which usually means the command or args in the manifest names a path that does not exist in the image. Exit code 137 is 128 plus 9, the signal number for SIGKILL, and in Kubernetes it almost always means OOMKilled: the container exceeded its memory limit and the kernel killed it. The Last State reason will say OOMKilled outright in that case.</p>
<h2>Causes 1–3 — Application Errors, Bad Configuration and Unreachable Dependencies</h2>
<p>Cause 1: the application throws an error at startup. Most of the time, the application inside the container is simply failing on startup. Read <code>kubectl logs --previous</code> and you will find the reason in the application's own words: a stack trace, a <code>ModuleNotFoundError</code> or <code>Error: Cannot find module</code>, a <code>panic:</code>, an <code>Address already in use</code>. The fix is in the code or the image, not in Kubernetes, and the fastest way to confirm it is to run the same image locally: <code>docker run --rm myapp:1.0</code> and see if it fails there too. If it fails locally, the problem is reproducible without Kubernetes, and you can debug it with your normal tools. If it works locally but fails in the cluster, the difference is the environment — which leads to the next two causes.</p>
<p>Cause 2: missing or wrong configuration. The application expects a value that is not there, or is wrong. Wrong environment variables, a missing file, a bad ConfigMap value, a Secret key misspelled in the deployment YAML — any of these will kill an application on startup, and the error in the logs will usually name the missing thing. Check three things in order: that the ConfigMap or Secret exists in the correct namespace, that it contains the expected keys, and that the pod references it correctly in <code>envFrom</code> or <code>valueFrom</code>. A missing ConfigMap or Secret does not always produce <code>CrashLoopBackOff</code> — if the resource does not exist at all, the pod may show <code>CreateContainerConfigError</code> instead, a different status with the same cause and fix. If the container is briefly up between crashes, <code>kubectl exec &lt;pod&gt; -- env</code> shows the environment as the application sees it; if not, <code>kubectl debug</code> with a copied pod inspects it without disturbing the original.</p>
<p>Cause 3: a dependency is not reachable. The application exits because the database, the cache or an upstream API is not ready, or its address is wrong. The log lines to recognise are <code>connection refused</code>, <code>could not translate host name</code> and <code>dial tcp: lookup db: no such host</code>. The first means the address resolved but nothing is listening; the second and third mean the name did not resolve at all, which usually means the Service name is misspelled or the Service is in a different namespace. If the address is wrong, correct it. If the dependency is simply not ready yet, make the application retry with back-off instead of exiting on the first failure — an application that gives up after one failed attempt will crash-loop on every deploy where the database starts slower than the application. An init container that waits for the dependency is the Kubernetes-side alternative, for when you cannot change the application's retry behaviour.</p>
<h2>Causes 4–6 — Wrong Command, Resource Limits and Probes</h2>
<p>Cause 4: wrong command, args or entrypoint. In Kubernetes, <code>command</code> replaces the image's ENTRYPOINT and <code>args</code> replaces its CMD, and that replacement causes a whole family of crashes. A common mistake is to set <code>command</code> to a shell script that does not exist in the image, or to pass arguments that belong to a different entrypoint. Another is to override the entrypoint with a command that needs a shell — <code>command: ["myapp --flag"]</code> as a single string does not work, because Kubernetes passes it as one argument; it must be split into <code>command: ["myapp"]</code> and <code>args: ["--flag"]</code>. Check what the manifest sets with <code>kubectl get pod &lt;pod&gt; -o jsonpath='{.spec.containers[*].command}'</code> and the same for <code>.args</code>, and compare it with the image's own entrypoint, which <code>docker inspect</code> shows. Exit codes 126 and 127 are the signature of this cause, and the previous logs are often empty, because the process never started far enough to write anything.</p>
<p>Cause 5: resource limits set too low, and OOMKilled. Memory exhaustion is one of the most frequent causes of <code>CrashLoopBackOff</code> in production. If the container exceeds its memory limit, the kernel kills it with OOMKilled, the Last State reason says so, and the exit code is 137. Raising the memory limit blindly might stop the crash, but it does not address whether the application is behaving as expected under load. Base limits on observed usage — staging load tests or production metrics — so the boundary is informed by real behaviour. Check what the pod used with <code>kubectl top pod</code>: a limit only just above steady-state use will kill the container on the first traffic spike, and a limit with no request set means the scheduler may place the pod on a node that cannot spare the memory. CPU limits behave differently — a container that exceeds its CPU limit is throttled, not killed — so a CPU problem shows up as slowness, not a crash loop.</p>
<p>Cause 6: a misconfigured liveness or startup probe. A liveness probe that fails tells the kubelet to kill the container and restart it, and if the probe keeps failing, the restarts become a crash loop. The classic case is a probe that is too aggressive for the application: the probe starts before the application has finished initialising, or its timeout is shorter than the application's response time under load. The fix is to align the probe with the application's real startup behaviour. Increase <code>initialDelaySeconds</code> and <code>timeoutSeconds</code>, but for slower applications the more reliable approach is a <code>startupProbe</code>: while the startup probe is running, the liveness and readiness probes are disabled, and the container is given up to <code>failureThreshold</code> × <code>periodSeconds</code> to start — with the common values of 30 failures at 10 seconds, that is 300 seconds. A second common mistake is using the liveness probe to check an external dependency, such as a database: when the database is slow, the probe fails, the container is killed, and the restart makes the problem worse. Liveness probes should check only the process's own health — a deadlock, a hung thread — never the health of something else. Readiness probes are different: they control whether the pod receives traffic, not whether it is restarted, so a failing readiness probe removes the pod from the Service but does not crash it.</p>
<h2>A Worked Diagnosis, End to End</h2>
<p>Here is the method applied to a deployment broken on purpose — a busybox image run with the command <code>false</code>, which exits with code 1 the moment it starts. It is the simplest possible crash loop, and it shows the shape of every diagnosis.</p>
<p>Create it and watch:</p>
<pre><code class="language-bash">kubectl create deployment crasher --image=busybox:1.28 -- false
kubectl get pods --watch
</code></pre>
<p>The pod appears, its restart count climbs, and its status cycles between Error, Running and <code>CrashLoopBackOff</code>. Describe it, using the pod name from your own output:</p>
<pre><code class="language-bash">kubectl describe pod crasher-6d8f7b9c4d-x2k9p
</code></pre>
<p>Skip to the container block. State is Waiting with reason <code>CrashLoopBackOff</code>. Last State is Terminated, reason Error, exit code 1, and the start and finish times are one second apart — a startup problem, not a runtime one. Restart Count is 4 and climbing. At the bottom, the Events section shows the kubelet's own record:</p>
<pre><code>Events:
  Type     Reason   Age   From     Message
  ----     ------   ----  ----     -------
  Warning  BackOff  12s   kubelet  Back-off restarting failed container busybox in pod crasher-6d8f7b9c4d-x2k9p_default(...)
</code></pre>
<p>Now the previous logs:</p>
<pre><code class="language-bash">kubectl logs crasher-6d8f7b9c4d-x2k9p --previous
</code></pre>
<p>The result is empty. The process exited before it wrote a single line, which matches the diagnosis: the command <code>false</code> exits immediately with code 1, and there is no application to produce output. The fix is to change the command to something that runs — and in a real case, the fix would be whatever the exit code and the logs point at. The pattern is the same every time: describe, read the Last State, read the previous logs, read the events, and let the exit code choose the cause.</p>
<h2>Stopping the Loop from Coming Back</h2>
<p>Fixing one crash loop is a good day's work; stopping the next one is better. Four practices cover most recurrences. First, test the image before it reaches the cluster. Run it locally with <code>docker run</code>, hit its health endpoint, and run its test suite inside the image. A container that cannot start on a laptop will not start on a node. Add a smoke test to CI that starts the built image and waits for a successful health check before the image is pushed.</p>
<p>Second, set resource requests and limits from observed use, not from guesses. A limit copied from a tutorial is a guess about someone else's application. Measure your own application's memory under load, set the request to its steady-state use and the limit to its peak plus a margin, and revisit both after every release that changes the application's behaviour. Monitor OOMKilled as an alert, not as a status you happen to notice — a container killed once is a warning, and a container killed repeatedly is a crash loop that has already happened.</p>
<p>Third, give slow starters a startup probe. Any application that takes more than a few seconds to initialise — a Java service warming a cache, a Python service loading a model — should have a <code>startupProbe</code> with a generous failure threshold, so the liveness probe never fires during normal startup. The cost is a few lines of YAML; the saving is the crash loop that would otherwise appear on every deploy.</p>
<p>Fourth, make the application resilient to its dependencies. Retry with back-off, wait for readiness, and log clearly when a dependency is missing — including the name of the missing variable or the address that could not be resolved. The application's error message is the first thing you will read in the previous logs, and a message that says which variable is missing saves the ten minutes that a bare stack trace costs. If you are preparing for interviews as well as for production, our <a href="https://devopsjobupdates.com/kubernetes-interview-questions-answers/">Kubernetes Interview Questions and Answers</a> covers <code>CrashLoopBackOff</code> as an interview topic, and the answer interviewers want is this method, not a list of causes.</p>
<h2>FAQ</h2>
<p><strong>What does CrashLoopBackOff mean?</strong></p>
<p>It means a container keeps starting and exiting, and the kubelet is waiting before it tries again. It is a state, not an error and not a cause — the cause is whatever made the process exit, and you find it in the pod's last state and the previous container's logs.</p>
<p><strong>Which kubectl commands diagnose CrashLoopBackOff?</strong></p>
<p>Three, in order: <code>kubectl get pods</code> to spot the pod and its restart count, <code>kubectl describe pod</code> for the exit code and events, and <code>kubectl logs &lt;pod&gt; --previous</code> for what the crashed run printed. <code>kubectl get events --sort-by='.lastTimestamp'</code> gives the cluster-wide picture, and <code>kubectl debug</code> helps when the image has no shell.</p>
<p><strong>What does exit code 137 mean?</strong></p>
<p>Exit code 137 is 128 plus 9, the signal number for SIGKILL, and in Kubernetes it almost always means OOMKilled — the container exceeded its memory limit and the kernel killed it. The Last State reason will say OOMKilled outright. Check the limits and the actual memory use before raising the limit.</p>
<p><strong>Why does my pod show CrashLoopBackOff when the application exits successfully?</strong></p>
<p>Because a Deployment expects a long-running process and its restart policy is <code>Always</code>. A container that exits with code 0 has succeeded, but Kubernetes restarts it anyway, and the restarts become a crash loop. A one-shot task belongs in a Job, and a recurring task belongs in a CronJob.</p>
<p><strong>How long does Kubernetes wait between restarts?</strong></p>
<p>The back-off starts at 10 seconds and doubles — 10, 20, 40 — up to a cap of five minutes. If the container then runs for ten minutes without problems, the delay resets. The timing is a protective mechanism to stop a broken container consuming the node's CPU in a tight restart loop.</p>
<h2>Conclusion</h2>
<p><code>CrashLoopBackOff</code> is Kubernetes doing its job: it is telling you, repeatedly and with a growing restart counter, that a container cannot stay up. The diagnosis is three commands — <code>kubectl get pods</code>, <code>kubectl describe pod</code> and <code>kubectl logs --previous</code> — and the exit code in the Last State block is the map from symptom to cause: 0 means the wrong workload type, 1 means an application error, 126 and 127 mean a command problem, 137 means out of memory, and a failing probe means the probe, not the application, is misconfigured. Fix the cause, not the status, and the status fixes itself.</p>
<p>Build the habit: test the image locally, set limits from observed use, give slow starters a startup probe, and make the application say clearly what is missing when it fails. Then go deeper with our <a href="https://devopsjobupdates.com/kubernetes-tutorial-beginners/">Kubernetes Tutorial for Beginners</a> for the fundamentals, and our <a href="https://devopsjobupdates.com/kubernetes-deployment-yaml-tutorial/">Kubernetes Deployment YAML Tutorial</a> for the manifests the fixes live in.</p>
<p>Sources checked 30 Nov 2026: Kubernetes documentation, Debug Running Pods (back-off behaviour, <code>kubectl describe pod</code>, <code>kubectl logs --previous</code>, ephemeral debug containers); Kubernetes documentation, Liveness, Readiness and Startup Probes (probe types, startup probe disabling liveness and readiness until it succeeds, caution against incorrect liveness probes causing cascading failures); 100daysofkubernetes.io, CrashLoopBackOff chapter, rewritten Oct 2026 for Kubernetes 1.37 (back-off 10s doubling to 5-minute cap, 10-minute reset, <code>KubeletCrashLoopBackOffMax</code> beta since 1.35, <code>ReduceDefaultCrashLoopBackOffDecay</code> alpha in 1.37, busybox <code>false</code> worked example shape); troubleshooting guides checked 30 Nov 2026 (exit-code table including 0 Completed, 1, 2, 126, 127, 137 OOMKilled; event message "Back-off restarting failed container"; log lines "connection refused" and "could not translate host name" as dependency-failure signatures). NOT VERIFIED and therefore not stated as fact above: any specific percentage of <code>CrashLoopBackOff</code> cases attributable to a single cause (no reliable source states one); the exact behaviour of the alpha <code>ReduceDefaultCrashLoopBackOffDecay</code> gate beyond the timings stated in the 100daysofkubernetes chapter. External references: <a href="https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/">Kubernetes documentation — Debug Running Pods</a> · <a href="https://v1-35.docs.kubernetes.io/docs/concepts/configuration/liveness-readiness-startup-probes/">Kubernetes documentation — Liveness, Readiness and Startup Probes</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Terraform Associate (004) Exam Guide 2026: Domains, Study Plan and Tips]]></title><description><![CDATA[The HashiCorp Certified: Terraform Associate is the entry-level credential for infrastructure as code, and in 2026 it changed in a way that matters. The…]]></description><link>https://devopsjobupdates.hashnode.dev/terraform-associate-004-exam-guide-2026-domains-study-plan-and-tips</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/terraform-associate-004-exam-guide-2026-domains-study-plan-and-tips</guid><category><![CDATA[Terraform]]></category><category><![CDATA[Certification]]></category><category><![CDATA[Devops]]></category><category><![CDATA[#IaC]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:49:25 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>The HashiCorp Certified: Terraform Associate is the entry-level credential for infrastructure as code, and in 2026 it changed in a way that matters. The old exam version, 003, retired on 7 January 2026. The current version, 004, was first delivered on 8 January 2026, and it tests Terraform 1.12 with a reorganised set of eight objectives — including a whole domain on HCP Terraform, new objectives on lifecycle rules, custom conditions and ephemeral values, and a heavier emphasis on writing and reading configuration. Anyone studying from a 003 guide is preparing for an exam that no longer exists.</p>
<p>This guide covers the 004 exam as it stands on 30 November 2026: what it costs, how long it lasts, what it tests across its eight objectives, how to study for it in six weeks, and what to do on exam day. Every fact HashiCorp publishes comes from its own certification pages or the official exam content list, checked on 30 November 2026. Two things HashiCorp does not publish — the number of questions and the passing score — are flagged as such wherever they appear. If you have not written Terraform before, start with our <a href="https://devopsjobupdates.com/terraform-tutorial-beginners/">Terraform Tutorial for Beginners</a>; for interview preparation, our <a href="https://devopsjobupdates.com/terraform-interview-questions-answers/">Terraform Interview Questions and Answers</a> covers the same ground in question form.</p>
<p>The short version, for readers in a hurry: the exam costs $70.50, lasts one hour, is multiple choice and online proctored, tests Terraform 1.12 across eight objectives, has no prerequisites, and the credential is valid for two years. Six weeks of hands-on practice — writing real configuration, not just reading about it — is enough for most candidates with basic terminal skills. The rest of this guide is the detail behind those sentences.</p>
<h2>Terraform Associate 004 at a Glance — Exam Facts</h2>
<p>The Terraform Associate is a single exam for a single certification: pass it and you are HashiCorp Certified: Terraform Associate. There are no prerequisites. HashiCorp states that candidates should have basic terminal skills and an understanding of on-premises and cloud architecture, and says you can prepare by practising the exam objectives in a personal demo setup. In practice, candidates who pass comfortably have spent a few weeks actually running <code>terraform plan</code> and <code>terraform apply</code> against real infrastructure, even if that is a free-tier cloud account.</p>
<table>
<thead>
<tr>
<th>Fact</th>
<th>Detail</th>
</tr>
</thead>
<tbody><tr>
<td>Exam code</td>
<td>Terraform Associate 004</td>
</tr>
<tr>
<td>Certification</td>
<td>HashiCorp Certified: Terraform Associate</td>
</tr>
<tr>
<td>Level</td>
<td>Associate (entry-level)</td>
</tr>
<tr>
<td>Terraform version tested</td>
<td>1.12</td>
</tr>
<tr>
<td>Price (US)</td>
<td>$70.50 plus applicable taxes</td>
</tr>
<tr>
<td>Exam time</td>
<td>60 minutes</td>
</tr>
<tr>
<td>Question count</td>
<td>Not published by HashiCorp (commonly estimated at around 57)</td>
</tr>
<tr>
<td>Passing score</td>
<td>Not published by HashiCorp (commonly estimated at around 70%)</td>
</tr>
<tr>
<td>Question types</td>
<td>True/false, single-select multiple choice, multi-select</td>
</tr>
<tr>
<td>Delivery</td>
<td>Online proctored</td>
</tr>
<tr>
<td>Language</td>
<td>English</td>
</tr>
<tr>
<td>Prerequisites</td>
<td>None; basic terminal skills and cloud architecture understanding expected</td>
</tr>
<tr>
<td>Validity</td>
<td>2 years</td>
</tr>
<tr>
<td>Previous version</td>
<td>003 retired 7 January 2026; 004 first delivered 8 January 2026</td>
</tr>
<tr>
<td>Free retake</td>
<td>Not included</td>
</tr>
</tbody></table>
<p>The price is the US list price — taxes may apply on top, so check the price shown at booking for your country. The fee does not include a retake, so a failed attempt costs another $70.50. Results are pass or fail, given immediately, with an objective-level report within 48 hours that shows how you did in each domain — useful if you need to retake.</p>
<p>Two facts are most often misstated online. First, HashiCorp does not publish the number of questions or a numeric passing score: "57 questions" and "70% to pass" repeat an estimate circulating since the 003 exam, and you should plan on the one-hour limit, not a question count. Second, HashiCorp does not publish weights for the eight objectives — percentages in third-party guides are those guides' own estimates, not HashiCorp's.</p>
<h2>The Eight Objectives, in Exam Order</h2>
<p>HashiCorp publishes eight objectives with 37 sub-objectives for the 004 exam, and a content list mapping each one to the documentation that demonstrates it. Study from the official content list rather than a printed book: the exam was refreshed in January 2026, and older material teaches the wrong structure.</p>
<table>
<thead>
<tr>
<th>Objective</th>
<th>What it covers</th>
</tr>
</thead>
<tbody><tr>
<td>1. Infrastructure as Code (IaC) with Terraform</td>
<td>What IaC is, the advantages of IaC patterns, multi-cloud, hybrid cloud and service-agnostic workflows</td>
</tr>
<tr>
<td>2. Terraform fundamentals</td>
<td>Installing and versioning providers, how Terraform uses providers, multi-provider configuration, how state is used and managed</td>
</tr>
<tr>
<td>3. Core Terraform workflow</td>
<td>Write, plan, apply: initialising a working directory, validating configuration, generating and reviewing a plan, applying and destroying, formatting and style</td>
</tr>
<tr>
<td>4. Terraform configuration</td>
<td>Resource and data blocks, cross-resource references, variables and outputs, complex types, expressions and functions, resource dependencies, lifecycle rules, custom conditions, sensitive data</td>
</tr>
<tr>
<td>5. Terraform modules</td>
<td>Sourcing modules, variable scope, using modules in configuration, managing module versions</td>
</tr>
<tr>
<td>6. Terraform state management</td>
<td>The local backend, state locking, configuring remote state with the backend block, managing resource drift</td>
</tr>
<tr>
<td>7. Maintain infrastructure with Terraform</td>
<td>Importing existing infrastructure, inspecting state from the CLI, verbose logging</td>
</tr>
<tr>
<td>8. HCP Terraform</td>
<td>Creating infrastructure through HCP Terraform, collaboration and governance features, organising work with workspaces and projects</td>
</tr>
</tbody></table>
<h2>Objectives 1–3 — IaC Concepts, Fundamentals and the Core Workflow</h2>
<p>Objective 1 is the conceptual foundation: what infrastructure as code is, why it beats manual provisioning, and how Terraform manages multi-cloud and hybrid-cloud workflows. The exam asks you to recognise the advantages — consistency, repeatability, version control, reviewable changes — and to understand that Terraform is cloud-agnostic: the same workflow provisions AWS, Azure, Google Cloud and on-premises resources, because the provider plugins do the cloud-specific work.</p>
<p>Objective 2 covers the fundamentals: providers, and state as a concept. A provider is a plugin that translates Terraform configuration into API calls against a specific platform, and the exam tests installing and versioning them. Know the <code>required_providers</code> block, the version constraint syntax (<code>~&gt; 5.0</code> means any 5.x release), and the dependency lock file (<code>.terraform.lock.hcl</code>), which records the exact provider versions and checksums so a later <code>terraform init</code> reproduces the same set. Know that a configuration can use multiple providers, including multiple instances of the same provider with aliases — the classic case is deploying to two AWS regions. And know what state is conceptually: the JSON record mapping your configuration to real resource IDs, which Terraform consults on every run to decide what has changed. State's mechanics are objective 6; here, the exam wants the concept.</p>
<p>Objective 3 is the core workflow, and the most practical of the eight: write, plan, apply. The cycle is <code>terraform init</code> to initialise a working directory and download providers, <code>terraform validate</code> to check the configuration is valid and internally consistent, <code>terraform plan</code> to preview the changes, <code>terraform apply</code> to make them, and <code>terraform destroy</code> to remove them. Know what each command does and does not do. <code>validate</code> checks syntax and references, not whether the resources will actually create — a configuration can validate cleanly and still fail on apply. <code>plan</code> is the review step: in a team, the plan is the artifact reviewed like a code change, not the apply. <code>fmt</code> is the formatter — run it before every commit, because the exam tests formatting and style conventions. And know the difference between <code>terraform plan</code> and <code>terraform apply -auto-approve</code>: the first previews, the second applies without asking.</p>
<h2>Objective 4 — Terraform Configuration, the Heart of the Exam</h2>
<p>Objective 4 is where the exam spends its time, and where hands-on practice pays off most. It covers the language itself: resource and data blocks, cross-resource references, variables and outputs, complex types, expressions and functions, resource dependencies, lifecycle rules, custom conditions and sensitive data. The official Terraform language documentation is the study source here, and it is worth reading in full rather than through summaries.</p>
<p>Start with the blocks. A resource block declares something Terraform should create and manage; a data block reads something that already exists. The distinction matters: if you need the ID of a VPC another team created, read it with a data source — do not declare it as a resource and try to manage it. Variables are inputs, outputs are results, and locals are named expressions for values used more than once. Know the variable types — string, number, bool, list, set, map, object, tuple — and that complex types let you pass a whole structured value, such as a list of subnet definitions, as a single variable. Know how references work: <code>aws_vpc.main.id</code> is the ID of the VPC resource, and using a reference creates an implicit dependency, so Terraform orders the resources correctly without being told.</p>
<p>Dependencies come in two forms, and the exam tests both. Implicit dependencies come from references, as above. Explicit dependencies come from <code>depends_on</code>, used when the dependency is real but invisible to Terraform — for example, when a resource depends on another resource's side effect rather than its output. The 004 exam added <code>depends_on</code> with <code>create_before_destroy</code> as a new lifecycle topic (4f), so know the lifecycle block as a whole: <code>create_before_destroy</code> creates the replacement before destroying the old one, right for resources that cannot have downtime and wrong where two instances cannot coexist; <code>prevent_destroy</code> blocks accidental deletion; <code>ignore_changes</code> tells Terraform to stop managing an argument.</p>
<p>Custom conditions (4g) are the 004 exam's validation mechanism. A precondition block checks something before Terraform acts, and a postcondition checks something after — for example, that a variable is within an allowed range, or that a created resource has a particular attribute. They test whether you can make a configuration fail loudly with a clear message instead of silently producing something wrong. Ephemeral values and write-only arguments (4h) are the other new 004 topic: ephemeral resources and variables hold values Terraform uses during a run but never writes to state — passwords, tokens and other secrets that should not be persisted. The exam angle is clear: the answer to "how do I pass a secret without storing it in state" is an ephemeral value, not a sensitive variable, because a sensitive variable is still written to state, just hidden from the output.</p>
<h2>Objectives 5–7 — Modules, State and Maintenance</h2>
<p>Modules are Terraform's reuse mechanism, and objective 5 tests how to use them rather than how to write complex ones. A module is a folder of configuration with inputs (variables) and outputs, called from a root module. Know how to source a module — from a local path, from a Git repository, or from the Terraform Registry — and that the source string determines where the code comes from and how it is versioned. Registry modules are versioned with constraints, and the convention is <code>~&gt; 5.0</code>, which accepts patch releases within the 5.x line. Know variable scope: variables declared inside a module are local to it, and the calling configuration passes values in through arguments; a variable set at the root does not leak into a child module unless passed explicitly. That scoping rule is the exam's favourite module question.</p>
<p>State is objective 6, and it separates candidates who have run Terraform from those who have only read about it. State is a JSON file mapping configuration to real resources, and it must be stored remotely, locked during applies, and treated as sensitive — it can contain secrets in plain text. Know the local backend (the default <code>terraform.tfstate</code> file, suitable for learning and unsuitable for teams) and the remote backends, configured with a backend block — most commonly an S3 bucket, an Azure storage account, or HCP Terraform. Know state locking: it prevents two applies running against the same state at once, and native S3 locking is the current mechanism, replacing the older separate DynamoDB table. Know drift: when someone changes a resource outside Terraform, the next plan detects the difference and proposes to put it back.</p>
<p>Objective 7 is maintenance: importing existing infrastructure, inspecting state from the CLI, and verbose logging. Importing brings a resource that already exists under Terraform management, and the 004 exam tests both methods — the <code>terraform import</code> command and the newer import block in configuration, which HashiCorp now recommends because it is reviewable and repeatable. Know <code>terraform state list</code> (what is in the state), <code>terraform state show</code> (the details of one resource) and <code>terraform state mv</code> (renaming a resource in state without recreating it). Know <code>TF_LOG</code> for verbose logging and its levels, least to most verbose — ERROR, WARN, INFO, DEBUG, TRACE — because the exam asks which level to use when debugging a provider problem, and the answer is DEBUG or TRACE, not INFO.</p>
<h2>Objective 8 — HCP Terraform, and What Changed from 003</h2>
<p>Objective 8 is the 004 exam's biggest structural change: HCP Terraform is now a domain of its own, not a side topic. HCP Terraform is HashiCorp's managed service for running Terraform — remote state, remote runs, workspaces, team collaboration and policy enforcement — and the exam tests it as a product you understand, not a service you have necessarily used.</p>
<p>The core concepts are workspaces and projects. A workspace maps a configuration to a set of resources: one workspace, one state file, one set of variables. Projects organise workspaces into groups — by team, by environment, by application — and the 004 exam added an explicit objective (8c) on organising and using them. Know the workspace workflow: code is connected from version control, a run is triggered by a pull request or a manual queue, the plan is reviewed in the HCP Terraform UI, and the apply runs remotely rather than on your laptop. Know the collaboration features: team permissions control who can approve applies, variable sets share values across workspaces, and run tasks and policy checks (Sentinel or OPA) can block an apply that violates a rule. And know the difference between the CLI-driven workflow, where you run Terraform locally against remote state, and the VCS-driven workflow, where HCP Terraform runs everything.</p>
<h2>Study Plan — Six Weeks, Hands-On First</h2>
<p>A realistic study plan for the Terraform Associate 004, for someone working full-time with basic terminal skills, is six weeks at about five hours a week — longer if you have never used a cloud console, shorter if you already write Terraform at work. The plan below follows the exam's own objective order, and every week has a hands-on task, because the exam rewards people who have run the commands, not people who have read about them.</p>
<p><strong>Week 1: concepts and the workflow.</strong> Work through the official 004 learning path on HashiCorp Developer, and install Terraform 1.12 locally. Build a first configuration against a free-tier cloud account or the local provider: a resource, a variable, an output. Run the full cycle — init, validate, plan, apply, destroy — until the commands are automatic, and be able to explain, in your own words, why version-controlled infrastructure beats manual provisioning.</p>
<p><strong>Week 2: configuration.</strong> Write configuration every day: resources and data sources, variables of every type, locals, outputs, <code>for_each</code> and <code>count</code>, functions and expressions. Practise the new 004 topics deliberately: add a precondition that rejects an invalid variable value, use an ephemeral variable for a secret, and set a lifecycle block with <code>create_before_destroy</code>. Break things on purpose — a bad reference, a circular dependency, a missing variable — and read the error messages, because the exam's questions are often about recognising what went wrong.</p>
<p><strong>Week 3: modules and state.</strong> Convert your week 2 configuration into a module and call it twice with different inputs. Then move the state to a remote backend — an S3 backend, or the free tier of HCP Terraform — and run an apply against it. Practise <code>terraform state list</code>, <code>terraform state show</code> and <code>terraform state mv</code>, and simulate drift by changing a resource in the cloud console and watching the next plan detect it. Read our <a href="https://devopsjobupdates.com/terraform-state-explained/">Terraform State Explained</a> this week.</p>
<p><strong>Week 4: maintenance and HCP Terraform.</strong> Import an existing resource with an import block. Practise verbose logging with <code>TF_LOG=DEBUG</code> and read a real debug log until you can find the provider call in it. Then read the HCP Terraform concepts documentation — workspaces, projects, runs, variable sets, permissions — and be able to describe the VCS-driven workflow end to end without having used it. If you have a free account, connect a repository and watch a speculative plan run on a pull request.</p>
<p><strong>Week 5: practice questions and weak spots.</strong> Take timed practice questions under exam conditions — one hour, no notes — and study every wrong answer, including why the right answer is right. Re-read the official content list and check off each of the 37 sub-objectives: if you cannot explain one in your own words, that is the next thing to study. Rebuild your module from scratch without looking at your notes, paying particular attention to the four new 004 topics and to state.</p>
<p><strong>Week 6: consolidate and book.</strong> Take a full practice assessment, review the objective-level results, and spend the remaining days only on the weakest objectives. Book the exam for the end of this week, before you feel fully ready — the date is the motivator, and the one-hour format is a small commitment. The day before, check your environment: a quiet room, a webcam, a clean desk, and the system test the proctoring service asks for. On the day, read each question twice — the questions are scenario-driven, so the detail in the stem is usually the detail that decides the answer.</p>
<h2>Booking, Retakes and What Comes After</h2>
<p>Booking is through HashiCorp's certification platform, and the exam is delivered online with a proctor. You need a quiet room, a webcam and a clean desk — the proctor checks the room on camera, so read the rules before the day and do a system test in advance. The exam is one hour, and the question types are true/false, single-select multiple choice and multi-select. For multi-select questions, read the stem carefully: it says how many answers to choose.</p>
<p>Passing earns the HashiCorp Certified: Terraform Associate credential, valid for two years, with a digital badge issued through Credly for a LinkedIn profile or a resume. Recertification is by retaking the current exam when the credential expires — there is no renewal assessment, so plan to retake against whatever version is current then. Failing costs another $70.50, since no free retake is included, but the objective-level report within 48 hours tells you exactly which objectives to study before the next attempt.</p>
<p>What comes after depends on where you are going. Inside the HashiCorp track, the next step is the Terraform Authoring and Operations Professional, a four-hour lab-based exam on authoring modules and operating Terraform at production scale; it costs $295 and includes a free retake. Outside the track, the Associate pairs well with a cloud certification — the AWS Solutions Architect Associate or the Azure Administrator Associate — because this exam proves you can write infrastructure as code, and the cloud exam proves you know what infrastructure to write. Our <a href="https://devopsjobupdates.com/terraform-interview-questions-answers/">Terraform Interview Questions and Answers</a> is the bridge: the exam tests whether you know Terraform, and the interview tests whether you can explain it to a team.</p>
<h2>FAQ</h2>
<p><strong>How much does the Terraform Associate 004 exam cost, and how long is it?</strong></p>
<p>The exam costs $70.50 plus applicable taxes, and lasts 60 minutes. The fee does not include a retake. Results are pass or fail, given immediately, with an objective-level report within 48 hours.</p>
<p><strong>How many questions are there, and what is the passing score?</strong></p>
<p>HashiCorp does not publish either figure. Guides commonly estimate around 57 questions and a pass mark around 70%, but both numbers are unofficial estimates, not HashiCorp figures. Plan your time on the one-hour limit, and treat any pass mark you see elsewhere as unofficial.</p>
<p><strong>What changed from the 003 exam to the 004 exam?</strong></p>
<p>The 003 exam retired on 7 January 2026 and 004 was first delivered on 8 January 2026. The 004 exam tests Terraform 1.12, reorganises the objectives from nine to eight, adds four new topics (lifecycle rules with <code>depends_on</code> and <code>create_before_destroy</code>, custom conditions, ephemeral values and write-only arguments, and HCP Terraform workspaces and projects), and makes HCP Terraform a full objective of its own.</p>
<p><strong>How long is the Terraform Associate valid?</strong></p>
<p>Two years. You recertify by retaking the current exam when the credential expires. There is no renewal assessment, and the credential you retake against will be whatever version is current at that time.</p>
<p><strong>Do I need experience with HCP Terraform to pass?</strong></p>
<p>You need to understand it conceptually — workspaces, projects, runs, variable sets, permissions and the VCS-driven workflow — but the exam's HCP questions are about concepts, not about having used the service. Reading the HCP Terraform concepts documentation is enough preparation for this objective.</p>
<h2>Conclusion</h2>
<p>The Terraform Associate 004 is a one-hour, $70.50 exam testing Terraform 1.12 across eight objectives — from IaC concepts and the core workflow, through configuration, modules and state, to maintenance and HCP Terraform. It has no prerequisites, it is valid for two years, and it is among the cheapest major infrastructure certifications to sit. Six weeks of hands-on study, built around real configuration and the official learning path, is enough for most candidates, and the reward is a credential hiring teams recognise immediately.</p>
<p>Start with the workflow, spend the most time on configuration and state, and give the four new 004 topics the attention they deserve — they are the questions your 003-era study material will not have. Then follow the path this guide points to: our <a href="https://devopsjobupdates.com/terraform-tutorial-beginners/">Terraform Tutorial for Beginners</a> for the hands-on foundations, our <a href="https://devopsjobupdates.com/terraform-state-explained/">Terraform State Explained</a> for the objective candidates underestimate most, and our <a href="https://devopsjobupdates.com/terraform-interview-questions-answers/">Terraform Interview Questions and Answers</a> for turning exam knowledge into interview answers.</p>
<p>Sources checked 30 Nov 2026: HashiCorp Developer, Terraform Associate 004 exam content list (8 objectives, 37 sub-objectives; new topics 4f <code>depends_on</code> and <code>create_before_destroy</code> lifecycle rules, 4g custom conditions, 4h ephemeral values and write-only arguments, 8c HCP Terraform workspaces and projects; tests Terraform 1.12; includes HCP Terraform content); HashiCorp-citing guides checked 30 Nov 2026 (003 retired 7 Jan 2026, 004 first delivered 8 Jan 2026; $70.50 plus taxes; 60 minutes; online proctored; true/false, single-select and multi-select; no prerequisites; valid 2 years; no free retake; immediate pass/fail with objective-level report within 48 hours; digital badge via Credly). NOT VERIFIED on an official page and therefore not stated as fact above: the number of questions (commonly estimated at around 57 — unofficial); the passing score (commonly estimated at around 70% — unofficial); domain weights (HashiCorp publishes none); the Terraform Authoring and Operations Professional price and format ($295, four hours, lab-based, free retake included — from a third-party guide, re-check on HashiCorp's certification page before booking). External references: <a href="https://developer.hashicorp.com/terraform/tutorials/certification-004/associate-review-004">HashiCorp Developer — Terraform Associate 004 exam content list</a> · <a href="https://developer.hashicorp.com/terraform/language">HashiCorp Developer — Terraform language documentation</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Dockerfile Best Practices: Smaller, Faster, More Secure Images]]></title><description><![CDATA[A Dockerfile is a short text file with an outsized effect. It decides how big your image is, how long your builds take, how many known vulnerabilities ship…]]></description><link>https://devopsjobupdates.hashnode.dev/dockerfile-best-practices-smaller-faster-more-secure-images</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/dockerfile-best-practices-smaller-faster-more-secure-images</guid><category><![CDATA[Docker]]></category><category><![CDATA[Dockerfile]]></category><category><![CDATA[Devops]]></category><category><![CDATA[containers]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:47:05 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>A Dockerfile is a short text file with an outsized effect. It decides how big your image is, how long your builds take, how many known vulnerabilities ship inside it, and whether a container that escapes its process boundary runs as root on the host. A careless Dockerfile can turn a small application into a huge image that takes minutes to pull on every deploy, carries a compiler and a package manager it never needs at runtime, and runs as root by default. A good one does the opposite: it builds fast because the cache works for it, it ships only what the application needs, and it gives an attacker almost nothing to work with.</p>
<p>This guide covers Dockerfile best practices as they stand on 30 November 2026, against Docker Engine 29.10.1, released 24 November 2026, with BuildKit 0.35.1 as the builder. Every practice below is one Docker itself documents or that follows directly from how layers and the build cache work. There is a worked example at the end — a Python web service taken from a naive first draft to a production-ready multi-stage Dockerfile — so you can see each rule change the result rather than just reading about it. If you are new to Docker itself, start with our <a href="https://devopsjobupdates.com/docker-tutorial-beginners/">Docker Tutorial for Beginners</a>; if you already run containers and want to orchestrate them, our <a href="https://devopsjobupdates.com/docker-compose-tutorial/">Docker Compose Tutorial</a> is the next step.</p>
<p>The short version: pin your base image, order instructions so the cache works, keep the build context small with a <code>.dockerignore</code> file, use multi-stage builds, run as a non-root user, and scan the finished image. The rest of this guide is the evidence for those six sentences.</p>
<h2>How Docker Builds an Image — Layers and the Cache</h2>
<p>A Dockerfile is a list of instructions, and each instruction creates a layer. A layer is a read-only snapshot of the filesystem changes that instruction made: the files it added, the files it changed, the files it deleted. The finished image is the stack of those layers, and a container is the same stack plus a thin writable layer on top. That stacking is what makes Docker fast and what makes it wasteful, depending on how you write the file.</p>
<p>The build cache is the key idea. When you rebuild an image, BuildKit reuses a cached layer if the instruction and its inputs have not changed. The moment one instruction changes, that layer is rebuilt — and so is every layer after it, because each layer is built on top of the one before. This single rule explains most Dockerfile advice. If you copy your source code into the image before installing dependencies, then every code change invalidates the dependency-install layer and reinstalls everything. If you copy the dependency list first, install, and only then copy the source, a code change rebuilds just the last layers. The order of instructions is therefore a performance decision, not a style choice.</p>
<p>Layers are also additive. If a layer downloads a 300 MB compiler and a later layer deletes it, the image is not 300 MB smaller — the deletion is recorded as a new layer, but the earlier layer still exists in the image and still has to be downloaded. That is why the advice is always to install and clean up in the same <code>RUN</code> instruction, and why multi-stage builds matter: the only way to truly leave something out of an image is for it never to be in the final stage at all.</p>
<p>The build context matters too. When you run <code>docker build</code>, the client sends the build context — the directory you point it at — to the daemon. If that directory contains a <code>.git</code> folder, a local virtual environment, log files and a <code>.env</code> file with secrets, all of it is sent on every build, and <code>COPY . .</code> will copy it into the image. A <code>.dockerignore</code> file is the fix: list what should never reach the daemon. A secret that reaches the build context can end up baked into a layer, where anyone with the image can read it.</p>
<p>One more piece of context for 2026: BuildKit has been the default builder since Docker 23.0, and Engine 29.10 ships BuildKit 0.35.1, which provides the cache mounts, secret mounts and parallel stage execution this guide relies on. The <code># syntax=docker/dockerfile:1</code> directive at the top of the example Dockerfiles asks BuildKit for the current stable Dockerfile frontend.</p>
<h2>Choose and Pin a Base Image</h2>
<p>The first line of a Dockerfile is the most consequential decision in the file, because everything else is built on top of it. The base image sets the operating system, the language runtime, the size of the image, and the number of known vulnerabilities it contains before you have written a single line of your own.</p>
<p>Start with an official image. Docker Official Images are a curated set maintained with the upstream projects, with clear documentation and regular updates. For language runtimes, the official image usually comes in several variants, and the variant matters as much as the name. A Python image, for example, is available as the full image, a slim variant based on Debian with most packages stripped out, and an alpine variant based on Alpine Linux with musl libc instead of glibc. The full image is the easiest to build against and the largest; slim is the usual sweet spot for production; Alpine is the smallest, but its different C library has historically broken compiled extensions, so test it before committing to it. Docker's own guidance is to choose a minimal base image that matches your requirements, and to use two types of base image where it helps: one for building and testing, and a slimmer one for production — which is exactly what multi-stage builds do.</p>
<p>Pin the version, and pin it precisely. <code>FROM python:latest</code> means a different image every time the tag moves, so a rebuild next month can silently change your runtime and libraries — and you will not know which build introduced the change. <code>FROM python:3.13-slim</code> pins the minor version and the variant, and naming the Debian release, as in <code>python:3.13-slim-trixie</code>, pins the distribution too. The strongest form is a digest, <code>FROM python:3.13-slim@sha256:...</code>, which pins the exact image bytes — the right choice where reproducibility matters. Whichever form you choose, rebuild regularly: a pinned image that is six months old carries six months of unpatched vulnerabilities. Use <code>docker build --pull</code> to force a fresh check for a newer base image even when a cached one exists.</p>
<p>Distroless images deserve a mention: Google's distroless images contain only the application and its runtime dependencies — no shell, no package manager, no extra tools. They are the smallest and most defensible runtime images available, and an excellent choice for compiled languages like Go and Java. The trade-off is debuggability: with no shell to exec into, you need the kubectl debug ephemeral-container workflow or good logging instead.</p>
<h2>Order Instructions for the Cache and Keep Layers Few</h2>
<p>If the base image is the first decision, instruction order is the second, and it saves the most build time. The rule is simple: copy files in order of how rarely they change. The dependency list changes occasionally; the source code changes constantly. So copy the dependency list, install, and only then copy the source:</p>
<pre><code class="language-dockerfile">COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
</code></pre>
<p>With that order, a code change rebuilds only the final <code>COPY</code> layer and whatever follows it. With the reverse order — <code>COPY . .</code> first, then the install — every code change reinstalls every dependency. On a project with a large dependency tree, that is the difference between a five-second rebuild and a five-minute one, multiplied by every developer and every CI run.</p>
<p>Combine related commands into a single <code>RUN</code> instruction, and clean up in the same instruction. This is the layer-additivity rule from the first section: a package cache deleted in a later layer still occupies space in the image. The correct pattern installs, then removes the cache, in one layer:</p>
<pre><code class="language-dockerfile">RUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends \
        build-essential \
    &amp;&amp; rm -rf /var/lib/apt/lists/*
</code></pre>
<p>The <code>--no-install-recommends</code> flag matters on Debian-based images: it skips the recommended packages that are not required, which can halve the size of an install. The <code>rm -rf /var/lib/apt/lists/*</code> at the end removes the package lists in the same layer, so they never reach the image. Note that <code>apt-get update</code> and <code>apt-get install</code> must be in the same <code>RUN</code> — if they are split across layers, the update layer can be cached while the package index it fetched goes stale, and the install then fails or installs the wrong versions.</p>
<p>Prefer <code>COPY</code> over <code>ADD</code>. <code>ADD</code> has two extra behaviours — it extracts tar archives and fetches remote URLs — and both are surprises waiting to happen. <code>COPY</code> does one thing: it copies files from the context into the image. If you need to download something, do it explicitly with <code>curl</code> inside a <code>RUN</code>, where the command is visible and its failure is obvious. Similarly, prefer the exec form of <code>CMD</code> and <code>ENTRYPOINT</code> — <code>CMD ["python", "app.py"]</code> — over the shell form, <code>CMD python app.py</code>. The exec form runs the process directly, so it receives signals correctly; the shell form wraps it in a shell, which can swallow the signal that tells a container to stop gracefully, and is a common cause of containers that take ten seconds to die on shutdown.</p>
<p>Use <code>WORKDIR</code> instead of <code>cd</code> in <code>RUN</code> commands. <code>WORKDIR /app</code> sets the working directory for every instruction that follows, it creates the directory if it does not exist, and it is readable at a glance. A <code>RUN cd /app &amp;&amp; ...</code> hides the same fact inside a shell command that only applies to that one layer.</p>
<h2>Multi-Stage Builds — Leave the Build Tools Behind</h2>
<p>Multi-stage builds are the single most effective Dockerfile technique, and they are the reason the naive-versus-optimised image sizes in this guide differ by an order of magnitude. A multi-stage Dockerfile uses several <code>FROM</code> instructions: one stage builds the application, and a second, clean stage runs it. Only what you explicitly copy from the build stage into the final stage ends up in the image, so compilers, headers, test frameworks and package caches stay behind.</p>
<p>Here is the shape of it for a compiled language, in this case Go:</p>
<pre><code class="language-dockerfile"># syntax=docker/dockerfile:1
FROM golang:1.25 AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /app/server ./cmd/server

FROM scratch
COPY --from=builder /app/server /server
USER 10001
EXPOSE 8080
ENTRYPOINT ["/server"]
</code></pre>
<p>The builder stage is a full Go toolchain image. It downloads the modules, compiles the binary, and is then discarded. The final stage is <code>scratch</code> — an empty image — containing only the compiled binary. Nothing else exists in the image: no shell, no package manager, no compiler, no source code.</p>
<p>The same pattern works for interpreted languages. A Python application can install its dependencies into a virtual environment in a build stage, then copy only the virtual environment and the application code into a slim runtime stage. A Node.js application can run <code>npm ci</code> and <code>npm run build</code> in a build stage, then copy only the built output and the production dependencies into the runtime stage. The principle is identical in every language: the build stage may be large and messy, because it never ships; the runtime stage is kept small and clean, because it does.</p>
<p>Name your stages with <code>AS</code>: <code>COPY --from=builder</code> reads better than <code>COPY --from=0</code>, and survives reordering — a numeric reference silently points at the wrong stage if you insert one later. You can also build a single stage on demand with <code>docker build --target builder</code>, which is useful for running tests in the build environment without producing a runtime image.</p>
<h2>Run as Non-Root and Keep Secrets Out of the Image</h2>
<p>By default, a container runs as root. That is the single most dangerous Dockerfile default, because a process that escapes its container — or a vulnerability in the application itself — then has root privileges on the host. The fix is one instruction, placed near the end of the Dockerfile, after everything that needs root has finished:</p>
<pre><code class="language-dockerfile">RUN groupadd -r app &amp;&amp; useradd -r -g app app
USER app
</code></pre>
<p>Create a dedicated user and group, then switch to them. The <code>USER</code> instruction applies to everything after it, including the <code>CMD</code>, so the application itself runs unprivileged. Two details matter. First, use a fixed numeric UID and GID — <code>USER 10001</code> is unambiguous, and Kubernetes securityContext settings like <code>runAsNonRoot</code> check the numeric UID, not the name. Second, make sure the application can still do what it needs: any directory it writes to must be owned by the application user, which is why the worked example below uses <code>COPY --chown=app:app</code>.</p>
<p>Secrets must never be baked into an image. Do not put an API key, a password or a private key in an <code>ENV</code> instruction, in a <code>COPY</code> of a <code>.env</code> file, or in a <code>RUN</code> command that downloads something with credentials — every one of those ends up in a layer, and layers are readable by anyone who can pull the image. The correct mechanisms are BuildKit's secret mount and the runtime's own secret handling. A BuildKit secret mount passes a secret into a single <code>RUN</code> instruction without storing it in any layer:</p>
<pre><code class="language-dockerfile">RUN --mount=type=secret,id=npmrc,target=/root/.npmrc \
    npm ci
</code></pre>
<p>The secret is available during that command and gone afterwards. At runtime, pass secrets as environment variables from your orchestrator or secrets manager, or mount them as files — never bake them into the image, and never commit them to the repository the Dockerfile lives in. The <code>.dockerignore</code> file is the backstop here: it should exclude <code>.env</code>, any <code>*.pem</code> or <code>*.key</code> files, and credential files, so that even a careless <code>COPY . .</code> cannot pick them up. Our <a href="https://devopsjobupdates.com/git-for-devops-engineers/">Git for DevOps Engineers</a> guide covers keeping secrets out of repositories, and the same discipline applies to images.</p>
<h2>Health Checks, Signals and the Worked Example</h2>
<p>A production image should tell its orchestrator whether it is healthy, and it should stop cleanly when asked. Both are small additions with large operational effects.</p>
<p>A <code>HEALTHCHECK</code> runs a command inside the container on a schedule, and Docker reports the result as the container's health status. Kubernetes has its own probes and does not use the Docker health check, but for Docker Compose, Docker Swarm and local development it is the mechanism that tells you a container is up but not actually working:</p>
<pre><code class="language-dockerfile">HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
    CMD curl -f http://localhost:8000/health || exit 1
</code></pre>
<p>The <code>--start-period</code> matters: it gives the application time to start before failures count, so a slow-starting application is not marked unhealthy during its normal startup. Keep the health check cheap — a single HTTP request to a lightweight endpoint, not a database query — because it runs every thirty seconds for the life of the container.</p>
<p>Signals are the other half. When Docker stops a container it sends <code>SIGTERM</code>, waits ten seconds, then sends <code>SIGKILL</code>. An application that handles <code>SIGTERM</code> shuts down cleanly — finishing in-flight requests, closing connections, flushing buffers. One that does not is killed mid-request after the grace period. The exec form of <code>CMD</code> matters here: it makes the application PID 1, so it receives the signal directly, while a shell-form <code>CMD</code> leaves a shell as PID 1 that may not forward it. If your application cannot handle <code>SIGTERM</code>, a tiny init process such as <code>tini</code> can be the entrypoint and will forward signals and reap zombie processes.</p>
<p>Now the worked example. The project is a small Python web service: an <code>app.py</code>, a <code>requirements.txt</code> with two dependencies, and a test suite. This is the Dockerfile most people start with:</p>
<pre><code class="language-dockerfile">FROM python:latest
COPY . .
RUN pip install -r requirements.txt
CMD python app.py
</code></pre>
<p>It has every problem in this guide: an unpinned <code>latest</code> tag, the whole context copied before the install (so the <code>.git</code> folder, the virtual environment and any <code>.env</code> file are all in the image, and every code change reinstalls the dependencies), no <code>.dockerignore</code>, no non-root user, no health check, and the shell form of <code>CMD</code>. And here is the production version of the same service:</p>
<pre><code class="language-dockerfile"># syntax=docker/dockerfile:1
FROM python:3.13-slim AS build
WORKDIR /app
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache/pip \
    pip install --no-cache-dir -r requirements.txt

FROM python:3.13-slim AS runtime
RUN groupadd -r app &amp;&amp; useradd -r -g app -m app
WORKDIR /app
COPY --from=build /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY --chown=app:app app.py ./
USER app
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
    CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
CMD ["python", "app.py"]
</code></pre>
<p>With a <code>.dockerignore</code> that excludes <code>.git</code>, <code>__pycache__</code>, <code>.venv</code>, <code>*.pyc</code>, <code>.env</code> and the test files, this version is a fraction of the size of the first, rebuilds in seconds when only the code changes, runs as a non-root user, and reports its own health. The <code>--mount=type=cache</code> on the pip install is a BuildKit cache mount: the pip download cache survives between builds without being copied into the image, so a rebuild with one new dependency downloads only that dependency. That is the whole guide in one file, and it is a good template to copy for your own services.</p>
<h2>Checklist, Scanning and Keeping Images Fresh</h2>
<p>Before an image reaches production, run through this checklist. It takes five minutes and catches the mistakes that cost hours later.</p>
<table>
<thead>
<tr>
<th>Check</th>
<th>What to verify</th>
<th>How</th>
</tr>
</thead>
<tbody><tr>
<td>Base image pinned</td>
<td>Specific version, not latest</td>
<td>Read the <code>FROM</code> line; prefer a digest in production</td>
</tr>
<tr>
<td>Build context small</td>
<td><code>.dockerignore</code> excludes <code>.git</code>, <code>.env</code>, virtual environments, logs</td>
<td><code>docker build</code> shows the context size; it should be kilobytes, not hundreds of megabytes</td>
</tr>
<tr>
<td>Cache order correct</td>
<td>Dependency list copied and installed before source code</td>
<td>Change one source file and rebuild; only the last layers should rebuild</td>
</tr>
<tr>
<td>Multi-stage</td>
<td>Build tools absent from the final stage</td>
<td><code>docker history</code> on the final image shows no compiler or package manager layers</td>
</tr>
<tr>
<td>Non-root user</td>
<td><code>USER</code> is set and the app owns its writable directories</td>
<td><code>docker run --rm myapp id</code> prints a non-root UID</td>
</tr>
<tr>
<td>No secrets in layers</td>
<td>No <code>ENV</code> with credentials, no copied <code>.env</code></td>
<td><code>docker history --no-trunc</code> shows no secret values</td>
</tr>
<tr>
<td>Health check present</td>
<td><code>HEALTHCHECK</code> hits a cheap endpoint with a start period</td>
<td><code>docker inspect</code> shows the health check configuration</td>
</tr>
<tr>
<td>Image scanned</td>
<td>Known vulnerabilities reviewed before deploy</td>
<td><code>docker scout cves myapp</code> or Trivy in CI</td>
</tr>
<tr>
<td>Size reasonable</td>
<td>Final image close to the runtime plus the app</td>
<td><code>docker images</code> — compare against the naive version</td>
</tr>
</tbody></table>
<p>Scanning deserves a paragraph of its own. An image built from a pinned base can still contain vulnerabilities — in the base image's system packages, in your language dependencies, or in a library you installed along the way. Docker Scout is built into Docker and reports vulnerabilities with fix guidance; Trivy is a widely used open-source scanner that is easy to add to a CI pipeline. Scan on every build and fail the build on critical vulnerabilities with a known fix, rather than scanning occasionally and discovering the problem in production. A scan result is a starting point, not a verdict: a vulnerability in a package your application never loads is less urgent than one in the web framework that handles every request.</p>
<p>Finally, images rot. A pinned base image does not update itself, and neither does a dependency list. Rebuild on a schedule — weekly is a good default for production services — with <code>docker build --pull</code> so the base image is refreshed, and use a dependency-update tool to open pull requests when libraries change. An image that is rebuilt regularly, scanned on every build and kept small is an image you can deploy with confidence.</p>
<h2>FAQ</h2>
<p><strong>What is the current Docker Engine version?</strong></p>
<p>Docker Engine 29.10.1, released 24 November 2026, is the current version as of 30 November 2026, with BuildKit 0.35.1. Engine 29.10.0 arrived on 16 November 2026. Re-check the release notes at publication time, as Docker ships patches frequently.</p>
<p><strong>Should I use Alpine, slim or distroless as a base image?</strong></p>
<p>Use slim for most production services: it is small, it uses the standard glibc, and it rarely breaks compiled extensions. Use Alpine when size matters most and you have tested it with your dependencies. Use distroless for compiled languages where you want the smallest possible attack surface and can debug without a shell.</p>
<p><strong>Why is my Docker build slow even though I changed one file?</strong></p>
<p>Because an early layer changed and every layer after it rebuilt. The usual cause is copying the source code before installing dependencies. Copy the dependency list, install, and only then copy the source — then a one-file change rebuilds only the last layers.</p>
<p><strong>Is running as root in a container really a problem?</strong></p>
<p>Yes. A container process that escapes, or an application vulnerability, has root privileges on the host if the container runs as root. Create a dedicated user and switch to it with <code>USER</code> near the end of the Dockerfile, and make sure the application owns the directories it writes to.</p>
<p><strong>How do I keep secrets out of my Docker image?</strong></p>
<p>Never put credentials in <code>ENV</code>, in a copied <code>.env</code> file, or in a <code>RUN</code> command. Use a BuildKit secret mount for secrets needed at build time, pass secrets as environment variables or mounted files at runtime, and exclude credential files in <code>.dockerignore</code> so a careless <code>COPY . .</code> cannot pick them up.</p>
<h2>Conclusion</h2>
<p>A good Dockerfile is a short file that does six things well: it pins a minimal base image, it orders instructions so the cache works, it keeps the build context small, it uses multi-stage builds to leave build tools behind, it runs as a non-root user, and it keeps secrets out of the image. Against Docker Engine 29.10.1, the tools for all six are built in — BuildKit cache and secret mounts, the <code># syntax=docker/dockerfile:1</code> frontend, and <code>docker scout</code> for scanning — so there is no reason to ship the naive version any longer.</p>
<p>Start with the worked example in this guide and adapt it to your own service: change the language, keep the structure, and run the checklist before the image reaches production. Then go deeper with our <a href="https://devopsjobupdates.com/docker-tutorial-beginners/">Docker Tutorial for Beginners</a> if any of the concepts need a fuller introduction, and our <a href="https://devopsjobupdates.com/docker-compose-tutorial/">Docker Compose Tutorial</a> when you are ready to run the image alongside a database and a reverse proxy.</p>
<p>Sources checked 30 Nov 2026: Docker Docs, Engine version 29 release notes (29.10.1, 24 Nov 2026; 29.10.0, 16 Nov 2026; BuildKit 0.35.1; Go 1.27.4; API 1.57; experimental daemon jobs; loopback insecure-registry behaviour change in 29.10.0); Docker Docs, Building best practices (multi-stage builds, minimal base images, .dockerignore, rebuilding regularly, --pull and --no-cache flags, ephemeral containers). NOT VERIFIED and therefore not stated as fact above: any specific before/after image size for the worked example (sizes vary by project — measure your own with <code>docker images</code>); the claim that any particular scanner finds a specific number of vulnerabilities. External references: <a href="https://docs.docker.com/build/building/best-practices/?spm=ata.21736010.0.0.49d87142onzZDs">Docker Docs — Building best practices</a> · <a href="https://docs.docker.com/engine/release-notes/29#29100">Docker Docs — Docker Engine version 29 release notes</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Terraform Workspaces Explained: Environments, State and When Not to Use Them]]></title><description><![CDATA[Every Terraform user hits the same problem within weeks of starting: the configuration works for one environment, and now there are three. Development…]]></description><link>https://devopsjobupdates.hashnode.dev/terraform-workspaces-explained-environments-state-and-when-not-to-use-them</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/terraform-workspaces-explained-environments-state-and-when-not-to-use-them</guid><category><![CDATA[Terraform]]></category><category><![CDATA[Devops]]></category><category><![CDATA[#IaC]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:44:18 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>Every Terraform user hits the same problem within weeks of starting: the configuration works for one environment, and now there are three. Development, staging and production need the same infrastructure in different sizes, with different values, and — critically — with different state, so that destroying development never touches production. Terraform workspaces are the built-in answer to that problem, and they are also one of the most misunderstood features in Terraform. They are not environments. They are not folders. They are not a deployment strategy. They are a way of keeping several state files behind a single configuration, and understanding exactly what that means is the difference between using them well and using them to build a system nobody can reason about.</p>
<p>This guide explains workspaces as they stand in Terraform 1.17.2, the current release as of 30 November 2026: what a workspace actually is, the commands that manage them, how to use the workspace name inside your configuration, how they differ from separate state files and from modules, what workspaces mean in HCP Terraform — where the word means something related but different — and, most importantly, when not to use them at all. If you are new to Terraform itself, start with our <a href="https://devopsjobupdates.com/terraform-tutorial-beginners/">Terraform Tutorial for Beginners</a> first; this guide assumes you can already write a configuration, run <code>terraform plan</code> and <code>terraform apply</code>, and configure a backend. Our <a href="https://devopsjobupdates.com/terraform-state-explained/">Terraform State Explained</a> covers backends, locking and state surgery in detail, and it is the companion to read alongside this one, because workspaces are a state feature before they are anything else.</p>
<h2>What a Workspace Actually Is</h2>
<p>A workspace is a named container for state, attached to a single configuration. When you run Terraform in a directory, you are always in a workspace — the <code>default</code> workspace, unless you have created and selected another one. Each workspace keeps its own state file, and the state files are kept apart by the backend: with a local backend they live in separate files under <code>terraform.tfstate.d/</code>, and with a remote backend such as S3, each workspace gets its own state object under a workspace-specific key. The configuration is the same in every workspace. The state is not. That is the whole mechanism, and everything else follows from it.</p>
<p>The practical effect is that you can run the same configuration three times — once in a <code>dev</code> workspace, once in <code>staging</code>, once in <code>production</code> — and each run manages a separate set of real resources. Destroying the <code>dev</code> workspace's resources does not touch production, because the two runs read and write different state, and a change to the configuration applies to all three environments the next time each one is applied. That single-source-of-truth property is the reason workspaces exist, and it is also what makes them dangerous when the environments are not, in fact, the same shape.</p>
<p>It helps to say plainly what a workspace is not. It is not an environment in the organisational sense: it carries no permissions or approval process, so anyone who can run Terraform against the configuration can select the production workspace and apply to it. It is not a folder: the configuration files do not change when you switch workspaces. It is not a deployment strategy: workspaces do not know about promotion or testing, and they will not stop you applying an untested change to production. And it is not a substitute for a module: a module packages configuration for reuse across different systems, while a workspace reuses one configuration across copies of the same system.</p>
<p>There is one more thing a workspace is not, and it is the source of the most common confusion in Terraform: a workspace in the Terraform CLI and a workspace in HCP Terraform are related but different things. A CLI workspace is the state container described above. An HCP Terraform workspace is a much larger object — a group of infrastructure resources managed by Terraform, with its own variables, its own run history, its own permissions, and its own connection to a version control repository. The two share a name and a purpose, but an HCP Terraform workspace is a managed environment with a UI and an API, while a CLI workspace is a state partition. The HCP Terraform section below covers the difference in full.</p>
<h2>The Workspace Commands</h2>
<p>There are only five workspace commands, and they do exactly what their names suggest. Learn them in one sitting and you will never need to look them up again.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
</tr>
</thead>
<tbody><tr>
<td><code>terraform workspace list</code></td>
<td>Lists all workspaces, marking the current one with an asterisk</td>
</tr>
<tr>
<td><code>terraform workspace show</code></td>
<td>Prints the name of the current workspace</td>
</tr>
<tr>
<td><code>terraform workspace new &lt;name&gt;</code></td>
<td>Creates a workspace with the given name and switches to it</td>
</tr>
<tr>
<td><code>terraform workspace select &lt;name&gt;</code></td>
<td>Switches to an existing workspace</td>
</tr>
<tr>
<td><code>terraform workspace delete &lt;name&gt;</code></td>
<td>Deletes a workspace (it must not be the current one)</td>
</tr>
</tbody></table>
<p>The workflow is the same every time. You start in <code>default</code>. You run <code>terraform workspace new staging</code>, which creates the staging workspace, switches to it, and gives it an empty state — the next <code>terraform plan</code> will show every resource as needing to be created, because staging has no state yet. You apply, and the staging resources are created and recorded in staging's state. You switch back with <code>terraform workspace select default</code>, and the plan goes back to showing the <code>default</code> workspace's resources. The asterisk in <code>terraform workspace list</code> is the only visible sign of which workspace you are in, which is why the first habit of workspace use is to run <code>terraform workspace show</code> before every apply — and the reason the second habit is to put the workspace name in your prompt or your CI output, so that a command run in the wrong workspace is visible before it does damage.</p>
<p>Two details deserve attention. The first is that <code>terraform workspace new</code> copies nothing: the new workspace starts with empty state, even if the <code>default</code> workspace already manages resources. The second is that <code>terraform workspace delete</code> refuses to delete a workspace that still tracks resources unless you pass <code>-force</code> — deleting a workspace's state without destroying its resources orphans real infrastructure that no state file knows about. Always destroy first, then delete the workspace.</p>
<p>Workspaces and backends interact in a way that is easy to get wrong. Workspaces are supported by the local backend and by the standard remote backends — S3, Azure Blob Storage, Google Cloud Storage, and the HCP Terraform remote backend — but the way each backend stores workspace state differs, and not every backend supports them. Before relying on workspaces, verify the behaviour in a scratch configuration: create two workspaces, apply a trivial resource in each, and confirm in the backend that two separate state objects exist.</p>
<h2>Using the Workspace Name in Your Configuration</h2>
<p>A workspace is only useful if the configuration can tell which workspace it is running in, and Terraform provides exactly one mechanism for that: the <code>terraform.workspace</code> value. Inside your configuration, <code>terraform.workspace</code> evaluates to the name of the current workspace — <code>default</code>, <code>staging</code>, <code>production</code>, or whatever you named it — and you can use it anywhere a value is expected: in a resource argument, in a variable default, in a local value, in a tag.</p>
<p>The standard pattern is a map lookup. Define a local value that maps workspace names to the values that differ between environments — instance sizes, replica counts, feature flags — and look the current workspace up in the map:</p>
<pre><code class="language-hcl">locals {
  instance_size = {
    default     = "t3.micro"
    staging     = "t3.small"
    production  = "t3.large"
  }
}

resource "aws_instance" "web" {
  ami           = var.ami
  instance_type = local.instance_size[terraform.workspace]
}
</code></pre>
<p>In the <code>default</code> workspace this creates a small instance; in production it creates a large one; and the configuration is a single file that describes all three. The same pattern works for tags — <code>Environment = terraform.workspace</code> is the single most common tag in workspace-based setups — and for counts, such as running one replica in development and three in production. The pattern is powerful precisely because it is small: one value, one lookup, and the environment differences are visible in one place.</p>
<p>The discipline around the pattern is what separates a good workspace setup from a bad one. First, keep the differences small. If the map has three entries that differ only in size, workspaces are working as intended. If the map has thirty entries, or the configuration is full of conditionals on <code>terraform.workspace</code>, the environments have diverged past the point where one configuration describes them honestly. Second, <strong>always provide a default entry in every map, because a workspace whose name is not in the map will fail the lookup and the plan will error. Third, do not branch on the workspace name for security or access decisions</strong>: a workspace name is a label, not a boundary. If production needs different credentials or approval from development, that boundary belongs in your backend permissions and your CI pipeline, not in a conditional in your configuration.</p>
<p>Variable files are the other half of the pattern. Many teams combine workspaces with per-environment variable files — <code>terraform apply -var-file=dev.tfvars</code> in the <code>dev</code> workspace, <code>-var-file=prod.tfvars</code> in production — and that combination is fine, provided the two mechanisms do not fight: the variable file sets the values, the workspace selects the state, and the configuration stays the same. The mistake is to use variable files to paper over environments that have genuinely diverged, so that the same configuration means different things in different workspaces and nobody can tell what production actually contains without reading three files. If you find yourself maintaining a variable file per workspace that is longer than the configuration itself, that is the signal to stop and read the section on when not to use workspaces.</p>
<h2>Workspaces vs Separate State Files vs Modules</h2>
<p>Workspaces are one of three ways to manage several environments, and choosing between them is the most consequential decision in this guide. The other two are separate state files — usually separate directories, one per environment, each with its own backend configuration — and modules, which package reusable configuration. The three are not interchangeable, and each one fits a different situation.</p>
<table>
<thead>
<tr>
<th>Approach</th>
<th>What changes per environment</th>
<th>What stays the same</th>
<th>Best for</th>
</tr>
</thead>
<tbody><tr>
<td>Workspaces</td>
<td>State only, plus values looked up by workspace name</td>
<td>The whole configuration</td>
<td>Near-identical environments that differ in size and values</td>
</tr>
<tr>
<td>Separate state files / directories</td>
<td>State and the configuration that references it</td>
<td>The module or shared code the directories call</td>
<td>Environments that differ in structure, resources or providers</td>
</tr>
<tr>
<td>Modules</td>
<td>Nothing — a module is called with different inputs</td>
<td>The module's own code</td>
<td>Repeating a pattern (a VPC, a service, a database) across systems</td>
</tr>
</tbody></table>
<p>Separate directories are the most explicit approach: a <code>dev/</code> directory, a <code>staging/</code> directory and a <code>production/</code> directory, each with its own backend configuration pointing at its own state, and each calling the same module with different inputs. The cost is duplication — three directories to keep in step — and the benefit is honesty: each environment's configuration is visible in its own directory, and the differences are explicit in the inputs. When environments differ in structure — production has a multi-region database and development does not — separate directories are the right answer, because the configuration genuinely differs and pretending otherwise with workspace conditionals only hides the difference.</p>
<p>Modules answer a different question. A module, covered in our <a href="https://devopsjobupdates.com/terraform-modules-tutorial/">Terraform Modules Tutorial</a>, is a reusable package of configuration: a VPC module, a service module, a database module. Modules are how you repeat a pattern across different systems, and they compose with either of the other two approaches — a workspace-based setup calls a module once with workspace-dependent inputs, and a directory-based setup calls the same module three times with different inputs. A workspace is not a module, and a module is not an environment.</p>
<p>The decision rule is simple enough to state in one paragraph. Use workspaces when the environments are the same shape and differ only in size, count and values — the classic dev, staging and production of a single application. Use separate directories when the environments differ in structure, in providers, in resources, or in who may change them — or when the team is large enough that an accidental apply to the wrong workspace is a real risk, because a directory makes the target visible in a way a workspace name in a prompt does not. And use modules in both cases, because the shared code should live in a module either way. If you are unsure which of the first two fits, choose separate directories: the cost of duplication is small, the cost of a production incident caused by a workspace mistake is large, and the duplication can always be reduced later by moving the shared code into a module.</p>
<h2>Workspaces in HCP Terraform</h2>
<p>In HCP Terraform — HashiCorp's managed Terraform platform, formerly Terraform Cloud — the word "workspace" means something larger, and the difference matters if you move from the CLI to the platform. An HCP Terraform workspace is a group of infrastructure resources managed by Terraform, with its own variables, its own run history, its own permissions, and its own connection to a version control repository. Each workspace belongs to a project, and its name must be unique within the organisation. You create workspaces in the HCP Terraform UI, through the workspaces API, with the <code>tfe</code> provider's <code>tfe_workspace</code> resource, or through no-code provisioning from a registry module — and a deleted workspace can be recovered within 30 days, provided the organisation has recovery enabled and holds a paid subscription.</p>
<p>The important difference is that an HCP Terraform workspace is an environment with a workflow, not just a state partition. It has an execution mode — remote, or agent-based on your own agents — and a workflow type, most commonly the VCS workflow, where a push to a connected repository triggers a plan automatically. It has variables of its own, including sensitive variables never shown in plain text, and run triggers, so a successful apply in one workspace can trigger a plan in another. And it has permissions: creating and managing workspaces requires a team with the Manage all projects, Manage all workspaces or project Admin permission. That permission model is the boundary CLI workspaces lack — in HCP Terraform, you can genuinely prevent an engineer from applying to production.</p>
<p>The relationship is straightforward: a CLI workspace partitions state within one backend configuration, while an HCP Terraform workspace is a managed environment that holds its own state, variables and history. When you use the HCP Terraform remote backend, your CLI configuration connects to one HCP Terraform workspace, and switching environments means switching HCP Terraform workspaces, not CLI workspaces. If your team is moving to HCP Terraform, plan for that shift of mental model explicitly.</p>
<p>One practical note on cost: HCP Terraform is a paid platform, and workspace recovery requires a paid subscription. The legacy free tier ended on 31 March 2026, according to a 2026 guide that tracked the change — check the current pricing page before planning a migration. The CLI, by contrast, is free, and CLI workspaces cost nothing beyond backend storage. HCP Terraform workspaces buy you a permission model, a run history and a VCS workflow, and the price is a subscription.</p>
<h2>When Not to Use Workspaces</h2>
<p>Workspaces are a good tool for a narrow job, and the rest of this section is the list of situations where they are the wrong tool. Each one is a pattern seen in real teams, and each one ends the same way: a production incident, or a configuration nobody can change safely.</p>
<p><strong>When the environments differ in structure.</strong> If production has resources that development does not — a multi-region database, a private network, a backup vault — then one configuration with workspace conditionals is lying about what it describes. The conditionals multiply, the maps grow, and eventually nobody can tell what production contains without running a plan against the production workspace, which is exactly the operation you wanted to avoid. Use separate directories, and let the difference be explicit.</p>
<p><strong>When the environments need different access.</strong> A workspace has no permission model. Anyone who can run Terraform against the configuration can select the production workspace and apply to it, and the only thing standing between them and production is their own care. If your organisation needs to restrict who may change production — and most organisations do, once they are large enough to have a production incident — then workspaces cannot provide that boundary. Use separate directories with separate backend permissions, or HCP Terraform workspaces with their team-based permissions.</p>
<p><strong>When the team is large or the stakes are high.</strong> The failure mode of workspaces is applying to the wrong workspace, and the probability rises with the number of people running Terraform. The asterisk in <code>terraform workspace list</code> is a thin defence. If a wrong-workspace apply would be a serious incident, the visibility of a directory — where the target is in the path you typed — is worth the duplication. Ask concretely: if someone applied to production thinking they were in staging, how would you know, and how fast?</p>
<p><strong>When you need different providers or provider versions per environment.</strong> A workspace shares one configuration, and therefore one provider configuration. If staging needs a different provider, a different region, or a different provider version from production, workspaces cannot express that without conditionals that make the configuration unreadable. Separate directories can, because each directory has its own provider block.</p>
<p><strong>When the state itself is the problem.</strong> Workspaces do not solve state size, state locking contention, or the blast radius of a single state file. If your state is large enough that plans are slow, or your team is large enough that applies queue behind one another's locks, splitting by workspace does not help — each workspace still holds a whole environment's state. The answer is to split the configuration into smaller pieces, with separate state per piece.</p>
<p>The short version of all five: workspaces are for near-identical environments that differ in size and values, run by a small team, where an accidental apply to the wrong workspace would be embarrassing rather than catastrophic. Outside that envelope, separate directories or HCP Terraform workspaces are the better answer — and the cost of choosing wrong is a production incident, which is why this section is the longest in the guide.</p>
<h2>A Practical Pattern That Works</h2>
<p>For a team that fits the workspace envelope — a small team, one application, three near-identical environments — here is a pattern that works, end to end, and that you can adopt without inventing anything.</p>
<p><strong>Keep one configuration, one module, three workspaces.</strong> The module holds the resources; the root configuration calls it once, with inputs looked up from maps keyed by <code>terraform.workspace</code>. The differences between environments live in those maps, and nowhere else: instance sizes, replica counts, and the environment tag. The backend is remote — S3 with native state locking, or the equivalent on your cloud — and the backend configuration is the same for all three workspaces, so that the state partition is the backend's job, not yours. Our <a href="https://devopsjobupdates.com/terraform-state-explained/">Terraform State Explained</a> covers the S3 backend and its locking in detail, including the native locking that arrived in Terraform 1.10 and became generally available in 1.11.</p>
<p><strong>Run Terraform from CI, not from laptops.</strong> The CI pipeline selects the workspace explicitly — the workspace name is a parameter of the job, visible in the pipeline's output — and the plan is posted for review before any apply. The production job requires an approval, and the approval is a human clicking a button. This is the permission boundary that workspaces lack, built in the pipeline instead: the pipeline, not the workspace, decides who may apply to production.</p>
<p><strong>And keep a written record of what each workspace contains.</strong> A short file in the repository — three lines, one per workspace, naming the environment, the workspace, and the variable file it uses — is enough. The file's purpose is not documentation for its own sake; it is to make the answer to "which workspace is production?" a fact in the repository rather than a fact in one person's head. The day that fact lives only in someone's head is the day someone applies to the wrong workspace, and the file costs nothing to write.</p>
<p>That is the whole pattern: one configuration, one module, three workspaces, a remote backend, CI-driven applies with approval for production, and a written record. It is deliberately boring, and boring is the point — the exciting workspace setups are the ones that produce incidents, and the boring ones are the ones that run for years without anyone thinking about them.</p>
<h2>FAQ</h2>
<p><strong>What is a Terraform workspace?</strong></p>
<p>A workspace is a named container for state, attached to a single configuration. Each workspace keeps its own state file, so the same configuration can manage separate sets of resources — typically development, staging and production. You are always in a workspace; the default is called <code>default</code>.</p>
<p><strong>How do I create and switch workspaces?</strong></p>
<p><code>terraform workspace new staging</code> creates a workspace called staging and switches to it. <code>terraform workspace select production</code> switches to an existing workspace. <code>terraform workspace list</code> shows all workspaces with the current one marked by an asterisk, and <code>terraform workspace show</code> prints the current workspace name.</p>
<p><strong>How is a workspace different from a module?</strong></p>
<p>A workspace reuses one configuration across copies of the same system, differing only in state and in values looked up by workspace name. A module packages configuration for reuse across different systems. They compose: a workspace-based setup usually calls a module with workspace-dependent inputs.</p>
<p><strong>When should I not use workspaces?</strong></p>
<p>When the environments differ in structure, when they need different access controls, when the team is large enough that a wrong-workspace apply is a real risk, when different providers or provider versions are needed per environment, or when the problem is state size or locking contention rather than environment separation. In those cases use separate directories, or HCP Terraform workspaces with their permission model.</p>
<p><strong>What is the difference between a CLI workspace and an HCP Terraform workspace?</strong></p>
<p>A CLI workspace is a state partition within one backend configuration. An HCP Terraform workspace is a managed environment with its own variables, run history, permissions and version-control connection, and its name must be unique within the organisation. When you use the HCP Terraform remote backend, the HCP Terraform workspace is the unit of state, and CLI workspace commands do not apply in the same way.</p>
<h2>Conclusion</h2>
<p>Terraform workspaces are a small, precise tool: a named container for state behind a single configuration, letting you run the same infrastructure three times — development, staging, production — with different sizes and values and separate state. The commands are five and the mechanism is one value, <code>terraform.workspace</code>, looked up in a map. Used inside their envelope — near-identical environments, a small team, differences of size and value rather than structure — they are the simplest answer to the environments problem, and they have been since workspaces were introduced. Used outside it, they are a way to hide real differences behind conditionals, to give everyone access to production, and to produce the wrong-workspace apply that every team dreads.</p>
<p>The decision rule is the guide in one paragraph: workspaces for same-shape environments that differ in size and values; separate directories when the environments differ in structure, providers or access; modules in both cases for the shared code; and HCP Terraform workspaces when you need a permission model, a run history and a VCS workflow, at the price of a subscription. And whatever you choose, run Terraform from CI with the workspace as a named parameter, keep a written record of which workspace is which environment, and run <code>terraform workspace show</code> before every apply — because the cheapest production incident is the one you never have. For the foundations, our <a href="https://devopsjobupdates.com/terraform-tutorial-beginners/">Terraform Tutorial for Beginners</a> covers the workflow, our <a href="https://devopsjobupdates.com/terraform-state-explained/">Terraform State Explained</a> covers backends and locking, and our <a href="https://devopsjobupdates.com/terraform-modules-tutorial/">Terraform Modules Tutorial</a> covers the modules this guide's pattern is built on.</p>
<p>Sources checked 30 Nov 2026: GitHub hashicorp/terraform releases (1.17.2, 11 Nov 2026; 1.17.1, 28 Oct 2026; 1.17.0, 21 Oct 2026; Terraform Policy generally available in 1.17.0); HashiCorp Developer HCP Terraform workspaces documentation (a workspace is a group of infrastructure resources managed by Terraform; each workspace belongs to a project; creation via UI, workspaces API, <code>tfe</code> provider or no-code provisioning; deleted workspaces recoverable within 30 days with recovery enabled and a paid subscription; workspace names 90 characters or fewer recommended); Terraform CLI workspace commands via command references checked 30 Nov 2026 (workspace list, show, new, select, delete, delete -force; <code>terraform.workspace</code> in configuration; install page showed 1.17.1 as latest on 27 Nov 2026, superseded by the 1.17.2 release listing of 11 Nov 2026). NOT VERIFIED on an official page and therefore not stated as fact above: the HCP Terraform legacy free tier end date of 31 March 2026 (reported by a 2026 guide, not verified on HashiCorp's pricing page — stated in this article only as a reported claim, with a direction to check the pricing page); HCP Terraform bundle prices and any per-workspace pricing (not stated). External references: <a href="https://developer.hashicorp.com/terraform/cloud-docs/workspaces/create">HashiCorp Developer — Create workspaces in HCP Terraform</a> · <a href="https://github.com/hashicorp/terraform/releases">GitHub — hashicorp/terraform releases</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Kubernetes Ingress Tutorial: NGINX, Routing, TLS for Beginners]]></title><description><![CDATA[Every application running in Kubernetes eventually needs the same thing: a way for traffic from outside the cluster to reach it. A Service gives your Pods…]]></description><link>https://devopsjobupdates.hashnode.dev/kubernetes-ingress-tutorial-nginx-routing-tls-for-beginners</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/kubernetes-ingress-tutorial-nginx-routing-tls-for-beginners</guid><category><![CDATA[Kubernetes]]></category><category><![CDATA[ingress]]></category><category><![CDATA[networking]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:40:48 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>Every application running in Kubernetes eventually needs the same thing: a way for traffic from outside the cluster to reach it. A Service gives your Pods a stable address inside the cluster, but it does not, on its own, give the outside world a front door. That front door is Ingress — a collection of rules that lets inbound connections reach the endpoints defined by a backend, with load balancing, TLS termination and name-based virtual hosting built in. If Kubernetes is the building, Ingress is the reception desk: one address, a set of rules about who goes where, and a secure connection for everyone who walks in.</p>
<p>This tutorial teaches Ingress from zero, as it stands on 30 November 2026 — and the date matters, because the Ingress landscape changed this year. The community Ingress-NGINX controller, the one most tutorials still tell you to install, was retired in March 2026 and now receives no releases, bugfixes or security patches. A beginner who follows a tutorial from 2025 will install unmaintained software on the edge of their cluster. This guide explains what was retired, what replaces it, and how to build a working Ingress setup with a maintained controller, host and path routing, and TLS — then shows you the Gateway API, the successor Kubernetes recommends for new work. If you are new to Kubernetes itself, start with our <a href="https://devopsjobupdates.com/kubernetes-tutorial-beginners/">Kubernetes Tutorial for Beginners</a> and our <a href="https://devopsjobupdates.com/kubernetes-deployment-yaml-tutorial/">Kubernetes Deployment YAML Tutorial</a> first; this guide assumes you can already deploy an application and expose it with a Service. Our <a href="https://devopsjobupdates.com/networking-basics-for-devops-engineers/">Networking Basics for DevOps Engineers</a> covers the underlying concepts — DNS, TLS, load balancing — that Ingress builds on.</p>
<h2>What Ingress Is and How Traffic Flows</h2>
<p>Ingress is an API object that manages external access to Services in a cluster, typically HTTP and HTTPS. It is a collection of rules, and each rule maps traffic — by hostname, by URL path, or both — to a backend Service. An Ingress can give Services externally-reachable URLs, load balance traffic across the Pods behind a Service, terminate TLS so the connection from the client is encrypted, and offer name-based virtual hosting, where several hostnames share a single IP address and the Ingress routes each one to a different Service.</p>
<p>The traffic flow has three parts. The Ingress resource is the YAML you write: the rules, the hosts, the paths, the TLS configuration. The Ingress controller is the software that reads those rules and makes them real — usually a reverse proxy and load balancer running as Pods in your cluster, watching for Ingress resources and reconfiguring itself whenever one changes. And the load balancer in front of the controller — often a cloud load balancer — is what gives the controller a public IP address. A request arrives at the load balancer, passes to the controller, and the controller matches it against your rules and forwards it to the right Service, which forwards it to a Pod.</p>
<p>Two facts about Ingress surprise beginners. First, an Ingress resource does nothing on its own. Creating the YAML without a controller running in the cluster is like writing a set of directions and never hiring a driver: the resource exists, the rules are stored, and no traffic moves. You must install a controller, and the controller you choose determines which features your rules can actually use. Second, the Ingress API is frozen. It became generally available in Kubernetes v1.19 in 2020, and Kubernetes states plainly that it is frozen — new features are being added to the Gateway API instead. The API is not deprecated and there are no plans to remove it, but it will not gain new capabilities. That frozen status is the context for everything else in this guide: Ingress still works, and will keep working, but the future of Kubernetes networking is elsewhere.</p>
<p>The Ingress resource itself is simple, and that simplicity is both its strength and its limit. A minimal Ingress has an <code>apiVersion</code> of <code>networking.k8s.io/v1</code>, a <code>kind</code> of Ingress, a <code>spec</code> with an <code>ingressClassName</code> naming the controller that should serve it, and a list of rules. Each rule has a <code>host</code> and an <code>http</code> block with paths, and each path has a <code>path</code>, a <code>pathType</code> — <code>Prefix</code> or <code>Exact</code> — and a <code>backend</code> naming a Service and a port. The <code>tls</code> block, when present, names the hosts the TLS certificate covers and the Secret that holds the certificate. That is the whole resource. Everything beyond it — rewrites, rate limiting, authentication, canary weights — lives in the controller, and historically it lived there as annotations, which is where the trouble started.</p>
<h2>The ingress-nginx Retirement — What Actually Happened</h2>
<p>If you learned Kubernetes before 2026, the controller you learned was almost certainly ingress-nginx — the community project under <code>kubernetes/ingress-nginx</code> that used NGINX as its reverse proxy and load balancer. It was the default answer in most tutorials, the default in minikube's ingress addon, and by some estimates it ran in around half of cloud-native environments. In March 2026 it was retired. Here is the timeline, from the Kubernetes project's own announcements as reported in November 2026.</p>
<table>
<thead>
<tr>
<th>Date</th>
<th>What happened</th>
</tr>
</thead>
<tbody><tr>
<td>11 Nov 2025</td>
<td>Kubernetes SIG Network and the Security Response Committee announce the retirement: best-effort maintenance until March 2026, then no more</td>
</tr>
<tr>
<td>19 Mar 2026</td>
<td>Final ingress-nginx releases ship: controller v1.15.1, v1.14.5, v1.13.9</td>
</tr>
<tr>
<td>24 Mar 2026</td>
<td>The kubernetes/ingress-nginx GitHub repository is archived and made read-only</td>
</tr>
<tr>
<td>Mar 2026</td>
<td>SIG Network ships ingress2gateway 1.0, a tool that converts Ingress resources into Gateway API resources</td>
</tr>
<tr>
<td>5 Nov 2026</td>
<td>CVE-2026-116472 is published against ingress-nginx; the Kubernetes project states it will not issue a fix</td>
</tr>
</tbody></table>
<p>Two things drove the decision, and both are worth understanding before you pick a replacement. The first is the maintainer situation: ingress-nginx was used by millions of clusters but was kept alive by one or two people working on it in their spare time, and that is not a sustainable basis for software that sits on the edge of a cluster. The second is the design of the controller itself. Ingress is a small API, so ingress-nginx extended it with annotations — more than 130 of them — and some of those annotations let any user with permission to create an Ingress object inject arbitrary NGINX configuration into the data plane. The clearest example is the configuration-snippet annotation, which let an Ingress author inject raw NGINX config, and that class of vulnerability — annotation-driven configuration injection — was behind the IngressNightmare vulnerabilities of March 2025. The Kubernetes Steering and Security Response Committees concluded that the design could not be fixed incrementally, and retired the project instead.</p>
<p>Three clarifications matter, because the names are easy to mix up. First, the Ingress API itself is not retired — it is generally available, frozen, and still supported; only this one controller is dead. Second, F5's NGINX Ingress Controller is a different project: a separate codebase, maintained by F5/NGINX Inc., available in open-source and commercial forms, and unaffected by the retirement. Third, existing deployments of ingress-nginx keep running — the installation artifacts remain available — but there will be no further releases, bugfixes or security updates. A vulnerability reported in November 2026 will not be fixed, so running ingress-nginx today is running unmaintained software on the edge of your cluster. If your cluster still runs it, the migration section at the end of this guide is the part to read first.</p>
<h2>Your Controller Choices in Late 2026</h2>
<p>With ingress-nginx retired, the choice of controller is the first real decision in any new Ingress setup, and there are three sensible answers depending on what you want. All three are maintained, and all three are worth knowing about.</p>
<p>F5 NGINX Ingress Controller is the path of least resistance if you want to keep your Ingress resources and stay on NGINX. It is the separate F5-maintained controller, shipping releases since November 2016, and F5 publishes a migration tool that maps more than 130 ingress-nginx annotations, plus ConfigMap settings, to it — so a migrating cluster can carry most of its configuration across. Choose this if your team knows NGINX and you want the smallest possible change to a working setup.</p>
<p>A cloud load balancer controller is the right choice if you run on a managed cloud. The AWS Load Balancer Controller, the Google Cloud load balancer integration, and Azure's Application Gateway Ingress Controller all turn your Ingress resources into cloud load balancers rather than in-cluster proxies. Your existing Ingress resources still work — only the controller behind them changes.</p>
<p>A Gateway API implementation is the long-term choice, and the one Kubernetes recommends for new work. Envoy Gateway, Traefik, Cilium, Istio, Kong and NGINX Gateway Fabric all implement the Gateway API, and the API is where the ecosystem's development now happens. This is a bigger change than swapping controllers — it means writing Gateway, HTTPRoute and related resources instead of Ingress resources — but it is the stack that will still be gaining features in three years' time. Choose this if you are starting fresh, or if you are migrating anyway and would rather move once to the future than twice.</p>
<p>For the hands-on part of this tutorial we use the F5 NGINX Ingress Controller, because it is the closest thing to the setup most readers already know, it is maintained, and its installation is a single Helm chart or a set of manifests. The routing and TLS sections below are written against the Ingress API itself, so the concepts transfer to any controller — but the exact annotation names and the installation steps are the NGINX Ingress Controller's, and if you choose a different controller, read its documentation for the equivalents. Kubernetes itself says the same thing in its Ingress documentation: review your controller's documentation to understand the caveats of choosing it.</p>
<h2>A First Ingress, Step by Step</h2>
<p>Start with a cluster running Kubernetes 1.37 — the current stable release — and an application already deployed and exposed by a Service. If you do not have one, deploy the standard NGINX demo: a Deployment with two replicas of the <code>nginx</code> image, and a ClusterIP Service named <code>web</code> on port 80 in front of it. Our <a href="https://devopsjobupdates.com/kubernetes-deployment-yaml-tutorial/">Kubernetes Deployment YAML Tutorial</a> walks through that Deployment manifest field by field if you need it.</p>
<p>First, install the controller. With Helm, add the NGINX Ingress Controller chart repository and install the chart into its own namespace, which creates the controller Deployment, its Service of type <code>LoadBalancer</code>, and the IngressClass it will serve. With plain manifests, apply the controller's install YAML from the project's documentation. Either way, verify the installation before you write any Ingress resource: the controller Pods should be running, and the controller's Service should have an external IP address or hostname. That address is the front door of your cluster — note it down, because it is the address your DNS records will point at.</p>
<p>Second, write the Ingress resource. A minimal one for a single host looks like this:</p>
<pre><code class="language-yaml">apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-ingress
  namespace: default
spec:
  ingressClassName: nginx
  rules:
  - host: web.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web
            port:
              number: 80
</code></pre>
<p>Apply it with <code>kubectl apply -f</code>, then check it with <code>kubectl get ingress</code> and <code>kubectl describe ingress web-ingress</code>. The describe output shows the address the controller has assigned and the rules it has loaded — if the address is empty, the controller is not serving this Ingress, and the first thing to check is the <code>ingressClassName</code>: it must match the IngressClass your controller owns, and a mismatch is the most common reason a first Ingress does nothing. The second most common reason is the namespace: an Ingress can only route to Services in its own namespace, so an Ingress in <code>default</code> cannot reach a Service in <code>production</code>.</p>
<p>Third, test it. Add the controller's external IP to your machine's hosts file against <code>web.example.com</code>, then request it with curl. You should get the NGINX welcome page from your application. If you get a 404, the rule matched nothing — check the host and the path. If you get a 502, the controller matched the rule but could not reach the Service — check that the Service exists, that its selector matches the Pods, and that the Pods are running. If you get no response at all, the load balancer or the controller Service is the problem, not the Ingress. Debugging in that order — load balancer, controller, Ingress, Service, Pod — is the habit that saves hours.</p>
<h2>Routing — Hosts, Paths, Rewrites and Canaries</h2>
<p>A single host and a single path is the beginning, not the end. Real Ingress setups route several applications through one controller, and the routing rules are where Ingress earns its keep. Three patterns cover most of what a beginner needs.</p>
<p>Name-based virtual hosting is the first: several hostnames share one IP address, and the Ingress routes each hostname to a different Service — <code>api.example.com</code> to an <code>api</code> Service, <code>web.example.com</code> to the <code>web</code> Service — using the Host header of each request. This is how a small cluster serves a website, an API and an admin interface from a single load balancer. The catch is DNS: every hostname in your rules needs a DNS record pointing at the controller's address.</p>
<p>Path-based routing is the second: one hostname, several paths, each path to a different Service. A rule for <code>example.com/</code> pointing at the <code>web</code> Service and a rule for <code>example.com/api</code> pointing at the <code>api</code> Service is the classic shape, and the <code>pathType</code> field decides how the matching works. <code>Prefix</code> matches the path and everything beneath it, so <code>/api</code> matches <code>/api/users</code> and <code>/api/users/123</code>; <code>Exact</code> matches only the path itself. The exam-style mistake is to use <code>Exact</code> where you meant <code>Prefix</code> and then wonder why <code>/api/users</code> returns a 404. Note also that the path the application sees is the full path unless the controller rewrites it — an application behind <code>/api</code> that expects requests at <code>/</code> will need a rewrite, which is controller-specific and, in the NGINX Ingress Controller, is done with the <code>rewrite-target</code> annotation.</p>
<p>Canary routing is the third, and the one that shows the limits of the Ingress API. Ingress has no native concept of traffic weighting — there is no field that says "send 10% of traffic to the new version". Controllers implement it with annotations, and that is exactly the annotation-driven design the ingress-nginx retirement was a reaction to: traffic splitting is a first-class field in a Gateway API HTTPRoute, not an annotation on an Ingress. If canary deployments matter to you, look at the Gateway API section below rather than building an annotation-heavy canary on Ingress.</p>
<p>One operational habit belongs in this section: keep one Ingress per application, not one Ingress per cluster. A single giant Ingress resource that routes everything is hard to review, hard to roll back, and a single bad edit away from breaking every application at once. One Ingress per application, each in the application's own namespace, is easier to own and easier to fix — and treat Ingress resources like code, stored in version control and applied through your deployment pipeline.</p>
<h2>TLS with cert-manager</h2>
<p>TLS termination is the feature that makes Ingress worth setting up properly, and it is simpler than most beginners expect — provided you automate the certificates. The Ingress resource's <code>tls</code> block names the hosts a certificate covers and the Secret that holds the certificate, and the controller terminates TLS at the edge: the client connects over HTTPS to the controller, the controller decrypts the traffic, and the traffic from the controller to the Pod travels over plain HTTP inside the cluster. That last hop is unencrypted by design in most setups, and it is acceptable because it never leaves the cluster — but if your threat model requires encryption all the way to the Pod, you need end-to-end TLS, which is a controller feature rather than an Ingress feature, and a reason to read your controller's documentation carefully.</p>
<p>The certificates themselves should come from cert-manager, the standard tool for automating certificates in Kubernetes. Install cert-manager, create a ClusterIssuer that talks to Let's Encrypt — the staging issuer first, while you are testing, because the production issuer has rate limits — and add the <code>cert-manager.io/cluster-issuer</code> annotation to your Ingress. Cert-manager watches the Ingress, requests a certificate for the hosts in the <code>tls</code> block, stores it in the named Secret, and renews it before it expires, with no human involvement once set up.</p>
<p>The mistakes to avoid are all in the setup. The first is testing against the production Let's Encrypt issuer: use the staging issuer until the flow works end to end, then switch to production, because the production rate limits are unforgiving of a misconfigured ClusterIssuer. The second is <strong>a host in the tls block that has no DNS record: Let's Encrypt validates ownership by reaching the host, and a host that does not resolve cannot be validated. The third is a Secret name that collides</strong>: cert-manager creates the Secret named in the tls block, and if a Secret with that name already exists with the wrong contents, delete the stale Secret and let cert-manager recreate it. And the fourth is forgetting the redirect: once TLS works, add the controller's <code>force-SSL-redirect</code> so plain HTTP requests are redirected to HTTPS rather than served.</p>
<h2>Gateway API — the Successor, and When to Move</h2>
<p>The Gateway API is the successor to Ingress, and it is worth understanding even if you are not ready to move to it yet, because it is where Kubernetes networking is heading. It is a family of API kinds that provide dynamic infrastructure provisioning and advanced traffic routing, and it has been generally available since 2023. Where Ingress is a single resource with a frozen spec, Gateway API splits the job across four stable kinds, each owned by a different role in an organisation.</p>
<p><code>GatewayClass</code> defines a set of gateways with a common configuration, and is managed by the controller — the infrastructure provider's role. <code>Gateway</code> defines an instance of traffic-handling infrastructure, such as a cloud load balancer, and is owned by the cluster operator. <code>HTTPRoute</code> defines the HTTP-specific rules that map traffic from a Gateway listener to backend Services, and is owned by the application developer. <code>GRPCRoute</code> does the same for gRPC traffic. The role-oriented split is the point: each role owns a resource shaped for its job, without being able to break the others' configuration — the structural answer to the annotation problem that killed ingress-nginx.</p>
<p>Gateway API is also more expressive than Ingress where it matters. Header-based matching, traffic weighting for canary deployments, request timeouts and retries, and request mirroring are first-class fields in the API rather than controller-specific annotations, so a route written against the Gateway API is portable between implementations — Envoy Gateway, Traefik, Cilium, Istio, Kong, NGINX Gateway Fabric — in a way an annotation-heavy Ingress never was.</p>
<p>When should you move? The migration tooling is ready: SIG Network shipped <code>ingress2gateway</code> 1.0 in March 2026, a tool that reads your existing Ingress resources and converts them into Gateway API resources, with converters for nine providers including ingress-nginx, NGINX, Traefik, Istio and Kong, and the 1.0 release expanded support from 3 to more than 30 ingress-nginx annotations. The tool handles the structural conversion and the common annotations, and it warns you about what it cannot translate so you can decide by hand. The migration itself splits into two halves: the mechanical half, converting hosts and paths and backends, which <code>ingress2gateway</code> does for you; and the annotation half, inventorying the behaviours you rely on — regex paths, rewrites, canary weights, configuration snippets — and deciding what each one becomes under Gateway API, because some of them change meaning and some vanish. That inventory is the step nobody likes and the step that decides whether a migration succeeds.</p>
<p>The practical advice is simple. If you are starting fresh, start with Gateway API. If you already run Ingress on a maintained controller, there is no urgency: the Ingress API is not deprecated, your resources keep working, and you can migrate when you have a reason to, such as a canary deployment. And if you still run ingress-nginx, migrate now — to the F5 NGINX Ingress Controller, a cloud load balancer controller, or a Gateway API implementation. The controller is the urgent part. The API can wait.</p>
<h2>FAQ</h2>
<p><strong>What is the difference between Ingress and a LoadBalancer Service?</strong></p>
<p>A <code>LoadBalancer</code> Service exposes one Service on one cloud load balancer, with one IP address per Service. An Ingress exposes many Services through one load balancer, routing by hostname and path, with TLS termination in one place. Ingress is cheaper and simpler to operate when you have more than a couple of Services; a <code>LoadBalancer</code> Service is simpler when you have exactly one.</p>
<p><strong>Do I still need an Ingress controller if I create an Ingress resource?</strong></p>
<p>Yes. An Ingress resource on its own does nothing — it is a set of rules stored in the cluster. A controller reads those rules and configures a reverse proxy and load balancer to enforce them. Without a controller, no traffic moves, whatever your YAML says.</p>
<p><strong>Is ingress-nginx really dead? Should I remove it today?</strong></p>
<p>The community project <code>kubernetes/ingress-nginx</code> was retired in March 2026: the final releases shipped on 19 March 2026, the repository was archived on 24 March 2026, and there will be no further releases, bugfixes or security patches. Existing deployments keep running, but they are unmaintained, and a vulnerability published in November 2026 will not be fixed. Plan a migration to a maintained controller or to the Gateway API rather than waiting.</p>
<p><strong>What is the difference between ingress-nginx and the NGINX Ingress Controller?</strong></p>
<p>They are different projects with similar names. Ingress-nginx was the Kubernetes community project under SIG Network, now retired. The NGINX Ingress Controller is F5/NGINX Inc.'s separate controller, still maintained, available in open-source and commercial forms, and unaffected by the retirement. F5 publishes a migration tool that maps ingress-nginx annotations to it.</p>
<p><strong>Should I learn Ingress or Gateway API in 2026?</strong></p>
<p>Learn Ingress first, because it is what most clusters still run and the concepts — hosts, paths, backends, TLS termination — are the same. Then learn Gateway API, because it is the successor: generally available since 2023, role-oriented, more expressive, and where the ecosystem's development happens. For a new cluster, start with Gateway API; for an existing Ingress setup on a maintained controller, migrate when you have a reason to.</p>
<h2>Conclusion</h2>
<p>Ingress is the front door of a Kubernetes cluster: one address, a set of rules about who goes where, and TLS termination for everyone who walks in. The resource itself is simple — hosts, paths, backends, a TLS block — and the controller behind it is where the real behaviour lives. That is why the retirement of ingress-nginx in March 2026 matters so much: the controller most tutorials still tell you to install is unmaintained, with no further releases, bugfixes or security patches. The Ingress API itself is fine — generally available since 2020, frozen but not deprecated — and the maintained replacements are ready, whether that is the F5 NGINX Ingress Controller, a cloud load balancer controller, or a Gateway API implementation.</p>
<p>Build your first Ingress on a maintained controller, route by host and path, automate TLS with cert-manager against the staging issuer first, and keep one Ingress per application in version control. Then look at the Gateway API, because it is where Kubernetes networking is heading, and because its role-oriented model — <code>GatewayClass</code>, <code>Gateway</code>, <code>HTTPRoute</code> — is the structural answer to the annotation problem that ended ingress-nginx. And if your cluster still runs the retired controller, start the migration now: use <code>ingress2gateway</code> to convert the structure, inventory your annotations by hand, and move before the next vulnerability, not after it. For the foundations underneath all of this, our <a href="https://devopsjobupdates.com/kubernetes-tutorial-beginners/">Kubernetes Tutorial for Beginners</a> and our <a href="https://devopsjobupdates.com/networking-basics-for-devops-engineers/">Networking Basics for DevOps Engineers</a> cover the concepts, and our <a href="https://devopsjobupdates.com/kubernetes-deployment-yaml-tutorial/">Kubernetes Deployment YAML Tutorial</a> covers the manifests you will write before you ever create an Ingress.</p>
<p>Sources checked 30 Nov 2026: Kubernetes documentation, Ingress concepts page (Ingress is a collection of rules allowing inbound connections to reach endpoints defined by a backend; Ingress may provide load balancing, SSL termination and name-based virtual hosting; feature state Kubernetes v1.19 stable; "Ingress is frozen. New features are being added to the Gateway API"); Kubernetes documentation, Gateway API page (Gateway API is a family of API kinds providing dynamic infrastructure provisioning and advanced traffic routing; role-oriented, portable, expressive; four stable kinds GatewayClass, Gateway, HTTPRoute, GRPCRoute); Google Open Source Blog networking post (Ingress NGINX maintenance ceases March 2026; Ingress API still available with no immediate plans for deprecation; F5 NGINX Ingress Controller continues to be maintained in open-source and commercial forms); NGINX community blog, KubeCon North America 2026 report (community Ingress-NGINX retired March 2026, no releases, bugfixes or security patches; migration tool maps 130+ annotations to NGINX Ingress Controller; ingress2gateway with NGINX emitter for Gateway API); Collabnix migration guide (Kubernetes project stopped maintaining Ingress-NGINX in March 2026; ingress2gateway 1.0 shipped March 2026; Kubernetes 1.37 current stable release); community migration checklists checked 30 Nov 2026 (retirement announced 11 Nov 2025; final releases 19 Mar 2026, controller v1.15.1, v1.14.5, v1.13.9; repository archived 24 Mar 2026; ingress2gateway 1.0 released 20 Mar 2026 with 30+ annotation converters). NOT VERIFIED on an official Kubernetes page and therefore flagged here: CVE-2026-116472 (published 5 Nov 2026, reported by a community checklist as a mirror-target annotation vulnerability with no fix forthcoming — not verified on kubernetes.io, and stated in this article only as a reported claim); the estimate that ingress-nginx ran in around 50% of cloud-native environments (SIG Network estimate as reported by a community post, not verified on an official page). External references: <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/">Kubernetes documentation — Ingress</a> · <a href="https://kubernetes.io/docs/concepts/services-networking/gateway/">Kubernetes documentation — Gateway API</a>.</p>
]]></content:encoded></item><item><title><![CDATA[DevOps Engineer Salary in Germany and the Netherlands 2026: What to Expect]]></title><description><![CDATA[Germany and the Netherlands are the two countries in continental Europe where a DevOps engineer can most realistically build a well-paid career without…]]></description><link>https://devopsjobupdates.hashnode.dev/devops-engineer-salary-in-germany-and-the-netherlands-2026-what-to-expect</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/devops-engineer-salary-in-germany-and-the-netherlands-2026-what-to-expect</guid><category><![CDATA[Devops]]></category><category><![CDATA[Career]]></category><category><![CDATA[salary]]></category><category><![CDATA[Germany]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:36:27 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>Germany and the Netherlands are the two countries in continental Europe where a DevOps engineer can most realistically build a well-paid career without leaving the continent. Berlin, Munich and Amsterdam host the engineering offices of global technology companies, a dense network of scale-ups, and the European headquarters of firms that pay at or near international levels. Both countries also run immigration routes designed for skilled technology workers, and both pay in euros, which makes comparing an offer in Berlin with one in Amsterdam a straightforward exercise.</p>
<p>The hard part is knowing what the offer should be. Published figures for these two countries disagree widely, because the sources measure different things, cover different cities, and draw on different samples. This guide does not pick a winner: it gives you the ranges each named source actually reports, explains why they differ, and shows you how to use them — what each level can expect in each country, what moves you up the range, what tax and benefits do to the gross figure, and how to negotiate in Berlin or Amsterdam. Every figure below is a range with a named source. No figure in this article is a single number presented as “the” salary, and no figure is unsourced. If a figure could not be sourced, it is left out and flagged in the Sources line at the end. For the English-speaking markets, our <a href="https://devopsjobupdates.com/devops-engineer-salary-usa-uk-canada-australia/">DevOps Engineer Salary in USA, UK, Canada and Australia</a> covers the same ground, and our <a href="https://devopsjobupdates.com/devops-engineer-roadmap-2026/">DevOps Engineer Roadmap 2026</a> maps the skills that move you between the levels discussed here.</p>
<h2>How to Read These Numbers — Ranges, Not Answers</h2>
<p>Before any figure, the method matters, because the method is why the figures disagree. Four things differ between the sources in this guide, and each one moves the numbers.</p>
<p><strong>First, base salary versus total compensation.</strong> Glassdoor's headline figures for Germany are base pay — the fixed gross salary before tax, excluding bonuses and stock. Levels.fyi reports total compensation, which is base salary plus the yearly value of stock grants plus bonus, and its figures therefore run higher than Glassdoor's for the same role at the same company. Neither is wrong; they measure different things. Comparing a levels.fyi total-compensation figure with a Glassdoor base-pay figure is comparing two different quantities, and it is the single most common mistake in salary research for these countries.</p>
<p><strong>Second, who reports the data.</strong> Glassdoor's German DevOps figures rest on 1,062 salaries submitted anonymously by employees in Germany as of November 2026 — a large sample, but self-reported and skewed towards the companies whose employees use Glassdoor. Join.com's guide draws on German salary data including the federal statistics office's earnings survey, the Stepstone salary report and Glassdoor, and breaks its figures down by level. Levels.fyi's data comes from its own salary submissions, which skew towards large technology companies that pay in stock. A source with 31 observations will disagree with a source with a thousand, and a source built on big-tech submissions will disagree with one built on the whole market.</p>
<p><strong>Third, where the job is.</strong> Berlin and Munich pay above the German national average — one 2026 guide puts the premium at 10–15% — and Amsterdam pays above the Dutch national average, with Rotterdam, Utrecht, Eindhoven and The Hague sitting below Amsterdam. A national figure and a Berlin figure are not interchangeable, and this guide says which one it is quoting every time.</p>
<p><strong>Fourth, gross versus net.</strong> Every figure in this article is gross, before tax — the figure on the contract, not the figure in the bank account. German and Dutch tax and social contributions take a large share of gross pay, and the gap between gross and net is the first surprise for engineers relocating from countries with lower deductions. The tax section below explains the shape of that gap without inventing rates.</p>
<p>One more warning: the sources do not just differ at the edges. One modelled site, working from 31 salary observations, puts the German mid-level figure far above the range Glassdoor and join.com report, and its own pages flag its figures as low-confidence modelled estimates — so this guide does not use them. When a figure online sits far outside the ranges below, check the sample size and the method before you believe it.</p>
<h2>Germany — Pay Ranges by Level</h2>
<p>Germany is the larger of the two markets, and the one with the most data. The ranges below are gross base salary per year, in euros, unless a source is explicitly described as total compensation.</p>
<table>
<thead>
<tr>
<th>Level</th>
<th>Glassdoor (Germany, Nov 2026)</th>
<th>join.com (Germany)</th>
</tr>
</thead>
<tbody><tr>
<td>All DevOps Engineers</td>
<td>Base €56,000–€70,000; typical range €58,000–€76,000 (25th–75th percentile)</td>
<td>25th percentile €58,000; 75th percentile €92,000</td>
</tr>
<tr>
<td>Entry-level (0–2 years)</td>
<td>Within the lower half of the overall range</td>
<td>€45,000–€62,000 (25th–75th percentile)</td>
</tr>
<tr>
<td>Mid-level (3–7 years)</td>
<td>Within the middle of the overall range</td>
<td>€58,000–€92,000 (25th–75th percentile)</td>
</tr>
<tr>
<td>Senior (6+ years)</td>
<td>Within the upper half of the overall range</td>
<td>€74,000–€98,000 (25th–75th percentile)</td>
</tr>
</tbody></table>
<p>Read the two columns together and the picture is consistent: a DevOps engineer in Germany typically earns a gross base salary somewhere in the €50,000s to the €90,000s, with the middle of the market in the €60,000s to the €70,000s. Glassdoor's overall base-pay range is €56,000–€70,000 per year, with a typical range — the middle 50% — of €58,000–€76,000. Join.com, which combines federal statistics, Stepstone and Glassdoor data, puts entry-level engineers at €45,000–€62,000, mid-level at €58,000–€92,000, and senior at €74,000–€98,000. The two sources agree closely at the bottom and diverge at the top, which is what you would expect: senior pay varies more, because it depends more on the company, the city and the specialism.</p>
<p>Levels.fyi's total-compensation data sits above both, as it should, because it adds stock grants and bonuses to base pay. That is the point to carry into any negotiation: if an offer includes stock or a bonus, compare its total against levels.fyi and its base against Glassdoor and join.com, and do not mix the two.</p>
<p>Berlin deserves a paragraph of its own, because it is where most international engineers land. Berlin pays above the German national average, and the gap is widest at senior level: one Berlin-focused 2026 guide reports advertised ranges running from the mid €40,000s at entry level to the €130,000s at staff level. Munich pays at a similar premium, driven by its automotive, industrial and enterprise software employers. Smaller cities — Hamburg, Frankfurt, Cologne, Stuttgart — pay closer to the national ranges, and remote roles typically pay to the national range rather than the Berlin one. A Berlin offer should be judged against Berlin ranges, not national ones.</p>
<h2>Netherlands — Pay Ranges by Level</h2>
<p>The Netherlands is a smaller market with less data, and the ranges are wider as a result — but the sources that do cover it agree on the shape: a junior DevOps engineer in the low-to-mid €40,000s to mid €50,000s, a mid-level engineer in the high €50,000s to low €80,000s, and a senior engineer in the €80,000s to around €110,000, with Amsterdam paying a premium over the rest of the country and the top international employers paying above even Amsterdam's ranges.</p>
<table>
<thead>
<tr>
<th>Level</th>
<th>iTechScope 2026 (Netherlands, mid-level)</th>
<th>Taleva 2026 (Netherlands, DevOps/Platform)</th>
<th>jobrise.io 2026 (Amsterdam)</th>
</tr>
</thead>
<tbody><tr>
<td>Junior (0–2 years)</td>
<td>—</td>
<td>€45,000–€55,000</td>
<td>€45,000–€60,000</td>
</tr>
<tr>
<td>Mid-level (3–5 years)</td>
<td>€60,000–€82,000</td>
<td>€58,000–€78,000</td>
<td>€60,000–€80,000</td>
</tr>
<tr>
<td>Senior (6+ years)</td>
<td>—</td>
<td>€80,000–€110,000</td>
<td>€80,000–€105,000</td>
</tr>
<tr>
<td>Lead / Staff</td>
<td>—</td>
<td>—</td>
<td>€95,000–€125,000</td>
</tr>
</tbody></table>
<p>The three sources converge tightly at mid-level, which is reassuring: iTechScope's 2026 Europe benchmarks, built from levels.fyi and Glassdoor data, put the Dutch mid-level DevOps range at €60,000–€82,000; Taleva's 2026 European tech salary report, built from Glassdoor, levels.fyi, government statistics and its own database, puts it at €58,000–€78,000; and jobrise.io's Amsterdam guide puts the city's mid-level range at €60,000–€80,000. Three independent sources, three overlapping ranges, all in the high €50,000s to low €80,000s — that is a range you can plan around. At junior level the two sources that break it out agree as well, at €45,000–€55,000 and €45,000–€60,000. At senior level they agree at €80,000–€110,000 and €80,000–€105,000. The agreement is the story: for the Netherlands, the mid-level and senior ranges are among the most consistent in this guide.</p>
<p>Amsterdam is to the Netherlands what Berlin is to Germany — the city where the ranges run highest and where most international engineers land. Its senior ranges reach €80,000–€105,000, with lead and staff platform roles at €95,000–€125,000, and the top international employers advertise above even those, with stock on top. Eindhoven pays close to Amsterdam for the right specialisms; Utrecht and The Hague sit a little below Amsterdam, and Rotterdam below that. Judge a national Dutch offer against the national ranges and an Amsterdam offer against the Amsterdam ones.</p>
<p>One Dutch figure that is not a salary range but matters to every offer is the holiday allowance: Dutch employers commonly pay an 8% holiday allowance on top of gross salary, and a 13th month is common in many companies, according to a 2026 Dutch salary benchmark built on the De ICT Recruiter salary guide. That means the gross figure on a Dutch contract is not always the whole cash story — ask whether the quoted figure includes the holiday allowance and any 13th month, and compare offers on the same basis. A German offer has no equivalent allowance, so a Dutch gross figure and a German gross figure are not directly comparable without adjusting for it.</p>
<h2>What Moves You Up the Range</h2>
<p>The ranges above are wide — €45,000 to €98,000 in Germany, €45,000 to €125,000 in the Netherlands — and where you land inside them is not luck. Four factors move an engineer up a range, and they move in roughly the same order in both countries.</p>
<p><strong>Experience level is the first and largest.</strong> The tables show it plainly: each step from junior to mid to senior adds roughly €15,000–€25,000 to the range in both countries. The steps are not automatic with time — they follow scope. A mid-level engineer owns a service end to end; a senior engineer owns a system, mentors others, and makes the design decisions. If your current title says senior but your scope says mid, the market will pay you as a mid, whatever your CV says.</p>
<p><strong>City is the second.</strong> Berlin and Munich in Germany, Amsterdam in the Netherlands, pay premiums over their national ranges — one 2026 guide puts the Berlin and Munich premium at 10–15% over the German national average. The premium roughly tracks the cost of housing rather than exceeding it: a higher gross figure in Amsterdam that is entirely consumed by rent is not a higher standard of living.</p>
<p><strong>Employer type is the third, and the largest single swing at senior level.</strong> Global technology companies with stock-based compensation pay total compensation well above the base-pay ranges in this guide, which is why levels.fyi's total-compensation figures sit above Glassdoor's base-pay figures. German industrial and automotive employers, Dutch banks and insurers, and the public sector pay solidly inside the ranges but rarely above them, and they compensate with stability, working hours and pensions rather than stock. Scale-ups sit in between: base pay inside the range, equity that may or may not be worth anything, and the widest variance of all.</p>
<p><strong>Skills are the fourth.</strong> Kubernetes in production, Terraform at scale, cloud architecture on AWS or Azure, and on-call ownership of a real system are the skills the Berlin and Amsterdam guides name as the ones that move an engineer up a band. A certification on its own does not move pay much — but the skills it represents, demonstrated in production, do.</p>
<h2>Taxes, Benefits and the Gross-to-Net Gap</h2>
<p>Every figure in this article is gross, and the gap between gross and net in Germany and the Netherlands is large enough to change how an offer feels. Both countries run progressive income tax — the rate rises with income — and both deduct social contributions for health insurance, pensions, unemployment and long-term care on top of income tax. The result is that take-home pay is a substantially smaller share of gross pay than an engineer from a low-tax country expects, and the share falls as gross pay rises. This guide does not state tax rates, because rates depend on personal circumstances — marital status, children, tax class in Germany, residency status — and a rate quoted without those caveats would mislead. The practical advice is instead: run any offer through an official or reputable gross-to-net calculator for the country, with your own circumstances, before you accept it, and compare offers on net pay, not gross.</p>
<p>The benefits around the salary matter as much as the tax. German employment typically includes statutory health insurance, a pension contribution, generous statutory holiday — usually around 30 days in technology roles — and strong dismissal protection after probation. Dutch employment typically includes the 8% holiday allowance and often a 13th month, statutory holiday of around 25 days, and a pension scheme. When comparing an offer with one elsewhere, price these in: a lower gross figure with 30 days of holiday, full health cover and a pension is not the same deal as a higher gross figure with none of them.</p>
<p>Two immigration details belong in any salary guide for these countries, because they set a floor under what an offer must be. Germany's EU Blue Card — the main route for non-EU engineers — sets a minimum gross salary threshold, reduced for IT and other shortage occupations; the 2026 threshold is reported at €50,700 gross, reduced to €45,934.20 for IT roles. An offer below the threshold cannot support a Blue Card, whatever the employer promises, so check the threshold for the year you apply. The Netherlands runs the 30% ruling, a tax facility for skilled migrants recruited from abroad that exempts a portion of gross salary from tax for a period of years — it does not change the gross figure, but it changes the net figure materially, and whether an employer will apply for it is a question worth asking before you accept. Both are administrative facts, not salary figures, and both should be confirmed with the relevant authority or an immigration adviser for your situation.</p>
<h2>Negotiating an Offer in Berlin or Amsterdam</h2>
<p>Negotiation in Germany and the Netherlands works differently from negotiation in the United States, and the difference is worth understanding before you start. The ranges in this guide are your leverage, but only if you use them the way these markets expect.</p>
<p><strong>First, know the range before the first call.</strong> Recruiters in Berlin and Amsterdam will ask for your salary expectation early, often in the first conversation. Have an answer ready that is a range, not a number — a range whose bottom is the lowest figure you would accept and whose top sits at the upper end of the market range for your level and city. A single number invites the employer to meet it exactly; a range invites a conversation. Base the range on the sources in this guide, and be ready to name them: “Glassdoor and join.com put the senior range in Germany at roughly €74,000–€98,000” is a stronger position than “I would like a good salary”.</p>
<p><strong>Second, negotiate the whole package, not the base.</strong> A signing bonus, an annual bonus, stock or equity, holiday days, remote-working days, a training budget and a pension contribution are often easier for an employer to move than the base, because they do not set a precedent for the rest of the team. In Germany, where salary bands are often rigid, the signing bonus is frequently where the flexibility lives; in the Netherlands, the 13th month and the holiday allowance are part of the same conversation.</p>
<p><strong>Third, use competing offers honestly.</strong> A competing offer from another Berlin or Amsterdam employer is the strongest negotiating tool there is, and it is expected — recruiters in these markets assume you are talking to more than one company. A competing offer from a different country is weaker leverage, because the employer knows the tax and cost-of-living arithmetic differs. And an invented competing offer is not leverage at all: these are small markets, and the technology communities in Berlin and Amsterdam are smaller still.</p>
<p><strong>Fourth, mind the timing.</strong> The probation period in Germany is typically six months, and a salary review at the end of probation is a common arrangement — get it in writing. In the Netherlands the annual review cycle is usually tied to the calendar year, so ask when the next review would be.</p>
<p><strong>Finally, do not accept a first offer on the call.</strong> Ask for the offer in writing, take a day to compare it against the ranges in this guide and against your other options, run it through a gross-to-net calculator, and then respond. An employer that pressures you to accept on the spot is telling you something about how it treats its people, and it is not good news.</p>
<h2>Relocation and the Job Search</h2>
<p>Most engineers reading this guide will be relocating, and the salary is only part of the relocation decision. Berlin and Munich hire heavily through LinkedIn, Stepstone and company career pages; Amsterdam hires through LinkedIn, local job boards and the international platforms' own Amsterdam offices. English is the working language of most technology teams in both cities. Apply in English unless the description asks for the local language.</p>
<p>The visa routes are straightforward for skilled engineers but slow, and the salary interacts with them. Germany's EU Blue Card requires a recognised degree or equivalent, a job offer, and a gross salary above the threshold described above; the reduced threshold for IT roles makes it accessible to mid-level engineers, not only seniors. The Netherlands' highly skilled migrant route requires a recognised sponsor employer and a salary above a threshold that depends on age — check the current threshold with the Dutch immigration service, as it changes annually. In both cases the employer's HR team will usually handle the application, and the question to ask is not whether they can but how long it will take: three months is a realistic planning figure from offer to start date, and the salary negotiation should account for it.</p>
<p>The cost of living is the last piece, and the one that most often surprises relocating engineers. Rents in Berlin, Munich and Amsterdam are the highest in their countries; a one-bedroom flat in a central district costs a large share of a mid-level net salary, and the city salary premium exists largely because of housing costs. Before accepting an offer, price a flat in the district you would actually live in and compare the result with the net figure from a gross-to-net calculator. A senior salary in a smaller German or Dutch city, with lower rent, can leave more at the end of the month than a higher Berlin or Amsterdam figure.</p>
<h2>FAQ</h2>
<p><strong>What is a typical DevOps engineer salary in Germany in 2026?</strong></p>
<p>There is no single figure — the sources disagree, and the range is the honest answer. Glassdoor reports a base-pay range of €56,000–€70,000 per year with a typical range of €58,000–€76,000, and join.com reports a 25th percentile of €58,000 and a 75th percentile of €92,000. Mid-level engineers sit around €58,000–€92,000 and senior engineers around €74,000–€98,000 on join.com's figures. Berlin and Munich pay a premium over the national ranges.</p>
<p><strong>What is a typical DevOps engineer salary in the Netherlands in 2026?</strong></p>
<p>Again, the range is the answer. The three sources in this guide agree closely at mid-level: €60,000–€82,000 (iTechScope), €58,000–€78,000 (Taleva) and €60,000–€80,000 in Amsterdam (jobrise.io). Junior engineers earn around €45,000–€60,000 and senior engineers around €80,000–€110,000. Amsterdam pays above the national ranges, and Dutch employers commonly add an 8% holiday allowance and often a 13th month.</p>
<p><strong>Why do salary sources disagree so much for Germany and the Netherlands?</strong></p>
<p>Because they measure different things: Glassdoor reports base pay, levels.fyi reports total compensation including stock and bonus, and the samples differ — Glassdoor's German figures rest on 1,062 submitted salaries, while one modelled site bases its figures on 31 observations. City matters too: Berlin and Amsterdam figures are higher than national ones. Compare like with like — base with base, total with total, city with city.</p>
<p><strong>Are these figures gross or net?</strong></p>
<p>Gross, before tax, in every case — the figure on the contract, not the figure in the bank account. German and Dutch tax and social contributions take a large share of gross pay, so run any offer through a gross-to-net calculator with your own circumstances before you accept it, and compare offers on net pay.</p>
<p><strong>Is it worth relocating to Berlin or Amsterdam for a DevOps role?</strong></p>
<p>It can be, for the career as much as the pay: both cities host global technology employers, dense scale-up scenes and international teams, and both offer immigration routes for skilled engineers. But the city salary premium roughly tracks housing costs, so price a flat and run the net-pay arithmetic before you decide — a senior salary in a smaller city can leave more money at the end of the month.</p>
<h2>Conclusion</h2>
<p>DevOps pay in Germany and the Netherlands in 2026 sits in a clear, if wide, band: roughly €45,000–€98,000 gross base salary in Germany, with the middle of the market in the €60,000s to €70,000s, and roughly €45,000–€125,000 in the Netherlands, with mid-level engineers in the high €50,000s to low €80,000s and senior engineers in the €80,000s to around €110,000. Berlin, Munich and Amsterdam pay premiums over their national ranges, and the Dutch holiday allowance and 13th month change what an offer is worth in ways a gross figure alone does not show.</p>
<p>Use the ranges, not a single number, when you set your expectation — and name your sources when you negotiate, because a range backed by Glassdoor, join.com, levels.fyi and the 2026 benchmark reports is a position, while a number pulled from a single search result is a guess. Then follow the path this guide points to: our <a href="https://devopsjobupdates.com/devops-engineer-salary-usa-uk-canada-australia/">DevOps Engineer Salary in USA, UK, Canada and Australia</a> if you are comparing markets, our <a href="https://devopsjobupdates.com/aws-cloud-engineer-salary-usa-uk-canada/">AWS Cloud Engineer Salary in USA, UK and Canada</a> for the cloud-engineer comparison, and our <a href="https://devopsjobupdates.com/devops-engineer-roadmap-2026/">DevOps Engineer Roadmap 2026</a> for the skills that move you up the ranges in this guide.</p>
<p>Sources checked 30 Nov 2026: Glassdoor DevOps Engineer salaries in Germany (base €56K–€70K/yr, typical range €58,000–€76,000 25th–75th percentile, 1,062 salaries submitted anonymously as of Nov 2026); join.com DevOps Engineer salary guide for Germany (25th percentile €58,000, 75th percentile €92,000; entry €45,000–€62,000, mid €58,000–€92,000, senior €74,000–€98,000 25th–75th; sources Destatis, Stepstone Gehaltsreport 2026, Glassdoor, Honeypot); levels.fyi DevOps Engineer salary in Germany and Berlin (total compensation, base plus stock grants plus bonus; figures cited only qualitatively in this article because they are single medians, not ranges — see the note below); iTechScope Salary Report 2026 Europe benchmarks (DevOps mid-level Germany €65,000–€88,000, Netherlands €60,000–€82,000; sources levels.fyi Apr 2026, Glassdoor); Taleva European Tech Salaries 2026 (DevOps/Platform Netherlands junior €45,000–€55,000, mid €58,000–€78,000, senior €80,000–€110,000; sources Glassdoor, levels.fyi, government statistics); jobrise.io Amsterdam 2026 guide (junior €45k–€60k, mid €60k–€80k, senior €80k–€105k, lead €95k–€125k); PayMetric Labs Netherlands 2026 benchmark (8% holiday allowance and 13th month common, benchmarked on De ICT Recruiter Salarisgids IT 2026); Berlin-focused 2026 guide checked 30 Nov 2026 (EU Blue Card 2026 threshold €50,700 gross, €45,934.20 for IT roles). NOT VERIFIED and therefore not stated as fact above: any single “typical” salary for either country — the sources disagree too widely for one figure to be honest, so only ranges are given; levels.fyi's single median figures (Germany and Berlin total compensation) are not quoted as numbers in this article because the article's rule is ranges only; one modelled site's German mid-level figures (based on 31 observations, far above the other sources) are not used as ranges; German and Dutch tax rates are not stated, because they depend on personal circumstances — use a gross-to-net calculator. External references: <a href="https://www.glassdoor.co.in/Salaries/germany-devops-engineer-salary-SRCH_IL.0,7_IN96_KO8,23_IP5.htm">Glassdoor — DevOps Engineer salaries in Germany</a> · <a href="https://www.levels.fyi/t/software-engineer/title/devops-engineer/locations/germany">levels.fyi — DevOps Engineer salary in Germany</a>.</p>
]]></content:encoded></item><item><title><![CDATA[CKAD Exam Guide 2026: Format, Domains, Commands and Study Plan]]></title><description><![CDATA[CKAD is the Kubernetes exam for people who ship applications rather than run clusters. It earns Certified Kubernetes Application Developer, and it is the…]]></description><link>https://devopsjobupdates.hashnode.dev/ckad-exam-guide-2026-format-domains-commands-and-study-plan</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/ckad-exam-guide-2026-format-domains-commands-and-study-plan</guid><category><![CDATA[Kubernetes]]></category><category><![CDATA[ckad]]></category><category><![CDATA[Certification]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:33:25 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>CKAD is the Kubernetes exam for people who ship applications rather than run clusters. It earns Certified Kubernetes Application Developer, and it is the developer-side exam in the family of three that the Linux Foundation and the Cloud Native Computing Foundation run: CKAD for developers, CKA for administrators, and CKS for security specialists. There are no multiple-choice questions anywhere in it. For two hours you sit at a command line in a live cluster and solve tasks — build the image, write the Deployment, mount the ConfigMap, set the resource limits, expose the Service, write the NetworkPolicy, fix the Pod that will not start — and the cluster grades what you built.</p>
<p>This guide covers the exam as it stands on 30 November 2026: what it costs, how it runs, what it tests across its five domains, the kubectl commands you must be able to type without thinking, and how to study for it in six weeks. Every price, duration, domain weight and pass mark below comes from the Linux Foundation's CKAD page or the CNCF curriculum as reported by guides that checked them in November 2026 — where a figure could not be verified, it is left out and flagged in the Sources line at the end. If you are still deciding which Kubernetes exam fits you, our <a href="https://devopsjobupdates.com/cka-certification-guide-2026/">CKA Certification Guide 2026</a> covers the administrator exam and our <a href="https://devopsjobupdates.com/cks-certification-guide-2026/">CKS Certification Guide 2026</a> covers the security exam, so you can compare all three before you pay.</p>
<h2>CKAD at a Glance — Exam Facts</h2>
<p>CKAD is a single exam for a single certification: pass it and you are Certified Kubernetes Application Developer. There are no prerequisites — you do not need the CKA first, and you do not need to take a course, although the Linux Foundation lists the expected experience level as intermediate and the exam assumes working knowledge of container runtimes and microservice architecture. The successful candidate is comfortable working with OCI-compliant container images, applying cloud-native application concepts, and working with and validating Kubernetes resource definitions.</p>
<table>
<thead>
<tr>
<th>Fact</th>
<th>Detail</th>
</tr>
</thead>
<tbody><tr>
<td>Exam code</td>
<td>CKAD</td>
</tr>
<tr>
<td>Certification</td>
<td>Certified Kubernetes Application Developer</td>
</tr>
<tr>
<td>Level</td>
<td>Intermediate</td>
</tr>
<tr>
<td>Price (US)</td>
<td>$445 (exam only, one retake included)</td>
</tr>
<tr>
<td>Exam time</td>
<td>2 hours</td>
</tr>
<tr>
<td>Tasks</td>
<td>15–20 performance-based tasks</td>
</tr>
<tr>
<td>Passing score</td>
<td>66%</td>
</tr>
<tr>
<td>Kubernetes version</td>
<td>v1.37</td>
</tr>
<tr>
<td>Delivery</td>
<td>Online proctored (PSI Secure Browser)</td>
</tr>
<tr>
<td>Languages</td>
<td>English, Simplified Chinese, Japanese</td>
</tr>
<tr>
<td>Prerequisites</td>
<td>None</td>
</tr>
<tr>
<td>Validity</td>
<td>2 years</td>
</tr>
<tr>
<td>Scheduling window</td>
<td>12 months from purchase</td>
</tr>
</tbody></table>
<p>The price is the exam alone — bundles including the Linux Foundation's Kubernetes for Developers course (LFS259) cost more. A standard registration includes two <code>Killer.sh</code> simulator attempts of 36 hours each, with graded results, and exam results are emailed within 24 hours. Renewal is by retaking and passing the same exam before it expires, which extends the certification two years from the new pass date. The Kubernetes version deserves a note: guides that checked the Linux Foundation page and the CNCF curriculum in mid-November 2026 report the exam environment running Kubernetes v1.37, following curriculum v1.37, but older guides cite v1.35 — the exam moves to a new minor version roughly four to eight weeks after its release, so confirm the version on the official page on the day you book.</p>
<h2>The Five Domains, in Exam Order</h2>
<p>The CNCF curriculum divides the exam into five domains, and the weights tell you where your study time should go. Configuration and security is the largest at 25% — a quarter of the exam on its own — while observability is the smallest at 15%. The three middle domains each carry 20%.</p>
<table>
<thead>
<tr>
<th>Domain</th>
<th>Weight</th>
<th>What it covers</th>
</tr>
</thead>
<tbody><tr>
<td>Application Environment, Configuration and Security</td>
<td>25%</td>
<td>ConfigMaps, Secrets, ServiceAccounts, SecurityContexts, resource limits, CRDs</td>
</tr>
<tr>
<td>Application Design and Build</td>
<td>20%</td>
<td>Container images, workload choice, multi-container Pods, volumes</td>
</tr>
<tr>
<td>Application Deployment</td>
<td>20%</td>
<td>Rolling updates, blue/green and canary, Helm, Kustomize</td>
</tr>
<tr>
<td>Services and Networking</td>
<td>20%</td>
<td>Services, Ingress, NetworkPolicies</td>
</tr>
<tr>
<td>Application Observability and Maintenance</td>
<td>15%</td>
<td>Probes, logs, CLI monitoring, debugging, API deprecations</td>
</tr>
</tbody></table>
<p>Study in proportion to the weights, and study in the order the work actually happens: design and build first, then deployment, then configuration and security, then networking, then observability — but give configuration and security the most hours, because it is both the largest domain and the one where a small mistake costs the most marks. The sections below walk through each domain in turn, with the commands the exam actually tests. For the full official list of competencies, study from the Linux Foundation's CKAD page and the CNCF curriculum rather than a printed book: the curriculum is versioned with the Kubernetes release, and older material teaches the wrong version.</p>
<h2>The Commands You Must Type Fast</h2>
<p>CKAD is a speed exam as much as a knowledge exam. Two hours for 15 to 20 tasks is six to eight minutes per task, and the tasks are not all equal — some are a single command, some are a chain of five. The candidates who pass comfortably are the ones who type kubectl without thinking, and the ones who fail are usually the ones who knew the answer but could not produce it fast enough. Speed comes from three habits: imperative commands for the simple things, YAML generation for the complicated things, and documentation lookups for the things you cannot memorise.</p>
<p>The imperative commands are your first habit. <code>kubectl run</code> creates a Pod, <code>kubectl create deployment</code> creates a Deployment, <code>kubectl create service</code> exposes one, <code>kubectl create configmap</code> and <code>kubectl create secret</code> create configuration objects from literals or files. <code>kubectl expose</code> turns a Deployment into a Service in one line. <code>kubectl scale</code> changes a replica count, <code>kubectl rollout status</code> watches a rollout, <code>kubectl rollout undo</code> rolls one back, and <code>kubectl set image</code> changes the image a Deployment runs. <code>kubectl get</code>, <code>kubectl describe</code> and <code>kubectl logs</code> are the three commands you will type most often of all — get to see what exists, describe to see why it is not working, logs to see what the application itself says. Learn the output flags too: <code>-o yaml</code> and <code>-o wide</code> change what you see, <code>--dry-run=client -o yaml</code> is the trick that turns an imperative command into a YAML file you can edit, and that trick is the single most valuable habit in the whole exam.</p>
<p>The second habit is generating YAML rather than writing it from scratch. Almost every task is faster if you generate the skeleton with kubectl and edit it than if you type a manifest from memory. <code>kubectl create deployment web --image=nginx --dry-run=client -o yaml &gt; deploy.yaml</code> gives you a correct Deployment manifest in a second; you then add the probes, the resource limits and the volume mounts by editing the file. <code>kubectl run</code> with <code>--dry-run=client -o yaml</code> does the same for a Pod. Keep a text editor you are fast in — <code>vi</code> is the default in the exam environment, so practise with <code>vi</code> until saving, searching and jumping between lines are automatic — and keep your manifests in files you can re-apply with <code>kubectl apply -f</code>.</p>
<p>The third habit is the documentation. The exam is open-book, but only specific sources are allowed, and only from the browser inside the exam virtual machine: <code>kubernetes.io/docs</code>, <code>kubernetes.io/blog</code>, <code>helm.sh/docs</code>, and the Kubernetes quick reference pages. Documentation search is allowed; other search results are not. Files under <code>/usr/share</code> in the exam environment are also allowed. That means the exam is not testing whether you have memorised every field of every resource — it is testing whether you can find the right page in seconds and copy the right example. Practise that skill directly: time how long it takes you to find a working example for a resource you do not know well.</p>
<h2>Application Design, Build and Deployment</h2>
<p>The design and build domain, at 20%, is where the exam tests whether you can choose the right Kubernetes object for the job. The exam assumes you know the workload resources and their differences, and it tests them through scenarios rather than definitions: a task that says “run this once to completion” is a Job, a task that says “run this every night at 2am” is a CronJob, a task that says “run one copy on every node” is a DaemonSet, and a task that says “run three copies that stay up” is a Deployment. Choosing the wrong workload is the most common design-domain mistake, and it is usually unrecoverable within the time available.</p>
<p>Container images are the other half of this domain: define, build and modify container images, and understand what makes an image usable in a cluster — the image name and tag, the <code>imagePullPolicy</code>, and what happens when the image cannot be pulled. Multi-container Pod patterns are tested directly: the sidecar pattern, where a helper container runs alongside the main container in the same Pod, sharing its network and volumes; the init container, which runs to completion before the application containers start, typically to set up files or wait for a dependency; and the adapter and ambassador patterns, where a container translates or proxies traffic for the main container. The exam asks you to write these patterns in YAML, so practise writing a Pod with an init container that creates a file and a sidecar that reads it — it is a task shape that recurs.</p>
<p>Volumes close the domain: a <code>PersistentVolumeClaim</code> requests storage that survives a Pod restart, an <code>emptyDir</code> lives and dies with the Pod, and a ConfigMap or Secret mounted as a volume gives a container files rather than environment variables. Know how to write the volume and volumeMount blocks without looking them up — they are among the most-typed YAML in the exam. Our <a href="https://devopsjobupdates.com/kubernetes-deployment-yaml-tutorial/">Kubernetes Deployment YAML Tutorial</a> walks through Deployment manifests field by field.</p>
<p>The deployment half of this domain, also at 20%, tests the lifecycle of an application once it exists: how to update it, how to roll it back, how to deploy it in stages, and how to install it from a package. The core object is the Deployment, and the core skill is the rolling update. A Deployment updates Pods gradually, replacing old replicas with new ones while keeping the application available, and the exam tests the whole mechanism: <code>kubectl set image</code> to start an update, <code>kubectl rollout status</code> to watch it, <code>kubectl rollout history</code> to see the revisions, and <code>kubectl rollout undo</code> to return to the previous revision when an update goes wrong. Know the strategy fields too — <code>maxUnavailable</code> and <code>maxSurge</code> — because the exam asks you to set them, and know what happens when a rollout stalls: a Pod that never becomes ready blocks the rollout, and the fix is usually in the Pod, not in the Deployment.</p>
<p>Blue/green and canary deployments are the strategies the exam asks you to implement with Kubernetes primitives. A blue/green deployment runs the old version and the new version side by side, then switches the Service selector from one to the other, so the cutover is instant and the rollback is a selector change. A canary deployment sends a small share of traffic to the new version first — a second Deployment with fewer replicas behind the same Service, or a Service split — and grows it only if the new version behaves. The exam tests these as YAML and kubectl tasks, not as essays, so practise both: a blue/green switch by editing a Service selector, and a canary by creating a second Deployment with one replica and the same labels. The labels are the mechanism in both cases, and a wrong label is the most common reason a canary sends traffic nowhere.</p>
<p>Helm and Kustomize are the packaging tools in this domain. Helm is the package manager: you install a chart with <code>helm install</code>, upgrade it with <code>helm upgrade</code>, list releases with <code>helm list</code>, and roll one back with <code>helm rollback</code>. The exam allows <code>helm.sh/docs</code> in the browser, and it expects you to know the commands rather than to write a chart from scratch. Kustomize is the overlay tool: a <code>kustomization.yaml</code> patches a base set of manifests for an environment without copying them. The exam tests it at a using level — apply with <code>kubectl apply -k</code> and understand what an overlay changes.</p>
<h2>Configuration, Security and Networking — the Biggest Domain</h2>
<p>Configuration and security, at 25%, is the largest domain and the broadest, and it is where the exam separates candidates who have run real applications from candidates who have only read about them. Its core is ConfigMaps and Secrets: creating them from literals, from files, and from environment files, and consuming them as environment variables or as mounted volumes. The exam tests the full cycle — create the ConfigMap, mount it into a Pod, verify the application sees the value — and it tests the differences: a ConfigMap holds plain configuration, a Secret holds sensitive data and is base64-encoded, and neither should be confused with the other. Know the commands cold: <code>kubectl create configmap</code>, <code>kubectl create secret generic</code>, and the <code>envFrom</code>, <code>env</code> and <code>volumeMounts</code> fields that consume them. A Secret that is created but never mounted is a task failed, and the exam's tasks are usually written so that the verification step — checking the Pod actually sees the value — is part of the mark.</p>
<p>ServiceAccounts and SecurityContexts are the identity and permission half of the domain. A ServiceAccount is the identity a Pod uses inside the cluster, and the exam asks you to create one and attach it to a Pod with <code>serviceAccountName</code>. A SecurityContext sets the security settings for a Pod or a container: run as a specific user ID, run as non-root, add or drop Linux capabilities, set a read-only root filesystem. The values are usually given in the task text — your job is to put them in the right place in the manifest. Resource requests and limits belong here too: requests are what the scheduler uses to place a Pod, limits are the ceiling the Pod may not exceed, and the exam asks you to set both, usually in milliCPU and mebibytes. ResourceQuotas cap what a namespace may consume, and the exam may ask you to create one and then show that a Pod exceeding it is rejected.</p>
<p>Services and Networking, at 20%, is the domain that exposes your application. A Service gives a set of Pods a stable address: <code>ClusterIP</code> for internal access only, <code>NodePort</code> for access through a node port, <code>LoadBalancer</code> for a cloud load balancer. The exam tests the Service types and the selector mechanism — a Service with the wrong selector matches no Pods and serves nothing, and the fix is in the labels. NetworkPolicies control traffic between Pods: a policy that allows traffic only from Pods with a certain label, or only on a certain port, and the exam asks you to write them. The key fact about NetworkPolicies is that they are additive and default-allow — a Pod with no policy selecting it accepts all traffic, and a policy that selects it restricts traffic to what the policy allows. Ingress rules expose HTTP routes from outside the cluster, and the exam tests the Ingress resource itself — host, path, backend service — rather than the controller behind it. Our <a href="https://devopsjobupdates.com/kubernetes-deployment-yaml-tutorial/">Kubernetes Deployment YAML Tutorial</a> covers the Service and Ingress YAML you will write here, and our <a href="https://devopsjobupdates.com/cks-certification-guide-2026/">CKS Certification Guide 2026</a> goes deeper on the security half of this domain if you plan to take that exam next.</p>
<h2>Observability, Debugging and Exam Tactics</h2>
<p>Observability and maintenance, at 15%, is the smallest domain but the one that saves you on exam day, because debugging is how you recover the marks other domains put at risk. Probes are the core: a liveness probe tells Kubernetes when to restart a container that has stopped working, a readiness probe tells it when a container is ready to receive traffic, and a startup probe protects a slow-starting container from being killed before it is ready. The exam asks you to add probes to a manifest — usually an HTTP GET against a path and port, or an exec command — and it tests the difference between them: a failing liveness probe restarts the container, a failing readiness probe removes it from the Service endpoints without restarting it. Mixing them up is the classic observability mistake, and the exam writes tasks that punish it.</p>
<p>The debugging half of the domain is the CLI: <code>kubectl logs</code> for what the application said, <code>kubectl describe pod</code> for the events behind a Pod's status, and <code>kubectl exec</code> to run a command inside a running container. Know the status meanings: <code>ImagePullBackOff</code> means the image could not be fetched, <code>CrashLoopBackOff</code> means the container starts and then exits, and <code>Pending</code> usually means the scheduler cannot place the Pod, often because of a resource request no node can satisfy. API deprecations are the domain's quiet topic: the exam expects you to recognise a removed API version and use the current one, which is why practising on the same Kubernetes version as the exam matters.</p>
<p>The tactics around the exam itself are worth a section of their own. First, read every task twice before typing: the task text tells you the namespace, the names and the values, and a task failed because you created the resource in the wrong namespace is a task failed for nothing. Second, flag and skip: if a task resists you for more than a few minutes, mark it and move on — the easy marks elsewhere are worth more than one hard task. Third, verify as you go: after creating a resource, run <code>kubectl get</code> and <code>kubectl describe</code> to confirm it is in the state you expect. Fourth, mind the clock: two hours for 15 to 20 tasks means you cannot spend twenty minutes on one task — use both simulator attempts under timed conditions to learn your pace before the real exam.</p>
<h2>Study Plan — Six Weeks, Hands-On First</h2>
<p>A realistic study plan for CKAD, for someone working full-time who already uses Kubernetes at a basic level, is six weeks at an hour or two a day — longer if you are new to Kubernetes, shorter if you already write manifests daily. The plan below follows the exam's own domains and weights, and every week has hands-on tasks on a real cluster, because the exam grades what you build, not what you have read.</p>
<p><strong>Weeks 1–2: design, build and deployment.</strong> Set up a practice cluster — <code>minikube</code> or <code>kind</code> on your own machine is enough — and work through the workload resources: Deployments, Jobs, CronJobs, DaemonSets, multi-container Pods with sidecars and init containers, and persistent and ephemeral volumes. Then rolling updates, rollbacks, blue/green and canary deployments, and the Helm and Kustomize basics. By the end of week two you should be able to write a Deployment manifest from memory and update it with <code>kubectl set image</code> without looking anything up.</p>
<p><strong>Weeks 3–4: configuration, security and networking.</strong> ConfigMaps and Secrets in all their forms, ServiceAccounts, SecurityContexts, resource requests and limits, Services of every type, NetworkPolicies and Ingress rules. This is the heaviest block because it covers the two largest domains, and it is the block to spend the most time on. Practise the full cycle for each object — create it, verify it, break it, fix it — because the exam's tasks are written as cycles, not as single commands.</p>
<p><strong>Week 5: observability and debugging.</strong> Probes of all three kinds, logs, describe, exec, and the status meanings. Then break your cluster on purpose — a Pod with a wrong image, a Service with a wrong selector, a NetworkPolicy that blocks the traffic it should allow — and diagnose each one with the CLI only, aiming to find the cause in under two minutes.</p>
<p><strong>Week 6: practise and consolidate.</strong> Take both <code>Killer.sh</code> simulator attempts under timed conditions, and study every task you missed — the explanation of what the task wanted matters more than the score. Rebuild your practice cluster from scratch and repeat the tasks you found slowest. Read the current curriculum end to end and check off each competency: if you cannot perform a competency at the command line, that is the next thing to study. Book the exam for the end of this block, before you feel fully ready — the date is the motivator, and the included retake gives you a second chance within twelve months of purchase.</p>
<h2>FAQ</h2>
<p><strong>How is CKAD different from CKA?</strong></p>
<p>CKAD is the developer exam and CKA is the administrator exam. CKAD tests designing, building, configuring and deploying applications — Deployments, ConfigMaps, Services, Ingress, Helm — while CKA tests running the cluster itself: installation, networking, storage, troubleshooting and upgrades. Both are two-hour, hands-on exams costing $445 with a 66% pass mark. Take CKAD if you ship applications; take CKA if you run clusters.</p>
<p><strong>How much does CKAD cost, and how long is the exam?</strong></p>
<p>The exam alone costs $445, which includes one free retake and two <code>Killer.sh</code> simulator attempts. The exam lasts 2 hours and consists of 15 to 20 performance-based tasks solved at the command line in a live cluster. Bundles with the Linux Foundation training course cost more.</p>
<p><strong>What is the passing score for CKAD?</strong></p>
<p>66%. Tasks are scored automatically and can carry different point values, so a harder task may be worth more than an easy one. Results are normally emailed within 24 hours of the sitting.</p>
<p><strong>Can I use documentation during the CKAD exam?</strong></p>
<p>Yes, but only specific sources, and only from the browser inside the exam virtual machine: <code>kubernetes.io/docs</code>, <code>kubernetes.io/blog</code>, <code>helm.sh/docs</code>, and the Kubernetes quick reference pages. Documentation search is allowed; other search results are not. Files under <code>/usr/share</code> in the exam environment are also allowed.</p>
<p><strong>How long is CKAD valid, and how do I renew it?</strong></p>
<p>Two years. You renew by retaking and passing the same exam before it expires, which extends the certification two years from the new pass date. There is no renewal assessment — a retake is the only route.</p>
<h2>Conclusion</h2>
<p>CKAD is the exam that proves you can build and run applications on Kubernetes rather than just describe them. It costs $445, lasts two hours, and tests five domains — configuration and security at 25%, design and build, deployment, and services and networking at 20% each, and observability at 15% — on Kubernetes v1.37, with a 66% pass mark and no multiple-choice questions anywhere in it. Six weeks of hands-on practice on a real cluster, built around kubectl speed and YAML generation, is enough for most working engineers, and the reward is a credential that sits naturally beside the other two Kubernetes exams.</p>
<p>Start with the imperative commands and the <code>--dry-run=client -o yaml</code> trick, learn the workload resources and the configuration objects until you can write them without looking them up, and use both simulator attempts under timed conditions before the real exam. Then follow the path this guide points to: our <a href="https://devopsjobupdates.com/cka-certification-guide-2026/">CKA Certification Guide 2026</a> if running clusters is your direction, our <a href="https://devopsjobupdates.com/cks-certification-guide-2026/">CKS Certification Guide 2026</a> if security is next, and our <a href="https://devopsjobupdates.com/kubernetes-deployment-yaml-tutorial/">Kubernetes Deployment YAML Tutorial</a> for the manifests you will write on exam day.</p>
<p>Sources checked 30 Nov 2026: Linux Foundation CKAD certification page via search results checked 30 Nov 2026 ($445 exam only, one free retake, two <code>Killer.sh</code> simulator attempts of 36 hours each, 2 hours, 66% pass, 2-year validity, 12-month scheduling window, no prerequisites, intermediate level, domains and weights 25/20/20/20/15%, online proctored via PSI Secure Browser, languages English, Simplified Chinese, Japanese); CNCF CKAD curriculum v1.37 and Kubernetes v1.37 exam environment via CKAD guides that checked the curriculum and the Linux Foundation page 13–15 Nov 2026 (15–20 tasks; allowed documentation <code>kubernetes.io/docs</code>, <code>kubernetes.io/blog</code>, <code>helm.sh/docs</code> and quick reference pages; files under <code>/usr/share</code> allowed; LFS259 aligns with CKAD); Kubernetes documentation (<code>kubernetes.io</code>) for the Ingress, Service and probe concepts cited. NOT VERIFIED on the official page and therefore not stated as fact above: the exact Kubernetes version on exam day — guides checked 13–15 Nov 2026 say v1.37, but older guides citing the same official page say v1.35, so confirm on the Linux Foundation page before booking; a tracker report dated 20 Nov 2026 claims the official page now shows 24 tasks instead of 15–20 — not confirmed on the official page and not stated above. External references: <a href="https://training.linuxfoundation.org/certification/certified-kubernetes-application-developer-ckad/">Linux Foundation — CKAD certification page</a> · Kubernetes documentation.</p>
]]></content:encoded></item><item><title><![CDATA[AZ-900 Exam Guide 2026: Azure Fundamentals Format, Domains and Study Plan]]></title><description><![CDATA[AZ-900 is the front door to Microsoft Azure. It earns Microsoft Certified: Azure Fundamentals, and it is the certification most people take first — not…]]></description><link>https://devopsjobupdates.hashnode.dev/az-900-exam-guide-2026-azure-fundamentals-format-domains-and-study-plan</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/az-900-exam-guide-2026-azure-fundamentals-format-domains-and-study-plan</guid><category><![CDATA[Azure]]></category><category><![CDATA[AZ-900]]></category><category><![CDATA[Certification]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:31:04 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>AZ-900 is the front door to Microsoft Azure. It earns Microsoft Certified: Azure Fundamentals, and it is the certification most people take first — not because it is easy, although it is the gentlest exam Microsoft sells, but because it teaches the vocabulary every later Azure conversation depends on. Cloud models, service types, regions and availability zones, compute and storage, identity and governance, cost management: the exam covers the whole platform at a describing level, and “describe” is the operative word. You are not asked to build anything. You are asked to explain what things are, when to use them, and how they fit together.</p>
<p>This guide covers the exam as it stands on 30 November 2026: what it costs, how long it lasts, what it tests across its three domains, how to study for it in three weeks using free Microsoft Learn material, and what it unlocks afterwards. The skills outline was updated on 20 July 2026, and the domain weights below come from the current Microsoft Learn study guide, fetched directly on 30 November 2026. If you are still deciding whether Azure is the right cloud for you at all, our <a href="https://devopsjobupdates.com/azure-vs-aws-which-cloud-to-learn/">Azure vs AWS: Which Cloud to Learn</a> compares the two platforms honestly before you commit to either exam path, and our <a href="https://devopsjobupdates.com/azure-certification-roadmap-2026/">Azure Certification Roadmap 2026</a> maps the whole ladder from AZ-900 to the expert exams.</p>
<h2>AZ-900 at a Glance — Exam Facts</h2>
<p>AZ-900 is a single exam for a single certification: pass it and you are Microsoft Certified: Azure Fundamentals. There are no prerequisites — Microsoft asks for no prior certification and no set amount of experience, although the study guide’s audience profile assumes you work in some area of IT, such as infrastructure management, database management or software development. The exam is aimed at technology professionals who want to demonstrate foundational knowledge of cloud concepts in general and Azure in particular, and it is a common starting point on the way to a career in Azure.</p>
<table>
<thead>
<tr>
<th>Fact</th>
<th>Detail</th>
</tr>
</thead>
<tbody><tr>
<td>Exam code</td>
<td>AZ-900</td>
</tr>
<tr>
<td>Certification</td>
<td>Microsoft Certified: Azure Fundamentals</td>
</tr>
<tr>
<td>Level</td>
<td>Fundamentals</td>
</tr>
<tr>
<td>Price (US)</td>
<td>$99</td>
</tr>
<tr>
<td>Exam time</td>
<td>45 minutes</td>
</tr>
<tr>
<td>Passing score</td>
<td>700 out of 1,000</td>
</tr>
<tr>
<td>Question count</td>
<td>Not published by Microsoft (typically 40–60)</td>
</tr>
<tr>
<td>Question types</td>
<td>Multiple choice, multiple select, drag-and-drop, scenario-based</td>
</tr>
<tr>
<td>Delivery</td>
<td>Pearson VUE testing centre or online proctored</td>
</tr>
<tr>
<td>Prerequisites</td>
<td>None</td>
</tr>
<tr>
<td>Validity</td>
<td>Does not expire</td>
</tr>
<tr>
<td>Skills outline last updated</td>
<td>20 July 2026</td>
</tr>
</tbody></table>
<p>The price is the US list price — Microsoft prices exams by the country or region in which the exam is proctored, and tax may apply on top, so check the price shown at booking for your country. The passing score is 700 on a scale of 1 to 1,000, and Microsoft states plainly that this is a scaled score which may not equal 70% of the points — do not treat it as a percentage, and do not try to work out how many questions you can afford to miss. The exam itself is 45 minutes of testing; allow extra time on top for check-in and the pre-exam survey, so plan on roughly 85 minutes of seat time in total. And the validity line is the best news in the table: fundamentals certifications never expire, so AZ-900 is a credential you earn once and keep. Associate and expert certifications, by contrast, expire after a year and need renewal — our <a href="https://devopsjobupdates.com/az-104-azure-administrator-guide-2026/">AZ-104 Azure Administrator Guide 2026</a> explains that annual renewal process in detail.</p>
<h2>The Three Domains, in Exam Order</h2>
<p>The AZ-900 study guide divides the exam into three domains, with weights from the skills outline updated on 20 July 2026. The change log on the official study guide shows the July 2026 update was minor — the three domains themselves did not change, but the compute and networking objectives, the deployment-tools objectives and the monitoring objectives were all lightly revised, and Azure Virtual Desktop was added to the virtual machine options. That is why older study material is a trap: a course recorded before July 2026 teaches the right shape but the wrong details.</p>
<table>
<thead>
<tr>
<th>Domain</th>
<th>Weight</th>
<th>What it covers</th>
</tr>
</thead>
<tbody><tr>
<td>Describe cloud concepts</td>
<td>25–30%</td>
<td>Cloud models, shared responsibility, IaaS/PaaS/SaaS, benefits of cloud</td>
</tr>
<tr>
<td>Describe Azure architecture and services</td>
<td>35–40%</td>
<td>Regions, compute, networking, storage, identity and security</td>
</tr>
<tr>
<td>Describe Azure management and governance</td>
<td>30–35%</td>
<td>Cost management, governance, deployment tools, monitoring</td>
</tr>
</tbody></table>
<p>The middle domain is the largest and the one where most candidates stumble, because it is where the exam stops asking about ideas and starts asking about services. Study in proportion to the weights: roughly a quarter of your time on cloud concepts, a little over a third on architecture and services, and a little under a third on management and governance. The sections below walk through each domain in turn, with the concepts the exam actually tests. For the full official list of objectives, study from the current guide on Microsoft Learn rather than a printed book: the outline was refreshed during 2026, and older material teaches the wrong structure.</p>
<h2>Cloud Concepts — the Foundation Domain</h2>
<p>The first domain, at 25–30%, is the most conceptual and the most forgiving — but it is also the domain where candidates lose marks they should not lose, because the questions test precise definitions rather than general understanding. The exam wants you to define cloud computing, describe the shared responsibility model, and distinguish the cloud models and the service types without hesitation.</p>
<p>Start with the shared responsibility model, because it appears in some form in almost every AZ-900 sitting. The model divides responsibility between Microsoft and the customer, and the division moves depending on the service type. With infrastructure as a service, Microsoft manages the physical infrastructure — the datacentres, the servers, the networking hardware — and you manage the operating system, the middleware and the applications. With platform as a service, Microsoft takes the operating system and the runtime as well, and you manage only your application and your data. With software as a service, Microsoft manages almost everything and you manage your data and who can access it. The exam’s favourite question is a scenario: a company runs a virtual machine, or an App Service web app, or a Microsoft 365 mailbox, and asks who is responsible for patching the operating system, or for the data. Learn the ladder and the answer is mechanical.</p>
<p>The cloud models are the second pillar: public cloud, where resources are shared across tenants and you pay for what you use; private cloud, where the infrastructure is dedicated to one organisation; and hybrid cloud, where the two are connected so workloads can move between them. The exam tests the use cases, not just the definitions: a public cloud fits a variable workload with no capital spending, a private cloud fits strict regulatory or latency requirements, and a hybrid cloud fits a company that must keep some data on-premises while bursting into the cloud for the rest. Add the consumption-based model — you pay for what you use, with no upfront cost — and the benefits of cloud services the exam lists: high availability and scalability, reliability and predictability, security and governance, and manageability. The exam also tests serverless computing, where you write a function and the platform runs it without you managing any server at all, and the difference between capital expenditure (buying servers) and operational expenditure (renting capacity by the hour). A question that asks whether a scenario describes CapEx or OpEx is a free mark if you have learned the distinction, and a lost mark if you have not.</p>
<h2>Azure Architecture and Services — the Biggest Domain</h2>
<p>The second domain, at 35–40%, is the heart of the exam. It starts with how Azure is organised and then walks through the services themselves: compute, networking, storage, and identity and security. This is the domain to build in a free Azure account as you study, because seeing the hierarchy in the portal makes it stick in a way reading never does.</p>
<p>The core architectural components are the hierarchy every Azure question assumes. A resource is anything you create — a virtual machine, a storage account, a database. Resource groups hold related resources together so they can be managed, billed and deleted as a unit. Subscriptions are the billing and access boundary: a subscription belongs to an account, and resources live inside subscriptions. Management groups sit above subscriptions and let you apply governance — policies and role assignments — across many subscriptions at once. Regions are the geographic locations where Azure runs, region pairs are two regions linked for disaster recovery, and availability zones are physically separate datacentres inside a region that protect a workload from a single datacentre failing. The exam tests the hierarchy directly: a policy applied at a management group flows down to every subscription beneath it, and an availability zone protects against a datacentre outage in a way a resource group never could.</p>
<p>Compute is the first service family. The exam expects you to compare compute types — virtual machines, containers and functions — and to know the virtual machine options, including virtual machines themselves, Virtual Machine Scale Sets, availability sets, and Azure Virtual Desktop, which the July 2026 update added explicitly. Application hosting options include web apps, containers and virtual machines, and the exam asks you to match a scenario to the right option: a container for a portable workload, a function for an event-driven task that runs for seconds, a virtual machine when you need full control of the operating system.</p>
<p>Networking follows: virtual networks, subnets, peering, Azure DNS, Azure VPN Gateway and ExpressRoute, and public and private endpoints. The distinction the exam returns to is VPN Gateway versus ExpressRoute — VPN Gateway connects over the public internet through an encrypted tunnel, ExpressRoute over a private dedicated connection — and the difference between a public endpoint, reachable from the internet, and a private endpoint, reachable only from inside a virtual network.</p>
<p>Storage is the third family: compare Azure Storage services, describe storage tiers, redundancy options, storage account options and storage types, and identify options for moving files — AzCopy, Azure Storage Explorer and Azure File Sync — and migration options such as Azure Migrate and Azure Data Box. Redundancy is the exam’s favourite storage topic: locally redundant storage keeps copies in one datacentre, zone-redundant storage spreads them across availability zones, and geo-redundant storage copies to a second region. The trade-off is cost against durability, and the exam asks you to choose the cheapest option that meets a stated requirement, not the most redundant one.</p>
<p>Identity, access and security close the domain. Microsoft Entra ID — formerly Azure Active Directory — is the identity service, and the exam covers directory services including Entra ID and Entra Domain Services, authentication methods including single sign-on, multifactor authentication and passwordless sign-in, external identities, Entra Conditional Access, and role-based access control. Around those sit the concepts: Zero Trust, the idea that no user or device is trusted by default and every access request is verified; the defense-in-depth model, layers of security so that a failure in one layer does not expose the system; and Microsoft Defender for Cloud, the service that assesses the security posture of your resources. The exam tests these at a describing level — what each one is for, not how to configure it — but the definitions must be exact, because the wrong answers in the multiple-choice questions are usually near-misses.</p>
<h2>Management and Governance — Cost, Control and Monitoring</h2>
<p>The third domain, at 30–35%, is the one candidates most often under-study, because it feels dull next to compute and storage — and it is the second-largest domain on the exam. It has four parts: cost management, governance and compliance, managing and deploying resources, and monitoring.</p>
<p>Cost management is where Azure’s business model meets the exam. The factors that affect costs — resource type, location, usage, and the pricing model — are tested directly, and so are the tools: the pricing calculator, which estimates the cost of a planned deployment before you build it, and Cost Management, which tracks what you are actually spending and can alert you when a budget is about to be exceeded. Tags are the mechanism that makes cost tracking work at scale: a tag is a name-value pair attached to a resource, such as environment=production or owner=finance, and cost reports can then be grouped by tag. A question that asks how to find out which department is driving a storage bill is a tags question, and it is a free mark if you have learned that.</p>
<p>Governance and compliance is the control half of the domain. Microsoft Purview is the data governance service — it helps you discover, classify and govern data across Azure. Azure Policy enforces rules across resources: a policy can deny a deployment that violates a rule, such as creating a virtual machine in an unapproved region, or audit resources that are already non-compliant. Resource locks prevent accidental change or deletion: a ReadOnly lock stops changes, a CanNotDelete lock stops deletion while still allowing changes. The exam tests the difference between a policy and a lock, and the difference between the two lock types, because they are easy to confuse and easy to test.</p>
<p>Managing and deploying resources covers the tools you use every day: the Azure portal, the web interface; Azure Cloud Shell, the browser-based shell; the Azure CLI and Azure PowerShell, the two command-line tools; Azure Arc, which extends Azure management to servers running outside Azure, on-premises or in another cloud; infrastructure as code, the practice of defining infrastructure in files rather than clicking through a portal; and Azure Resource Manager and ARM templates, the deployment and management layer that every resource in Azure passes through. The exam tests these at a describing level, but the distinction between the portal, the CLI and Cloud Shell is a common question, and the idea of infrastructure as code — repeatable, version-controlled, reviewable — is one the exam returns to.</p>
<p>Monitoring closes the domain: Azure Advisor gives personalised recommendations for cost, security, reliability and performance; Azure Service Health tells you about Azure service issues that affect your region and your resources; and Azure Monitor, including Log Analytics, Azure Monitor alerts and Application Insights, collects metrics and logs, queries them, alerts on them, and watches application performance. The exam asks what each tool is for — Advisor recommends, Service Health reports outages, Monitor watches your resources — and the three are easy marks if you keep their purposes straight.</p>
<h2>Study Plan — Three Weeks, Free Resources</h2>
<p>A realistic study plan for AZ-900, for someone working full-time, is three weeks at an hour a day — longer if you are completely new to cloud, shorter if you already know another cloud provider. The plan below uses only free material, because Microsoft Learn’s own learning path covers every objective on the exam, and it is written by the people who write the exam. Plan for roughly 15 to 25 hours of study if you are new to cloud, and 8 to 12 hours if you already know cloud basics from another provider.</p>
<p><strong>Week 1: cloud concepts and Azure architecture.</strong> Work through Microsoft Learn’s free AZ-900 learning path for the first domain — cloud models, the shared responsibility model, IaaS, PaaS and SaaS, CapEx versus OpEx — and then the Azure hierarchy: regions, region pairs, availability zones, resource groups, subscriptions and management groups. Create a free Azure account and click through the portal as you go: create a resource group, look at the regions list, open the pricing calculator and price a small virtual machine. Seeing the hierarchy in the portal makes it stick in a way reading never does.</p>
<p><strong>Week 2: core services.</strong> Compute, networking, storage, and identity and security — the biggest domain, so give it the most time. For each service family, learn the services, then learn the distinctions the exam tests: virtual machine versus container versus function, VPN Gateway versus ExpressRoute, locally redundant versus geo-redundant storage, single sign-on versus multifactor authentication. Write the distinctions down in your own words; if you cannot explain a distinction in one sentence, you have not learned it yet. Take the free official practice assessment for this domain before moving on — Microsoft Learn’s practice assessments are the closest thing to the real exam you will get for free, and they show you the question style as well as the content. A new practice assessment experience is now available on AI Skills Navigator, and Microsoft recommends it over the legacy practice assessment on Learn, which is no longer being updated.</p>
<p><strong>Week 3: management, governance and practice.</strong> Cost management, Azure Policy, resource locks, deployment tools and monitoring — the domain candidates skip and then regret skipping. Then take full practice assessments under timed conditions, and study every wrong answer: the explanation of why the right answer is right matters more than the score. Read the current study guide end to end and check off each objective; if you cannot describe an objective in your own words, that is the next thing to study. Book the exam for the end of this week, before you feel fully ready — the date is the motivator, and AZ-900’s gentleness means the risk of booking early is low.</p>
<h2>Booking, Validity and What Comes After</h2>
<p>Booking is through Pearson VUE, either at a testing centre or online proctored from home. For the online option you need a quiet room, a webcam, and a clean desk — the proctor checks the room on camera and the rules are strict, so read them before the day and do a system test in advance. On the day, arrive early, bring the ID Pearson VUE asks for, and expect the check-in process to take time out of your schedule, not out of the exam clock. If English is not your first language and the exam is not available in your preferred language, Microsoft notes that you can request an additional 30 minutes to complete the exam.</p>
<p>Passing AZ-900 earns a certification that never expires, which makes it the cheapest credential in the Azure family to hold — there is no renewal assessment to schedule and no expiry date to track. It is also the natural first step on the ladder our <a href="https://devopsjobupdates.com/azure-certification-roadmap-2026/">Azure Certification Roadmap 2026</a> maps in full. The usual next step is AZ-104, the associate-level administrator exam, which assumes the vocabulary AZ-900 teaches and tests whether you can operate a real Azure environment: identities, storage, compute, networking and monitoring, all under your hands. Our <a href="https://devopsjobupdates.com/az-104-azure-administrator-guide-2026/">AZ-104 Azure Administrator Guide 2026</a> covers that exam in the same format as this guide — cost, five domains and weights, study plan, hands-on labs and renewal. If you are still weighing clouds rather than exams, our <a href="https://devopsjobupdates.com/azure-vs-aws-which-cloud-to-learn/">Azure vs AWS: Which Cloud to Learn</a> compares the two platforms on jobs, pricing and learning curve before you commit to either path. Whichever direction you take, AZ-900 is the right first move: it is inexpensive, it never expires, and it gives you the language every later Azure conversation is conducted in.</p>
<h2>FAQ</h2>
<p><strong>Do I need any experience before taking AZ-900?</strong></p>
<p>No. Microsoft imposes no prerequisites for sitting AZ-900, and no prior certification is required. The study guide’s audience profile assumes you work in some area of IT, such as infrastructure management, database management or software development, but a motivated beginner with no IT background can pass with three weeks of study using the free Microsoft Learn path.</p>
<p><strong>How much does AZ-900 cost, and how long is the exam?</strong></p>
<p>The US list price is $99, and the exam time is 45 minutes. Prices vary by the country or region in which the exam is proctored, and tax may apply, so check the price shown at booking for your country. Allow roughly 85 minutes of seat time in total once check-in and the pre-exam survey are included.</p>
<p><strong>What is the passing score for AZ-900?</strong></p>
<p>700 on a scale of 1 to 1,000. Microsoft states that this is a scaled score and may not equal 70% of the points, so do not treat it as a percentage or try to work out how many questions you can afford to miss.</p>
<p><strong>Does AZ-900 expire?</strong></p>
<p>No. Fundamentals certifications never expire, so AZ-900 is a credential you earn once and keep. Associate and expert certifications, such as AZ-104, are valid for one year and are renewed free through an online assessment on Microsoft Learn.</p>
<p><strong>Should I take AZ-900 or go straight to AZ-104?</strong></p>
<p>Take AZ-900 first if you are new to Azure or new to cloud altogether — it teaches the vocabulary AZ-104 assumes, it costs $99, and it never expires. Go straight to AZ-104 if you already administer Azure daily or hold an equivalent certification on another cloud, since Microsoft imposes no prerequisites for AZ-104 either.</p>
<h2>Conclusion</h2>
<p>AZ-900 is the cheapest, gentlest and most durable first step into Microsoft Azure. It costs $99, lasts 45 minutes, and tests three domains — cloud concepts at 25–30%, Azure architecture and services at 35–40%, and management and governance at 30–35% — with the skills outline updated on 20 July 2026. Three weeks of study using the free Microsoft Learn path is enough for most people, and the reward is a certification that never expires and a vocabulary that every later Azure exam assumes.</p>
<p>Start with the shared responsibility model and the service types, build the Azure hierarchy in a free account so you can see it rather than memorise it, and do not skip the management and governance domain — it carries nearly a third of the marks and it is the domain candidates most often under-study. Then follow the path this guide points to: our <a href="https://devopsjobupdates.com/azure-certification-roadmap-2026/">Azure Certification Roadmap 2026</a> for the full ladder, our <a href="https://devopsjobupdates.com/az-104-azure-administrator-guide-2026/">AZ-104 Azure Administrator Guide 2026</a> if administration is your direction, and our <a href="https://devopsjobupdates.com/azure-vs-aws-which-cloud-to-learn/">Azure vs AWS: Which Cloud to Learn</a> if you are still choosing a cloud.</p>
<p>Sources checked 30 Nov 2026: Microsoft Learn AZ-900 study guide, fetched directly 30 Nov 2026 (skills measured as of 20 July 2026; three domains and weights: cloud concepts 25–30%, Azure architecture and services 35–40%, management and governance 30–35%; pass 700 or greater; no prerequisites; fundamentals certifications never expire; change log confirms the July 2026 update was minor, with Azure Virtual Desktop added to the VM options); Microsoft-citing guides checked 30 Nov 2026 ($99 US price; 45 minutes exam time; typically 40–60 questions; free Microsoft Learn learning path and practice assessments). NOT VERIFIED on an official page and therefore not stated as fact above: the exact question count for AZ-900 (Microsoft publishes only the typical 40–60 range); the exact total seat time including check-in (45 minutes is the exam time; the ~85-minute total is a planning allowance from secondary guides). External references: <a href="https://learn.microsoft.com/en-us/credentials/certifications/resources/study-guides/az-900">Microsoft Learn — AZ-900 study guide</a> · <a href="https://learn.microsoft.com/en-us/credentials/certifications/exams/az-900">Microsoft Learn — AZ-900 exam page</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Jenkinsfile Declarative Pipeline: A Complete Hands-On Guide]]></title><description><![CDATA[A Jenkinsfile is a text file that describes your entire delivery pipeline as code. Build, test, scan, deploy: every step lives in the file, versioned…]]></description><link>https://devopsjobupdates.hashnode.dev/jenkinsfile-declarative-pipeline-a-complete-hands-on-guide</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/jenkinsfile-declarative-pipeline-a-complete-hands-on-guide</guid><category><![CDATA[Jenkins]]></category><category><![CDATA[CI/CD]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Pipeline]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:28:20 GMT</pubDate><content:encoded><![CDATA[<p>A Jenkinsfile is a text file that describes your entire delivery pipeline as code. Build, test, scan, deploy: every step lives in the file, versioned alongside the application it ships. When a deploy fails at 2 a.m., nobody has to remember which buttons someone clicked in a web interface six months ago. The pipeline is in the repository, it is readable, and it can be reviewed like any other code.</p>
<p>This guide teaches the declarative Pipeline syntax, which is the structured, opinionated way to write a Jenkinsfile. Jenkins also offers scripted Pipeline, a more flexible Groovy-based syntax, but declarative is the right default for almost every team: it is easier to read, easier to validate, and Jenkins can check its syntax before the pipeline runs. Everything here is tested against Jenkins LTS 2.580.3, released on 25 November 2026, which requires Java 21 or 25 to run the controller. If you are new to Jenkins itself, start with our <a href="https://devopsjobupdates.com/jenkins-cicd-pipeline-tutorial/">Jenkins CI/CD pipeline tutorial</a>, which covers installation and your first freestyle job, then come back here.</p>
<p>By the end of this guide you will have a complete Jenkinsfile for a real application: it checks out code, builds it, runs tests, builds a Docker image, scans it, and deploys it, with notifications and cleanup. You will also understand parameters, credentials, parallel stages, post actions and shared libraries, which are the tools that turn a simple pipeline into one a whole team can rely on.</p>
<h2>What a Jenkinsfile Is and How Declarative Pipeline Works</h2>
<p>A Jenkinsfile is a file named Jenkinsfile, stored in the root of a repository, that defines a Pipeline. When Jenkins builds a project that uses Pipeline as code, it reads the Jenkinsfile from the repository, either from the branch being built or from a branch you specify, and executes it. The pipeline runs on agents, which are machines that execute the steps, and the controller orchestrates the run, shows the results, and stores the logs.</p>
<p>Declarative Pipeline has a fixed structure. The whole file is a <code>pipeline</code> block. Inside it, an <code>agent</code> section says where the pipeline runs. An <code>environment</code> section sets variables. A <code>stages</code> section holds one or more <code>stage</code> blocks, and each stage holds a <code>steps</code> block with the actual commands. <code>Options</code>, <code>triggers</code>, <code>parameters</code>, <code>tools</code> and <code>post</code> sections add behaviour around the stages. That structure is enforced by Jenkins: if the file does not follow it, the pipeline fails validation before it runs anything, which catches mistakes early.</p>
<p>The fixed structure is a feature, not a limitation. Because every declarative pipeline has the same shape, any engineer can read any pipeline in the organisation and understand it in minutes. Because the structure is validated, a typo in a stage name fails fast instead of failing halfway through a deploy. And because the structure is declarative, Jenkins can render the pipeline visually in the Blue Ocean interface or the Pipeline graph view, showing each stage as a box that turns green or red as it runs. That visual feedback is genuinely useful during an incident: you can see exactly which stage failed without reading logs first.</p>
<p>To use a Jenkinsfile, create a Pipeline job in Jenkins and point it at your repository. The most common setup is a Multibranch Pipeline, which scans the repository, finds every branch with a Jenkinsfile, and creates a job for each one. Pull requests get their own builds automatically, which means every change is tested before it merges. For a single-branch project, a plain Pipeline job with the definition set to “Pipeline script from SCM” works fine. Either way, the Jenkinsfile is the source of truth, and Jenkins reads it from the repository on every run.</p>
<p>One decision to make early is where the pipeline runs. The <code>agent</code> directive controls this. <code>agent any</code> runs on any available agent, which is fine for learning. In production you will usually label your agents, for example <code>agent { label 'docker' }</code> to run on agents with Docker installed, or use a Docker agent to run the whole pipeline inside a container. Agent choice matters because the tools available, the network access, and the credentials installed all depend on which machine runs the steps. If a step fails with “command not found”, the first thing to check is whether the agent it ran on actually has that tool.</p>
<h2>Your First Jenkinsfile: Build, Test and Report</h2>
<p>Here is a complete Jenkinsfile for a Node.js application. It is short enough to read in one sitting and complete enough to use as a starting point for a real project. Read it first, then the explanation below walks through every section.</p>
<pre><code class="language-groovy">pipeline {
    agent any

    tools {
        nodejs 'node-20'
    }

    environment {
        APP_NAME = 'shop-api'
        NODE_ENV = 'test'
    }

    stages {
        stage('Checkout') {
            steps {
                checkout scm
            }
        }
        stage('Install') {
            steps {
                sh 'npm ci'
            }
        }
        stage('Test') {
            steps {
                sh 'npm test'
            }
        }
        stage('Build') {
            steps {
                sh 'npm run build'
            }
        }
    }

    post {
        always {
            junit 'test-results/**/*.xml'
            archiveArtifacts artifacts: 'dist/**/*', fingerprint: true
        }
        success {
            echo 'Build passed.'
        }
        failure {
            echo 'Build failed. Check the Test stage first.'
        }
    }
}
</code></pre>
<p>The <code>tools</code> section tells Jenkins to make a named tool installation available on the agent. <code>nodejs 'node-20'</code> refers to a Node.js installation configured in Jenkins under Manage Jenkins, then Tools. The name must match exactly, including case, or the pipeline fails at startup with a clear error. Tools configured this way are installed automatically on the agent if they are not already there, which makes agents reproducible without baking every tool into every image.</p>
<p>The <code>environment</code> section sets variables that are available to every step in the pipeline. <code>APP_NAME</code> and <code>NODE_ENV</code> here are simple strings, but environment variables can also come from credentials, which the credentials section of this guide covers. Environment variables set here are visible in the build log only if a step prints them, so do not put secrets in this section.</p>
<p>Each stage is a named unit of work. The stage name appears in the Pipeline graph view, so name stages for the reader, not for the machine: “Test” and “Build” are good names. “Stage 3” is not. The <code>steps</code> block holds the actual work, usually shell commands with <code>sh</code>, but also Pipeline steps such as <code>echo</code>, <code>checkout</code> and <code>archiveArtifacts</code>.</p>
<p>The <code>post</code> section runs after all stages finish, and the condition decides when each block runs. <code>always</code> runs every time, which is where test reporting and artifact archiving belong, because you want the test results even when the build fails. <code>success</code> runs only when the build passed, and <code>failure</code> runs only when it failed. Other conditions include <code>unstable</code> for builds that passed with test failures, <code>changed</code> for builds whose result differs from the previous one, and <code>cleanup</code>, which runs last and is the right place for workspace cleanup. The <code>junit</code> step publishes test results so Jenkins shows a test trend and a list of failing tests, which is far more useful than a log line saying tests failed.</p>
<p>Save this file as Jenkinsfile in a repository, create a Pipeline job, and run it. The first run will probably fail, and that is normal. Read the error, fix the cause, and run it again. The fastest way to learn Jenkinsfile syntax is to break a pipeline and read the error message, because Jenkins errors usually name the exact line and the exact problem.</p>
<h2>Stages, Steps, Agents and When Conditions</h2>
<p>Stages can do more than run in sequence. They can run in parallel, they can run only when a condition is met, and they can use a different agent from the rest of the pipeline. These three features cover most of the real-world pipeline designs you will meet.</p>
<p>Parallel stages run at the same time, which shortens the build when stages do not depend on each other. Linting, unit tests and a security scan can all run in parallel, because none of them needs the others to finish first. The syntax nests stages inside a <code>parallel</code> block.</p>
<pre><code class="language-groovy">stage('Quality checks') {
    parallel {
        stage('Lint') {
            steps {
                sh 'npm run lint'
            }
        }
        stage('Unit tests') {
            steps {
                sh 'npm test'
            }
        }
        stage('Security scan') {
            steps {
                sh 'npm audit --audit-level=high'
            }
        }
    }
}
</code></pre>
<p>Be careful with parallel stages that share state. Two stages that both write to the same directory or the same database will interfere with each other in ways that are hard to reproduce. Parallel stages should be independent: each one works on its own files, or reads shared files without writing to them. If two stages need the same resource, run them in sequence instead. A build that is five minutes faster but fails randomly is not faster.</p>
<p>The <code>when</code> directive controls whether a stage runs at all. The most common conditions are branch-based: deploy only from the main branch, run a heavy end-to-end suite only on pull requests, or skip a slow stage on feature branches. The directive supports branch names, environment variables, change requests, and expressions that evaluate Groovy code.</p>
<pre><code class="language-groovy">stage('Deploy to staging') {
    when {
        branch 'main'
    }
    steps {
        sh './deploy.sh staging'
    }
}
stage('Deploy to production') {
    when {
        allOf {
            branch 'main'
            expression { params.DEPLOY_PROD == true }
        }
    }
    steps {
        sh './deploy.sh production'
    }
}
</code></pre>
<p>The <code>agent</code> directive can also be set per stage. A pipeline that mostly runs on a general agent might run its Docker build stage on an agent labelled <code>docker</code>, and its deploy stage on an agent with production credentials. Per-stage agents are also how you run a stage inside a container while the rest of the pipeline runs directly on the agent.</p>
<pre><code class="language-groovy">stage('Build image') {
    agent {
        docker { image 'node:20-alpine' }
    }
    steps {
        sh 'node --version'
        sh 'npm ci'
    }
}
</code></pre>
<p>The Docker agent pulls the image, runs the stage inside a container based on it, and removes the container when the stage finishes. This guarantees the build environment is identical every time, regardless of what is installed on the agent. It is the simplest form of reproducible builds in Jenkins, and it is the right choice when the build depends on a specific version of a tool. For the broader picture of how pipelines fit into delivery, our <a href="https://devopsjobupdates.com/cicd-pipeline-explained/">CI/CD pipeline explained</a> guide covers the concepts this syntax implements.</p>
<h2>Parameters, Environment and Credentials</h2>
<p>A pipeline that cannot be configured without editing the Jenkinsfile is a pipeline that will be edited constantly. Parameters solve this. They let the person who starts a build choose values: which environment to deploy to, whether to run the slow test suite, or which version to build. Parameters are declared in a <code>parameters</code> block, and they appear as a form when the build is triggered.</p>
<pre><code class="language-groovy">parameters {
    choice(name: 'ENVIRONMENT', choices: ['staging', 'production'], description: 'Where to deploy')
    booleanParam(name: 'RUN_E2E', defaultValue: false, description: 'Run end-to-end tests')
    string(name: 'VERSION', defaultValue: '', description: 'Version tag to build (empty means latest)')
}
</code></pre>
<p>Use parameters inside steps as <code>params.ENVIRONMENT</code> and inside shell commands as <code>${params.ENVIRONMENT}</code>. The production deploy example in the previous section used a boolean parameter as a safety gate: deploying to production requires someone to check the box deliberately. That pattern is worth copying. A deploy that happens because someone forgot to uncheck a box is an accident; a deploy that happens because someone checked a box is a decision.</p>
<p>Credentials are how a pipeline uses passwords, tokens and keys without writing them in the Jenkinsfile. Jenkins stores credentials in its credential store, each with an ID, and the pipeline refers to the ID. The <code>withCredentials</code> step makes the credential available as environment variables inside its block, and Jenkins masks the values in the build log so they do not leak into the output.</p>
<pre><code class="language-groovy">stage('Push image') {
    steps {
        withCredentials([usernamePassword(credentialsId: 'docker-hub', usernameVariable: 'REG_USER', passwordVariable: 'REG_PASS')]) {
            sh 'echo "$REG_PASS" | docker login -u "$REG_USER" --password-stdin'
            sh 'docker push myapp:${BUILD_NUMBER}'
        }
    }
}
</code></pre>
<p>Three rules govern credentials in pipelines. First, never write a secret in a Jenkinsfile, in an <code>echo</code> statement, or in a build parameter with a default value. Second, use the narrowest credential type for the job: a username and password binding for a registry, a secret text binding for a token, and an SSH key binding for Git operations. Third, give credentials descriptive IDs that say what they are for, such as <code>docker-hub</code> or <code>aws-deploy</code>, and restrict which jobs can use them through folder-scoped credentials where your Jenkins setup supports it. The official Pipeline syntax documentation lists every credential binding type and the parameters each one accepts.</p>
<p>Environment variables set in the <code>environment</code> section can also draw on credentials directly, which is cleaner when the whole pipeline needs a value rather than one stage.</p>
<pre><code class="language-groovy">environment {
    AWS_ACCESS_KEY_ID = credentials('aws-access-key')
    DOCKERHUB = credentials('docker-hub')
}
</code></pre>
<p>Be aware of one sharp edge: credentials bound this way are available to every stage, which is convenient but broad. Prefer <code>withCredentials</code> inside the stage that needs the secret when only one stage needs it. Least privilege applies to pipelines as much as it applies to servers.</p>
<h2>A Complete Pipeline: Docker Build, Scan and Deploy</h2>
<p>The Jenkinsfile below ties the pieces together into a pipeline that a small team could use in production. It checks out the code, runs quality checks in parallel, builds a Docker image, scans it, pushes it, and deploys to staging automatically and to production only when the build runs on the main branch with the deploy parameter enabled. Read it as a template and adapt the commands to your own stack.</p>
<pre><code class="language-groovy">pipeline {
    agent { label 'docker' }

    parameters {
        booleanParam(name: 'DEPLOY_PROD', defaultValue: false, description: 'Deploy to production')
    }

    environment {
        IMAGE = "myregistry/shop-api:${env.BUILD_NUMBER}"
    }

    stages {
        stage('Checkout') {
            steps { checkout scm }
        }
        stage('Quality checks') {
            parallel {
                stage('Lint') {
                    steps { sh 'npm run lint' }
                }
                stage('Unit tests') {
                    steps { sh 'npm test' }
                }
            }
        }
        stage('Build image') {
            steps {
                sh 'docker build -t "$IMAGE" .'
            }
        }
        stage('Scan image') {
            steps {
                sh 'trivy image --exit-code 1 --severity HIGH,CRITICAL "$IMAGE"'
            }
        }
        stage('Push image') {
            steps {
                withCredentials([usernamePassword(credentialsId: 'docker-hub', usernameVariable: 'REG_USER', passwordVariable: 'REG_PASS')]) {
                    sh 'echo "$REG_PASS" | docker login -u "$REG_USER" --password-stdin'
                    sh 'docker push "$IMAGE"'
                }
            }
        }
        stage('Deploy to staging') {
            when { branch 'main' }
            steps {
                sh './deploy.sh staging "$IMAGE"'
            }
        }
        stage('Deploy to production') {
            when {
                allOf {
                    branch 'main'
                    expression { params.DEPLOY_PROD == true }
                }
            }
            steps {
                input message: 'Deploy to production?', ok: 'Deploy'
                sh './deploy.sh production "$IMAGE"'
            }
        }
    }

    post {
        always {
            junit 'test-results/**/*.xml'
            sh 'docker rmi "$IMAGE" || true'
        }
        failure {
            emailext subject: "Build failed: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
                     body: "See ${env.BUILD_URL} for details.",
                     to: 'team@example.com'
        }
    }
}
</code></pre>
<p>Three parts of this pipeline deserve attention. The scan stage uses Trivy, an open source image scanner, and fails the build on high or critical vulnerabilities. Scanning in the pipeline means a vulnerable image cannot reach production by accident. If your team does not scan images yet, this one stage is the highest-value addition you can make to any pipeline.</p>
<p>The production deploy stage uses the <code>input</code> step, which pauses the pipeline and waits for a human to approve. The build waits, the approver clicks Deploy, and the pipeline continues. The <code>input</code> step is the simplest form of a manual approval gate, and it is the right tool when production deploys need a human decision but the rest of the pipeline should be automatic. Set a timeout on the <code>input</code> step in a real pipeline, so a build that nobody approves does not wait forever and hold an executor.</p>
<p>The <code>post</code> section cleans up the Docker image from the agent, so disk space does not fill up over weeks of builds, and sends an email when the build fails. The <code>|| true</code> after the <code>docker rmi</code> command means the cleanup step cannot fail the build if the image is already gone. That pattern, making cleanup steps unable to fail, is worth using everywhere: a build that passed should not turn red because its cleanup hit a snag.</p>
<h2>Shared Libraries, Multibranch Pipelines and Troubleshooting</h2>
<p>When every repository has its own Jenkinsfile, the same steps get copied everywhere: the same lint command, the same scan command, the same deploy script invocation. Shared libraries fix this. A shared library is a separate repository with reusable Pipeline code, usually in a <code>vars</code> directory, and any Jenkinsfile can call it as if it were a built-in step.</p>
<pre><code class="language-groovy">@Library('my-shared-library') _

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                buildNodeApp()
            }
        }
    }
}
</code></pre>
<p>In this example, <code>buildNodeApp</code> is a step defined once in the shared library and used by every Node.js service in the organisation. When the build process changes, one change in the library updates every pipeline. That is the same argument as for any shared code, and it applies just as strongly to pipelines. Keep the library small and focused: a handful of steps that every team uses, with clear names and documentation. A library that tries to cover every case becomes a framework, and frameworks are harder to change than the duplication they replaced.</p>
<p>Multibranch Pipeline is the job type that makes Jenkinsfiles scale. It scans a repository, creates a job for every branch and pull request that contains a Jenkinsfile, and deletes jobs for branches that are gone. Each branch builds with its own Jenkinsfile, so a change to the pipeline in a feature branch is tested by that branch’s build before it merges. Combined with the <code>when</code> directive, this gives you per-branch behaviour without per-branch configuration: feature branches run tests, the main branch deploys to staging, and production deploys need a parameter and an approval.</p>
<p>When a pipeline fails, work through the failure in order. First, read the Pipeline graph view to find which stage failed. Second, open that stage’s logs and read the last lines, where the error usually is. Third, check the agent: was the tool installed, did the agent have network access, did the disk fill up? Fourth, validate the Jenkinsfile itself. Jenkins has a built-in Declarative Pipeline linter: paste the file into the Pipeline Syntax page, or use the replay feature on a failed build to edit the Jenkinsfile and run it again without committing. Replay is the fastest way to iterate on a pipeline, because it skips the commit and push cycle. The official Jenkinsfile documentation explains the linter, the replay feature and the full syntax in detail.</p>
<p>Common errors have recognisable signatures. “No such DSL method” means a step is misspelled or used in the wrong context, such as a step that only works inside a <code>script</code> block. “Expected a step” means a stage is missing its <code>steps</code> block. “WorkflowScript” errors with a line number point at the exact line to fix. And a pipeline that fails immediately, before any stage runs, almost always has a syntax error in the <code>pipeline</code> block itself, often a missing brace. Count your braces, and let your editor’s Groovy support highlight them.</p>
<p>If you are comparing Jenkins with other CI systems, our <a href="https://devopsjobupdates.com/github-actions-tutorial/">GitHub Actions tutorial</a> covers the equivalent concepts in GitHub’s YAML-based system, which is useful context when you need to choose between the two or migrate from one to the other.</p>
<h2>Frequently Asked Questions</h2>
<p><strong>What is the difference between declarative and scripted Pipeline?</strong> Declarative Pipeline uses a fixed, structured syntax with <code>pipeline</code>, <code>agent</code>, <code>stages</code> and <code>steps</code> blocks, and Jenkins validates it before running. Scripted Pipeline is Groovy code with a <code>node</code> block, which is more flexible but harder to read and easier to break. Declarative is the right default for most teams, and scripted is for the rare cases where declarative cannot express what you need.</p>
<p><strong>Where does the Jenkinsfile live?</strong> In the root of your repository, next to the code it builds. Jenkins reads it from the repository on every build, which means the pipeline is versioned, reviewed and branched alongside the application. For a Multibranch Pipeline, every branch with a Jenkinsfile gets its own job automatically.</p>
<p><strong>How do I use secrets in a Jenkinsfile?</strong> Store them in the Jenkins credential store and reference them by ID with <code>withCredentials</code> or the <code>credentials</code> helper in the <code>environment</code> section. Jenkins masks the values in build logs. Never write a secret in the Jenkinsfile itself, in a build parameter default, or in an <code>echo</code> statement.</p>
<p><strong>Can I test a Jenkinsfile without committing it?</strong> Yes. Use the Replay feature on a previous build to edit the Jenkinsfile and run it again, or validate the syntax on the Pipeline Syntax page in Jenkins. Both let you iterate without pushing a commit for every change, which makes debugging a pipeline much faster.</p>
<p><strong>How do I deploy only from the main branch?</strong> Use the <code>when</code> directive with a <code>branch</code> condition on the deploy stage, as shown in this guide. Combine it with a boolean parameter and an <code>input</code> step for production, so deploys need both the right branch and a deliberate human decision. Feature branches then run tests without ever reaching a deployment stage.</p>
<h2>Conclusion</h2>
<p>A Jenkinsfile turns your delivery process from a set of manual steps into code that is versioned, reviewed and repeatable. Start with the simple pipeline from this guide, add quality checks in parallel, gate production behind a parameter and an approval, and extract the repeated steps into a shared library once you have more than one service using them. The declarative syntax rewards you for that discipline: it validates your pipeline before it runs, it renders each stage visually so failures are easy to find, and it stays readable when the pipeline grows. The next step is to take one project you currently deploy by hand and write its Jenkinsfile. When the first green build deploys itself to staging, you will have replaced a manual process with a system, and that is the whole point of CI/CD.</p>
<p>Sources: Verified 2 Dec 2026. Jenkins Pipeline syntax documentation: <a href="https://www.jenkins.io/doc/book/pipeline/syntax/">https://www.jenkins.io/doc/book/pipeline/syntax/</a> ; Jenkinsfile documentation: <a href="https://www.jenkins.io/doc/book/pipeline/jenkinsfile/">https://www.jenkins.io/doc/book/pipeline/jenkinsfile/</a> . Jenkins LTS 2.580.3 current (released 25 Nov 2026); controller requires Java 21 or 25. No unverified figures stated.</p>
]]></content:encoded></item><item><title><![CDATA[Kubernetes ConfigMap vs Secret: Key Differences Explained]]></title><description><![CDATA[Every application needs configuration, and every application has secrets. The database host is configuration. The database password is a secret. Kubernetes…]]></description><link>https://devopsjobupdates.hashnode.dev/kubernetes-configmap-vs-secret-key-differences-explained</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/kubernetes-configmap-vs-secret-key-differences-explained</guid><category><![CDATA[Kubernetes]]></category><category><![CDATA[Devops]]></category><category><![CDATA[configmap]]></category><category><![CDATA[secrets]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:25:57 GMT</pubDate><content:encoded><![CDATA[<p>Every application needs configuration, and every application has secrets. The database host is configuration. The database password is a secret. Kubernetes gives you two objects for these two jobs, ConfigMap and Secret, and they look almost identical. Both store key-value pairs. Both can be mounted into a pod as files or injected as environment variables. Both are created with similar commands and referenced from the same places in a manifest. That similarity is exactly why people mix them up, and mixing them up is how passwords end up in plain text in a repository.</p>
<p>The difference is not about the shape of the data. It is about intent, handling and risk. A ConfigMap says “this value is not sensitive, and anyone who can read the cluster can read it.” A Secret says “this value is sensitive, handle it carefully, restrict who can read it, and do not store it in plain text.” The most important fact in this whole article, and the one to remember if you remember nothing else, is this: base64 is not encryption. A Secret’s values are base64-encoded, which is an encoding, not a cipher. Anyone who can read the Secret can decode it in one command. Kubernetes does not encrypt Secrets by default, and treating base64 as security is the single most dangerous misunderstanding in this area.</p>
<p>This article explains both objects properly: what each one stores, how to create and use them, how they differ in practice, when to use which, and how to keep real secrets safe in a production cluster. The examples use Kubernetes v1.37, the current release line as of December 2026, with 1.38 planned for around 16 December 2026. The ConfigMap and Secret APIs have been stable since v1, so nothing here depends on a recent version.</p>
<h2>What a ConfigMap Is and What It Is For</h2>
<p>A ConfigMap is a Kubernetes object that stores non-confidential configuration data as key-value pairs. It exists to separate configuration from code. Instead of baking a database host, a feature flag or a log level into a container image, you put it in a ConfigMap and let the pod read it at runtime. The same image can then run in development, staging and production, each with a different ConfigMap. That separation is one of the core practices of twelve-factor applications, and it is the reason ConfigMaps exist.</p>
<p>ConfigMaps hold plain text. The values are stored exactly as you write them, readable by anyone with permission to read ConfigMaps in the namespace. That is fine, because the values are not sensitive: hostnames, ports, feature flags, log levels, timeouts, and the names of queues and buckets. If a value would cause harm in the wrong hands, it does not belong in a ConfigMap.</p>
<p>A ConfigMap can also hold whole files. You can store an nginx configuration file, an application properties file, or a JSON document as a single key whose value is the file contents. When the ConfigMap is mounted into a pod, each key becomes a file, and the application reads its configuration file exactly as if it had been baked into the image. This pattern is extremely common for applications that expect a configuration file on disk and cannot read environment variables. The official <a href="https://kubernetes.io/docs/concepts/configuration/configmap/">Kubernetes ConfigMap documentation</a> covers the full set of creation methods, including generating ConfigMaps from directories and from environment files.</p>
<p>ConfigMaps have a size limit of 1 MiB per object, which is generous for configuration and far too small for anything else. If you find yourself approaching the limit, your configuration has grown into something else, probably a dataset or a set of templates, and it belongs in a volume or an object store instead. The limit also applies to Secrets, for the same reason: etcd, the cluster’s data store, is not a file server.</p>
<p>Create a ConfigMap from literals, from files, or from a manifest. The imperative commands are the fastest way to learn, and the manifest is the right way to work in production.</p>
<pre><code class="language-bash">kubectl create configmap app-config \
  --from-literal=APP_ENV=production \
  --from-literal=LOG_LEVEL=info \
  --from-literal=DB_HOST=postgres.db.svc.cluster.local

kubectl create configmap nginx-config --from-file=nginx.conf

kubectl get configmap app-config -o yaml
</code></pre>
<p>A manifest for the same ConfigMap looks like this, and it belongs in your repository, because configuration that is not sensitive can and should be versioned alongside the code that uses it.</p>
<pre><code class="language-yaml">apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
  namespace: web
data:
  APP_ENV: production
  LOG_LEVEL: info
  DB_HOST: postgres.db.svc.cluster.local
</code></pre>
<h2>What a Secret Is and Why Base64 Is Not Encryption</h2>
<p>A Secret is a Kubernetes object that stores sensitive data: passwords, API tokens, TLS certificates, SSH keys and OAuth credentials. It has the same key-value shape as a ConfigMap, but Kubernetes treats it differently in several ways, and those differences are the whole point of having a separate object.</p>
<p>First, the values are base64-encoded. When you create a Secret from a literal, kubectl encodes the value before storing it. When you read the Secret back, you see the encoded form, and you must decode it to read the original. This confuses many people into thinking the value is protected. It is not. Base64 is a way of representing binary data as text, not a way of hiding it. Decoding a base64 value takes one command, and anyone who can run <code>kubectl get secret</code> can do it. The encoding exists so that binary data such as certificates and keys can be stored safely in etcd, not to keep the data secret.</p>
<pre><code class="language-bash">kubectl get secret db-credentials -o jsonpath='{.data.password}' | base64 --decode
echo
</code></pre>
<p>Second, Secrets are handled more carefully by the system. They are not written to disk on nodes by default when mounted as volumes, they are stored in tmpfs, which is memory, and they are removed when the pod stops. The API server can be configured to encrypt Secrets at rest in etcd, which is a real protection and one you should enable. And RBAC can restrict who can read Secrets separately from who can read ConfigMaps, which lets you give a developer access to configuration while keeping passwords out of their reach.</p>
<p>Third, Secrets have types. The type tells Kubernetes and the tools around it what kind of data the Secret holds, and it enables validation. The common types are <code>Opaque</code>, the default for arbitrary data; <code>kubernetes.io/tls</code> for a TLS certificate and key pair, which Ingress controllers consume directly; <code>kubernetes.io/basic-auth</code> for a username and password; <code>kubernetes.io/ssh-auth</code> for SSH credentials; and <code>kubernetes.io/dockerconfigjson</code> for registry credentials, which the kubelet uses to pull private images. Using the right type matters: an Ingress that expects a TLS Secret will not accept an Opaque one. The official <a href="https://kubernetes.io/docs/concepts/configuration/secret/">Kubernetes Secret documentation</a> lists every type and the fields each one requires, and it is the reference to check when a type behaves unexpectedly.</p>
<p>Create a Secret the same way you create a ConfigMap, but think before you type. A password passed with <code>--from-literal</code> on the command line is stored in your shell history, which is a leak in itself. Prefer <code>--from-file</code>, which reads the value from a file, or create the Secret from a manifest that is generated by a secrets manager and never committed to Git.</p>
<pre><code class="language-bash">kubectl create secret generic db-credentials \
  --from-literal=username=appuser \
  --from-literal=password='change-me-in-production'

kubectl create secret tls web-tls \
  --cert=tls.crt --key=tls.key

kubectl get secret db-credentials -o yaml
</code></pre>
<p>Never commit a Secret manifest to Git. A ConfigMap manifest belongs in a repository. A Secret manifest, with real values, is a credential leak the moment it is pushed. If you need a Secret in Git for GitOps, use a sealed secret, an external secrets operator, or a templating approach where the values are injected at deploy time from a vault. The rule is absolute: secrets do not go in version control, in any form, including base64, because base64 is not encryption and anyone who finds the file can decode it.</p>
<h2>ConfigMap vs Secret: The Differences That Matter</h2>
<p>Side by side, the two objects are easy to compare, and the comparison shows why you need both rather than one. The table below covers the differences that change real decisions.</p>
<table>
<thead>
<tr>
<th>Aspect</th>
<th>ConfigMap</th>
<th>Secret</th>
</tr>
</thead>
<tbody><tr>
<td>What it stores</td>
<td>Non-sensitive configuration: hosts, ports, flags, log levels</td>
<td>Sensitive data: passwords, tokens, certificates, keys</td>
</tr>
<tr>
<td>Encoding</td>
<td>Plain text, stored as written</td>
<td>Base64-encoded, which is not encryption</td>
</tr>
<tr>
<td>Encryption at rest</td>
<td>Not encrypted by default</td>
<td>Not encrypted by default; enable encryption in etcd explicitly</td>
</tr>
<tr>
<td>Size limit</td>
<td>1 MiB per object</td>
<td>1 MiB per object</td>
</tr>
<tr>
<td>Can hold files</td>
<td>Yes, a whole file as one key</td>
<td>Yes, certificates and keys as files</td>
</tr>
<tr>
<td>Safe in Git</td>
<td>Yes, configuration belongs in version control</td>
<td>No, never commit real secret values</td>
</tr>
<tr>
<td>RBAC</td>
<td>Readable by anyone with ConfigMap access</td>
<td>Can be restricted separately from ConfigMaps</td>
</tr>
<tr>
<td>Types</td>
<td>No types</td>
<td>Opaque, TLS, basic-auth, SSH, dockerconfigjson</td>
</tr>
<tr>
<td>Volume storage</td>
<td>Written to disk on the node</td>
<td>Stored in tmpfs memory, removed when the pod stops</td>
</tr>
<tr>
<td>Updates</td>
<td>Mounted volumes update automatically, with a delay</td>
<td>Mounted volumes update automatically, with a delay</td>
</tr>
<tr>
<td>Environment variables</td>
<td>Injected at pod start; changing them needs a restart</td>
<td>Injected at pod start; changing them needs a restart</td>
</tr>
</tbody></table>
<p>Two rows in that table deserve more attention. The first is updates. When a ConfigMap or Secret is mounted as a volume, the kubelet updates the files in the pod automatically when the object changes, usually within a minute or so. That sounds like live configuration, and it is, but only for applications that re-read their files. Most applications read configuration once at startup and never look again, so the updated file sits there unused until the pod restarts. If you need a configuration change to take effect, the reliable answer is to restart the pods, usually with <code>kubectl rollout restart deployment/NAME</code>. Do not assume a ConfigMap edit has taken effect just because the file changed.</p>
<p>The second is the environment variable row. Injecting configuration as environment variables is convenient, but the values are fixed at pod start. Changing the ConfigMap or Secret does nothing until the pod is recreated. Worse, environment variables are visible to any process that can inspect the pod, including through <code>kubectl exec</code> and, in some runtimes, through the process list. A Secret injected as an environment variable is easier to leak accidentally than one mounted as a file. Prefer volume mounts for sensitive values, and reserve environment variables for values that are genuinely not sensitive.</p>
<p>The practical test for choosing between them is a single question: if this value were published on the internet tomorrow, would it cause harm? If the answer is yes, it is a Secret. If the answer is no, it is a ConfigMap. When you are unsure, treat it as a Secret. The cost of over-protecting a value is small. The cost of under-protecting one can be a breach.</p>
<h2>Using ConfigMaps and Secrets in a Pod</h2>
<p>Both objects reach a pod in the same two ways: as environment variables, or as files in a mounted volume. The manifest below shows both, for a Deployment that needs a database host from a ConfigMap and a database password from a Secret. If you are still learning how Deployments are written, our <a href="https://devopsjobupdates.com/kubernetes-deployment-yaml-tutorial/">Kubernetes Deployment YAML tutorial</a> explains every field in a manifest like this one.</p>
<pre><code class="language-yaml">apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web
        image: myapp:1.4.0
        env:
        - name: APP_ENV
          valueFrom:
            configMapKeyRef:
              name: app-config
              key: APP_ENV
        - name: DB_HOST
          valueFrom:
            configMapKeyRef:
              name: app-config
              key: DB_HOST
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: db-credentials
              key: password
        volumeMounts:
        - name: tls
          mountPath: /etc/tls
          readOnly: true
        - name: app-files
          mountPath: /etc/app
          readOnly: true
      volumes:
      - name: tls
        secret:
          secretName: web-tls
      - name: app-files
        configMap:
          name: app-config
</code></pre>
<p>There are two more ways to inject a whole object at once. <code>envFrom</code> loads every key in a ConfigMap or Secret as environment variables, which is convenient when the object has many keys and you want them all. <code>volumeMounts</code> with a whole ConfigMap or Secret mounts every key as a file in one directory. Both are shorter to write, and both hide which values the pod actually uses, which makes auditing harder. Prefer explicit references for anything important, and use the bulk forms only for objects whose entire contents the pod genuinely needs.</p>
<pre><code class="language-yaml">envFrom:
- configMapRef:
    name: app-config
- secretRef:
    name: db-credentials
</code></pre>
<p>Two failure modes are worth knowing. If a pod references a ConfigMap or Secret that does not exist, the pod will not start. It stays in Pending or ContainerCreating with an event explaining that the object was not found. That is a safety feature: it is better for the pod to refuse to start than to start with missing configuration and fail in a confusing way. The second failure mode is subtler. If a key referenced in <code>env</code> does not exist in the object, the pod also fails to start, unless you mark the reference as optional with <code>optional: true</code>. Use optional references sparingly, because a pod that starts without a value it needs will fail later, in a harder place to diagnose.</p>
<p>Be careful with the order of creation. The ConfigMap or Secret must exist before the pod that references it is created. In practice this means applying your configuration manifests before your workload manifests, or keeping them in the same directory and applying the whole directory at once, which kubectl handles in an order that usually works but is not guaranteed. If a deploy fails because a ConfigMap is missing, create the ConfigMap and re-apply: the failure is recoverable and the error message names the missing object.</p>
<h2>Keeping Real Secrets Safe in Production</h2>
<p>Kubernetes Secrets, on their own, are not enough for production. Base64 is not encryption, etcd does not encrypt by default, and anyone with read access to Secrets in a namespace can decode every value. A production setup needs more, and the layers below are the standard ones.</p>
<p>First, enable encryption at rest for Secrets in etcd. The API server supports an encryption configuration that encrypts Secret data before it is written to etcd, using a key stored on the control plane or in an external key management service. Managed Kubernetes services generally enable this by default or offer it as a setting; on a self-managed cluster you must configure it yourself. This is the single most important step, because without it, anyone who can read etcd or its backups can read every secret in the cluster.</p>
<p>Second, restrict RBAC. Give developers access to ConfigMaps but not Secrets, and give Secrets access only to the service accounts that need it and the operators who manage them. Audit who can read Secrets regularly, because permissions accumulate over time and the person who needed access for one incident three months ago still has it. The principle is least privilege: nobody should be able to read a secret they do not need for their current work.</p>
<p>Third, use an external secrets manager. Tools such as HashiCorp Vault, AWS Secrets Manager, Azure Key Vault and Google Secret Manager store secrets outside the cluster, with rotation, auditing and access control built in. The External Secrets Operator synchronises values from the manager into Kubernetes Secrets, so applications keep using the native Secret mechanism while the real storage lives in a system designed for secrets. The operator also handles rotation: when a password changes in the vault, the Kubernetes Secret is updated automatically.</p>
<p>Fourth, avoid putting secrets in environment variables where you can. Mount them as files instead, so they are not visible in process listings and are not inherited by child processes that do not need them. And never log a secret. Applications that log their environment on startup are leaking every secret they were given, and that log line will live in your log aggregator long after the pod is gone. Audit your application’s startup logs for secret values before you ship it.</p>
<p>Fifth, rotate secrets regularly. A password that has not changed in two years is a password that has had two years to leak. Rotation is easier when secrets come from a manager that supports it, and harder when they were created by hand with kubectl. If rotation is painful, that is a sign the secrets workflow needs fixing, not a reason to skip rotation.</p>
<h2>Common Mistakes and How to Avoid Them</h2>
<p>The most common mistake is putting a secret in a ConfigMap because it was convenient. A database password in a ConfigMap is readable by everyone who can read ConfigMaps, it is stored in plain text, and it is probably committed to Git. The fix is mechanical: move it to a Secret, restrict RBAC, and remove it from the repository history, remembering that removing a file from the current commit does not remove it from history. If a secret has ever been committed, rotate it. There is no way to un-leak a credential.</p>
<p>The second mistake is storing a Secret manifest in Git. The base64 values look protected, and they are not. Anyone with repository access can decode them. Use sealed secrets, external secrets, or generate the Secret at deploy time from a vault. If your GitOps pipeline needs a Secret to exist, the pipeline should create it from a secure source, not from a file in the repository.</p>
<p>The third mistake is assuming a ConfigMap change takes effect immediately. Mounted volumes update within about a minute, but the application usually does not re-read its files, and environment variables never update without a restart. After changing a ConfigMap or Secret, restart the pods with a rollout restart and verify the new value is in use. A change that was never applied is worse than no change at all, because it creates a false belief that the problem is fixed.</p>
<p>The fourth mistake is creating Secrets with <code>--from-literal</code> on a shared machine or in a script that logs its commands. The password ends up in shell history, in the terminal scrollback, and in any audit log that records commands. Use <code>--from-file</code> instead, or read the value from a prompt without echo. Small habits like this are what separate a secure workflow from a leaky one.</p>
<p>The fifth mistake is giving every pod access to every Secret in the namespace. A pod should only be able to read the secrets it needs, and the service account it runs as should only have the permissions it needs. Broad permissions feel harmless until a pod is compromised, at which point the attacker inherits every secret the pod could read. Scope permissions narrowly from the start, because narrowing them later is a migration project.</p>
<h2>Frequently Asked Questions</h2>
<p><strong>Is a Kubernetes Secret encrypted?</strong> Not by default. Secret values are base64-encoded, which is an encoding, not encryption, and anyone who can read the Secret can decode it. Encryption at rest must be enabled explicitly on the API server, and for production you should also use an external secrets manager with rotation and auditing. Treat a Secret as a labelled container for sensitive data, not as a vault.</p>
<p><strong>Can I use a ConfigMap for passwords?</strong> You can, but you should not. A ConfigMap stores values in plain text, is readable by anyone with ConfigMap access, and is safe to commit to Git, which means a password in a ConfigMap is likely to end up in a repository. Passwords, tokens and keys belong in Secrets, with RBAC restrictions and encryption at rest enabled.</p>
<p><strong>How do I update a ConfigMap without downtime?</strong> Edit the ConfigMap, then run <code>kubectl rollout restart</code> on the Deployment so new pods pick up the change. Mounted volumes update automatically within about a minute, but most applications only read configuration at startup, so a restart is the reliable path. For zero-downtime updates, rely on the Deployment’s rolling update strategy, which replaces pods gradually.</p>
<p><strong>What is the difference between env and envFrom?</strong> The <code>env</code> field injects one key at a time with an explicit name, so you control exactly which values the pod receives. <code>envFrom</code> injects every key in a ConfigMap or Secret at once, which is shorter but gives the pod everything in the object, including values it may not need. Prefer <code>env</code> for important values and reserve <code>envFrom</code> for objects whose entire contents the pod genuinely uses.</p>
<p><strong>Should I use Secrets or an external secrets manager?</strong> Use both. Kubernetes Secrets are the mechanism applications consume, and an external manager such as Vault or a cloud secrets service is where the values live, with rotation and auditing. The External Secrets Operator bridges the two. For learning and small projects, native Secrets with encryption at rest and tight RBAC are enough. For production, an external manager is the standard.</p>
<h2>Conclusion</h2>
<p>ConfigMaps and Secrets look alike because they solve the same problem, getting configuration into a pod, for two different kinds of data. ConfigMaps hold the values that are safe to share: hosts, ports, flags and file-based configuration that belongs in version control. Secrets hold the values that must be protected: passwords, tokens and keys, with the understanding that base64 is not encryption and that real protection comes from encryption at rest, tight RBAC, an external secrets manager and regular rotation. Choose between them with one question: would publishing this value cause harm? If yes, it is a Secret. Keep that test in mind, restart pods after changing configuration, and never commit a secret to Git. If you want to go deeper into Kubernetes fundamentals, our <a href="https://devopsjobupdates.com/kubernetes-tutorial-beginners/">Kubernetes tutorial for beginners</a> covers pods, deployments and services from first principles, and our <a href="https://devopsjobupdates.com/cka-certification-guide-2026/">CKA certification guide for 2026</a> shows how ConfigMaps and Secrets appear in the exam, which runs on Kubernetes v1.37 with a two-hour limit, 15 to 20 tasks and a 66 percent pass mark.</p>
<p>Sources: Verified 2 Dec 2026. Kubernetes ConfigMap documentation: <a href="https://kubernetes.io/docs/concepts/configuration/configmap/">https://kubernetes.io/docs/concepts/configuration/configmap/</a> ; Kubernetes Secret documentation: <a href="https://kubernetes.io/docs/concepts/configuration/secret/">https://kubernetes.io/docs/concepts/configuration/secret/</a> . Kubernetes v1.37 current; 1.38 planned ~16 Dec 2026. CKA format (2 hours, 15–20 tasks, 66%, v1.37) cross-checked against Linux Foundation summaries. No unverified figures stated.</p>
]]></content:encoded></item><item><title><![CDATA[Linux systemd Tutorial: Services, Timers, Targets and Logs]]></title><description><![CDATA[Every Linux server you will ever manage as a DevOps engineer runs systemd. It is the first process that starts when the machine boots, it is the process…]]></description><link>https://devopsjobupdates.hashnode.dev/linux-systemd-tutorial-services-timers-targets-and-logs</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/linux-systemd-tutorial-services-timers-targets-and-logs</guid><category><![CDATA[Linux]]></category><category><![CDATA[systemd]]></category><category><![CDATA[Devops]]></category><category><![CDATA[sysadmin]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:23:44 GMT</pubDate><content:encoded><![CDATA[<p>Every Linux server you will ever manage as a DevOps engineer runs systemd. It is the first process that starts when the machine boots, it is the process that starts your application, restarts it when it crashes, collects its logs, and schedules its recurring jobs. You can be a competent engineer without understanding systemd deeply, but you cannot be a fast one. The engineers who fix a failed service in two minutes are the ones who know systemctl, journalctl and unit files by heart.</p>
<p>This tutorial teaches systemd the practical way. You will learn what units and targets are, write a service unit for a real application, control it with systemctl, replace cron jobs with timers, read logs with journalctl, and harden a service so a compromised process cannot damage the host. The examples use Ubuntu 24.04, which ships systemd 255.4, but the commands are the same on Debian 13 (257.13), RHEL 10 (257) and other current distributions. Upstream systemd is at v262 as of September 2026, with 262.2 released on 5 November, but distributions freeze a version for years, so run <code>systemctl --version</code> before trusting any claim about a feature, including the claims in this article.</p>
<p>One important change to know about: systemd 258 removed cgroup v1 support entirely, so cgroup v2 is now always in use, and systemd 260 removed System V init script support. If you still have legacy init scripts on a host, they will not work on a current systemd. The migration path is to write a native unit file, which is exactly what this tutorial teaches you to do.</p>
<h2>What systemd Is and How It Boots Your Machine</h2>
<p>systemd is the init system, process ID 1, on almost every mainstream Linux distribution: Ubuntu, Debian, RHEL, Fedora, SUSE, Arch and Amazon Linux all use it. As PID 1, it is the first process the kernel starts, and it is the parent of every other process on the system. When you shut the machine down, systemd is the last process to exit. That position gives it enormous responsibility: starting services in the right order, watching them while they run, restarting them when they fail, and collecting their output.</p>
<p>It helps to think of systemd as a set of tools rather than one program. The core is the service manager, but the family includes journald for logging, logind for user sessions, networkd for networking, resolved for DNS, timesyncd for time synchronisation, and tmpfiles for managing temporary files. You will meet journald constantly in this tutorial and the others occasionally in passing. The important point is that they share a design philosophy: declarative configuration files, called units, that describe desired state instead of scripts that describe steps.</p>
<p>Everything systemd manages is a unit, named in the form <code>name.type</code>. The types you will meet every week are <code>.service</code> for a process, <code>.socket</code> for a listening socket that can start a service on demand, <code>.timer</code> for a schedule that starts a service, <code>.target</code> for a named group of units used as a synchronisation point, <code>.mount</code> for a filesystem mount, and <code>.slice</code> for a node in the cgroup tree that groups processes for resource control. Targets are the closest thing systemd has to the old runlevels: <code>multi-user.target</code> is the normal state of a server, and <code>graphical.target</code> adds a desktop on top of it.</p>
<p>Unit files live in three places, and the order matters. Distribution packages install units in <code>/usr/lib/systemd/system</code>. The administrator’s overrides and custom units go in <code>/etc/systemd/system</code>, which takes precedence. Per-user units live in <code>~/.config/systemd/user</code>. The rule is simple: never edit a file in <code>/usr/lib/systemd/system</code>, because the next package update will overwrite your changes. Put your unit in <code>/etc/systemd/system</code> or add a drop-in override, which is a small file in a directory named after the unit, such as <code>/etc/systemd/system/nginx.service.d/override.conf</code>. Drop-ins are the clean way to change one setting of a packaged service without copying the whole file.</p>
<p>When you change a unit file, systemd does not notice automatically. You must run <code>sudo systemctl daemon-reload</code> to make it re-read the configuration. Forgetting this step is the single most common systemd mistake, and it produces a confusing symptom: you edit a file, restart the service, and nothing changes. If a change seems to have no effect, run <code>daemon-reload</code> first and ask questions later.</p>
<h2>systemctl: Starting, Stopping and Inspecting Services</h2>
<p>systemctl is the command you will use most, and it controls both the service manager and the units it manages. The verbs are few and consistent, which is what makes them easy to learn. Start, stop, restart, reload, enable, disable, status and is-active cover the large majority of daily work.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
<th>When to use it</th>
</tr>
</thead>
<tbody><tr>
<td><code>systemctl status nginx</code></td>
<td>Shows whether the service is running, its process, recent log lines and whether it is enabled</td>
<td>Your first check on any service; start here before anything else</td>
</tr>
<tr>
<td><code>systemctl start nginx</code></td>
<td>Starts the service now, but not at boot</td>
<td>Starting a service by hand after installing it</td>
</tr>
<tr>
<td><code>systemctl stop nginx</code></td>
<td>Stops the service now</td>
<td>Taking a service down for maintenance</td>
</tr>
<tr>
<td><code>systemctl restart nginx</code></td>
<td>Stops and starts the service</td>
<td>Applying a configuration change that needs a fresh process</td>
</tr>
<tr>
<td><code>systemctl reload nginx</code></td>
<td>Asks the service to reload its configuration without stopping</td>
<td>Configuration changes on services that support reload; no dropped connections</td>
</tr>
<tr>
<td><code>systemctl enable nginx</code></td>
<td>Starts the service automatically at boot</td>
<td>Making a service permanent; always do this for production services</td>
</tr>
<tr>
<td><code>systemctl enable --now nginx</code></td>
<td>Enables at boot and starts immediately</td>
<td>The one command you want when setting up a service</td>
</tr>
<tr>
<td><code>systemctl disable nginx</code></td>
<td>Stops the service starting at boot</td>
<td>Retiring a service without removing it</td>
</tr>
<tr>
<td><code>systemctl is-active nginx</code></td>
<td>Prints active or inactive</td>
<td>Scripts and health checks that need a yes or no answer</td>
</tr>
<tr>
<td><code>systemctl is-enabled nginx</code></td>
<td>Prints enabled or disabled</td>
<td>Auditing which services start at boot</td>
</tr>
<tr>
<td><code>systemctl list-units --type=service --state=failed</code></td>
<td>Lists every failed service</td>
<td>After a reboot or an incident, to find what did not come back</td>
</tr>
<tr>
<td><code>systemctl list-units --type=service --state=running</code></td>
<td>Lists every running service</td>
<td>Getting an overview of what a machine is doing</td>
</tr>
<tr>
<td><code>systemctl show nginx</code></td>
<td>Dumps every property of the service</td>
<td>Debugging a property you cannot find in the unit file</td>
</tr>
<tr>
<td><code>systemctl cat nginx</code></td>
<td>Shows the unit file and its drop-ins</td>
<td>Seeing the effective configuration, including overrides</td>
</tr>
</tbody></table>
<p>Learn the difference between restart and reload, because using the wrong one causes real outages. Restart kills the process and starts a new one, which drops in-flight connections. Reload asks the running process to re-read its configuration, which most well-written daemons support without dropping anything. For nginx, <code>systemctl reload nginx</code> after a configuration change is the safe choice; restart is for when the binary itself changed or the process is wedged. A useful rule: if you changed a configuration file, try reload first. If the service does not support reload, systemctl will tell you, and then you restart.</p>
<p>The status output deserves a careful read. It shows the loaded state, the active state, the main process ID, the cgroup the service runs in, and the last few log lines. The exit code and the signal that killed a process are both shown here, and they often name the problem directly. A service that shows “failed (Result: exit-code)” with status 203 means the executable could not be found or could not be run, which usually points at a wrong path in <code>ExecStart</code>. A service that shows “failed (Result: timeout)” means it did not signal readiness within the timeout, which points at a slow start or a wrong <code>Type</code> setting. Read the status output before reaching for the logs; it narrows the search.</p>
<p>If you want a broader grounding in the Linux commands that surround systemctl, our <a href="https://devopsjobupdates.com/linux-commands-devops-engineers/">Linux commands guide for DevOps engineers</a> covers the essential toolkit.</p>
<h2>Writing Your First Service Unit</h2>
<p>A service unit is a small text file with three sections: <code>Unit</code>, <code>Service</code> and <code>Install</code>. The <code>Unit</code> section describes the service and its dependencies. The <code>Service</code> section describes how to run it. The <code>Install</code> section says when it should start. Here is a complete unit for a small Python web application, which you can adapt to almost any long-running process.</p>
<pre><code class="language-ini">[Unit]
Description=My web application
Documentation=https://example.com/docs
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=appuser
Group=appuser
WorkingDirectory=/opt/myapp
ExecStart=/opt/myapp/venv/bin/python /opt/myapp/app.py
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=5
StartLimitIntervalSec=60
StartLimitBurst=3
Environment=APP_ENV=production
EnvironmentFile=/etc/myapp/env
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target
</code></pre>
<p>Walk through the choices. <code>After=network-online.target</code> with <code>Wants=network-online.target</code> means the service starts after the network is actually usable, not merely after the network service has started. That distinction matters: a service that binds to an address or calls an external API on startup will fail if the network is not ready.</p>
<p><code>Type=simple</code> is the right default for most applications. It means the process started by <code>ExecStart</code> is the main process, and systemd considers the service started as soon as the process is running. The alternatives are <code>forking</code> for old daemons that fork into the background, <code>oneshot</code> for tasks that run and exit, and <code>notify</code> for services that tell systemd explicitly when they are ready. If you are unsure, use <code>simple</code>. Choosing <code>forking</code> for a process that does not fork is a classic error that leaves the service stuck in “activating” forever.</p>
<p><code>Restart=on-failure</code> tells systemd to restart the process when it exits with a non-zero status or is killed by a signal, but not when it exits cleanly. That distinction is deliberate: a process that exits with status zero is saying it finished, and restarting it would loop forever. <code>RestartSec=5</code> waits five seconds between restarts, and the <code>StartLimit</code> settings stop the loop entirely if the service fails three times in sixty seconds. Without a start limit, a broken service restarts forever, filling the disk with logs and hammering the CPU. With one, it fails, stays failed, and waits for a human. That is the correct behaviour: a service that cannot start is a problem to investigate, not a problem to hide with restarts.</p>
<p><code>User</code> and <code>Group</code> run the process as an unprivileged user. Never run an application as root when you can avoid it. Create a dedicated user with no login shell and no home directory, give it ownership of only the files it needs, and let systemd drop privileges before starting the process. If the application is compromised, the attacker gets the permissions of that user, which should be as close to nothing as possible.</p>
<p>To install the unit, save it as <code>/etc/systemd/system/myapp.service</code>, then run <code>sudo systemctl daemon-reload</code>, <code>sudo systemctl enable --now myapp</code>, and <code>sudo systemctl status myapp</code> to confirm it is running. If it fails, the status output and <code>journalctl -u myapp</code> will tell you why. Common first-time errors are a wrong path in <code>ExecStart</code>, a missing <code>WorkingDirectory</code>, and environment variables that exist in your shell but not in the unit.</p>
<h2>Timers: Replacing Cron the systemd Way</h2>
<p>Cron has scheduled jobs on Unix for decades, and it still works. But systemd timers are better for most DevOps work, for three concrete reasons. First, a timer is a unit, which means it has logging, status and failure handling built in, and you can see its history with the same tools you use for services. Second, a timer can run a job that was missed while the machine was off, which cron cannot do. Third, a timer can express schedules cron cannot, such as running a job a fixed time after boot, or with a randomised delay so a hundred machines do not hit a server at the same second.</p>
<p>A timer always works in pairs: a <code>.timer</code> unit that defines the schedule, and a <code>.service</code> unit that defines what runs. Here is a timer that runs a backup script every night at 2 a.m., with the matching service.</p>
<pre><code class="language-ini"># /etc/systemd/system/backup.timer
[Unit]
Description=Run nightly backup

[Timer]
OnCalendar=*-*-* 02:00:00
Persistent=true
RandomizedDelaySec=600

[Install]
WantedBy=timers.target

# /etc/systemd/system/backup.service
[Unit]
Description=Nightly backup job

[Service]
Type=oneshot
User=backup
ExecStart=/usr/local/bin/backup.sh
</code></pre>
<p>The <code>OnCalendar</code> setting uses a calendar expression. <code>*-*-* 02:00:00</code> means every day at 2 a.m. Other useful expressions are <code>Mon *-*-* 03:00:00</code> for Mondays at 3 a.m., <code>*-*-* *:00:00</code> for every hour on the hour, and <code>*-*-01 00:00:00</code> for the first of every month. You can also use monotonic timers: <code>OnBootSec=15min</code> runs fifteen minutes after boot, and <code>OnUnitActiveSec=1h</code> runs one hour after the last run finished. Monotonic timers are ideal for maintenance tasks that should run regularly but do not need a specific clock time.</p>
<p><code>Persistent=true</code> is the setting that makes timers better than cron for machines that are not always on. If the machine was off at 2 a.m., a persistent timer runs the job as soon as the machine boots. <code>RandomizedDelaySec=600</code> spreads the start time by up to ten minutes, which prevents a fleet of machines from all starting a heavy job at the same instant. Both settings cost nothing and prevent real problems.</p>
<p>Manage timers with the same systemctl verbs you already know, plus one extra command to see them all.</p>
<pre><code class="language-bash">sudo systemctl enable --now backup.timer
systemctl list-timers --all
systemctl status backup.timer
sudo systemctl start backup.service   # run the job now, outside its schedule
journalctl -u backup.service          # see the last run's output
</code></pre>
<p>Note that enabling the timer is what matters, not enabling the service. The service is started by the timer, and enabling the service would run it at boot, which is not what you want for a nightly job. A common mistake is enabling both and then wondering why the backup ran at boot. Enable the timer, leave the service disabled, and start the service by hand when you want a run outside the schedule.</p>
<p>When should you keep cron? When the job is trivial, the machine already uses cron for other jobs, and nobody needs logging or failure alerts for it. But the moment a scheduled job matters, when a missed backup or a failed cleanup has consequences, a timer is the better tool. It logs to the journal, it shows up in systemctl status, and it can notify you when it fails.</p>
<h2>journalctl: Reading Logs That Actually Help</h2>
<p>journald collects the output of every service managed by systemd and stores it in a structured, indexed journal. journalctl is the tool for reading it, and it is dramatically more powerful than reading text files, because every log line carries metadata: the unit that produced it, the priority, the timestamp with microsecond precision, and the boot it belongs to.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
<th>When to use it</th>
</tr>
</thead>
<tbody><tr>
<td><code>journalctl -u nginx</code></td>
<td>Shows logs for one unit</td>
<td>Debugging a specific service</td>
</tr>
<tr>
<td><code>journalctl -u nginx -f</code></td>
<td>Follows logs live</td>
<td>Watching a service while you reproduce a problem</td>
</tr>
<tr>
<td><code>journalctl -u nginx --since "1 hour ago"</code></td>
<td>Shows logs from the last hour</td>
<td>Cutting through old noise to the recent problem</td>
</tr>
<tr>
<td><code>journalctl -u nginx --since today</code></td>
<td>Shows today’s logs</td>
<td>Reviewing what happened since midnight</td>
</tr>
<tr>
<td><code>journalctl -b</code></td>
<td>Shows logs from the current boot only</td>
<td>After a reboot, to see what happened since startup</td>
</tr>
<tr>
<td><code>journalctl -b -1</code></td>
<td>Shows logs from the previous boot</td>
<td>Investigating a crash that took the machine down</td>
</tr>
<tr>
<td><code>journalctl -p err</code></td>
<td>Shows only errors and worse</td>
<td>Finding problems without reading informational noise</td>
</tr>
<tr>
<td><code>journalctl -u nginx -o json-pretty</code></td>
<td>Shows logs as structured JSON</td>
<td>Shipping logs to a collector or parsing them in a script</td>
</tr>
<tr>
<td><code>journalctl --disk-usage</code></td>
<td>Shows how much disk the journal uses</td>
<td>When disk space is disappearing</td>
</tr>
<tr>
<td><code>journalctl --vacuum-size=500M</code></td>
<td>Deletes old journal data down to 500 MB</td>
<td>Reclaiming disk in an emergency</td>
</tr>
<tr>
<td><code>journalctl -u nginx --no-pager</code></td>
<td>Prints logs without opening a pager</td>
<td>Scripts and piping output to grep</td>
</tr>
</tbody></table>
<p>The flags combine freely, and the combinations are where the power is. <code>journalctl -u myapp -f --since "10 minutes ago"</code> follows a service’s recent logs live. <code>journalctl -b -p err</code> shows every error since the machine booted, which is the fastest way to find out what went wrong after a bad reboot. <code>journalctl -u myapp -o json-pretty --since today | grep -i timeout</code> finds every timeout in today’s structured logs.</p>
<p>Two things catch people out with journald. The first is persistence. On many distributions, the journal is stored in memory by default and lost on reboot, because the directory <code>/var/log/journal</code> does not exist. Create that directory and restart journald, or set <code>Storage=persistent</code> in <code>/etc/systemd/journald.conf</code>, and logs survive reboots. Do this on every server you care about: logs from the previous boot are exactly the logs you need after a crash, and they are gone forever if the journal was not persistent.</p>
<p>The second is disk usage. The journal grows without limit until it hits its configured cap, and on a busy machine that cap arrives faster than you expect. Check <code>journalctl --disk-usage</code> regularly and set <code>SystemMaxUse</code> in <code>journald.conf</code> to a sensible value for the machine.</p>
<h2>Targets, Dependencies and Troubleshooting Failed Services</h2>
<p>Targets group units and define the state of the machine. <code>multi-user.target</code> is the normal server state. <code>network-online.target</code> means the network is usable. <code>timers.target</code> is the target that timers attach to. You rarely need to create a target, but you need to understand them to read unit files and to debug boot ordering.</p>
<p>Dependencies are declared with a small set of directives, and confusing them causes most boot-order bugs. <code>Wants</code> says start this unit too, but do not fail if it fails. <code>Requires</code> says start this unit, and fail if it fails. <code>After</code> says start this unit after that one, but says nothing about whether it should start at all. The classic mistake is writing <code>After=postgresql.service</code> without <code>Requires</code> or <code>Wants</code>: the service starts after PostgreSQL when PostgreSQL happens to start, but nothing guarantees PostgreSQL starts. If your service needs the database, declare both: <code>After=postgresql.service</code> and <code>Requires=postgresql.service</code>. If it merely benefits from the database being available, use <code>Wants</code> instead of <code>Requires</code>, so a database failure does not take your service down with it.</p>
<p>When a service fails, work through a fixed sequence. First, <code>systemctl status</code> and read the active state, the exit code and the last log lines. Second, <code>journalctl -u SERVICE --since "30 minutes ago"</code> for the full story. Third, <code>systemctl cat SERVICE</code> to see the effective unit file, including drop-ins you may have forgotten. Fourth, check the obvious: does the executable path exist, does the user exist, does the working directory exist, and are the permissions right? Most failures are one of these, and the sequence finds them in minutes.</p>
<p>Some failures have specific signatures worth memorising. Exit code 203 means the executable could not be run, usually a wrong <code>ExecStart</code> path. Exit code 200 means a missing directory in a path directive. A service stuck in “activating” usually means the wrong <code>Type</code>: a simple service that forks, or a forking service that does not. A service that starts by hand but fails at boot usually means a missing <code>After</code> dependency, most often the network. A service that fails only sometimes usually means a race with another service, and the fix is a dependency declaration, not a sleep in a wrapper script. If you write automation around services, our <a href="https://devopsjobupdates.com/bash-scripting-devops/">bash scripting guide for DevOps</a> shows how to check service state from scripts safely.</p>
<h2>Hardening Services and Limiting Resources</h2>
<p>systemd can sandbox a service with a few lines, and this is one of the most valuable things it does for security. The directives below restrict what a compromised process can do, and they cost almost nothing to add. Not every directive works for every service, so add them one at a time and test, but a service that runs with these restrictions is dramatically harder to exploit than one that does not.</p>
<pre><code class="language-ini">[Service]
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
NoNewPrivileges=true
PrivateDevices=true
ProtectKernelTunables=true
ProtectControlGroups=true
ReadWritePaths=/var/lib/myapp
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
MemoryMax=512M
CPUQuota=50%
TasksMax=100
</code></pre>
<p><code>PrivateTmp=true</code> gives the service its own temporary directory, so it cannot see or interfere with other processes’ temporary files. <code>ProtectSystem=strict</code> mounts the whole filesystem read-only except for the paths you explicitly allow with <code>ReadWritePaths</code>. <code>NoNewPrivileges=true</code> prevents the process from gaining new privileges, which blocks a whole class of privilege escalation. Together these turn a compromised application into a process trapped in a small box with nothing useful to attack.</p>
<p>Resource limits use cgroup v2, which is now the only cgroup version systemd supports. <code>MemoryMax=512M</code> kills the process if it exceeds 512 MB of memory, which prevents a memory leak in one service from taking down the whole machine. <code>CPUQuota=50%</code> limits the service to half a CPU. <code>TasksMax=100</code> limits the number of threads and processes it can create, which blocks fork bombs. Set these limits based on what the service actually needs: watch the service under load, find its real usage, and set the limit a little above it.</p>
<p>Use <code>systemd-analyze security SERVICE</code> to audit a service. It scores the unit against a checklist of hardening options and reports an exposure level, with suggestions for what to add. Run it on every service you write, and treat a high exposure score the way you would treat a failing test: fix it before shipping. The systemd.service man page documents every directive, and the systemctl man page documents every command in this tutorial. When a directive behaves in a way you did not expect, the man page is the authority, not a blog post.</p>
<h2>Frequently Asked Questions</h2>
<p><strong>What is the difference between systemctl and service?</strong> The <code>service</code> command is a compatibility wrapper from the old SysV init era that forwards to systemctl on systemd machines. <code>systemctl</code> is the native tool and the one you should learn: it exposes everything systemd can do, while <code>service</code> only covers the basics. The old wrapper still works, but it hides the features that make systemd worth using.</p>
<p><strong>Why does my service fail at boot but work when I start it manually?</strong> Almost always a missing dependency. The usual cause is the network: the service needs <code>network-online.target</code> but only declares <code>network.target</code>, or declares neither. Another common cause is a dependency on a mounted filesystem that is not ready yet. Check the journal for the boot in question with <code>journalctl -b</code> and look at the first error; it usually names the missing resource directly.</p>
<p><strong>Should I use systemd timers or cron?</strong> Use timers when the job matters: when a missed run has consequences, when you need logging and failure alerts, or when you want the job to run after a missed schedule. Use cron for trivial jobs on machines that already use it. Timers are units, so they get status, logging and failure handling for free, which is why they are the better default for production work.</p>
<p><strong>How do I see logs from the previous boot?</strong> Run <code>journalctl -b -1</code> to see the previous boot, or <code>journalctl –list-boots</code> to see all recorded boots and pick one. This only works if the journal is persistent, which requires the directory <code>/var/log/journal</code> to exist or <code>Storage=persistent</code> in <code>journald.conf</code>. Set that up before you need it, because logs from a crashed boot cannot be recovered afterwards.</p>
<p><strong>Can I run systemd services as a normal user?</strong> Yes. User services live in <code>~/.config/systemd/user</code> and are managed with <code>systemctl –user</code>. They run with your permissions, start when you log in by default, and can be made to start at boot with <code>loginctl enable-linger</code>. User services are ideal for development tools and personal daemons that do not need root, and they keep system services clean.</p>
<h2>Conclusion</h2>
<p>systemd is not glamorous, but it is the foundation every Linux service stands on. Learn systemctl until the verbs are automatic, write unit files instead of wrapper scripts, use timers for jobs that matter, and read the journal before guessing. The habits in this tutorial, declaring dependencies explicitly, setting restart limits, running as an unprivileged user, hardening with sandbox directives, are small individually and transformative together. The next step is to take a service you currently start by hand or from a script and convert it to a unit file. If you want to go deeper into Linux for operations work, our <a href="https://devopsjobupdates.com/linux-for-devops-engineers/">Linux for DevOps engineers guide</a> covers the wider toolkit this tutorial builds on.</p>
<p>Sources: Verified 2 Dec 2026. systemd.service man page: <a href="https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html">https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html</a> ; systemctl man page: <a href="https://www.freedesktop.org/software/systemd/man/latest/systemctl.html">https://www.freedesktop.org/software/systemd/man/latest/systemctl.html</a> . systemd v262 upstream (22 Sep 2026, 262.2 on 5 Nov); distro versions per release trackers — re-check your distro’s version with systemctl –version before relying on a feature. No unverified figures stated.</p>
]]></content:encoded></item><item><title><![CDATA[kubectl Cheat Sheet: 100+ Commands for Daily Kubernetes Work]]></title><description><![CDATA[kubectl is the tool you will type more than any other in a Kubernetes job. Every deploy, every debug session, every 3 a.m. incident runs through it. The…]]></description><link>https://devopsjobupdates.hashnode.dev/kubectl-cheat-sheet-100-commands-for-daily-kubernetes-work</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/kubectl-cheat-sheet-100-commands-for-daily-kubernetes-work</guid><category><![CDATA[Kubernetes]]></category><category><![CDATA[kubectl]]></category><category><![CDATA[Devops]]></category><category><![CDATA[cli]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:21:06 GMT</pubDate><content:encoded><![CDATA[<p>kubectl is the tool you will type more than any other in a Kubernetes job. Every deploy, every debug session, every 3 a.m. incident runs through it. The difference between a fast engineer and a slow one is rarely knowledge of Kubernetes internals. It is fluency: knowing the right command without searching, reading output quickly, and never running a destructive command against the wrong cluster.</p>
<p>This cheat sheet is organised by the job in front of you, not by resource type. When a pod is crashing, you do not want a list of every command that mentions pods. You want the five commands that diagnose a crash, in order. Each section below follows that logic: the commands for one task, what each one does, when to use it, and the mistakes that catch people out. Everything is verified against kubectl v1.37, the current release line as of December 2026, with the latest patch at v1.37.2. The command syntax is stable across recent versions, so these commands also work on 1.36 and 1.35 clusters, but keep your kubectl client within one minor version of the cluster: that is the official version skew policy, and straying further produces warnings and, eventually, real incompatibilities.</p>
<p>Before you copy anything into a terminal, learn the one habit that prevents the most damage in Kubernetes work. Always confirm your context before a command that changes something. A <code>kubectl delete</code> against production when you thought you were on a local cluster is the kind of mistake that ends careers and weekends. The first section of this sheet is about contexts for exactly that reason. Read it first, set up the safety habits, and then use the rest of the sheet freely.</p>
<h2>Setup, Contexts and Knowing Where You Are</h2>
<p>kubectl talks to clusters through a kubeconfig file, usually at <code>~/.kube/config</code>. That file lists clusters, users and contexts. A context ties a cluster, a user and a default namespace together, and one context is marked current. Every kubectl command runs against the current context unless you override it with a flag. Understanding that single sentence explains half of all kubectl surprises.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
<th>When to use it</th>
</tr>
</thead>
<tbody><tr>
<td><code>kubectl version</code></td>
<td>Shows client and server versions</td>
<td>First check on any unfamiliar machine; warns when client and server are more than one minor version apart</td>
</tr>
<tr>
<td><code>kubectl version --client</code></td>
<td>Shows only the client version</td>
<td>When there is no cluster to talk to, or you only care about the local binary</td>
</tr>
<tr>
<td><code>kubectl cluster-info</code></td>
<td>Shows the API server address and core services</td>
<td>Sanity check that you can reach a cluster at all</td>
</tr>
<tr>
<td><code>kubectl config get-contexts</code></td>
<td>Lists every context; a star marks the current one</td>
<td>Before any destructive command, and whenever you switch machines</td>
</tr>
<tr>
<td><code>kubectl config current-context</code></td>
<td>Prints the name of the current context</td>
<td>The fastest safety check; put it in your shell prompt</td>
</tr>
<tr>
<td><code>kubectl config use-context NAME</code></td>
<td>Switches the current context</td>
<td>Moving between staging and production, or between clusters</td>
</tr>
<tr>
<td><code>kubectl config set-context --current --namespace=web</code></td>
<td>Sets the default namespace for the current context</td>
<td>When you will spend a session working in one namespace</td>
</tr>
<tr>
<td><code>kubectl config view --minify</code></td>
<td>Shows the current context in detail</td>
<td>Debugging authentication or namespace surprises</td>
</tr>
</tbody></table>
<p>Two habits make contexts safe. First, put the current context and namespace in your shell prompt. Tools such as <code>kube-ps1</code> do this for bash and zsh, and once you have it you will wonder how you worked without it. Second, use the <code>--context</code> and <code>--namespace</code> flags for one-off commands instead of switching context.</p>
<p>Install kubectl from the official Kubernetes package repository for your distribution, or download the static binary from <code>dl.k8s.io</code>. The <a href="https://kubernetes.io/docs/reference/kubectl/quick-reference/">kubectl quick reference</a> in the official Kubernetes documentation is the authoritative companion to this sheet: it lists every command with its flags, and it is the page the CKA exam allows you to consult during the test. Speaking of the exam, if you are preparing for certification, this sheet covers the commands you will need most. The CKA is a two-hour performance-based exam with 15 to 20 practical tasks on live clusters, a 66 percent pass mark, and a current version of Kubernetes v1.37. Our <a href="https://devopsjobupdates.com/cka-certification-guide-2026/">CKA certification guide for 2026</a> explains the format, domains and study plan in full.</p>
<p>Enable shell completion and set up a short alias. Completion turns kubectl from a memory test into a guided interface, and the alias saves thousands of keystrokes over a year. Keep the full kubectl spelling in runbooks and documentation, and use the alias only interactively.</p>
<pre><code class="language-bash">source &lt;(kubectl completion bash)   # bash; use zsh or fish equivalents
echo 'source &lt;(kubectl completion bash)' &gt;&gt; ~/.bashrc
alias k=kubectl
complete -o default -F __start_kubectl k
</code></pre>
<h2>Reading State: get, describe and Output Formats</h2>
<p>Most kubectl work is reading state. You ask what exists, what state it is in, and what changed. The <code>get</code> command lists resources, and <code>describe</code> explains one resource in human-readable detail. Learn their flags and you will spend far less time guessing.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
<th>When to use it</th>
</tr>
</thead>
<tbody><tr>
<td><code>kubectl get pods</code></td>
<td>Lists pods in the current namespace</td>
<td>Your first look at any namespace</td>
</tr>
<tr>
<td><code>kubectl get pods -A</code></td>
<td>Lists pods in every namespace</td>
<td>Finding a pod when you do not know its namespace</td>
</tr>
<tr>
<td><code>kubectl get pods -o wide</code></td>
<td>Adds node, IP and nominated node columns</td>
<td>Checking where pods are scheduled and whether IPs look right</td>
</tr>
<tr>
<td><code>kubectl get pods -w</code></td>
<td>Watches pods and updates live</td>
<td>Watching a rollout or a pod restarting in real time</td>
</tr>
<tr>
<td><code>kubectl get pods --field-selector=status.phase!=Running</code></td>
<td>Lists only pods that are not running</td>
<td>Finding the broken pods without scrolling through healthy ones</td>
</tr>
<tr>
<td><code>kubectl get pods -l app=web</code></td>
<td>Lists pods matching a label</td>
<td>Working with one application among many</td>
</tr>
<tr>
<td><code>kubectl get deploy,svc,cm -l app=web</code></td>
<td>Lists several resource types at once</td>
<td>Getting the whole picture for one application</td>
</tr>
<tr>
<td><code>kubectl get pod NAME -o yaml</code></td>
<td>Shows the full object as YAML</td>
<td>Copying a spec, or seeing fields that describe hides</td>
</tr>
<tr>
<td><code>kubectl get pod NAME -o jsonpath='{.status.podIP}'</code></td>
<td>Prints one field</td>
<td>Scripting, or pulling one value out of a large object</td>
</tr>
<tr>
<td><code>kubectl get pods --sort-by=.metadata.creationTimestamp</code></td>
<td>Sorts by age</td>
<td>Finding the newest or oldest pods quickly</td>
</tr>
<tr>
<td><code>kubectl describe pod NAME</code></td>
<td>Human-readable summary: status, events, mounts, conditions</td>
<td>Diagnosing why a pod is not starting or not ready</td>
</tr>
<tr>
<td><code>kubectl describe deploy -l app=web</code></td>
<td>Describes every matching deployment</td>
<td>Checking rollout state and replica counts</td>
</tr>
<tr>
<td><code>kubectl explain pod.spec.containers.resources</code></td>
<td>Shows the documentation for a field</td>
<td>Writing YAML when you cannot remember a field name</td>
</tr>
<tr>
<td><code>kubectl api-resources</code></td>
<td>Lists every resource type the cluster knows</td>
<td>Discovering custom resources and short names</td>
</tr>
</tbody></table>
<p>Output formats deserve a closer look because they change how fast you work. The default table output is for humans. YAML output is for copying and for seeing everything, including the fields you did not know existed. JSONPath output is for scripts and for extracting one value.</p>
<pre><code class="language-bash">kubectl get pods -o custom-columns=NAME:.metadata.name,NODE:.spec.nodeName,RESTARTS:.status.containerStatuses[0].restartCount
kubectl get pods -o jsonpath='{.items[*].metadata.name}'
kubectl get svc -o wide
</code></pre>
<p>Learn the short names. They are not trivia; they are speed. <code>po</code> for pods, <code>deploy</code> for deployments, <code>svc</code> for services, <code>cm</code> for configmaps, <code>secret</code> for secrets, <code>ns</code> for namespaces, <code>no</code> for nodes, <code>ing</code> for ingress, <code>sts</code> for statefulsets, <code>ds</code> for daemonsets, <code>job</code> for jobs. <code>kubectl get po</code> is the same as <code>kubectl get pods</code>, and after the hundredth time the saved keystrokes add up. The full list is in <code>kubectl api-resources</code>, which also shows the short names for custom resources installed in your cluster.</p>
<p>One more reading habit: use <code>kubectl get events</code> early in any investigation. Events are the cluster’s own diary: scheduled, pulled, started, failed, back-off. They expire after about an hour by default, so they are most useful soon after a problem starts.</p>
<pre><code class="language-bash">kubectl get events --sort-by=.lastTimestamp
kubectl get events --types=Warning
kubectl get events -n web --field-selector involvedObject.name=api-7d9f
</code></pre>
<h2>Creating, Applying and Editing Resources</h2>
<p>There are two ways to create resources: imperative commands that do one thing immediately, and declarative files that describe the desired state. Imperative commands are for learning, experimenting and emergencies. Declarative files are for everything that matters. A deployment created with a one-liner cannot be reviewed, versioned or reproduced. The same deployment in a YAML file in Git can be all three.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
<th>When to use it</th>
</tr>
</thead>
<tbody><tr>
<td><code>kubectl apply -f app.yaml</code></td>
<td>Creates or updates resources from a file</td>
<td>Everyday deployments; the default for real work</td>
</tr>
<tr>
<td><code>kubectl apply -f .</code></td>
<td>Applies every file in a directory</td>
<td>Deploying a whole application at once</td>
</tr>
<tr>
<td><code>kubectl apply -f https://example.com/app.yaml</code></td>
<td>Applies a manifest from a URL</td>
<td>Installing operators and add-ons from upstream</td>
</tr>
<tr>
<td><code>kubectl diff -f app.yaml</code></td>
<td>Shows what would change, without changing anything</td>
<td>Before every apply you are unsure about</td>
</tr>
<tr>
<td><code>kubectl create deployment web --image=nginx:1.29</code></td>
<td>Creates a deployment imperatively</td>
<td>Quick experiments and learning</td>
</tr>
<tr>
<td><code>kubectl create namespace web</code></td>
<td>Creates a namespace</td>
<td>Setting up a new environment or team space</td>
</tr>
<tr>
<td><code>kubectl create configmap app --from-literal=KEY=VALUE</code></td>
<td>Creates a ConfigMap from a literal</td>
<td>Quick configuration for a test</td>
</tr>
<tr>
<td><code>kubectl create secret generic db --from-literal=password=secret</code></td>
<td>Creates a Secret from a literal</td>
<td>Seeding a secret by hand; prefer sealed or external secrets in production</td>
</tr>
<tr>
<td><code>kubectl run debug --image=busybox:1.28 -it --rm -- sh</code></td>
<td>Runs a one-off pod and deletes it on exit</td>
<td>Network tests and quick checks from inside the cluster</td>
</tr>
<tr>
<td><code>kubectl edit deploy/web</code></td>
<td>Opens a resource in your editor</td>
<td>Small urgent fixes; the change is not in Git, so record it</td>
</tr>
<tr>
<td><code>kubectl delete -f app.yaml</code></td>
<td>Deletes everything defined in a file</td>
<td>Tearing down an application cleanly</td>
</tr>
<tr>
<td><code>kubectl delete pod NAME --grace-period=0 --force</code></td>
<td>Force-deletes a pod</td>
<td>Only for pods stuck terminating; never as a routine</td>
</tr>
</tbody></table>
<p>The <code>kubectl diff</code> command is the most underused safety tool in the set. Running <code>kubectl diff -f app.yaml</code> before <code>kubectl apply -f app.yaml</code> shows exactly what will change, in the same way <code>git diff</code> shows what a commit will do. Make it a habit, and make it a team rule. The five seconds it takes have saved more production incidents than any other single habit in this sheet.</p>
<p>When you need a starting manifest, generate one instead of writing it from memory. <code>kubectl create deployment web --image=nginx:1.29 --dry-run=client -o yaml</code> prints the YAML without creating anything, and <code>--dry-run=client -o yaml</code> works with most create commands. Pipe the output to a file and you have a valid starting point that you can edit and commit. This is also the fastest way to learn YAML structure: generate it, read it, change one thing, and see what happens.</p>
<p>Be careful with <code>kubectl edit</code>. It is fast and it feels productive, but the change lives only in the cluster. The next time someone applies the manifest from Git, your edit is overwritten. If you must edit imperatively during an incident, open a pull request to put the change in Git before the incident review.</p>
<h2>Logs, Exec and Debugging a Failing Pod</h2>
<p>When a pod is failing, work in order: status, events, logs, then a shell inside the container. Skipping ahead to a shell wastes time when the answer was in the events all along. The commands below follow that order.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
<th>When to use it</th>
</tr>
</thead>
<tbody><tr>
<td><code>kubectl logs POD</code></td>
<td>Shows the current container logs</td>
<td>First look at what the application is saying</td>
</tr>
<tr>
<td><code>kubectl logs POD -f</code></td>
<td>Streams logs live</td>
<td>Watching behaviour as it happens</td>
</tr>
<tr>
<td><code>kubectl logs POD --previous</code></td>
<td>Shows logs from the previous, crashed container</td>
<td>The container that just died holds the answer; this is the single most missed flag in kubectl</td>
</tr>
<tr>
<td><code>kubectl logs POD -c CONTAINER</code></td>
<td>Shows logs for one container in a multi-container pod</td>
<td>Sidecar pods, where the default container is not the one you want</td>
</tr>
<tr>
<td><code>kubectl logs -l app=web --tail=50</code></td>
<td>Shows the last 50 lines for all matching pods</td>
<td>Getting a quick sample across replicas</td>
</tr>
<tr>
<td><code>kubectl logs POD --since=10m</code></td>
<td>Shows logs from the last ten minutes</td>
<td>Cutting through hours of noise to the recent problem</td>
</tr>
<tr>
<td><code>kubectl exec -it POD -- sh</code></td>
<td>Opens a shell in the container</td>
<td>Inspecting files, environment and network from inside</td>
</tr>
<tr>
<td><code>kubectl exec POD -- env</code></td>
<td>Runs one command without an interactive shell</td>
<td>Checking environment variables or running a single diagnostic</td>
</tr>
<tr>
<td><code>kubectl debug -it POD --image=busybox:1.28 --target=CONTAINER</code></td>
<td>Adds an ephemeral debug container sharing the pod’s namespaces</td>
<td>The image has no shell; distroless and minimal images need this</td>
</tr>
<tr>
<td><code>kubectl port-forward svc/api 8080:80</code></td>
<td>Forwards a local port to a service</td>
<td>Testing a service from your laptop without exposing it</td>
</tr>
<tr>
<td><code>kubectl port-forward pod/POD 8080:80</code></td>
<td>Forwards a local port to one pod</td>
<td>Testing a single replica in isolation</td>
</tr>
<tr>
<td><code>kubectl cp POD:/path/file ./file</code></td>
<td>Copies a file out of a container</td>
<td>Retrieving a config file or a crash dump for inspection</td>
</tr>
</tbody></table>
<p>The <code>--previous</code> flag deserves emphasis because it is the difference between solving a crash and staring at an empty log. When a container crashes and restarts, <code>kubectl logs</code> shows the new container, which has just started and has nothing interesting to say. The old container, the one that actually failed, is only reachable with <code>--previous</code>. If you remember one flag from this whole sheet, remember that one.</p>
<p>When the image has no shell, <code>kubectl debug</code> is the answer. Distroless images are popular precisely because they contain no shell and no package manager, which makes them smaller and harder to attack, but it also means <code>kubectl exec</code> fails. The debug command attaches an ephemeral container with the tools you need, sharing the target container’s process namespace so you can inspect it. The ephemeral container disappears when you exit, and it requires a cluster that supports ephemeral containers, which all recent versions do.</p>
<p>A reliable debugging sequence for a pod stuck in CrashLoopBackOff looks like this. First, <code>kubectl describe pod</code> and read the events at the bottom: they often name the cause directly, such as a failed image pull or a missing ConfigMap. Then <code>kubectl logs POD --previous</code> to read the crash output. Then check the pod’s resource requests against the node’s available capacity, and check whether a liveness probe is killing a slow-starting container. Most crashes are one of these causes, and the sequence finds them in minutes.</p>
<h2>Rollouts, Scaling and Rollbacks</h2>
<p>Deployments exist so that updates are boring. The rollout commands let you watch an update, pause it, and roll it back when it goes wrong, all without touching YAML.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
<th>When to use it</th>
</tr>
</thead>
<tbody><tr>
<td><code>kubectl rollout status deployment/web</code></td>
<td>Waits and reports until the rollout finishes or fails</td>
<td>After every apply; add it to your deploy scripts</td>
</tr>
<tr>
<td><code>kubectl rollout history deployment/web</code></td>
<td>Lists past revisions</td>
<td>Finding which revision is live and what came before</td>
</tr>
<tr>
<td><code>kubectl rollout history deployment/web --revision=3</code></td>
<td>Shows the details of one revision</td>
<td>Checking what changed in a specific release</td>
</tr>
<tr>
<td><code>kubectl rollout undo deployment/web</code></td>
<td>Rolls back to the previous revision</td>
<td>The new version is broken; get the old one back now</td>
</tr>
<tr>
<td><code>kubectl rollout undo deployment/web --to-revision=2</code></td>
<td>Rolls back to a specific revision</td>
<td>The previous revision was also bad; go further back</td>
</tr>
<tr>
<td><code>kubectl rollout restart deployment/web</code></td>
<td>Restarts all pods gradually</td>
<td>Picking up a changed ConfigMap or Secret, or clearing a stuck state</td>
</tr>
<tr>
<td><code>kubectl rollout pause deployment/web</code></td>
<td>Pauses a rollout mid-flight</td>
<td>Canary style: stop at one replica and check before continuing</td>
</tr>
<tr>
<td><code>kubectl rollout resume deployment/web</code></td>
<td>Resumes a paused rollout</td>
<td>The canary looks good; let the rollout finish</td>
</tr>
<tr>
<td><code>kubectl set image deployment/web app=img:1.1</code></td>
<td>Changes the image of one container</td>
<td>Quick image update without editing a file</td>
</tr>
<tr>
<td><code>kubectl scale deployment/web --replicas=5</code></td>
<td>Sets the replica count</td>
<td>Manual scaling for a traffic spike or a quiet period</td>
</tr>
<tr>
<td><code>kubectl autoscale deployment/web --min=2 --max=10 --cpu-percent=70</code></td>
<td>Creates a HorizontalPodAutoscaler</td>
<td>Letting the cluster scale on CPU automatically</td>
</tr>
<tr>
<td><code>kubectl get hpa</code></td>
<td>Shows autoscaler status</td>
<td>Checking whether scaling is keeping up with demand</td>
</tr>
</tbody></table>
<p>Two rollout facts save real incidents. First, <code>kubectl rollout undo</code> is fast because the old ReplicaSet still exists with its old pods ready to scale back up. It is not a redeploy; it is a switch back to something that already ran. Second, a rollout that is stuck usually means the new pods never became ready, which usually means a readiness probe is failing or the image cannot be pulled. If you are learning how deployments are written, our <a href="https://devopsjobupdates.com/kubernetes-deployment-yaml-tutorial/">Kubernetes Deployment YAML tutorial</a> walks through a complete manifest field by field.</p>
<p>Be careful with <code>kubectl rollout restart</code>. It is tempting to use it as a fix for everything, because restarting pods often makes a symptom disappear. But it also destroys the evidence: the logs of the old pods are gone unless you captured them, and the underlying cause is still there. Restart to recover service, then investigate the cause.</p>
<h2>Nodes, Namespaces and Cluster Administration</h2>
<p>Nodes are where pods run, and namespaces are how teams share a cluster without stepping on each other. The commands in this section are the ones cluster administrators and on-call engineers reach for when the problem is bigger than one pod.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
<th>When to use it</th>
</tr>
</thead>
<tbody><tr>
<td><code>kubectl get nodes</code></td>
<td>Lists nodes and their status</td>
<td>First check when pods cannot be scheduled</td>
</tr>
<tr>
<td><code>kubectl get nodes -o wide</code></td>
<td>Adds addresses, OS and container runtime</td>
<td>Checking node versions and network details</td>
</tr>
<tr>
<td><code>kubectl describe node NODE</code></td>
<td>Shows capacity, allocatable resources and conditions</td>
<td>Working out whether a node is full or unhealthy</td>
</tr>
<tr>
<td><code>kubectl top nodes</code></td>
<td>Shows live CPU and memory per node</td>
<td>Finding the hot node; requires metrics-server</td>
</tr>
<tr>
<td><code>kubectl top pods -A</code></td>
<td>Shows live CPU and memory per pod</td>
<td>Finding the pod eating all the memory</td>
</tr>
<tr>
<td><code>kubectl cordon NODE</code></td>
<td>Marks a node unschedulable</td>
<td>Preparing a node for maintenance without killing anything</td>
</tr>
<tr>
<td><code>kubectl drain NODE --ignore-daemonsets --delete-emptydir-data</code></td>
<td>Evicts pods from a node safely</td>
<td>Removing a node for maintenance or replacement</td>
</tr>
<tr>
<td><code>kubectl uncordon NODE</code></td>
<td>Marks a node schedulable again</td>
<td>After maintenance is finished</td>
</tr>
<tr>
<td><code>kubectl get namespaces</code></td>
<td>Lists namespaces</td>
<td>Seeing how the cluster is divided up</td>
</tr>
<tr>
<td><code>kubectl get all -n web</code></td>
<td>Lists the common resources in a namespace</td>
<td>A quick inventory; note it does not show every resource type</td>
</tr>
<tr>
<td><code>kubectl delete namespace web</code></td>
<td>Deletes a namespace and everything in it</td>
<td>Only when you are certain; this is not undoable</td>
</tr>
<tr>
<td><code>kubectl get pods -A --field-selector spec.nodeName=NODE</code></td>
<td>Lists every pod on one node</td>
<td>Seeing what will be affected before draining a node</td>
</tr>
</tbody></table>
<p>Always cordon before you drain, and always check what is on the node first. Draining evicts pods, and pods with local <code>emptyDir</code> data or without a controller to recreate them will be lost unless you pass the right flags. The drain command will refuse to proceed when it would strand a pod, which is a safety feature, not an annoyance.</p>
<p><code>kubectl get all</code> is a useful shortcut with a trap: it shows pods, services, deployments, ReplicaSets and a few other common types, but not ConfigMaps, Secrets, Ingresses or custom resources. A namespace can look empty under <code>get all</code> while still holding the ConfigMap your application needs. For a real inventory, list the specific types or use <code>kubectl api-resources</code> to see what exists in your cluster.</p>
<h2>Permissions, Output Tricks and Daily Habits</h2>
<p>RBAC decides what you are allowed to do, and the fastest way to understand a permission error is to ask the cluster before you try the action. The <code>auth can-i</code> command does exactly that.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
<th>When to use it</th>
</tr>
</thead>
<tbody><tr>
<td><code>kubectl auth can-i delete pods</code></td>
<td>Checks whether you can delete pods in the current namespace</td>
<td>Before a command that might fail on permissions</td>
</tr>
<tr>
<td><code>kubectl auth can-i create deployments -n web</code></td>
<td>Checks a permission in a specific namespace</td>
<td>Confirming access before a deploy to a new namespace</td>
</tr>
<tr>
<td><code>kubectl auth can-i '*' '*' --all-namespaces</code></td>
<td>Checks whether you are effectively a cluster admin</td>
<td>Understanding how much power your account has</td>
</tr>
<tr>
<td><code>kubectl auth whoami</code></td>
<td>Shows who you are authenticated as</td>
<td>Debugging identity surprises on shared machines</td>
</tr>
<tr>
<td><code>kubectl get roles,rolebindings -n web</code></td>
<td>Lists RBAC roles and bindings</td>
<td>Working out who can do what in a namespace</td>
</tr>
<tr>
<td><code>kubectl get clusterroles,clusterrolebindings</code></td>
<td>Lists cluster-wide RBAC</td>
<td>Auditing broad permissions</td>
</tr>
<tr>
<td><code>kubectl wait --for=condition=Ready pod -l app=web --timeout=120s</code></td>
<td>Blocks until pods are ready or the timeout hits</td>
<td>Scripts that must not proceed until the app is up</td>
</tr>
<tr>
<td><code>kubectl get pods -A -o json | jq -r '.items[].metadata.name'</code></td>
<td>Pipes full JSON into jq for processing</td>
<td>Reporting and scripting across the whole cluster</td>
</tr>
<tr>
<td><code>kubectl proxy</code></td>
<td>Starts a local proxy to the API server</td>
<td>Exploring the API from a browser or curl on localhost</td>
</tr>
<tr>
<td><code>kubectl get pods -A --no-headers | wc -l</code></td>
<td>Counts all pods in the cluster</td>
<td>Quick size checks and capacity conversations</td>
</tr>
</tbody></table>
<p>A few habits tie the whole sheet together. Keep kubectl within one minor version of your clusters, and upgrade the client when the cluster upgrades. Use <code>kubectl diff</code> before every apply you are unsure about. Put the context in your prompt. Use <code>--previous</code> for crashed containers. And never run a delete against a context you have not just verified. These five habits prevent the large majority of kubectl accidents, and they cost nothing.</p>
<p>The official kubectl reference documents every command and flag in full, including the ones this sheet skips, such as certificate management, node debugging and the plugin system. When you need a flag this sheet does not list, that reference is the first place to look, and <code>kubectl COMMAND --help</code> is the fastest way to see it in the terminal.</p>
<h2>Frequently Asked Questions</h2>
<p><strong>How do I switch between clusters with kubectl?</strong></p>
<p>Use contexts. <code>kubectl config get-contexts</code> lists them, <code>kubectl config use-context NAME</code> switches the current one, and <code>kubectl --context NAME get pods</code> runs a single command against another cluster without switching. Put the current context in your shell prompt so you always know where you are.</p>
<p><strong>Why does kubectl say my pod is in CrashLoopBackOff?</strong></p>
<p>The container starts, fails, and Kubernetes restarts it with increasing delays. Run <code>kubectl describe pod</code> for the events, then <code>kubectl logs POD --previous</code> to read the output of the container that crashed. The common causes are a bad image, a missing ConfigMap or Secret, a failed readiness probe, or the application itself exiting on startup.</p>
<p><strong>What is the difference between kubectl apply and kubectl create?</strong></p>
<p>Create makes a new resource and fails if it already exists. Apply creates it if it is missing and updates it if it exists, based on the file you pass. Apply is the right default for real work because it is repeatable: you can run the same command ten times and get the same result. Create is for one-off experiments.</p>
<p><strong>Can I use kubectl without a cluster?</strong></p>
<p>Mostly no. kubectl is a client for the Kubernetes API, so it needs a cluster to talk to. You can run <code>kubectl version --client</code> and generate YAML with <code>--dry-run=client</code> without a cluster, and for learning you can run a local cluster with <code>kind</code> or <code>minikube</code> on your laptop, which gives you a real API server to practise against.</p>
<p><strong>How do I prepare for the CKA exam with kubectl?</strong></p>
<p>Practise the commands in this sheet until they are muscle memory, especially <code>get</code>, <code>describe</code>, <code>logs</code>, <code>exec</code>, <code>apply</code>, <code>diff</code>, <code>rollout</code> and <code>drain</code>. The CKA is a two-hour performance-based exam with 15 to 20 tasks, a 66 percent pass mark, and Kubernetes v1.37 as the current version. Speed matters as much as knowledge: you have roughly six to eight minutes per task, so practise under time pressure and learn to use the official documentation quickly.</p>
<h2>Conclusion</h2>
<p>kubectl rewards fluency more than almost any other tool in DevOps. The commands in this sheet are the ones working engineers type every day, and the habits around them, verifying context, diffing before applying, reading logs from the previous container, are what separate a smooth shift from a painful one. Keep this sheet open in a second tab, practise the debugging sequence until it is automatic, and build a local cluster with <code>kind</code> or <code>minikube</code> so you can try the destructive commands safely. If you are still learning the basics, our <a href="https://devopsjobupdates.com/kubernetes-tutorial-beginners/">Kubernetes tutorial for beginners</a> covers pod lifecycle and common failure states from first principles.</p>
<p>Sources: Verified 2 Dec 2026. kubectl quick reference: <a href="https://kubernetes.io/docs/reference/kubectl/quick-reference/">https://kubernetes.io/docs/reference/kubectl/quick-reference/</a> ; kubectl reference: <a href="https://kubernetes.io/docs/reference/kubectl/">https://kubernetes.io/docs/reference/kubectl/</a> . kubectl v1.37.2 latest stable; version skew policy within one minor version. CKA format (2 hours, 15–20 tasks, 66%, v1.37) cross-checked against Linux Foundation summaries; exam price not stated — re-check on the Linux Foundation CKA page before booking.</p>
]]></content:encoded></item><item><title><![CDATA[Grafana Dashboard Tutorial: Build, Customise and Alert]]></title><description><![CDATA[A Grafana dashboard turns raw metrics into something a human can act on at 3 a.m. When a service starts failing, nobody opens a terminal and reads a wall…]]></description><link>https://devopsjobupdates.hashnode.dev/grafana-dashboard-tutorial-build-customise-and-alert</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/grafana-dashboard-tutorial-build-customise-and-alert</guid><category><![CDATA[Grafana]]></category><category><![CDATA[monitoring]]></category><category><![CDATA[Devops]]></category><category><![CDATA[observability]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:18:25 GMT</pubDate><content:encoded><![CDATA[<p>A Grafana dashboard turns raw metrics into something a human can act on at 3 a.m. When a service starts failing, nobody opens a terminal and reads a wall of numbers. They open a dashboard, and within seconds they need to know three things: what is broken, how bad it is, and whether it is getting worse. A well-built dashboard answers all three. A badly built one adds noise to an incident that is already stressful enough.</p>
<p>This tutorial walks you through building Grafana dashboards the way working DevOps engineers actually build them: install Grafana, connect Prometheus, build a dashboard that answers the four golden signals, template it with variables so it works across environments, wire up alerting, and store the result as code. By the end you will have a production-shaped dashboard for a web service: request rate, error rate, latency and saturation — the same shape you would build on the job.</p>
<h2>What a Grafana Dashboard Is and How It Works</h2>
<p>Grafana itself does not collect metrics. That surprises people who are new to observability, so it is worth stating plainly: Grafana is a visualisation and alerting layer that sits on top of a data source. The data source — Prometheus, in this tutorial — stores the time series, and Grafana queries it, draws the results, and fires alerts when a threshold is crossed. Understanding that split makes everything else in this tutorial easier, because every decision about what a panel shows is really a decision about what the underlying query asks for.</p>
<p>A dashboard is a collection of panels arranged in rows on a grid. Each panel runs one or more queries against a data source and visualises the result — a time series graph, a single number, a gauge, a table. Panels can be resized and rearranged, grouped into rows, and linked to other dashboards. A dashboard is not a report: it is a live view that refreshes as new data arrives, and the refresh interval you choose is part of the design.</p>
<p>Behind the scenes, a dashboard is a JSON document. Every panel, query, threshold and layout choice is stored as JSON, which means dashboards can be exported, version-controlled, and provisioned from files — the basis of the “dashboard as code” approach covered later in this tutorial. <a href="https://grafana.com/docs/grafana/latest/dashboards/">Grafana dashboard documentation</a> describes the full JSON model and every panel option.</p>
<p>Grafana organises dashboards into folders, and access is controlled by organisations, folders and dashboard permissions. Give the whole team viewer access to the dashboards they need, editor access only to the people who build them, and admin access to almost nobody. That discipline matters more as dashboards multiply, because a dashboard that anyone can edit is a dashboard that someone will break at 2 a.m.</p>
<p>Before you build anything, decide what the dashboard is for. The best dashboards answer one question for one audience — the on-call engineer at 3 a.m., the team lead reviewing a release, the product manager tracking adoption. A dashboard that tries to answer everything answers nothing, because every extra panel dilutes the ones that matter.</p>
<p>The classic starting point for a web service is the four golden signals: latency, traffic, errors and saturation. Latency is how long requests take, traffic is how many requests arrive, errors are the share that fail, and saturation is how close your resources are to their limits. A dashboard that shows all four, at a glance, tells you whether the service is healthy or not.</p>
<h2>Installing Grafana and Connecting Prometheus</h2>
<p>The fastest reliable way to run Grafana for learning is Docker. One container gives you a clean install you can delete and recreate in seconds, and a named volume keeps your dashboards when the container is removed:</p>
<pre><code class="language-bash">docker volume create grafana-data
docker run -d --name grafana \
  -p 3000:3000 \
  -v grafana-data:/var/lib/grafana \
  -e GF_SECURITY_ADMIN_USER=admin \
  -e GF_SECURITY_ADMIN_PASSWORD=admin \
  grafana/grafana-oss:latest
</code></pre>
<p>Open <code>http://localhost:3000</code> in your browser and sign in with the default credentials, admin and admin. Grafana will ask you to change the password on first login — do it, even on a local install, because a default password on a service that eventually gets exposed to a network is how incidents start.</p>
<p>If you would rather install Grafana on a Linux server, Grafana Labs publishes official packages for Debian, Ubuntu and Red Hat-based distributions, and the service is managed with systemd like any other: <code>sudo systemctl enable --now grafana-server</code> to start it and enable it at boot, and <code>sudo systemctl status grafana-server</code> to check it is running. The configuration file lives at <code>/etc/grafana/grafana.ini</code>, and the data directory defaults to <code>/var/lib/grafana</code>. If you want a refresher on how services like this are managed on Linux, our <a href="https://devopsjobupdates.com/linux-commands-devops-engineers/">Linux commands guide for DevOps engineers</a> covers the systemctl workflow in detail.</p>
<p>Next you need data. A dashboard without a data source is an empty frame, so connect Prometheus before you build anything. If you followed our <a href="https://devopsjobupdates.com/prometheus-grafana-monitoring-tutorial/">Prometheus and Grafana monitoring tutorial</a>, you already have a Prometheus server scraping targets. If not, you can run one quickly with Docker:</p>
<pre><code class="language-bash">docker run -d --name prometheus \
  -p 9090:9090 \
  prom/prometheus:v3.0.0
</code></pre>
<p>To add Prometheus as a data source, go to Connections, then Data sources, then Add data source, and choose Prometheus. The URL is <code>http://localhost:9090</code> if Prometheus runs on the same machine, or the address of your Prometheus server if it runs elsewhere. The <a href="https://grafana.com/docs/grafana/latest/datasources/prometheus/">Prometheus data source documentation</a> lists the full set of connection options. Click Save and test. Grafana runs a small query and reports success — if it fails, check that Prometheus is actually running and that the URL is reachable from the Grafana container, which is the most common mistake when both run in Docker.</p>
<p>Set a sensible default refresh interval for each dashboard. A five-minute refresh is reasonable for a dashboard you glance at occasionally; a five-second refresh is for a dashboard you stare at during an incident, and it hammers the data source. Choose the interval that matches how the dashboard is actually used.</p>
<h2>Building Your First Dashboard Step by Step</h2>
<p>With Grafana running and Prometheus connected, create your first dashboard. Click Dashboards, then New, then New dashboard, and add your first panel.</p>
<p>Start with the simplest useful panel: request rate. If your Prometheus server scrapes a web application that exposes an <code>http_requests_total</code> counter, the query <code>rate(http_requests_total[5m])</code> gives you requests per second over a five-minute window. If you only have Prometheus scraping itself, use <code>rate(prometheus_http_requests_total[5m])</code> instead; the mechanics are identical. Choose the Time series visualisation, set the panel title to “Request rate” and the unit to Requests/sec. Save the panel.</p>
<p>Now add a second panel for error rate. The query below divides the rate of error responses by the rate of all responses, giving you the share of requests that fail:</p>
<pre><code class="language-promql">sum(rate(http_requests_total{status=~"5.."}[5m]))
  /
sum(rate(http_requests_total[5m]))
</code></pre>
<p>Set the unit to Percent (0-1) if your query returns a ratio, or Percent (0-100) if it returns a number out of a hundred — getting this wrong is the most common reason an error-rate panel shows 0.04% when the real error rate is 4%. Set the title to “Error rate” and add a threshold at 0.05 so the panel turns red when more than 5% of requests are failing.</p>
<p>Repeat the pattern for latency. A good latency query uses a histogram if your application exposes one: <code>histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))</code> gives you the 95th percentile latency, which is the number that matters in practice. Averages hide the slow requests that your users actually notice, while the 95th percentile shows what the slowest 5% of requests experience. Set the unit to seconds and the title to “95th percentile latency”.</p>
<p>Arrange the three panels in a row across the top of the dashboard. This top row is the most valuable real estate on the dashboard: it is what the on-call engineer sees first, and it should answer the three questions from the introduction — what is broken, how bad it is, and whether it is getting worse. Below it, add a second row for saturation: CPU and memory usage, disk usage, and the number of running instances. Those panels tell you why the top row looks the way it does.</p>
<p>Save the dashboard with a clear name, such as “Web API overview”, and add a description explaining what it covers and who it is for. A dashboard with no description is a dashboard nobody trusts, because nobody knows whether it is current or abandoned.</p>
<h2>Panels That Actually Help: Time Series, Stat, Gauge and Table</h2>
<p>Grafana ships with many visualisation types, and beginners often try all of them at once. Resist that. Four panel types cover almost every monitoring need, and learning when to use each one is more valuable than learning the other twenty.</p>
<p>The time series panel is the default and the workhorse. Use it whenever the shape of a metric over time matters: request rate, error rate, latency, CPU usage. If you cannot see the trend, you cannot tell whether a problem is getting worse or getting better, and the time series panel is the only visualisation that shows you the trend.</p>
<p>The stat panel shows a single number, large and unmissable. Use it for the numbers that define health right now: current error rate, requests per second, number of healthy instances. A stat panel answers “how bad is it?” at a glance, and it is the right choice for the top row of an incident dashboard, where the reader has no time to read a graph.</p>
<p>The gauge panel is similar to a stat panel but shows the value against a range, which makes it good for saturation metrics: CPU usage as a percentage of capacity, memory usage, disk usage, queue depth. A gauge tells you not just the number but how close you are to the limit, which is the information that matters for saturation.</p>
<p>The table panel is for lists: the top ten endpoints by error count, instances sorted by memory usage, the slowest queries in the last hour. Use it when the question is “which one?” rather than “how much?” — which endpoint is failing, which instance is hot, which query is slow.</p>
<p>Whatever visualisation you choose, apply the same discipline to thresholds. A threshold should mean something: the value above which a human needs to act. A threshold set at an arbitrary round number is decoration, and a dashboard full of decorative thresholds trains the team to ignore all of them, including the ones that matter.</p>
<h2>Variables, Templating and Multi-Environment Dashboards</h2>
<p>The moment you have a second environment, copy-pasting dashboards becomes a liability. You end up with a production dashboard, a staging dashboard and a development dashboard that drift apart, and a fix applied to one never reaches the others. Variables solve this: one dashboard, templated, that works for every environment.</p>
<p>Create a variable from the dashboard settings, under Variables. The most common type is a query variable, which runs a PromQL query and uses the results to populate a dropdown. To build an environment variable, use <code>label_values(http_requests_total, environment)</code>, which returns every value of the environment label. To build a service variable, use <code>label_values(http_requests_total, service)</code>. Grafana populates the dropdown from the query results, so the list stays accurate as your infrastructure changes — no manual updates when a new service appears.</p>
<p>Use the variable in your queries with the dollar syntax. A query that was <code>rate(http_requests_total[5m])</code> becomes <code>rate(http_requests_total{environment="$environment", service="$service"}[5m])</code>. When you switch the dropdown, every panel updates. You can also set a variable to multi-value, which lets the reader select several environments at once and compare them on the same graph — useful when you want to see whether a problem affects production only or every environment.</p>
<p>Variables can depend on each other. A service variable can be filtered by the selected environment, with a query such as <code>label_values(http_requests_total{environment="$environment"}, service)</code>, and Grafana refreshes it whenever the environment changes.</p>
<p>Two practical tips make variables work smoothly. First, give every variable a clear label, because the dropdown is the first thing a reader interacts with, and a variable labelled “env” with values “prod”, “staging” and “dev” is clearer than one labelled “e” with values nobody recognises. Second, set a sensible default — usually production — so the dashboard opens on the view that matters most.</p>
<p>Variables also make dashboards reusable across teams. A platform team can build one dashboard for HTTP services, template it by service, and hand it to every team, instead of building a slightly different dashboard for each one. That is how a small platform team supports dozens of services without drowning in dashboard maintenance.</p>
<h2>Alerting and Dashboard as Code</h2>
<p>A dashboard that nobody watches is a poster. Alerting is what turns it into a monitoring system. Grafana includes a built-in alerting system — Grafana Alerting — that evaluates rules against your data sources and sends notifications when a condition is met.</p>
<p>Create an alert rule from a panel by choosing Alert in the panel menu, or from the Alerting section in the sidebar. A rule has a query, a condition, and an evaluation interval. The classic first rule is the one from the error-rate panel: alert when the error rate exceeds 5% for five minutes. The “for five minutes” part matters — without it, a single spike triggers a page, and the team learns to ignore alerts. Set the evaluation interval to match the pace of the problem: a minute for fast-moving errors, five minutes for slower trends.</p>
<p>Every alert needs a runbook link and a clear summary. The alert message should say what is wrong, which service is affected, and where to look first. An alert that says “Error rate high” at 3 a.m. is a puzzle; an alert that says “Error rate on the payments API is 12%, runbook at <a href="https://example.com/runbooks/payments-errors%E2%80%9D">https://example.com/runbooks/payments-errors”</a> is a task. Write the message as if the reader has just been woken up, because they have.</p>
<p>Once dashboards and alerts are working, store them as code. Export a dashboard from its settings menu as JSON, commit the JSON to version control, and provision it with Grafana’s provisioning system or the API. Provisioning loads dashboard JSON from a directory on disk, so a Grafana instance that starts fresh automatically gets the dashboards your team has committed. That means dashboards survive a Grafana rebuild, changes are reviewed like code, and a dashboard that was accidentally deleted is one git revert away from being restored.</p>
<p>The same approach applies to alert rules, which can be provisioned from files or managed through the API. The full provisioning model is covered in Grafana’s documentation, and the investment pays off the first time a dashboard is lost and restored from version control instead of rebuilt from memory.</p>
<h2>Common Mistakes and How to Fix Them</h2>
<p>The most common dashboard mistake is too many panels. A dashboard with forty panels is not comprehensive, it is unreadable. If a panel has not helped anyone make a decision in the last month, delete it. A dashboard should fit on one screen without scrolling, and every panel on it should earn its place.</p>
<p>The second mistake is queries that are too expensive. A query that scans a huge amount of data over a long time range is slow, and a dashboard full of them is unusable during an incident, which is exactly when you need it most. Use recording rules in Prometheus to pre-compute expensive queries, keep the time range short by default, and avoid queries that return thousands of series when a dozen would do.</p>
<p>The third mistake is stale dashboards. A dashboard built for a service that has since changed its metrics, its labels or its architecture shows numbers that no longer mean what they say. Review dashboards regularly — quarterly is a good cadence — and delete or fix the ones that have drifted. A dashboard that shows wrong numbers is worse than no dashboard, because it creates false confidence.</p>
<p>The fourth mistake is ignoring time zones and time ranges. Grafana defaults to the browser’s local time zone, which means the same dashboard shows different times to engineers in different countries, and an incident timeline discussed in UTC does not match a graph drawn in local time. Set the dashboard time zone explicitly — UTC is the usual choice for teams that span time zones — and make sure the default time range is useful, usually the last hour or the last six hours rather than the last 24.</p>
<p>Finally, watch out for panels that look healthy because they show no data. A graph with no line can mean the metric is zero, or it can mean the query matches nothing, and those two situations are very different. Use the “No data” state deliberately: configure panels to show a clear warning when there is no data, so a missing metric is visible instead of invisible.</p>
<h2>Frequently Asked Questions</h2>
<p><strong>What is the difference between Grafana and Prometheus?</strong></p>
<p>Prometheus collects and stores time series metrics by scraping targets, and it has its own query language, PromQL, and a basic built-in interface. Grafana is a visualisation and alerting layer that queries Prometheus (and many other data sources) and turns the results into dashboards and alerts. You need Prometheus to have data; you need Grafana to make that data readable at a glance.</p>
<p><strong>Is Grafana free to use?</strong></p>
<p>Yes. Grafana open source is free under the AGPL licence and covers dashboards, data sources and alerting. Grafana Labs also offers a managed cloud service and an enterprise edition with additional features such as advanced authentication and reporting, but the open source edition is what this tutorial uses, and it is enough for the dashboards described here.</p>
<p><strong>How do I share a dashboard with my team?</strong></p>
<p>The simplest way is to give teammates access to the same Grafana instance with viewer or editor roles, and organise dashboards into folders so each team finds its own. For sharing outside your Grafana instance, export the dashboard as JSON and share the file, or use a snapshot, which creates a public, read-only link to a static copy of the dashboard at a point in time.</p>
<p><strong>Why is my panel showing no data?</strong></p>
<p>The usual causes are a wrong data source, a query that matches no series, a label value that does not exist, or a time range in which the metric was not collected. Check the query in the Explore view, where you can run it directly and see the raw results, and verify that the data source is connected and the metric name is correct.</p>
<p><strong>Should I use Grafana Cloud or self-host Grafana?</strong></p>
<p>Self-hosting is free and gives you full control, and it is the best choice for learning. Grafana Cloud removes the operational work — no upgrades, no backups, no availability worries — and it is the better choice for a team that wants monitoring without running another service. The dashboards you build work the same way in both, so starting self-hosted and moving later costs you nothing.</p>
<h2>Conclusion</h2>
<p>A good Grafana dashboard is a tool for making decisions under pressure. Build it around the four golden signals, keep the panel count small, template it with variables so one dashboard serves every environment, and wire up alerting with clear messages and runbook links. Store the result as code, review it regularly, and delete the panels that have stopped earning their place.</p>
<p>If dashboards are the visible part of the job, read our <a href="https://devopsjobupdates.com/site-reliability-engineer-career-guide/">site reliability engineer career guide</a> to see how dashboards and alerting fit into the wider SRE role.</p>
<p>Sources: Verified 2 Dec 2026. Grafana dashboard documentation: <a href="https://grafana.com/docs/grafana/latest/dashboards/">https://grafana.com/docs/grafana/latest/dashboards/</a> ; Prometheus data source documentation: <a href="https://grafana.com/docs/grafana/latest/datasources/prometheus/">https://grafana.com/docs/grafana/latest/datasources/prometheus/</a> .</p>
]]></content:encoded></item><item><title><![CDATA[GitHub Actions Self-Hosted Runners: Setup, Security and Scaling]]></title><description><![CDATA[GitHub-hosted runners are the easy default for GitHub Actions: you write a workflow, GitHub provides the machine, and the job runs on a clean environment…]]></description><link>https://devopsjobupdates.hashnode.dev/github-actions-self-hosted-runners-setup-security-and-scaling</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/github-actions-self-hosted-runners-setup-security-and-scaling</guid><category><![CDATA[GitHub]]></category><category><![CDATA[CI/CD]]></category><category><![CDATA[Devops]]></category><category><![CDATA[runners]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:13:44 GMT</pubDate><content:encoded><![CDATA[<p>GitHub-hosted runners are the easy default for GitHub Actions: you write a workflow, GitHub provides the machine, and the job runs on a clean environment every time. But there comes a point where the default is not enough. Your builds need a GPU, or a licensed tool that only exists on your network, or a machine with far more memory than the hosted options offer, or simply a machine you already pay for that sits idle overnight. That is when you run your own runner.</p>
<p>A self-hosted runner is a machine you deploy and manage that executes jobs from GitHub Actions. It can be physical, virtual, in a container, on-premises or in a cloud — the shape does not matter, the contract does: the runner application connects to GitHub, receives job assignments, runs them, and reports the results back. This guide takes you through that contract end to end: choosing between hosted and self-hosted, meeting the requirements, registering your first runner, routing jobs with labels, keeping the fleet healthy, securing it, and scaling it when one machine is no longer enough.</p>
<h2>Self-Hosted vs GitHub-Hosted Runners</h2>
<p>The trade-off is control against convenience. GitHub-hosted runners need no setup, start from a clean image for every job, and disappear when the job finishes, which makes them the safest choice for public repositories and the simplest choice for most teams. Self-hosted runners give you custom hardware, custom software and access to your local network, and they cost nothing from GitHub — you pay for the machines you already own or rent. The price of that control is that you own the maintenance: patching, monitoring, scaling and securing the fleet is your job now.</p>
<p>Choose self-hosted when the job has a requirement the hosted runners cannot meet. The common reasons are specialised hardware such as GPUs or Apple silicon for iOS builds, software that is licensed to a specific machine or only available on your internal network, very large jobs that need more CPU or memory than hosted runners provide, and jobs that must run inside a private network to reach internal services. Choose hosted when none of those apply, and especially for public repositories, where a self-hosted runner can be tricked into running untrusted code from a fork — a risk covered in detail in the security section below.</p>
<p>There are differences in behaviour to plan for. GitHub-hosted runners always start clean, so a job cannot be affected by the previous job’s leftovers. A self-hosted runner keeps its state between jobs unless you clean it, which means a build that passes on a hosted runner can fail on a self-hosted one because of a cached dependency, and a job can accidentally read files left behind by the previous job. The runner application itself receives automatic updates, though you can disable them — keep them on unless you have a reason not to, because an outdated runner is a runner with known bugs. If you have not used Actions at all yet, our <a href="https://devopsjobupdates.com/github-actions-tutorial/">GitHub Actions tutorial</a> builds your first workflow on hosted runners first, and our <a href="https://devopsjobupdates.com/cicd-pipeline-explained/">CI/CD pipeline explained</a> guide covers the concepts — build, test, deploy — that the runners in this guide exist to execute.</p>
<h2>Requirements: OS, Hardware and Network</h2>
<p>A machine can be a self-hosted runner if it meets three conditions: you can install and run the runner application on it, it can communicate with GitHub Actions, and it has enough hardware for the workflows you plan to run. The runner application itself needs only minimal resources — the hardware requirement comes from your jobs, not from the runner, so size the machine for the heaviest workflow it will run, not for the runner process.</p>
<p>GitHub documents the supported operating systems on the <a href="https://docs.github.com/en/actions/reference/runners/self-hosted-runners">self-hosted runners reference</a> page. On Linux, that includes Red Hat Enterprise Linux 8 or later, CentOS 8 or later, Oracle Linux 8 or later, Fedora 29 or later, Debian 10 or later, Ubuntu 20.04 or later, Linux Mint 20 or later, openSUSE 15.2 or later and SUSE Enterprise Linux 15 SP2 or later. On Windows, it is Windows 10 64-bit, Windows 11 64-bit and Windows Server 2016, 2019 and 2022, all 64-bit. On macOS, it is macOS 11.0 (Big Sur) or later. The supported processor architectures are x64 on all three platforms, and ARM64 on Linux, macOS and Windows, which the reference page marks as currently in public preview. If your machine runs an older operating system than these minimums, upgrade it before you start — an unsupported OS is the most common reason a runner installation fails.</p>
<p>One rule catches many teams: if your workflows use Docker container actions or service containers, you must use a Linux machine with Docker installed. Container actions do not run on Windows or macOS runners, so a team that standardises on container actions needs a Linux fleet even if its developers use Macs. Check what your workflows actually use before you choose the fleet’s operating system.</p>
<p>The network requirements are modest but specific. The runner needs at least 70 kilobits per second of upload and download speed, and it must be able to reach GitHub’s domains over HTTPS on port 443. The runner connects out to GitHub — GitHub does not connect in to the runner — so you do not need to open inbound ports, but a restrictive corporate proxy or firewall that blocks the GitHub domains will stop the runner from receiving jobs. If the runner is behind a proxy, configure the proxy in the runner’s environment before registration, and verify the connection with a simple job before you declare the runner ready.</p>
<p>Size the hardware for the job, not for the runner. A machine that only runs linting and unit tests is comfortable with two CPUs and a few gigabytes of memory, while a machine that builds container images or compiles a large codebase wants four or more CPUs, at least 16 gigabytes of memory, and fast local disk — image builds are usually disk-bound before they are CPU-bound. Give the runner a generous disk: a single Docker build can leave behind gigabytes of layers, and a runner that shares a small disk with the operating system will fill it without warning. If you run several runners on one host, remember they share the host’s resources, so the sizing is per concurrent job, not per machine. Start with one runner per machine while you learn the load pattern, and only pack multiple runners onto a host once you know how much a single job actually consumes.</p>
<h2>Installing and Registering Your First Runner</h2>
<p>Registration starts in the GitHub UI, not on the machine. Open the repository, organisation or enterprise settings, go to Actions, then Runners, and click New self-hosted runner. Choose the operating system and architecture, and GitHub shows you the exact download and configuration commands for that platform, including a registration token that is generated for you. That token expires after one hour, so have the machine ready before you generate it — if it expires, generate a new one and start the configuration step again.</p>
<p>On a Linux machine, the commands look like this. The version in the download URL is whatever GitHub shows on the New runner page at the time you register — use the commands from that page, not a version number from a tutorial, because the runner is updated regularly:</p>
<pre><code class="language-bash"># Create a directory for the runner and move into it
mkdir actions-runner &amp;&amp; cd actions-runner

# Download the runner package shown on the New runner page.
# Copy the URL from that page — it contains the current version number,
# which changes with every release, so do not copy one from a tutorial.
curl -o actions-runner-linux-x64.tar.gz -L \
  https://github.com/actions/runner/releases/download/v2.338.2/actions-runner-linux-x64-2.338.2.tar.gz

# Extract the package
tar xzf ./actions-runner-linux-x64.tar.gz

# Install the dependencies the runner needs
sudo ./bin/installdependencies.sh

# Configure the runner — the URL is your repository or organisation,
# and the token is the one shown on the New runner page
./config.sh --url https://github.com/your-org/your-repo --token YOUR_TOKEN

# Start the runner
./run.sh
</code></pre>
<p>The version in that download URL is 2.338.2, the current release as of 2 December 2026. If you are reading this later, copy the exact URL from the New self-hosted runner page, because the runner is updated regularly — if you hard-code an old version from a blog post, you will install an old runner and spend an afternoon wondering why a feature is missing.</p>
<p>Run the runner as a dedicated, unprivileged user — never as root. Create a user account for the runner, give it ownership of the runner directory, and run the configuration and the runner process as that user. The configuration script asks a few questions: the runner’s name, whether to add custom labels, and which work folder to use. Accept the defaults the first time, verify the runner appears in the GitHub UI with the status Idle, and only then start customising. GitHub’s enterprise guide, <a href="https://docs.github.com/en/enterprise-cloud@latest/admin/github-actions/getting-started-with-github-actions-for-your-enterprise/getting-started-with-self-hosted-runners-for-your-enterprise">Getting started with self-hosted runners for your enterprise</a>, walks through the same flow at organisation and enterprise level, including the policy that restricts which actions and reusable workflows are allowed — worth reading before you add runners to an organisation rather than a single repository.</p>
<h2>Labels and Routing Jobs to the Right Runner</h2>
<p>Labels are how GitHub decides which runner runs a job. Every runner automatically gets the labels self-hosted, its operating system (linux, windows or macos) and its architecture (x64 or arm64). You can add custom labels at registration time with the --labels flag, and a workflow requests runners by listing the labels its jobs need:</p>
<pre><code class="language-bash">./config.sh --url https://github.com/your-org/your-repo \
  --token YOUR_TOKEN \
  --labels gpu,cuda,linux-large
</code></pre>
<pre><code class="language-yaml">jobs:
  train-model:
    runs-on: [self-hosted, gpu, cuda]
    steps:
      - uses: actions/checkout@v4
      - run: python train.py

  build:
    runs-on: [self-hosted, linux, large]
    steps:
      - uses: actions/checkout@v4
      - run: make build
</code></pre>
<p>GitHub routes a job to a runner that matches all of the requested labels, and the routing rules have a few sharp edges. A job that asks for a label no runner has will sit in the queue until it fails — the maximum time a job stays queued before it fails is 24 hours, and if an assigned runner does not pick the job up within 60 seconds, GitHub re-queues it to another matching runner. A job that asks only for self-hosted can land on any runner in the pool, including one without the tools it needs, so be specific about the labels that matter and keep the label set small: a handful of meaningful labels per runner is maintainable, while a dozen overlapping labels becomes a routing puzzle nobody can reason about.</p>
<p>Runner groups add a layer of access control on top of labels. At organisation and enterprise level, you can put runners into groups and decide which repositories may use each group — a GPU group for the machine-learning repositories, a general group for everything else. Groups are the mechanism that stops a repository from borrowing a runner it should not have access to, and they are worth setting up before the fleet grows, because retrofitting access control onto a fleet that every repository already uses is a migration in itself.</p>
<h2>Running as a Service and Keeping Runners Healthy</h2>
<p>A runner started with ./run.sh in a terminal stops when the terminal closes and does not survive a reboot. For anything beyond a first experiment, install the runner application as a service. On Linux that means systemd, on macOS a launchd agent, and on Windows a Windows service — GitHub’s documentation covers each platform, and the commands are run from the runner directory:</p>
<pre><code class="language-bash">sudo ./svc.sh install
sudo ./svc.sh start
sudo ./svc.sh status
</code></pre>
<p>On Linux, <code>svc.sh</code> install takes an optional username argument — pass the dedicated runner user you created, so the service runs as that user rather than root. On macOS, the service installs as a launchd agent for the logged-in user. Check the status after installation, reboot the machine, and confirm the runner comes back online and shows Idle in the GitHub UI. A runner that does not survive a reboot is a runner that will be offline on Monday morning after a weekend of patching.</p>
<p>Healthy runners need routine care. Watch disk space, because build artefacts, Docker images and caches accumulate on a machine that runs job after job, and a full disk is the most common cause of a runner that starts failing jobs for no apparent reason. Schedule a clean-up job — either a workflow that runs on the runner itself or a cron job on the host — that removes old work directories, prunes unused Docker images and clears package caches. Monitor the runner’s status in the GitHub UI: Idle, Active and Offline are the states that matter, and a runner that sits Offline after a reboot needs attention before the queue backs up behind it.</p>
<p>Keep the software on the runner current, and keep the runner’s own dependencies pinned deliberately. If your workflows need a specific version of Node, Python or the AWS CLI, install it on the runner image and document the version, so a job that passes today does not fail next month because a tool was upgraded underneath it. Better still, build the runner as an image — a virtual machine image or a container image — so that every runner in the fleet is identical and a replacement is a fresh copy of the image rather than a hand-configured machine.</p>
<p>When a runner misbehaves, the logs are on the machine, not in the GitHub UI. The runner writes its own logs into the _diag folder inside the runner directory, and each job writes a log for every step it runs, which you can read in the workflow run view on GitHub. Start with the job log: it shows which step failed and the command that failed. If the runner itself is the problem — it shows Offline, or it never picks up jobs — read the _diag logs, which record the runner’s connection attempts, its registration state and its update history. A runner that appears Offline usually has a network problem, an expired registration, or a service that is not running; the diagnostic log distinguishes those three in a few lines, while guessing from the UI takes far longer. Re-registering a runner that has lost its configuration is a normal operation, not a failure: remove it with ./config.sh remove --token YOUR_TOKEN and register it again.</p>
<h2>Security: The Rules That Protect Your Machine</h2>
<p>Self-hosted runners are powerful and therefore dangerous, and GitHub’s documentation is unusually direct about the risk: it recommends using self-hosted runners only with private repositories. The reason is that a fork of a public repository can open a pull request that runs code in a workflow, and that code executes on your runner, on your network, with whatever permissions the runner’s environment provides. A malicious workflow could read files from the machine, reach internal services, or exfiltrate secrets. That is not a theoretical risk; it is the documented reason for the recommendation, and it is the first thing to internalise before you add a self-hosted runner to a public repository.</p>
<p>Limit what the runner can reach. The runner machine should not hold production credentials, should not have network access to production databases, and should not share a network segment with anything sensitive. Treat the runner as untrusted compute: give it the minimum network access its jobs need, put it in its own network segment, and assume that any job could be malicious. If a workflow needs a secret, pass it through GitHub’s encrypted secrets, scoped to the repository that needs it, rather than storing it on the machine where every job can read it.</p>
<p>Ephemeral runners are the strongest mitigation. An ephemeral runner is configured with --ephemeral at registration, runs exactly one job, and then is automatically removed. Because each job starts from a clean machine, there is no state for a malicious job to poison and no credential for it to steal from a previous run. Ephemeral runners are more work to operate — you need automation that creates a fresh runner for each job and destroys it afterwards — but for public repositories or untrusted workloads they are the correct design, and they are the foundation of the scaling approach in the next section.</p>
<p>Compare that with the Jenkins model many teams already know, where the controller and its agents live on infrastructure the team fully controls and the same trust questions apply in a different shape. Our <a href="https://devopsjobupdates.com/jenkins-cicd-pipeline-tutorial/">Jenkins CI/CD pipeline tutorial</a> covers agents, credentials and pipeline security in that world, and the principles transfer: least privilege for the agent, secrets in the credential store rather than on disk, and no agent that can reach production without going through a gate.</p>
<h2>Scaling: Ephemeral Runners and Actions Runner Controller</h2>
<p>One runner is a hobby; a fleet is an operation. The naive way to scale is to register more long-lived runners and hope the queue stays short, but that leaves machines idle most of the time and creates the state-pollution problem from the earlier sections. The better pattern is to scale the fleet to the queue: create runners when jobs are waiting, destroy them when the queue is empty, and make every runner ephemeral so each job starts clean.</p>
<p>GitHub provides two supported paths. The first is to build your own autoscaling around the runner application, using the webhook events GitHub emits when a workflow job is queued, and a script or service that provisions a runner, registers it with an ephemeral token, and destroys it after the job. The second, and the one most teams should use, is Actions Runner Controller — the Kubernetes-based autoscaling implementation maintained in the actions-runner-controller project. It runs runners as pods inside a Kubernetes cluster, scales the number of pods based on the workflow queue, and removes each pod after its job finishes. The controller is documented in its own repository, and it is the reference implementation GitHub points teams towards for Kubernetes-based scaling. The shape of an ARC deployment is a controller installed in the cluster, a runner scale set that describes the runner image and the labels it carries, and a GitHub App or token that lets the controller listen to the queue — the project’s own documentation gives the exact installation steps, and they change often enough that copying them from a tutorial is a mistake.</p>
<p>Whichever path you choose, a few rules apply. Scale on the queue, not on a schedule: a fleet sized for the average load is either idle or overwhelmed, while a fleet that follows the queue is neither. Keep the runner image small and the start-up fast, because a runner that takes five minutes to boot is a runner that adds five minutes to every job’s queue time — pre-install the tools your workflows need in the image rather than installing them at start-up. Set a maximum fleet size so that a runaway workflow cannot provision an unbounded number of machines, and alert on the queue depth so you know when jobs are waiting longer than they should. And remember the timing rules from the reference documentation: a job that waits more than 24 hours fails, and a runner that does not pick up an assigned job within 60 seconds loses it to re-queueing, so a fleet that scales too slowly is a fleet that fails jobs.</p>
<h2>Frequently Asked Questions</h2>
<p><strong>Are self-hosted runners free?</strong></p>
<p>GitHub does not charge for the self-hosted runner application itself — you can use it with GitHub Actions at no additional cost from GitHub. You pay for the machines you run it on, whether that is hardware you own or cloud instances you rent, and for the network and storage those machines use.</p>
<p><strong>Can I use a self-hosted runner with a public repository?</strong></p>
<p>GitHub recommends against it. Forks of a public repository can run code on your runner through a pull request workflow, which can expose the machine and your network. If you must use self-hosted runners with a public repository, use ephemeral runners and isolate the machine from anything sensitive.</p>
<p><strong>What operating systems can run a self-hosted runner?</strong></p>
<p>Ubuntu 20.04 or later, Debian 10 or later, RHEL 8 or later and other listed Linux distributions, Windows 10 and 11 64-bit and Windows Server 2016, 2019 and 2022, and macOS 11.0 (Big Sur) or later. Architectures are x64 everywhere, with ARM64 in public preview. Docker container actions require a Linux runner with Docker installed.</p>
<p><strong>Why is my job stuck in the queue?</strong></p>
<p>Usually because no runner matches the labels the job requested, or every matching runner is offline or busy. Check the runner list for an Idle runner with the right labels, check that the runner is actually online, and remember that a job left queued for more than 24 hours fails. A label typo in the workflow is the most common cause.</p>
<p><strong>How do I keep a runner running after a reboot?</strong></p>
<p>Install it as a service with <code>svc.sh</code> install followed by <code>svc.sh</code> start, run as your dedicated runner user on Linux. Verify it survives a reboot by rebooting the machine and confirming the runner shows Idle in the GitHub UI before you rely on it.</p>
<h2>Conclusion</h2>
<p>Self-hosted runners trade convenience for control, and the trade is worth it when your jobs need hardware, software or network access that GitHub-hosted runners cannot provide. Start with one machine, register it, run a real workflow on it, and install it as a service under a dedicated user. Add labels deliberately, keep the machine clean and isolated, and never point a long-lived runner at a public repository. When one machine is not enough, move to ephemeral runners and scale on the queue with Actions Runner Controller. The runner is a small piece of software, but the discipline around it — patching, monitoring, least privilege and clean state — is what makes a self-hosted fleet reliable instead of merely available.</p>
]]></content:encoded></item><item><title><![CDATA[Terraform Import Tutorial: Bring Existing Resources Under Management]]></title><description><![CDATA[Almost every team that adopts Terraform inherits infrastructure that was built by hand: a bucket created in the console during an incident, a database…]]></description><link>https://devopsjobupdates.hashnode.dev/terraform-import-tutorial-bring-existing-resources-under-management</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/terraform-import-tutorial-bring-existing-resources-under-management</guid><category><![CDATA[Terraform]]></category><category><![CDATA[Devops]]></category><category><![CDATA[#IaC]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:11:34 GMT</pubDate><content:encoded><![CDATA[<p>Almost every team that adopts Terraform inherits infrastructure that was built by hand: a bucket created in the console during an incident, a database provisioned years ago, a virtual network nobody dares to touch. The choice is not between managing it with Terraform or leaving it alone — it is between importing it properly and rebuilding it, with the downtime and risk that rebuilding brings. Terraform import is the tool that moves existing resources under Terraform management without recreating them.</p>
<p>This tutorial covers both ways to import: the classic <code>terraform import</code> command and the modern import block, which is the approach you should use for anything that goes through review. You will import a real S3 bucket, generate configuration from the live resource, import a whole set of resources at once, and fix the errors that appear when the import does not go to plan. The examples use AWS, but the mechanics are identical on Azure and GCP — only the resource IDs change.</p>
<h2>What Terraform Import Does (and Does Not Do)</h2>
<p>Import does one thing: it records an existing cloud resource in Terraform’s state file, mapping a resource address in your configuration to the real object in the cloud. After an import, Terraform knows the resource exists, and the next plan compares your configuration with the live resource instead of proposing to create it. Import does not create the resource, does not delete it, and — in the classic form — does not write any configuration for you. That last point surprises beginners: after a classic import, you still have to write the resource block yourself, and until the configuration matches the live resource, Terraform will propose changes.</p>
<p>Import is also deliberately limited. The command imports one resource at a time, and it cannot import an entire collection — such as a whole VPC with its subnets, route tables and gateways — in a single operation. Each resource is imported individually, which is slow for a large estate and is exactly why the bulk techniques in the later sections exist. Import also assumes that each remote object is bound to only one resource address. Importing the same object twice, under two different addresses, produces behaviour Terraform’s own documentation warns against, because two parts of your configuration will then fight over one real object.</p>
<p>Before you import anything, protect the state. Import writes directly to the state file, so a mistake can corrupt the record of your whole environment. Back the state up first — with a remote backend such as S3, enable versioning on the state bucket so you can restore a previous version; with a local backend, copy the state file before you begin. Our <a href="https://devopsjobupdates.com/terraform-state-explained/">Terraform state explained</a> guide covers backends, locking and recovery in detail, and it is worth reading before you run your first import against a production state file. If you are new to Terraform entirely, start with our <a href="https://devopsjobupdates.com/terraform-tutorial-beginners/">Terraform tutorial for beginners</a>, which builds a working configuration from scratch before any of the import mechanics in this guide.</p>
<h2>The Classic terraform import Command</h2>
<p>The classic workflow has three steps: write a resource block for the existing resource, run the import command, and then run a plan to align the configuration with reality. The resource block can be nearly empty to start with — Terraform only needs the address to exist — and you fill in the arguments after the import, using the plan output to tell you what is missing.</p>
<p>Suppose a bucket called <code>acme-prod-assets</code> was created in the console and now needs to be managed by Terraform. First, declare it:</p>
<pre><code class="language-hcl">terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~&gt; 5.0"
    }
  }
}

provider "aws" {
  region = "eu-west-1"
}

resource "aws_s3_bucket" "assets" {
  # Arguments will be filled in after the import.
}
</code></pre>
<p>Then import it. The command takes the resource address and the ID Terraform’s provider uses to find the object — for an S3 bucket, the ID is simply the bucket name; for an EC2 instance it is the instance ID; for a Route 53 zone it is the zone ID. The ID format depends on the resource type, so check the provider’s documentation for each resource you import rather than guessing.</p>
<pre><code class="language-bash">terraform init
terraform import aws_s3_bucket.assets acme-prod-assets
</code></pre>
<p>HashiCorp’s own documentation describes this flow in <a href="https://developer.hashicorp.com/terraform/cli/import/usage?optInFrom=terraform-io">Import existing resources</a>: write the resource block, run the command, and then run a plan to see how the configuration compares with the imported resource. The plan after an import is the moment of truth. It will usually propose changes, because your empty resource block does not yet describe the live bucket — its tags, its versioning, its encryption. Add the arguments one at a time and re-run the plan until it reports no changes. When the plan is clean, the import is complete: Terraform manages the bucket, and the next apply will change nothing.</p>
<p>The classic command’s weakness is that it writes state immediately, with no preview. There is no plan step before the state changes, no pull request to review, and no easy undo beyond restoring a state backup. That is acceptable for a single resource in a development account. For production, or for anything a teammate should review, the import block is the better tool — and it is the subject of the next section.</p>
<p>One more worked example, because a second resource type shows how the ID changes while the workflow stays the same. An EC2 instance is imported by its instance ID, and its security group by its group ID, each in its own command:</p>
<pre><code class="language-hcl">resource "aws_instance" "web" {
  # Fill in ami, instance_type and tags after the import.
}

resource "aws_security_group" "web" {
  # Fill in ingress and egress rules after the import.
}
</code></pre>
<pre><code class="language-bash">terraform import aws_instance.web i-0123456789abcdef0
terraform import aws_security_group.web sg-0123456789abcdef0
terraform plan
</code></pre>
<p>The plan will propose changes for both resources, because the empty blocks do not yet describe them. Fill in the arguments from the live resources — the AMI ID, the instance type, the security group’s ingress and egress rules — and re-run the plan until it is empty. Notice the order matters here: the instance references the security group, so import the security group first and add the reference to the instance block, otherwise the plan will propose replacing the instance to attach a group it does not yet know about. When two resources depend on each other, import the dependency first.</p>
<h2>Import Blocks: The Modern, Reviewable Way</h2>
<p>Import blocks, available since Terraform 1.5, move the import into your configuration, where it can be reviewed like any other change. An import block maps a resource address to a cloud ID, and Terraform processes it during the next plan, so the import itself goes through the same review and approval flow as the rest of your infrastructure changes.</p>
<pre><code class="language-hcl">import {
  to = aws_s3_bucket.assets
  id = "acme-prod-assets"
}

resource "aws_s3_bucket" "assets" {
  # Arguments will be filled in after the import.
}
</code></pre>
<p>Run a plan and Terraform imports the bucket into state as part of the plan, then shows you the configuration drift between your resource block and the live bucket. Nothing is applied until you approve the apply, which means the import is visible in the pull request before it touches anything. When the import is done and the configuration matches, remove the import block — it is a one-time instruction, not a permanent part of the configuration — and leave the resource block behind.</p>
<p>Import blocks also solve the problem of importing into modules. If the bucket belongs inside a module, the <code>to</code> address includes the module path:</p>
<pre><code class="language-hcl">import {
  to = module.storage.aws_s3_bucket.assets
  id = "acme-prod-assets"
}
</code></pre>
<p>And for a resource created with <code>for_each</code> or <code>count</code>, the address includes the specific instance key, such as <code>aws_s3_bucket.assets["prod"]</code> or <code>aws_s3_bucket.assets[0]</code>. Getting that address wrong is the most common import-block error: Terraform will tell you the address does not match any resource in the configuration, and the fix is to copy the address from the plan output rather than typing it from memory.</p>
<h2>Generating Configuration with -generate-config-out</h2>
<p>The most tedious part of an import is writing the resource block to match a live resource you did not create. Terraform can do that for you. When you run a plan with <code>-generate-config-out</code>, Terraform reads the imported resource and writes a generated configuration file containing the arguments it discovered:</p>
<pre><code class="language-bash">terraform plan -generate-config-out=generated.tf
</code></pre>
<p>The generated file is a starting point, not a finished product. It contains everything Terraform could read from the live resource, including arguments you would never write by hand — computed values, default settings, and attributes that are only relevant to the provider’s internal bookkeeping. Your job is to move the meaningful parts into your real configuration files, delete the noise, and remove the generated file. A typical clean-up pass removes read-only attributes, replaces hard-coded values with variables where the value should vary by environment, and adds the tags and lifecycle rules your team standardises on.</p>
<p>Work through the generated file with the plan as your guide. After you move the cleaned configuration into place and delete the import block, run a plan: if it shows no changes, the generated configuration matches reality. If it shows changes, read them carefully — they are usually a missing argument, such as a bucket’s versioning status or a security group’s description, and the fix is to add that argument to the resource block. Repeat until the plan is empty. That empty plan is the definition of a finished import, and it is worth insisting on: a plan that still shows changes after an import means Terraform will try to apply those changes on the next run, which may modify a production resource you only meant to adopt.</p>
<p>One caution about generated configuration: it reflects the resource as it is, not as it should be. If the bucket you imported has no encryption and no versioning, the generated configuration will faithfully reproduce that — and your plan will be clean while your security posture stays weak. Treat the import as the moment to fix the resource, not just to adopt it: add the encryption block, enable versioning, and let the next apply improve the resource rather than merely preserving it. The same caution applies to secrets. Generated configuration can contain values that should never be committed — a database password captured in a resource argument, or an access key embedded in a user-data script. Read the generated file line by line before it enters source control, move any secret into a variable backed by a secrets manager or a secure variable store, and check the file into version control only after that review. A generated file that is committed without review is how credentials end up in a repository.</p>
<h2>Importing at Scale: for_each and Bulk Imports</h2>
<p>Importing one bucket by hand is fine. Importing forty is not, and this is where import blocks earn their keep. Since Terraform 1.7, an import block itself accepts <code>for_each</code>, so a single block can import a whole set of resources from a map of names to IDs:</p>
<pre><code class="language-hcl">locals {
  buckets = {
    prod    = "acme-prod-assets"
    staging = "acme-staging-assets"
    dev     = "acme-dev-assets"
  }
}

import {
  for_each = local.buckets
  to       = aws_s3_bucket.this[each.key]
  id       = each.value
}

resource "aws_s3_bucket" "this" {
  for_each = local.buckets
  bucket   = each.value
}
</code></pre>
<p>Generate the map from the cloud rather than typing it by hand. A short script that lists resources through the provider’s CLI — <code>aws s3api list-buckets</code>, for example — and writes the import blocks is faster and less error-prone than forty copy-paste operations, and it can be re-run when the estate changes. Keep the script in the repository next to the configuration, so the next person who inherits the estate can see how the imports were produced. A minimal version for S3 looks like this:</p>
<pre><code class="language-bash">#!/bin/bash
# Generate one import block per bucket whose name starts with acme-.
# Review the output before running any plan: generated code is a draft.
set -euo pipefail

{
  echo 'locals {'
  echo '  buckets = {'
  aws s3api list-buckets \
    --query "Buckets[?starts_with(Name, \`acme-\`)].Name" \
    --output text | tr '\t' '\n' | while read -r bucket; do
      key=$(echo "$bucket" | sed 's/^acme-//; s/-assets$//')
      echo "    $key = \"$bucket\""
  done
  echo '  }'
  echo '}'
  echo ''
  echo 'import {'
  echo '  for_each = local.buckets'
  echo '  to       = aws_s3_bucket.this[each.key]'
  echo '  id       = each.value'
  echo '}'
} &gt; imports.tf

echo "Wrote imports.tf — review it, then run terraform plan."
</code></pre>
<p>That script shows the pattern rather than a finished tool: list the resources, derive a key for each one, and emit the block. In practice you will adapt it to the resource type — EC2 instances need their IDs, not their names — and you will review every line of generated output before it reaches a plan, because a script that imports the wrong resource is worse than typing slowly. For a one-off migration, a script you run once and delete is fine; for an estate that keeps growing outside Terraform, the script belongs in the repository as a maintained tool.</p>
<p>For very large estates, HCP Terraform offers a search-and-import feature that discovers resources across your cloud providers through a visual query builder or through list blocks in configuration, then generates the configuration for the resources you select. It needs a workspace running Terraform 1.14 or newer, and it is the right tool when the estate is too large to enumerate by hand. The HCP documentation, <a href="https://developer.hashicorp.com/terraform/cloud-docs/workspaces/import">Search and import resources</a>, sets out the workflow and its requirements, including the note that policy evaluation against query results needs Terraform 1.17.0 or later. As of this writing the current release is Terraform 1.17.2, released 11 November 2026, so a workspace on the current version meets both requirements.</p>
<p>Whatever the scale, import in waves, not all at once. Import one resource type — buckets first, then the roles that use them — and get a clean plan for each wave before starting the next. A clean plan per wave localises failures: when something goes wrong, you know which wave introduced it. Importing everything at once and then debugging a plan with hundreds of proposed changes is how a migration stalls for a week.</p>
<h2>Modules, Count and Tricky Resource IDs</h2>
<p>Real estates are rarely flat, and imports get harder as the configuration gets more structured. Resources inside modules need module-prefixed addresses, resources with <code>count</code> need an index, and resources with <code>for_each</code> need a key. The address syntax is the same one Terraform uses everywhere — <code>module.storage.aws_s3_bucket.assets</code>, <code>aws_instance.web[0]</code>, <code>aws_s3_bucket.this["prod"]</code> — but it must match the configuration exactly, including the module path and the key type. A string key in quotes and a number index without quotes are different addresses, and Terraform will reject the wrong one.</p>
<p>Resource IDs are the second trap. The ID format is defined by the provider, not by Terraform, and it varies by resource: a bucket uses its name, an EC2 instance uses its instance ID, a Route 53 zone uses the domain name, and a security group rule uses a composite ID that combines the group and the rule. Some resources have IDs that are not obvious from the console, and a few cannot be imported at all — the provider’s documentation for each resource states whether import is supported and what ID format it expects. When an import fails with an error about the ID, the provider documentation for that resource is the first place to look, not the Terraform CLI documentation.</p>
<p>Complex imports are a third complication. Some resources import secondary resources along with them: importing an AWS network ACL, for example, also imports one <code>aws_network_acl_rule</code> for each rule it contains. Those secondary resources land in state without a corresponding resource block, and if you do not add blocks for them, Terraform will plan to destroy them on the next run. Always read the import output for a mention of secondary resources, and add a block for each one before you run your next plan.</p>
<p>Our <a href="https://devopsjobupdates.com/terraform-modules-tutorial/">Terraform modules tutorial</a> covers the module patterns that make large imports manageable — one module per resource type, composition through outputs — and it is the natural next step once the resources are under management and you need to organise them.</p>
<h2>Common Errors and How to Fix Them</h2>
<p>Most import failures fall into a small set of patterns, and each has a clear fix. “Cannot import non-existent remote object” means the ID is wrong, the resource is in a different Region or account than your provider is configured for, or the resource was already deleted. Check the provider configuration first — the wrong Region is the most common cause — then verify the ID with the cloud CLI before retrying.</p>
<p>“Resource already managed by Terraform” means the object is already in state under a different address. Find it with <code>terraform state list</code>, and move it to the right address with <code>terraform state mv</code> instead of importing it a second time. Importing the same object twice is exactly the situation Terraform warns against, and the state move command is the correct remedy.</p>
<p>A plan that proposes to destroy the resource you just imported means the configuration does not describe it, or the resource block is missing entirely. With the classic command, this happens when you import and then forget to write the block; with import blocks, it happens when the generated configuration was deleted before being moved into the real files. Write the block, re-run the plan, and the destroy should disappear.</p>
<p>A plan that proposes to replace the resource — destroy and recreate — is more serious, because applying it would delete the live object. Replacement is proposed when an argument that forces recreation differs between the configuration and the live resource, such as a bucket name or a database engine version. Find the differing argument in the plan output, set it to the live value, and the replacement should become an update or disappear. Never apply a plan that replaces a production resource you only meant to adopt.</p>
<p>Finally, a state lock error during an import means another Terraform process holds the lock — usually a colleague’s run, or a crashed process that never released it. Do not force-unlock a lock you do not understand: check who holds it, and only use <code>terraform force-unlock</code> when you are certain no other process is running. A forced unlock during a concurrent write is how state files get corrupted.</p>
<p>Two state commands round out the toolkit. <code>terraform state mv</code> renames or relocates a resource in state without touching the cloud, which is how you fix an import that landed at the wrong address, or move a resource into a module after the fact:</p>
<pre><code class="language-bash">terraform state list
terraform state mv aws_s3_bucket.assets module.storage.aws_s3_bucket.assets
terraform state mv 'aws_s3_bucket.this["prod"]' 'aws_s3_bucket.this["production"]'
</code></pre>
<p><code>terraform state rm</code> removes a resource from state without destroying it in the cloud — the opposite of import, and the right command when something was imported by mistake or when a resource should leave Terraform management but keep running. And if you need to stop managing a resource permanently through configuration rather than a command, the <code>removed</code> block, available since Terraform 1.7, declares that a resource should be removed from state on the next apply, without destroying it. All three commands edit state directly, so back the state up before you run any of them, exactly as you did before the import itself.</p>
<h2>Frequently Asked Questions</h2>
<p><strong>Does terraform import change or recreate the resource?</strong></p>
<p>No. Import only records the existing resource in Terraform’s state file. It does not modify, delete or recreate anything in the cloud. Changes only happen later, when you apply a plan that proposes them.</p>
<p><strong>What is the difference between terraform import and an import block?</strong></p>
<p>The command writes state immediately, generates no configuration, and has no plan step, so you must write the resource block by hand first. An import block, available since Terraform 1.5, goes through the plan, can generate configuration with <code>-generate-config-out</code>, and sits in a pull request for review before anything touches state.</p>
<p><strong>Can I import a whole VPC at once?</strong></p>
<p>No. Terraform imports one resource at a time, and it cannot import an entire collection such as a VPC with its subnets and route tables in a single operation. Import each resource individually, or use <code>for_each</code> on an import block, or HCP Terraform’s search-and-import for large estates.</p>
<p><strong>What should I do with the import block after the import?</strong></p>
<p>Remove it. The import block is a one-time instruction: once the resource is in state and the configuration matches, the block has done its job. Leaving it in place causes Terraform to try the import again on the next plan.</p>
<p><strong>Why does Terraform want to destroy the resource I just imported?</strong></p>
<p>Because the resource exists in state but there is no matching resource block in the configuration. Terraform reads that as “this object should not exist” and plans to destroy it. Add the resource block, run a plan, and the destroy should disappear.</p>
<h2>Conclusion</h2>
<p>Import is how Terraform meets reality: the infrastructure you already have, built by hand over years, brought under management without downtime. Use import blocks for anything that deserves review, generate configuration from the live resource instead of typing it from memory, clean the generated output before you commit it, and insist on an empty plan before you call the import done. Import in waves, back up state before you start, and fix the security gaps the import reveals rather than preserving them. Do that, and the estate you inherited becomes an estate you can change with confidence — which is the whole point of infrastructure as code.</p>
]]></content:encoded></item><item><title><![CDATA[AWS IAM Tutorial for Beginners: Users, Groups, Roles and Policies]]></title><description><![CDATA[AWS Identity and Access Management — IAM — is the service that decides who can do what in your AWS account. Every EC2 instance you launch, every file you…]]></description><link>https://devopsjobupdates.hashnode.dev/aws-iam-tutorial-for-beginners-users-groups-roles-and-policies</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/aws-iam-tutorial-for-beginners-users-groups-roles-and-policies</guid><category><![CDATA[AWS]]></category><category><![CDATA[IAM]]></category><category><![CDATA[Security]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:07:51 GMT</pubDate><content:encoded><![CDATA[<p>AWS Identity and Access Management — IAM — is the service that decides who can do what in your AWS account. Every EC2 instance you launch, every file you read from S3, every deployment your pipeline runs: IAM either allowed it or it did not. Beginners often treat IAM as an administrative chore to rush past, and then spend days debugging AccessDenied errors, or worse, discover that a leaked access key gave a stranger the run of their account. This tutorial treats IAM as the foundation it is.</p>
<p>You will build a working IAM setup from scratch: lock down the root user, create users and groups, write policies that grant exactly the access needed, use roles for temporary credentials, and enforce MFA. By the end you will know the four building blocks — users, groups, roles and policies — and how they fit together.</p>
<h2>What Is AWS IAM?</h2>
<p>IAM is the AWS service that controls authentication — who is signed in — and authorisation — what they are allowed to do. Every request to AWS, whether from the console, the CLI or a service, is checked against IAM before it is allowed. There is no way around it and no service that skips it: if IAM says no, the request fails, which is why the first skill in AWS is understanding how IAM makes its decisions.</p>
<p>IAM is built from four components. Users are identities for individual people or applications, each with its own credentials. Groups are collections of users who share the same permissions, so you manage the group rather than each person. Roles are identities for services and temporary access, with credentials that expire. Policies are the JSON documents that grant or deny specific actions on specific resources. Everything else in IAM is a variation on these four.</p>
<p>Two design choices shape how you should use IAM. First, IAM is global rather than regional: users, groups, roles and policies exist once per account and apply in every Region, so a user created in eu-west-1 works in us-east-1 without any extra step. Second, IAM is free: there is no charge for users, groups, roles or policies, and no reason to share credentials because extra users cost nothing. If you are new to AWS itself, our <a href="https://devopsjobupdates.com/aws-tutorial-beginners/">AWS tutorial for beginners</a> covers accounts, Regions and your first resources, and the official starting point is AWS’s own <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started.html">Getting started with IAM</a> guide, which sets out the same concepts from the service’s own documentation.</p>
<h2>The Root User: Lock It Down First</h2>
<p>The root user is the identity created when you opened your AWS account. It is the email address and password you signed up with, and it has unrestricted access to everything, including billing, account closure and the ability to delete all your resources. It has no MFA by default, its credentials never expire, and it cannot be limited by any policy. It is the most dangerous identity in your account, and the first thing to do in any AWS account is to make sure it is barely usable.</p>
<p>Your first job in any AWS account is to make the root user hard to use and almost never used. Enable MFA on the root user the moment you create the account, store the recovery codes somewhere safe — not in the same place as the password — and then create an IAM user with administrative access for day-to-day work and stop signing in as root. Do not create access keys for the root user: they are the single most dangerous credential in AWS, and there is no task that needs them.</p>
<p>Check your own account now. Sign in to the console, open IAM, and look at the Security Status dashboard: it tells you whether root MFA is on, whether there are access keys you did not create, and whether any user has overly broad permissions. The credential report and account summary give you the same picture from the CLI:</p>
<pre><code class="language-bash">aws iam get-credential-report
aws iam generate-credential-report
aws iam get-account-summary
</code></pre>
<p>The account summary is worth reading in full. It shows the number of users, groups, roles and policies, whether MFA is enabled on the root account, and whether the account has a password policy at all. Fix the gaps it shows before you build anything else, because every resource you create afterwards inherits the security posture of the account it sits in.</p>
<h2>IAM Users and Groups</h2>
<p>An IAM user represents a person or an application that needs to interact with AWS. Each user has a name and a set of credentials — a console password, an access key, or both — and, by default, no permissions at all. A new user cannot do anything until a policy gives them access, which is the safe default: access must be granted explicitly, never assumed.</p>
<p>Create users through groups, not one at a time with individual policies. A group is a collection of users who share the same access, and you attach policies to the group rather than to each person. When someone joins a team you add them to the group; when they leave you remove them. That single habit keeps permissions consistent and auditable, and it scales where per-user policies do not.</p>
<pre><code class="language-bash">aws iam create-group --group-name developers

aws iam create-user --user-name priya

aws iam add-user-to-group --group-name developers --user-name priya

aws iam attach-group-policy --group-name developers \
  --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess
</code></pre>
<p>That sequence creates a group, a user, adds the user to the group, attaches AWS’s managed read-only policy to the group, and finishes with the user able to view but not change anything. The ReadOnlyAccess policy is the right starting point for a new team member: they can look at everything and break nothing while they learn the environment. The <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html">IAM users</a> page in the official user guide explains the same model: a user consists of a name and credentials, a group is a way to attach the same permissions to many users, and deleting a user removes their access but not the resources they created.</p>
<p>A word on modern practice. AWS’s current best practice is to require human users to use federation with an external identity provider — AWS IAM Identity Center — instead of long-lived IAM users, because federation gives you centralised control and temporary credentials. IAM users are still the right tool for programmatic access that cannot federate, such as CI/CD pipelines and automation, and they are the mechanism this tutorial uses throughout.</p>
<h2>IAM Policies: The JSON That Grants Access</h2>
<p>A policy is a JSON document that answers three questions: who can do what, to which resource, and under what conditions. Every policy has a Version and a Statement list, and each statement has an Effect (Allow or Deny), an Action (the API calls it covers) and a Resource (the thing it applies to). A request is allowed only if some policy explicitly allows it and no policy explicitly denies it — an explicit Deny always wins, even over an Allow.</p>
<p>Here is a policy that lets a user list and read objects in one specific S3 bucket and nothing else.</p>
<pre><code class="language-json">{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:ListBucket",
        "s3:GetObject"
      ],
      "Resource": [
        "arn:aws:s3:::acme-app-assets",
        "arn:aws:s3:::acme-app-assets/*"
      ]
    }
  ]
}
</code></pre>
<p>Notice the two resource ARNs. S3 distinguishes the bucket itself (<code>arn:aws:s3:::acme-app-assets</code>) from the objects inside it (<code>arn:aws:s3:::acme-app-assets/*</code>), and ListBucket applies to the bucket while GetObject applies to the objects. Forgetting one of the two is the most common reason a policy that looks right returns AccessDenied.</p>
<p>The <code>Version</code> field is always <code>2012-10-17</code> — it is the policy language version, not a date you update.</p>
<p>There are two kinds of policy to know. Identity-based policies attach to users, groups or roles and say what that identity can do. Resource-based policies attach to the resource itself — an S3 bucket policy, for example — and say who can access that resource. A request is allowed if either kind grants it, so you can give access from either side, and the two combine in ways that surprise beginners: an identity policy that allows access to a bucket does not help if the bucket policy denies it.</p>
<p>Test a policy before you trust it. The IAM policy simulator lets you select a user, a policy and an action and shows whether the request is allowed and which statement decided it. A five-minute simulation is cheaper than a production incident caused by a policy that allows more than you intended.</p>
<h2>IAM Roles and Temporary Credentials</h2>
<p>A role is an identity with permissions but no permanent credentials. Instead of a password or an access key, something assumes the role and receives temporary credentials that expire after a set time. That makes roles the safe way to grant access to services and to workloads that run outside AWS: nothing to store, nothing to rotate, nothing to leak that stays valid for long.</p>
<p>The classic example is an EC2 instance that needs to read files from S3. The wrong approach is to create an IAM user, generate an access key and put it on the instance, where anyone who reads the disk can copy it. The right approach is to create a role with an S3 read policy and a trust policy that lets EC2 assume it, then attach the role to the instance as an instance profile. The instance gets temporary credentials automatically, they rotate on their own, and there is no key on the disk to steal.</p>
<pre><code class="language-bash">aws iam create-role --role-name app-server-s3-read \
  --assume-role-policy-document '{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Principal": {
          "Service": "ec2.amazonaws.com"
        },
        "Action": "sts:AssumeRole"
      }
    ]
  }'

aws iam attach-role-policy --role-name app-server-s3-read \
  --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
</code></pre>
<p>The trust policy is the part beginners overlook. It is a separate document from the permissions policy, and it says which identity is allowed to assume the role at all. A role with a generous permissions policy and a trust policy that allows anyone to assume it is effectively public, so read the trust policy first whenever you audit a role. The permissions policy then says what the assumed role can do once it has been assumed.</p>
<p>Roles are also the mechanism behind the two patterns you will meet most in production. The first is cross-account access: an account that trusts another account’s role can let its users assume it, which is how you grant a partner limited access without sharing credentials. The second is service roles: services such as Lambda, ECS and EKS run under a role that you define, and the role’s permissions are the permissions the service has. Our <a href="https://devopsjobupdates.com/aws-lambda-serverless-tutorial/">AWS Lambda serverless tutorial</a> shows an execution role in a working function, including the CloudWatch Logs permissions every Lambda needs before it can log anything.</p>
<h2>MFA, Access Keys and Credential Hygiene</h2>
<p>Multi-factor authentication is the cheapest security improvement in all of AWS. It adds a second factor — usually a code from an authenticator app — to a sign-in, so a stolen password alone is not enough to get into the account. Enable MFA for the root user and for every user with administrative access, and make it a condition of access rather than a suggestion. An attacker who compromises a password but does not have the second factor gets nothing.</p>
<p>Access keys deserve the same discipline. Each user can have at most two access keys, and you should treat them like passwords that are pasted into code: never commit them, never share them, and rotate them regularly. When an access key is no longer needed, delete it rather than deactivating it — a deactivated key can be reactivated by mistake, a deleted one cannot. The CLI makes rotation straightforward:</p>
<pre><code class="language-bash">aws iam create-access-key --user-name priya
aws iam list-access-keys --user-name priya
aws iam update-access-key --user-name priya --access-key-id AKIAIOSFODNN7EXAMPLE --status Inactive
aws iam delete-access-key --user-name priya --access-key-id AKIAIOSFODNN7EXAMPLE
</code></pre>
<p>Enforcing MFA through policy is the step that turns a good intention into a guarantee. This policy denies every action unless the request was authenticated with MFA:</p>
<pre><code class="language-json">{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Deny",
      "Action": "*",
      "Resource": "*",
      "Condition": {
        "BoolIfExists": {
          "aws:MultiFactorAuthPresent": "false"
        }
      }
    }
  ]
}
</code></pre>
<p>Attach that policy with care: applied to the wrong group it locks everyone out, including the person who attached it. <code>aws:MultiFactorAuthPresent</code> is the mechanism, and <code>BoolIfExists</code> handles the case where the key is absent entirely, which is exactly what happens for a request made with an access key rather than a console session. Test it on a single user first.</p>
<p>Never put access keys where they can leak. Do not commit them to a repository, do not paste them into a chat message, do not email them, and do not store them in a ticket. The correct places for an access key are an environment variable on the machine that needs it, a secrets manager such as AWS Secrets Manager or a CI/CD secrets store, or a credentials file on a machine only you control. A key that appears in a public repository is compromised the moment it is pushed, and automated scanners will find it within minutes.</p>
<p>Set a password policy for console users: a minimum length, required character types, and a rule that forces a password change after a period. A password policy does not make weak passwords strong, but it stops the worst ones, and it is the control an auditor will ask about first.</p>
<h2>Least Privilege in Practice</h2>
<p>Least privilege means giving every identity only the permissions it actually needs, and nothing more. It is easy to state and hard to maintain, because workloads change and the safe fix for a denied request is to widen the policy. Resist that: every widened policy is a permission that an attacker can use if they get hold of the identity, and the blast radius of a breach is set by the broadest policy in the account.</p>
<p>Build the habit with a repeatable loop. Start from a managed read-only policy for a new team member, add the specific write permissions their work actually needs, and use IAM Access Analyzer to see which permissions are unused so you can remove them. Every few months, review the permissions your roles and users have and remove the ones nobody uses. The goal is not zero permissions — it is permissions that match the job, and nothing extra.</p>
<p>Permission boundaries and service control policies are the guardrails for larger accounts. A permissions boundary caps the maximum permissions an identity can have, even if an attached policy grants more. A service control policy, applied at the organisation level, restricts what whole accounts can do — for example, blocking access to a Region or a service for every account in the organisation. Both exist so that one mistake, or one overly broad policy, cannot grant more access than the organisation intends.</p>
<p>When access is denied, debug it methodically instead of adding AdministratorAccess and moving on. First, read the error: it names the action and the resource that was denied. Then use the policy simulator to test the same request, and use CloudTrail to see exactly which identity made the call and which policy evaluation failed. The fix is usually a missing action, a wrong resource ARN, or a condition that does not match — not a missing AdministratorAccess policy. Our <a href="https://devopsjobupdates.com/aws-eks-tutorial/">AWS EKS tutorial</a> covers the IAM roles an EKS cluster needs and the errors you see when one is missing.</p>
<h2>Frequently Asked Questions</h2>
<p><strong>What is the difference between an IAM user and an IAM role?</strong></p>
<p>A user has permanent credentials — a password, access keys, or both — and represents a person or an application that needs long-term access. A role has no permanent credentials and is assumed to get temporary ones, which makes it the right choice for services, for cross-account access, and for anything that should not hold a long-lived secret.</p>
<p><strong>Why does my new IAM user get AccessDenied for everything?</strong></p>
<p>Because a new user has no permissions by default. Until a policy is attached to the user directly or through a group, every request is denied. Attach a policy — start with ReadOnlyAccess — and test again.</p>
<p><strong>Should I ever create access keys for the root user?</strong></p>
<p>No. There is no normal task that needs programmatic root access, and a root access key is the most dangerous credential in AWS because it cannot be limited by policy. Use an IAM user with administrative access instead.</p>
<p><strong>What is the difference between an identity-based policy and a resource-based policy?</strong></p>
<p>An identity-based policy attaches to a user, group or role and says what that identity can do. A resource-based policy attaches to a resource, such as an S3 bucket, and says who can use that resource. A request is allowed if either grants it, so you need to check both sides when debugging access.</p>
<p><strong>How do I know which permissions a role actually needs?</strong></p>
<p>Start from what the workload really calls, not from a guess. Use CloudTrail to see the API calls an identity makes over a few days, then write a policy that allows exactly those calls and nothing more. IAM Access Analyzer can generate a policy from observed activity, which is the fastest way to move from AdministratorAccess to least privilege.</p>
<h2>Conclusion</h2>
<p>IAM is not a formality you complete before the real work — it is the real work, because every AWS workload you build inherits the permissions of the identities it runs as. Lock down the root user, create users through groups, write policies that grant exactly what is needed, use roles for services and temporary access, and enforce MFA for every human who signs in. Do that from the start, and the AccessDenied errors you meet later will be a sign that the system is working as designed, not a mystery to debug.</p>
]]></content:encoded></item><item><title><![CDATA[AWS VPC Explained: Subnets, Routing and Security]]></title><description><![CDATA[Every AWS workload you will ever run lives inside a virtual private cloud, whether you built it yourself or inherited the default one. The VPC is the…]]></description><link>https://devopsjobupdates.hashnode.dev/aws-vpc-explained-subnets-routing-and-security</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/aws-vpc-explained-subnets-routing-and-security</guid><category><![CDATA[AWS]]></category><category><![CDATA[vpc]]></category><category><![CDATA[networking]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 18:02:01 GMT</pubDate><content:encoded><![CDATA[<p>Every AWS workload you will ever run lives inside a virtual private cloud, whether you built it yourself or inherited the default one. The VPC is the network boundary for your EC2 instances, your databases, your load balancers and your Kubernetes clusters. If you do not understand it, every networking problem becomes a mystery: instances that cannot reach the internet, a load balancer that never becomes healthy, a database that refuses connections from the application sitting next to it.</p>
<p>This guide explains the VPC from the ground up, the way you will actually use it. You will learn how CIDR blocks carve up address space, what makes a subnet public or private, how route tables and gateways move traffic, and how security groups and network ACLs filter it. Each section ends with something you can run or check, and the final section is a troubleshooting checklist for the failures that appear in real environments and in interviews.</p>
<h2>What Is an AWS VPC?</h2>
<p>An Amazon Virtual Private Cloud is a logically isolated virtual network that you define inside AWS. It closely resembles a traditional network you would operate in your own data centre, with the benefits of AWS’s scalable infrastructure: you choose the IP address range, create subnets, configure route tables and gateways, and attach security controls. Resources you launch — EC2 instances, RDS databases, load balancers — run inside the subnets of your VPC, and traffic between them stays on AWS’s private network unless you deliberately route it elsewhere.</p>
<p>A VPC spans a whole Region, while each subnet inside it lives in a single Availability Zone. That split matters for high availability: you place subnets in at least two Availability Zones so that the loss of one zone does not take your whole application down, and you put a load balancer across them so traffic keeps flowing. A VPC is also isolated from every other VPC by default. Two VPCs cannot talk to each other, even in the same account, until you connect them explicitly with peering, a transit gateway or a PrivateLink endpoint.</p>
<p>Every AWS account comes with a default VPC in each Region, using the CIDR block 172.31.0.0/16, which provides 65,536 IP addresses. The default VPC is ready to use immediately: its subnets are public, it has an internet gateway attached, and instances launched into it get public IP addresses. It is convenient for a first experiment and a poor home for production, because it was not designed around your application — your subnets, your routing and your security rules should be deliberate choices, not defaults you inherited. AWS itself charges nothing extra for the VPC itself; the billable parts are components such as NAT gateways, traffic mirroring and VPC endpoints, which is why a careless NAT gateway layout is one of the easiest ways to inflate an AWS bill. The official overview, <a href="https://docs.aws.amazon.com/vpc/latest/userguide/how-it-works.html">How Amazon VPC works</a>, covers the same concepts — VPCs and subnets, default and non-default VPCs, route tables and the ways a VPC reaches the internet — and it is the page to keep open while you build your first VPC.</p>
<p>If networking fundamentals feel shaky, read our <a href="https://devopsjobupdates.com/networking-basics-for-devops-engineers/">networking basics for DevOps engineers</a> first — it covers IP addressing, CIDR notation and routing in plain language, and everything in this guide builds on it. If you are brand new to AWS itself, our <a href="https://devopsjobupdates.com/aws-tutorial-beginners/">AWS tutorial for beginners</a> walks through accounts, the console and your first EC2 instance before you touch a VPC.</p>
<h2>CIDR Blocks and IP Addressing</h2>
<p>The first decision in any VPC is the CIDR block: the range of private IP addresses the VPC owns. AWS lets you choose a VPC CIDR between a /16 and a /28 netmask, using the private ranges defined for internal networks — 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. A /16 gives you 65,536 addresses; a /20 gives 4,096; a /24 gives 256. The block you choose sets a hard ceiling on everything inside the VPC, so choose with growth in mind rather than convenience.</p>
<p>The most common beginner mistake is picking a CIDR that is too small, or one that overlaps with another network you later need to connect to. A VPC peered with another VPC, or connected to an office network over a VPN, cannot have overlapping CIDR ranges — traffic cannot be routed when two networks claim the same addresses. Plan before you build: give each environment its own non-overlapping slice of the 10.0.0.0/8 space, for example 10.0.0.0/16 for production, 10.1.0.0/16 for staging and 10.2.0.0/16 for development. That scheme leaves room for dozens of environments and makes the address itself tell you which environment a resource belongs to.</p>
<p>Subnet CIDR blocks are carved out of the VPC block, and every subnet block must sit entirely inside it. A common layout for a 10.0.0.0/16 VPC is four /20 subnets — two public and two private, one pair per Availability Zone — which leaves most of the address space unused for future subnets. Size subnets generously: a /24 subnet holds 256 addresses, but AWS reserves five in every subnet (the network address, the VPC router, the DNS server, a reserved address and the broadcast address), leaving 251 usable. That sounds like plenty until an auto scaling group, an EKS cluster and a database subnet share one small block and you run out of addresses during a scale-out at the worst possible moment.</p>
<p>You can also add IPv6 to a VPC. AWS assigns a /56 IPv6 block from its own pool, and subnets take /64 slices of it. IPv6 addresses are globally unique rather than private, so the security model is different — an egress-only internet gateway replaces the NAT gateway for outbound-only IPv6 traffic — but for most teams IPv4 remains the working default, and you should only enable IPv6 when you have a concrete reason, such as an application that needs it or an address-exhaustion problem in a large VPC.</p>
<p>Here is a worked layout for a 10.0.0.0/16 VPC across two Availability Zones. It uses /20 subnets, which keeps the arithmetic simple and leaves most of the VPC’s address space free for future growth:</p>
<table>
<thead>
<tr>
<th>Subnet</th>
<th>Availability Zone</th>
<th>CIDR block</th>
<th>Addresses</th>
<th>Route table</th>
</tr>
</thead>
<tbody><tr>
<td>public-1a</td>
<td>eu-west-1a</td>
<td>10.0.0.0/20</td>
<td>4,096</td>
<td>Public — 0.0.0.0/0 to internet gateway</td>
</tr>
<tr>
<td>public-1b</td>
<td>eu-west-1b</td>
<td>10.0.16.0/20</td>
<td>4,096</td>
<td>Public — 0.0.0.0/0 to internet gateway</td>
</tr>
<tr>
<td>private-1a</td>
<td>eu-west-1a</td>
<td>10.0.32.0/20</td>
<td>4,096</td>
<td>Private — 0.0.0.0/0 to NAT gateway in 1a</td>
</tr>
<tr>
<td>private-1b</td>
<td>eu-west-1b</td>
<td>10.0.48.0/20</td>
<td>4,096</td>
<td>Private — 0.0.0.0/0 to NAT gateway in 1b</td>
</tr>
<tr>
<td>data-1a</td>
<td>eu-west-1a</td>
<td>10.0.64.0/20</td>
<td>4,096</td>
<td>Isolated — local route only</td>
</tr>
<tr>
<td>data-1b</td>
<td>eu-west-1b</td>
<td>10.0.80.0/20</td>
<td>4,096</td>
<td>Isolated — local route only</td>
</tr>
</tbody></table>
<p>Notice the data subnets have no route to the internet at all — not even through a NAT gateway. Databases belong in isolated subnets like these, because a database that cannot reach the internet cannot leak data to it, and nothing outside the VPC can reach it except through the application tier. Each private subnet points at the NAT gateway in its own Availability Zone, so a zone failure takes out one zone’s egress but not the other’s. Six /20 subnets consume only 24,576 of the VPC’s 65,536 addresses, leaving room for more subnets, more zones and more environments without re-addressing anything.</p>
<h2>Subnets: Public vs Private</h2>
<p>A subnet is a range of IP addresses inside your VPC, tied to one Availability Zone. Nothing about a subnet is inherently public or private — the distinction comes entirely from its route table. A subnet is public when its route table has a route to an internet gateway; it is private when it does not. That single fact explains most VPC confusion: you do not make a subnet public by giving instances public IPs, and you do not make it private by withholding them. The route table decides.</p>
<p>The standard production layout uses both kinds. Public subnets hold the things that must face the internet: load balancers, NAT gateways and bastion hosts. Private subnets hold everything else: application servers, databases, caches and worker nodes. Traffic reaches the private subnets through the load balancer, and the private resources reach the internet — for patches and package downloads — through the NAT gateway. Nothing in a private subnet is directly reachable from the internet, which removes a whole class of exposure before any firewall rule is written.</p>
<p>Create the VPC and its subnets with the CLI to see the shape of it. This example builds a 10.0.0.0/16 VPC with one public and one private subnet in a single Availability Zone; in production you would repeat the subnet pair in a second zone.</p>
<pre><code class="language-bash">aws ec2 create-vpc --cidr-block 10.0.0.0/16 \
  --tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value=demo-vpc}]'

aws ec2 create-subnet --vpc-id vpc-0123456789abcdef0 \
  --cidr-block 10.0.0.0/24 --availability-zone eu-west-1a \
  --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=demo-public-1a}]'

aws ec2 create-subnet --vpc-id vpc-0123456789abcdef0 \
  --cidr-block 10.0.1.0/24 --availability-zone eu-west-1a \
  --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=demo-private-1a}]'
</code></pre>
<p>Enable DNS hostnames on the VPC if you want instances to get public DNS names, and enable DNS support so that AWS’s DNS resolver answers queries for AWS service endpoints from inside the VPC. Both are on by default in the default VPC, but on a VPC you create yourself you must set them explicitly — a missing DNS hostname setting is a classic reason a new instance is unreachable by name even though its IP works fine.</p>
<h2>Route Tables and Internet Gateways</h2>
<p>A route table is a set of rules that decides where traffic leaving a subnet goes. Every VPC has a main route table, and you can create custom ones and associate them with individual subnets. Each route has a destination CIDR and a target: the local route, which covers traffic inside the VPC and cannot be changed or deleted, and routes you add yourself pointing at gateways, NAT devices, VPC endpoints or peered VPCs. The most specific matching route wins, so a route to 10.0.1.0/24 beats the default route to 0.0.0.0/0.</p>
<p>The internet gateway is the component that connects a VPC to the internet. It is a horizontally scaled, redundant gateway managed by AWS — you do not run it, patch it or size it. One internet gateway attaches to one VPC, and a public subnet’s route table sends internet-bound traffic (0.0.0.0/0) to it. An instance in a public subnet also needs a public IP address or an Elastic IP, because the internet gateway translates between the instance’s private address and its public one. Without a public IP, the instance can still receive traffic through a load balancer, but it cannot initiate outbound internet connections itself.</p>
<pre><code class="language-bash">aws ec2 create-internet-gateway \
  --tag-specifications 'ResourceType=internet-gateway,Tags=[{Key=Name,Value=demo-igw}]'

aws ec2 attach-internet-gateway --vpc-id vpc-0123456789abcdef0 \
  --internet-gateway-id igw-0123456789abcdef0

aws ec2 create-route-table --vpc-id vpc-0123456789abcdef0 \
  --tag-specifications 'ResourceType=route-table,Tags=[{Key=Name,Value=demo-public-rt}]'

aws ec2 create-route --route-table-id rtb-0123456789abcdef0 \
  --destination-cidr-block 0.0.0.0/0 --gateway-id igw-0123456789abcdef0

aws ec2 associate-route-table --route-table-id rtb-0123456789abcdef0 \
  --subnet-id subnet-0123456789abcdef0
</code></pre>
<p>Two routing mistakes cause most outages. The first is associating the wrong route table with a subnet, which silently makes a public subnet private or vice versa — always check the subnet’s explicit association in the console rather than assuming. The second is a missing return route: traffic can flow out through a NAT gateway in one Availability Zone but the response has no route back, which looks exactly like a security group problem until you compare the route tables. When traffic is not flowing, read the route table first and the firewall second.</p>
<h2>NAT Gateways and Egress</h2>
<p>Resources in a private subnet still need to reach the internet for software updates, package registries and external APIs. The NAT gateway provides that outbound-only path: instances in private subnets can initiate connections to the internet, but nothing on the internet can initiate a connection to them. AWS manages the NAT gateway as a service, and you place it in a public subnet with an Elastic IP address, then point the private subnets’ route tables at it for 0.0.0.0/0.</p>
<p>NAT gateways come in two connectivity types. A public NAT gateway sits in a public subnet, has an Elastic IP, and routes traffic to the internet gateway — this is the type almost every tutorial means. A private NAT gateway has no Elastic IP and cannot reach the internet at all; it routes traffic to other VPCs or an on-premises network through a transit gateway or virtual private gateway. If you attach a private NAT gateway and route its traffic to an internet gateway, the internet gateway drops it. Choose the type by asking where the traffic needs to go, not by guessing. AWS documents both types, their considerations and their limitations on the <a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html">NAT gateways</a> page, including the rule that connections must always be initiated from inside the VPC — a NAT gateway never accepts an unsolicited inbound connection.</p>
<p>The cost of a NAT gateway is the part beginners underestimate. The gateway itself is billed hourly, and data processed through it is billed per gigabyte on top of ordinary data-transfer charges. A single NAT gateway shared across Availability Zones works, but it creates a cross-zone dependency and cross-zone traffic charges, so the recommended layout is one NAT gateway per Availability Zone, each serving the private subnets in its own zone. For a cost-sensitive development environment, a NAT instance — a small EC2 instance running NAT software — is cheaper and fully under your control, but you then own its availability, patching and bandwidth limits, which is why production systems use the managed gateway.</p>
<p>There is also an alternative that avoids NAT entirely for AWS services: VPC endpoints. A gateway endpoint for S3 or DynamoDB adds a route to your route table that sends traffic to the service over the AWS private network, with no gateway and no data-transfer charge for the endpoint itself. Interface endpoints use PrivateLink and place an elastic network interface inside your subnet, which does carry an hourly charge. If your private workloads only need S3 and DynamoDB, gateway endpoints remove the NAT gateway from that path completely.</p>
<h2>Security Groups vs Network ACLs</h2>
<p>Two firewalls protect a VPC, and they work at different layers. A security group is attached to a resource — an EC2 instance, a load balancer, a database — and filters traffic at the instance level. A network ACL is attached to a subnet and filters traffic at the subnet boundary. They are complementary, not interchangeable, and understanding how they differ is one of the most-tested topics in AWS networking interviews.</p>
<table>
<thead>
<tr>
<th>Feature</th>
<th>Security group</th>
<th>Network ACL</th>
</tr>
</thead>
<tbody><tr>
<td>Attached to</td>
<td>Resource (instance, load balancer, database)</td>
<td>Subnet</td>
</tr>
<tr>
<td>Stateful or stateless</td>
<td>Stateful — return traffic is automatically allowed</td>
<td>Stateless — return traffic needs an explicit rule</td>
</tr>
<tr>
<td>Rules</td>
<td>Allow rules only</td>
<td>Allow and deny rules, evaluated in number order</td>
</tr>
<tr>
<td>Default behaviour</td>
<td>All inbound denied, all outbound allowed</td>
<td>All traffic allowed (default NACL)</td>
</tr>
<tr>
<td>Typical use</td>
<td>Day-to-day access control per workload</td>
<td>Subnet-level guardrail, such as blocking a port range</td>
</tr>
</tbody></table>
<p>Stateful versus stateless is the distinction that causes real debugging pain. With a security group, allowing inbound traffic on port 443 automatically allows the response back out, because the group remembers the connection. With a network ACL, allowing inbound port 443 is not enough: you must also allow the outbound ephemeral ports (1024–65535) that the response uses, or the reply is dropped and the connection appears to hang. If a connection works from one subnet but not another, and the security groups are identical, the network ACL is the first place to look.</p>
<p>Write security group rules by reference, not by address, wherever possible. Instead of opening port 5432 to a CIDR block, allow it from the security group of the application servers — AWS resolves the reference dynamically, so instances can be replaced without rewriting rules. Keep the default deny posture: a new security group denies all inbound traffic, and you add only the rules the workload needs. Open 0.0.0.0/0 to a port only when the service genuinely faces the internet, and never to a database or an administration port. A public SSH port is the fastest way to collect automated login attempts, and it is the first thing an auditor will flag.</p>
<h2>VPC Endpoints, Peering, Flow Logs and Troubleshooting</h2>
<p>Connecting VPCs is a separate skill from building one. VPC peering connects two VPCs so they can route traffic privately using private IP addresses, but peering is not transitive: if VPC A is peered with B, and B is peered with C, A cannot reach C through B. Peering also cannot connect VPCs with overlapping CIDR blocks, which is the second reason to plan address space before you build. For more than a handful of VPCs, a transit gateway is the hub that replaces a mesh of peering connections with one central router, and AWS PrivateLink exposes a service in one VPC to another without any peering at all.</p>
<p>VPC Flow Logs record the IP traffic flowing to and from network interfaces in your VPC. They capture accepted and rejected traffic, and they are the fastest way to answer “is my traffic being blocked, and by what?” Enable flow logs on the VPC or the specific subnet you are debugging, send them to CloudWatch Logs or S3, and look for REJECT entries for the address and port you care about. A REJECT in the flow log with no matching security group or NACL rule usually means the route table is sending the traffic somewhere it should not go.</p>
<p>Run through this checklist when something in a VPC does not connect. First, is the instance running and in the right subnet? Second, does the subnet’s route table send the traffic to the right target — internet gateway for public, NAT gateway for private egress? Third, does the security group allow the traffic, and does the network ACL allow both directions? Fourth, does the instance have a public IP if it needs one, and is DNS resolution enabled on the VPC? Fifth, what do the flow logs say — ACCEPT, REJECT, or nothing at all, which points at routing rather than filtering? Work the list in order and you will find the fault instead of changing rules at random.</p>
<p>A concrete example ties it together. An application server in a private subnet cannot download packages, and the error is a connection timeout rather than a refusal. A timeout with no response usually means routing, not filtering, so you check the route table first: the private subnet’s route table has no 0.0.0.0/0 route at all, because the subnet was created but never associated with the private route table and fell back to the VPC’s main route table, which only has the local route. You associate the subnet with the private route table that points at the NAT gateway, and the downloads start working. If the flow log had shown REJECT instead, the same symptom would have pointed at the security group or the network ACL — and if the flow log showed nothing at all, the traffic was never leaving the instance, which would point at the instance’s own configuration. The log entry tells you which layer to fix, and that is why flow logs are worth enabling before you need them rather than after.</p>
<p>Kubernetes makes all of this concrete, because an EKS cluster is a VPC construct: the control plane and the worker nodes live in your subnets, and the cluster’s networking choices — public versus private endpoint, node subnets, security groups — are VPC choices. Our <a href="https://devopsjobupdates.com/aws-eks-tutorial/">AWS EKS tutorial</a> builds a cluster inside a VPC and shows how the networking decisions from this guide map onto a real workload.</p>
<h2>Frequently Asked Questions</h2>
<p><strong>What is the difference between a public and a private subnet?</strong></p>
<p>The route table decides. A public subnet has a route to an internet gateway; a private subnet does not. Instances in a public subnet usually have public IPs, but the route is what makes the subnet public, not the address.</p>
<p><strong>How many IP addresses does a /24 subnet have?</strong></p>
<p>A /24 holds 256 addresses, of which AWS reserves five — the network address, the VPC router, the DNS server, a reserved address and the broadcast address — leaving 251 usable. Size subnets with that reservation in mind, and remember that load balancers, NAT gateways and EKS nodes all consume addresses too.</p>
<p><strong>Do I need a NAT gateway in every Availability Zone?</strong></p>
<p>For production, yes. One NAT gateway per Availability Zone keeps each zone independent, so a zone failure does not cut off internet access for the others, and it avoids cross-zone traffic charges. A single shared gateway is acceptable for a development environment where cost matters more than availability.</p>
<p><strong>What is the difference between a security group and a network ACL?</strong></p>
<p>A security group is stateful, attached to a resource, and supports allow rules only. A network ACL is stateless, attached to a subnet, supports allow and deny rules evaluated in order, and requires explicit rules for return traffic. Use security groups for everyday access control and NACLs as a subnet-level guardrail.</p>
<p><strong>Can two VPCs with the same CIDR block be peered?</strong></p>
<p>No. VPC peering requires non-overlapping CIDR blocks, because routing cannot distinguish two networks that claim the same addresses. This is why address planning comes before building: overlapping ranges are painful to fix after resources exist.</p>
<h2>Conclusion</h2>
<p>A VPC is four ideas working together: an address range you choose, subnets that divide it by Availability Zone, route tables that decide where traffic goes, and firewalls that decide what gets through. Build one yourself with the CLI, put a load balancer in the public subnets and an application in the private ones, break it deliberately by removing a route, and fix it with the flow logs. That single exercise teaches more about AWS networking than any diagram, and it is the foundation for everything else on AWS — EKS clusters, RDS databases and serverless workloads all sit inside the network you just learned to build.</p>
]]></content:encoded></item><item><title><![CDATA[Azure Bicep Tutorial for Beginners: Deploy Your First Template]]></title><description><![CDATA[If you have ever built Azure infrastructure by clicking through the portal, you already know the problem. The first environment takes an afternoon, the…]]></description><link>https://devopsjobupdates.hashnode.dev/azure-bicep-tutorial-for-beginners-deploy-your-first-template</link><guid isPermaLink="true">https://devopsjobupdates.hashnode.dev/azure-bicep-tutorial-for-beginners-deploy-your-first-template</guid><category><![CDATA[Azure]]></category><category><![CDATA[Bicep]]></category><category><![CDATA[#IaC]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[DevOps Job Updates]]></dc:creator><pubDate>Wed, 02 Dec 2026 17:56:35 GMT</pubDate><content:encoded><![CDATA[<p>If you have ever built Azure infrastructure by clicking through the portal, you already know the problem. The first environment takes an afternoon, the second takes just as long, and nobody can say exactly what is different between them. Azure Bicep fixes that. It is a domain-specific language for deploying Azure resources, and it lets you describe the infrastructure you want in a short, readable file, then deploy that file again and again with identical results.</p>
<p>This tutorial takes you from zero to a working deployment. You will install the tools, write a template that creates a storage account, add parameters and modules, preview changes before they happen, and wire the result into a pipeline. Everything here uses the Azure CLI, so it works the same on Windows, macOS and Linux. You need an Azure subscription and a resource group to follow along; every command that creates something billable is flagged, and the clean-up step at the end removes it all.</p>
<h2>What Is Azure Bicep and Why Use It?</h2>
<p>Bicep is a declarative language that sits on top of Azure Resource Manager (ARM). You declare the resources you want — a storage account, a virtual network, a web app — and Azure Resource Manager works out the order to create them in. A Bicep file compiles to an ARM JSON template behind the scenes, so anything that is valid in an ARM template is valid in Bicep. The difference is that Bicep is far shorter and easier to read: no bracketed expressions, no deeply nested JSON, and symbolic names instead of long resource IDs.</p>
<p>Three properties make Bicep worth learning. First, it is idempotent. Deploy the same file twice and the second run changes nothing, because Azure compares the desired state with what already exists. Second, it needs no state file. Azure itself stores the state of your resources, so there is no state file to lock, back up or accidentally delete — a real contrast with tools that keep state locally. Third, it supports every Azure resource type and API version on day one, because it is a transparent layer over ARM templates rather than a separate provider that has to catch up.</p>
<p>Bicep also handles orchestration for you. When one resource references another by its symbolic name, Bicep automatically creates an implicit dependency, so the referenced resource is deployed first. You rarely need to write explicit dependency declarations, and when resources are independent, Resource Manager deploys them in parallel, which makes large deployments finish faster than a sequence of manual steps.</p>
<table>
<thead>
<tr>
<th>Approach</th>
<th>Language</th>
<th>State file</th>
<th>Cloud scope</th>
<th>Best for</th>
</tr>
</thead>
<tbody><tr>
<td>Bicep</td>
<td>Bicep DSL</td>
<td>None — Azure stores state</td>
<td>Azure only</td>
<td>Azure-only teams who want the shortest path to repeatable deployments</td>
</tr>
<tr>
<td>ARM JSON templates</td>
<td>JSON</td>
<td>None — Azure stores state</td>
<td>Azure only</td>
<td>Teams with existing JSON templates or generated templates</td>
</tr>
<tr>
<td>Terraform</td>
<td>HCL</td>
<td>Yes — local or remote backend</td>
<td>Multi-cloud</td>
<td>Teams managing Azure alongside AWS, GCP or on-premises systems</td>
</tr>
</tbody></table>
<p>None of these is wrong. If your whole estate is Azure, Bicep is usually the fastest to learn and the least to maintain. If you manage several clouds with one workflow, Terraform earns its state file. Many teams use both — Bicep for Azure platform resources and Terraform for the multi-cloud parts — and that is a reasonable choice rather than a contradiction. Microsoft’s own overview, <a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/learn-bicep">What is Bicep?</a>, sets out the same benefits: concise syntax, type safety, idempotent deployments and no state file to manage. Our <a href="https://devopsjobupdates.com/terraform-tutorial-beginners/">Terraform tutorial for beginners</a> covers that path in the same hands-on style, so you can compare the two from real examples rather than marketing claims.</p>
<p>Before you write a line of code, it helps to know where the guardrails are. Bicep files are plain text, so they belong in source control with the same review process as application code. A pull request that changes a template should show a what-if preview, just as a pull request that changes application code shows test results. That single habit — never deploying a template that nobody reviewed — prevents more incidents than any amount of clever syntax. The Bicep Playground, linked from the Microsoft Learn overview, lets you try syntax in the browser without installing anything, which is a good way to test an expression before you paste it into a real file.</p>
<h2>Setting Up Your Bicep Environment</h2>
<p>You need two things: the Azure CLI and an editor with Bicep support. Microsoft recommends Visual Studio Code with the Bicep extension, which gives you IntelliSense, syntax validation and one-click deployment. Install VS Code, open the Extensions tab, search for “bicep” and install the extension published by Microsoft. Visual Studio has its own Bicep extension if that is your editor of choice. The full setup steps, including the manual install for Azure PowerShell and the download for air-gapped clouds, are on Microsoft Learn’s <a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install">Install Bicep tools</a> page.</p>
<p>The Azure CLI installs the Bicep CLI automatically the first time you run a command that needs it, but Microsoft documents a minimum Azure CLI version of 2.20.0, so check yours first. If you use Azure PowerShell instead, you need version 5.6.0 or later, and you must install the Bicep CLI manually — PowerShell does not fetch it for you.</p>
<pre><code class="language-bash">az --version
az login
az account show --query "{subscription:name, id:id}" --output table
az bicep version
az bicep upgrade
</code></pre>
<p>Run <code>az login</code> and sign in with the account that owns your subscription. Then confirm which subscription is active with <code>az account show</code>, because deploying to the wrong subscription is the most common beginner mistake and the hardest to notice until the bill arrives. If you manage several subscriptions, set the right one with <code>az account set --subscription "Your Subscription Name"</code> before you deploy anything.</p>
<p>Create a resource group to hold the practice resources. Resource groups are the deployment boundary for most Bicep files: you deploy into a group, and deleting the group deletes everything inside it, which makes clean-up trivial.</p>
<pre><code class="language-bash">az group create --name rg-bicep-demo --location uksouth
</code></pre>
<p>If <code>az bicep version</code> reports an error, the CLI has not installed Bicep yet. Run <code>az bicep install</code> explicitly, then try again. In an air-gapped environment you can download the Bicep CLI directly, but for a normal workstation the automatic install is the path Microsoft documents.</p>
<h2>Your First Bicep File: A Storage Account</h2>
<p>Create a file called <code>main.bicep</code>. Every Bicep file is built from four building blocks: parameters, variables, resources and outputs. This first example uses a parameter and a single resource. It deploys a storage account, which is the simplest real Azure resource and a good first deployment because it is cheap and fast to create.</p>
<pre><code class="language-bicep">param location string = resourceGroup().location
param storageAccountName string = 'toylaunch${uniqueString(resourceGroup().id)}'

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: storageAccountName
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  properties: {
    accessTier: 'Hot'
  }
}
</code></pre>
<p>Read it line by line. The <code>param</code> declarations define inputs: <code>location</code> defaults to the resource group’s location, and <code>storageAccountName</code> builds a globally unique name by appending a hash of the resource group ID to a prefix, because storage account names must be unique across all of Azure and contain only lowercase letters and numbers. The <code>resource</code> declaration names the resource type and API version — <code>Microsoft.Storage/storageAccounts@2023-05-01</code> — gives it a symbolic name (<code>storageAccount</code>) that other parts of the file can reference, and sets its properties.</p>
<p>Before you deploy, compile the file to check for syntax errors. The Bicep CLI converts it to an ARM JSON template, which you can inspect if you are curious about what Azure actually receives.</p>
<pre><code class="language-bash">az bicep build --file main.bicep
</code></pre>
<p>Now deploy it into the resource group you created. The deployment name is just a label in your deployment history, so make it descriptive.</p>
<pre><code class="language-bash">az deployment group create \
  --name first-bicep-deploy \
  --resource-group rg-bicep-demo \
  --template-file main.bicep
</code></pre>
<p>Check the result in the portal or with <code>az storage account list --resource-group rg-bicep-demo --output table</code>. Then run the same deployment command again and watch the output: the second run reports no changes, because the deployment is idempotent. That is the behaviour you want from infrastructure as code — running the same file twice is safe, not destructive. If you want to see what Azure recorded, run <code>az deployment group show --resource-group rg-bicep-demo --name first-bicep-deploy</code> and look at the properties section: it lists the template, the parameters that were supplied, the outputs, and the state of every resource the deployment touched. That deployment history is also where you go when something fails, because the error message there is usually more detailed than the one printed to your terminal.</p>
<p>When you are finished practising, remove everything with a single command. Deleting the resource group deletes the storage account and every other resource inside it, which is exactly why practice deployments belong in a disposable group rather than one shared with real workloads:</p>
<pre><code class="language-bash">az group delete --name rg-bicep-demo --yes --no-wait
</code></pre>
<h2>Parameters, Variables and Outputs</h2>
<p>Hard-coded values make a template usable exactly once. Parameters, variables and outputs make it reusable across environments. Parameters are inputs supplied at deployment time. Variables are values computed inside the file. Outputs return values — such as a resource ID or endpoint — to whoever or whatever called the deployment.</p>
<p>Give every parameter a type and, where it helps, a decorator that constrains it. Types are <code>string</code>, <code>int</code>, <code>bool</code>, <code>array</code> and <code>object</code>, plus <code>secureString</code> and <code>secureObject</code> for secrets. The <code>@allowed</code> decorator restricts a parameter to a list of values, which stops a typo from deploying a premium SKU when you meant standard. The <code>@description</code> decorator documents what the parameter is for, and it shows up in tooling, so write it for every parameter a teammate might have to fill in.</p>
<pre><code class="language-bicep">@description('The environment this deployment targets.')
@allowed([
  'dev'
  'test'
  'prod'
])
param environment string = 'dev'

@description('Administrator password. Never commit a real value.')
@secure()
param adminPassword string

var storageName = 'st${environment}${uniqueString(resourceGroup().id)}'
var tags = {
  environment: environment
  managedBy: 'bicep'
}

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: storageName
  location: resourceGroup().location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  tags: tags
}
</code></pre>
<p>Two rules matter here. First, never put a secret in a parameter file that is committed to source control. Mark secrets with <code>@secure()</code> so their values are not logged or returned in deployment outputs, and pass them at deployment time or from Azure Key Vault. Bicep can read a secret from Key Vault at deployment time with the <code>getSecret()</code> function, which keeps the value out of your repository entirely.</p>
<p>Second, keep environment differences in parameter files, not in copies of the template. A parameter file is a JSON file that supplies values for one environment, so you keep one <code>main.bicep</code> and a <code>main.dev.bicepparam</code> or <code>parameters.dev.json</code> per environment. Deploy with <code>--parameters @parameters.dev.json</code> and the same template produces a development environment or a production one depending only on the file you point at.</p>
<p>Outputs close the loop. When a later step in a pipeline needs the storage account name, output it from the template instead of reconstructing it with string manipulation:</p>
<pre><code class="language-bicep">output storageAccountName string = storageAccount.name
output storageAccountId string = storageAccount.id
</code></pre>
<p>Outputs are also how modules talk to each other, which is the subject of the next section.</p>
<h2>Modules: Reusing Bicep Code</h2>
<p>A module is a Bicep file that another Bicep file deploys. Modules are how you stop copying the same virtual network or storage account definition into every project. You write the resource once, expose its inputs as parameters and its useful values as outputs, then reference it from a parent file.</p>
<p>Start by moving the storage account into <code>modules/storage.bicep</code>. The file looks almost identical to the standalone version, except it declares an output for the account name. Then the parent file, <code>main.bicep</code>, calls it:</p>
<pre><code class="language-bicep">param location string = resourceGroup().location
param environment string = 'dev'

module storage 'modules/storage.bicep' = {
  name: 'storageDeploy'
  params: {
    location: location
    environment: environment
  }
}

output storageAccountName string = storage.outputs.storageAccountName
</code></pre>
<p>Modules can be scoped to a resource group, a subscription, a management group or a tenant, so a single parent file can deploy a resource group at subscription scope and then deploy resources inside it. They can also be published to a private module registry — Azure Container Registry doubles as a Bicep registry — so teams share versioned modules the same way they share container images. Pin a version when you reference a registry module, exactly as you would pin an image tag, so a teammate’s update does not silently change your next deployment.</p>
<p>Two patterns cover most real projects. The first is a module per resource type: one module for a virtual network, one for a key vault, one for an app service plan. The second is a module per reusable stack: a “web app with database” module that wires several resources together and exposes only the handful of parameters that vary. Start with the first pattern; move to the second when you find yourself deploying the same three resources together for the third time.</p>
<p>Loops and conditions keep modules small. A <code>for</code> loop creates one subnet per entry in an array, and an <code>if</code> condition deploys a resource only in production. Here is a virtual network whose subnets come from a loop, so adding a fourth subnet means adding one line to an array instead of copying a whole block:</p>
<pre><code class="language-bicep">param subnetNames array = [
  'web'
  'app'
  'data'
  'AzureBastionSubnet'
]

resource vnet 'Microsoft.Network/virtualNetworks@2023-05-01' = {
  name: 'vnet-demo'
  location: resourceGroup().location
  properties: {
    addressSpace: {
      addressPrefixes: [
        '10.0.0.0/16'
      ]
    }
    subnets: [for (name, i) in subnetNames: {
      name: name
      properties: {
        addressPrefix: '10.0.${i}.0/24'
      }
    }]
  }
}

resource publicIp 'Microsoft.Network/publicIPAddresses@2023-05-01' = if (environment == 'prod') {
  name: 'pip-bastion-demo'
  location: resourceGroup().location
  sku: {
    name: 'Standard'
  }
  properties: {
    publicIPAllocationMethod: 'Static'
  }
}

resource bastion 'Microsoft.Network/bastionHosts@2023-05-01' = if (environment == 'prod') {
  name: 'bastion-demo'
  location: resourceGroup().location
  properties: {
    ipConfigurations: [
      {
        name: 'bastionConfig'
        properties: {
          subnet: {
            id: vnet.properties.subnets[3].id
          }
          publicIPAddress: {
            id: publicIp.id
          }
        }
      }
    ]
  }
}
</code></pre>
<p>Notice two things in that example. The loop builds each subnet’s address prefix from its index, so the web subnet becomes 10.0.0.0/24, the app subnet 10.0.1.0/24 and the data subnet 10.0.2.0/24, with no repeated code. And the bastion host is wrapped in an <code>if</code> condition, so it only deploys when the environment is production — a cheap way to keep development environments small without maintaining a second template. When a loop grows complicated, move it into its own module — readability is the point of Bicep, and a file nobody can read is worse than the JSON it replaced.</p>
<h2>Deploying Safely: What-If, Validation and Scopes</h2>
<p>The most important Bicep command for a beginner is the one that deploys nothing. <code>az deployment group what-if</code> previews exactly what a deployment would create, modify or delete, and which properties would change. Run it before every deployment, in every environment, without exception. The output colour-codes changes — creates, modifies and deletes — so a destructive change is visible before it happens rather than after.</p>
<pre><code class="language-bash">az deployment group what-if \
  --resource-group rg-bicep-demo \
  --template-file main.bicep \
  --parameters environment=prod
</code></pre>
<p>Understand the two deployment modes. Incremental is the default: resources in the template are created or updated, and anything already in the resource group but not in the template is left alone. Complete mode deletes resources in the group that are not in the template. Complete mode is powerful for keeping an environment exactly in sync with code, and dangerous for the same reason — a template that omits a resource deletes it. Never use complete mode on a resource group that contains resources managed outside the template, and never use it for the first time on a production group.</p>
<p>Validate a template without deploying it by using what-if, or by running a validation-only deployment. In a pipeline, add a <code>az bicep build</code> step to catch syntax errors, a what-if step to catch unintended changes, and only then the real deployment. The Bicep linter, built into the VS Code extension, also flags common problems as you type — unused parameters, hard-coded secrets, and API versions that are out of date — so fix warnings before they reach a pull request. A minimal pipeline sequence looks like this: build the template, run what-if against the target resource group and fail the pipeline if the preview shows a delete you did not expect, then deploy with the environment’s parameter file. Keep the deployment’s output — the deployment name, the template hash and the what-if result — as a build artefact, because that is the audit trail that shows exactly what was deployed, when, and by whom. If a deployment ever goes wrong, the same history lets you redeploy the previous known-good template instead of guessing what changed.</p>
<p>Deployment scopes decide where resources land. Most files deploy at resource-group scope, but you can target a subscription to create resource groups themselves, or a management group or tenant for policy and role assignments. The scope is set in the file with <code>targetScope</code> or on the command line with <code>az deployment sub create</code> instead of <code>az deployment group create</code>. Mixing scopes in one file is a common source of confusing errors, so keep one file to one scope and use modules when you need to cross a boundary.</p>
<h2>Bicep vs Terraform, and the Errors You Will Meet</h2>
<p>The honest comparison is about scope, not quality. Bicep is Azure-only, has no state file, and gets day-one support for new Azure features because it is built by the Azure team. Terraform is multi-cloud, keeps its own state, and has a larger ecosystem of providers and modules. If you work only in Azure, Bicep is less to operate. If you work across clouds, Terraform is the single workflow. Many teams use both — Bicep for Azure platform resources and Terraform for the multi-cloud parts — and that is a reasonable choice rather than a contradiction. Our <a href="https://devopsjobupdates.com/azure-devops-pipeline-tutorial/">Azure DevOps pipeline tutorial</a> shows how to run Bicep validation and deployment as pipeline stages, so the template gets the same review and testing discipline as application code.</p>
<p>Now the errors. <code>InvalidTemplateDeployment</code> with a message about a storage account name usually means the name breaks the naming rules — lowercase letters and numbers only, between 3 and 24 characters. <code>ResourceNotFound</code> during a deployment usually means a module references a resource in a different resource group without a scope, or a symbolic name is used before the resource it points to is declared. <code>DeploymentActive</code> means another deployment is already running against the same resource group; wait for it or cancel it before retrying.</p>
<p>The most confusing error is a deployment that succeeds but changes nothing you expected. That is almost always a parameter file pointing at the wrong environment, or a default parameter value silently winning because the parameter file did not override it. Check the deployment inputs in the portal — every deployment records the exact parameters it received — before you assume the template is wrong.</p>
<p>Finally, remember that Bicep is also a career skill, not just a tool. Infrastructure as code appears in Azure administrator and DevOps engineer roles, and the certification path around it is changing: exam AZ-400 and the DevOps Engineer Expert certification retire on 1 February 2027, and the successor is exam AZ-401, which leads to the Agentic DevOps Engineer Expert certification. Our <a href="https://devopsjobupdates.com/azure-certification-roadmap-2026/">Azure certification roadmap for 2026</a> explains the new path, including the AZ-401 plus GH-300 or AZ-104 combination, so you can plan study around the retirement date rather than discovering it after booking.</p>
<h2>Frequently Asked Questions</h2>
<p><strong>Is Bicep free to use?</strong></p>
<p>Yes. Bicep itself costs nothing — Microsoft states that you do not pay for premium capabilities, and support is included. You pay only for the Azure resources your templates create, such as storage accounts and virtual machines, at their normal rates.</p>
<p><strong>Do I need to learn ARM JSON before Bicep?</strong></p>
<p>No. Bicep is designed so you never have to write JSON templates by hand. It helps to know that Bicep compiles to ARM JSON, because that explains error messages and the deployment history you see in the portal, but you can be productive in Bicep without writing a line of JSON.</p>
<p><strong>Does Bicep replace Terraform?</strong></p>
<p>Not exactly. Bicep replaces ARM JSON templates for Azure-only work, and it is the simplest choice there. Terraform remains the better fit when you manage several clouds with one tool, because Bicep only targets Azure. Many engineers learn both and choose per project.</p>
<p><strong>What is the difference between what-if and a real deployment?</strong></p>
<p>What-if previews the changes a deployment would make — creates, modifies and deletes — without changing anything. A real deployment applies them. Run what-if first, read the output, and only then deploy, especially in production.</p>
<p><strong>Can I convert my existing ARM JSON templates to Bicep?</strong></p>
<p>Yes. The Bicep CLI can decompile a JSON template with <code>az bicep decompile --file template.json</code>. The result usually needs tidying — decompiled files are more verbose than hand-written Bicep — but it is a fast starting point for migrating existing templates.</p>
<h2>Conclusion</h2>
<p>You now have the full Bicep workflow: install the tools, write a template, preview it with what-if, deploy it, and organise it into modules that a team can reuse. The next step is to convert one real piece of your own infrastructure — a storage account, a virtual network, a small web app — into a Bicep file and deploy it to a test resource group. Keep the file in source control, add what-if to your pipeline, and delete the practice resource group when you are done with <code>az group delete --name rg-bicep-demo --yes --no-wait</code>. The habit that matters is not the syntax; it is deploying from code, previewing before you apply, and never clicking through the portal for something you will need to build twice.</p>
]]></content:encoded></item></channel></rss>