DevOps Tutorials for Beginners: Hands-On Architecture, Automation & Infrastructure
A comprehensive, hands-on foundation guide for engineers entering platform and operations engineering: Linux systems, Git workflows, Docker multi-stage containers, GitHub Actions CI/CD, Terraform Infrastructure as Code, and Kubernetes orchestration.
The transition into DevOps and platform engineering is frequently obscured by an overwhelming landscape of tooling acronyms, commercial marketing hype, and disconnected tutorials. Beginners often encounter tutorials that demonstrate installing a single tool in isolation without explaining how distributed systems actually interact in production. Understanding DevOps requires stepping beyond individual commands to grasp the foundational architectural model: how source code evolves from a developer's local workstation into an immutable, containerized workload running reliably across distributed cloud clusters.
DevOps is fundamentally an operational methodology and engineering discipline designed to eliminate friction between software development and production system reliability. It replaces manual handoffs, unpredictable server configurations, and stressful midnight deployments with automated pipelines, immutable infrastructure definitions, and continuous feedback loops. Rather than managing servers as individual bespoke pets, modern DevOps engineers treat infrastructure as reproducible code.
This comprehensive, hands-on tutorial is structured specifically for engineers, developers, and systems administrators beginning their DevOps journey. We strip away marketing buzzwords and examine the core technical pillars: Linux kernel foundations, modern version control, multi-stage container builds, automated CI/CD pipelines, declarative Infrastructure as Code (IaC), container orchestration with Kubernetes, and production observability. Every section contains reproducible examples, production architectural trade-offs, and verification commands.
1. The Production DevOps Lifecycle: Understanding the Core Flow
Before executing technical commands, engineers must understand the standard software delivery lifecycle. In a mature cloud-native environment, software progresses through six deterministic stages:
- Source Control (Code): Developers collaborate using git, committing atomic changes into feature branches governed by branch protection policies and peer review gates.
- Continuous Integration (Build & Test): Automated runners intercept push events, compile source code, execute unit tests, scan for vulnerabilities, and package artifacts into immutable container images.
- Artifact Registry (Package & Sign): Container images are tagged with git commit SHAs, signed with cryptographic keys (such as Sigstore Cosign), and published to an OCI-compliant registry.
- Infrastructure Provisioning (IaC): Cloud networks, compute clusters, databases, and IAM access policies are declared in version-controlled Terraform or OpenTofu files and applied through automated CI/CD runners.
- Continuous Delivery (Orchestration & Release): GitOps controllers or deployment pipelines pull approved release artifacts and orchestrate rolling, blue-green, or canary deployments across Kubernetes clusters.
- Continuous Observability (Monitor & Alert): Telemetry systems collect metrics, logs, and distributed traces, evaluating service level objectives (SLOs) and notifying on-call engineers when failure thresholds are breached.
2. The Linux Systems Engineering Foundation
Every major container engine, cloud platform, and Kubernetes worker node runs on the Linux operating system. Platform engineers who lack Linux systems fundamentals struggle to diagnose container crashes, performance bottlenecks, and network failures. To operate effectively, beginners must master four core Linux concepts:
Linux Process Hierarchy and State Tracking
In Linux, every running program is represented as a process. The Linux kernel assigns each process a unique Process ID (PID). Process ID 1 (systemd on modern hosts, or your container entrypoint inside a pod) serves as the parent of all subsequent processes. When debugging performance saturation, engineers inspect process execution states using ps and top:
- State R (Running/Runnable): The process is currently executing on a CPU core or waiting in the scheduler run queue.
- State S (Interruptible Sleep): The process is waiting for an event, such as network I/O, a timer, or user input.
- State D (Uninterruptible Sleep): The process is blocked waiting directly for kernel disk or hardware I/O. Processes stuck in D state cannot be terminated with
kill -9and indicate disk saturation or NFS timeouts. - State Z (Zombie): The process has completed execution, but its parent process has not yet read its exit status via the
wait()system call.
# Inspect processes consuming CPU and memory, including execution state
ps aux --sort=-%cpu | head -n 10
# Inspect kernel wait channels for processes in uninterruptible sleep (D state)
ps -eo pid,user,stat,wchan:25,cmd | grep " D"
Filesystem Permissions and Ownership
Linux security relies on POSIX permissions: read (4), write (2), and execute (1), assigned across owner, group, and others. In containerized environments, running workloads as the root user (UID 0) presents severe host security risks. Production applications must run under an unprivileged user (e.g., UID 10001):
# Create an unprivileged service account group and user
sudo groupadd -g 10001 appgroup
sudo useradd -u 10001 -g appgroup -s /sbin/nologin -M appuser
# Set strict permissions on application configuration directories
sudo chown -R appuser:appgroup /opt/app
sudo chmod -R 750 /opt/app
Kernel Resource Boundaries: cgroups v2 and Namespaces
Containers are not virtual machines; there is no hypervisor running an independent guest operating system. A container is simply a standard Linux process isolated by the kernel using two core mechanisms:
- Namespaces (Isolation): Partitions system resources so that a process sees its own isolated view of the system. Six primary namespaces exist: PID (process trees), NET (network interfaces and routing tables), MNT (mount points), IPC (inter-process communication), UTS (hostnames), and USER (UID/GID mappings).
- Control Groups / cgroups v2 (Resource Metering): Enforces hard ceilings on CPU time, memory limits, and disk I/O throughput. When a container exceeds its memory cgroup limit, the Linux kernel Out-Of-Memory (OOM) killer immediately terminates the process with exit code 137.
3. Modern Version Control and Git Collaboration Workflows
Version control is the single source of truth for all software, application configuration, and infrastructure definitions. Beginners must move beyond basic git push commands to understand production branch management and commit hygiene.
Trunk-Based Development vs GitFlow
Traditional teams frequently utilized complex branching strategies such as GitFlow, maintaining long-lived branches (develop, release, feature, hotfix) that resulted in painful merge conflicts and delayed releases. High-performing DevOps organizations universally adopt Trunk-Based Development:
- Developers create short-lived feature branches branching directly off the main trunk (
main). - Feature branches live for hours or days, not weeks. Developers merge changes back into
mainfrequently via small, tested pull requests. - Production releases are cut directly from
mainor annotated git tags. - Incomplete features are hidden behind runtime feature flags rather than kept in isolated unmerged branches.
Essential Git Commands for Platform Engineers
# Initialize repository and configure branch naming
git init -b main
# Create a scoped feature branch
git checkout -b feature/docker-multistage-build
# Stage changes and create an atomic, semantic commit
git add Dockerfile
git commit -m "feat(build): implement multi-stage build reducing image size to 25MB"
# Rebase feature branch cleanly against main before opening a pull request
git fetch origin main
git rebase origin/main
# Tag an immutable semantic release
git tag -a v1.0.0 -m "Release v1.0.0: Initial production release"
git push origin v1.0.0
4. Containerization Essentials with Docker and Multi-Stage Builds
Before containerization, applications suffered from the classic failure mode: "It works on my machine, but fails in production." Operating system library mismatches, conflicting Python or Node.js runtime versions, and unrecorded environmental dependencies caused frequent deployment downtime. Containers solve this by packaging the compiled application binary, required runtime dependencies, configuration files, and system libraries into a single portable OCI image.
Anatomy of a Production Multi-Stage Dockerfile
A naive Dockerfile installs compilers, build tools, package managers, and development headers directly into the container image. This results in bloated images (exceeding 1GB in size), sluggish deployment download times, and an expansive attack surface riddled with unpatched CVEs.
Production containerization mandates multi-stage builds. The first stage contains all compilers and dependencies required to build the application. The second stage uses a minimal, hardened base image (such as alpine or distroless) and copies only the compiled binary artifact, discarding compilers and source code completely.
# Stage 1: Build Environment
FROM golang:1.23-alpine AS builder
# Install security certificates and build dependencies
RUN apk add --no-cache ca-certificates git
WORKDIR /src
# Leverage Docker layer caching for dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy source code and compile an optimized, static binary
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-w -s" -o /bin/app ./main.go
# -------------------------------------------------------------
# Stage 2: Hardened Runtime Environment
FROM scratch
# Import system CA certificates for outbound HTTPS calls
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Import unprivileged user configuration
COPY --from=builder /etc/passwd /etc/passwd
USER 10001:10001
# Copy compiled binary from builder stage
COPY --from=builder /bin/app /bin/app
# Expose HTTP service port
EXPOSE 8080
# Configure healthcheck and entrypoint
ENTRYPOINT ["/bin/app"]
Container Image Build and Verification
# Build container image tagging with semantic version and git commit SHA
docker build -t devopstribune/sample-service:1.0.0 \
-t devopstribune/sample-service:$(git rev-parse --short HEAD) .
# Verify image size (Scratch/Distroless multi-stage builds typically measure < 30MB)
docker images devopstribune/sample-service
# Run container locally in isolated network bridge
docker run -d --name sample-app -p 8080:8080 --read-only devopstribune/sample-service:1.0.0
# Verify local container response
curl -i http://localhost:8080/healthz
5. Continuous Integration (CI) with GitHub Actions
Continuous Integration is the automated practice of building, testing, and validating code changes on every commit. A robust CI pipeline acts as an automated quality gate, preventing regressions, syntax errors, and security vulnerabilities from ever reaching production.
The Anatomy of a Production CI Pipeline
A production-ready GitHub Actions workflow should automate four sequential validation steps:
- Code Formatting and Linting: Verify syntax rules, style guides, and static analysis checks.
- Unit and Integration Testing: Execute test suites with code coverage thresholds.
- Vulnerability Scanning: Scan third-party dependencies and container base images for known vulnerabilities (CVEs).
- Container Artifact Build: Compile the container image and upload it to an OCI registry upon successful tests.
# .github/workflows/ci.yml
name: Continuous Integration
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Setup Go Runtime
uses: actions/setup-go@41dfa10bad2bb2aeab793297a7605d0458dfe336 # v5.1.0
with:
go-version: '1.23'
cache: true
- name: Run Linter
run: |
go vet ./...
- name: Run Unit Tests
run: |
go test -v -race -covermode=atomic ./...
container-scan:
needs: lint-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Build Local Container Image
run: |
docker build -t local/sample-app:test .
- name: Scan Image for High & Critical CVEs
uses: aquasecurity/trivy-action@master
with:
image-ref: 'local/sample-app:test'
format: 'table'
exit-code: '1'
severity: 'CRITICAL,HIGH'
6. Infrastructure as Code (IaC) with Terraform and OpenTofu
Before Infrastructure as Code, deploying servers required clicking through cloud provider web consoles (AWS Management Console, Azure Portal, GCP Console). This manual approach—often referred to as "ClickOps"—results in undocumented configurations, configuration drift, and environments that cannot be reliably reproduced during a disaster recovery scenario.
Infrastructure as Code allows platform engineers to declare virtual private clouds (VPCs), subnets, routing tables, Kubernetes clusters, and DNS records in declarative configuration files using HashiCorp Configuration Language (HCL). Tools such as Terraform and OpenTofu read these files, determine the difference between desired state and actual cloud state, and execute API calls to reconcile them.
Core Declarative HCL Configuration
The following example declares an isolated AWS S3 storage bucket configured with default server-side encryption and public access blocks:
# main.tf
terraform {
required_version = ">= 1.5.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
# Remote State Storage Backend
backend "s3" {
bucket = "devopstribune-terraform-state-prod"
key = "foundation/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "devopstribune-terraform-locks"
encrypt = true
}
}
provider "aws" {
region = var.aws_region
}
# S3 Bucket with Mandatory Encryption and Public Access Block
resource "aws_s3_bucket" "app_storage" {
bucket = "devopstribune-app-assets-${var.environment}"
tags = {
Environment = var.environment
ManagedBy = "Terraform"
}
}
resource "aws_s3_bucket_server_side_encryption_configuration" "app_storage" {
bucket = aws_s3_bucket.app_storage.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
resource "aws_s3_bucket_public_access_block" "app_storage" {
bucket = aws_s3_bucket.app_storage.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
The Essential IaC Execution Cycle
Managing infrastructure follows a strict three-phase command loop:
tofu init: Downloads cloud provider plugins and initializes the remote S3 state backend.tofu plan: Queries current cloud infrastructure, compares it against local HCL declarations, and outputs a dry-run execution plan showing resources to add, modify, or destroy.tofu apply: Executes authorized API calls against the cloud provider to match the declared architecture.
# Initialize plugins and backend
tofu init
# Dry run execution plan (Review carefully before executing changes)
tofu plan -out=tfplan
# Apply the approved changes safely
tofu apply tfplan
7. Container Orchestration Foundations with Kubernetes
While Docker runs containers on a single host machine, production systems span dozens or hundreds of virtual servers. If a server experiences a hardware failure, how do containers automatically restart on a healthy node? How do applications scale from two replicas to twenty during traffic spikes? How do external HTTP requests route evenly across identical replicas?
Kubernetes is the industry-standard distributed container orchestrator. It manages a cluster of nodes, abstracts underlying compute resources, and continuously works to maintain the declared desired state of running applications.
Core Kubernetes Primitives
- Pod: The smallest deployable computing unit in Kubernetes. A Pod encapsulates one or more closely coupled containers that share network namespaces, IP addresses, and storage volumes.
- Deployment: A declarative controller that manages the lifecycle of Pods. It defines the desired replica count, container image versions, rolling update strategies, and health check probes.
- Service: An internal abstraction that defines an immutable IP address and DNS name to balance network traffic across a dynamically changing set of Pod replicas.
- ConfigMap and Secret: Decouples runtime configuration variables and encrypted credentials from the container image.
Production-Ready Deployment and Service Manifest
# k8s/app-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-service
namespace: production
labels:
app.kubernetes.io/name: api-service
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: api-service
template:
metadata:
labels:
app: api-service
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
fsGroup: 10001
containers:
- name: web
image: devopstribune/sample-service:1.0.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "256Mi"
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10
periodSeconds: 15
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: api-service
namespace: production
spec:
type: ClusterIP
selector:
app: api-service
ports:
- name: http
port: 80
targetPort: 8080
8. Production Observability: Metrics, Logs, and Tracing
A core tenet of Site Reliability Engineering (SRE) states: "You cannot manage what you cannot measure." Traditional monitoring answered simple binary questions: is server A online or offline? In distributed microservices architectures, systems fail in complex, partial, and nuanced ways. Observability is the degree to which an engineering team can infer the internal health state of a distributed system based solely on its external telemetry outputs.
The Three Pillars of Observability
- Metrics (Aggregated Numerics): Numeric representations of data measured over intervals of time. Metrics are exceptionally lightweight and power dashboards and alerting rules. Key metric types include Counters (monotonically increasing values like total HTTP requests), Gauges (values that fluctuate up and down like memory usage), and Histograms (duration sampling like API latency percentiles).
- Structured Logs (Event Details): Discrete, timestamped records of events formatted as machine-readable JSON. Unlike unstructured text strings, JSON logs allow centralized ingestion engines (such as OpenSearch, Elasticsearch, or Loki) to index fields for sub-second filtering and error analysis.
- Distributed Traces (Request Journeys): Tracks the end-to-end journey of a single user request as it traverses across multiple microservices, API gateways, database queries, and third-party APIs. Tracing identifies precisely which downstream microservice introduced latency or returned a 500 status code.
The SRE "Four Golden Signals"
When creating alerting policies, avoid measuring raw server metrics like CPU utilization alone. Instead, anchor dashboards around Google's Four Golden Signals:
- Latency: The time it takes to service a request (distinguishing successful request latency from error latency).
- Traffic: The demand placed on the system (e.g., HTTP requests per second or network bandwidth).
- Errors: The rate of requests that fail (e.g., HTTP 5xx errors or connection timeouts).
- Saturation: How full the service is (e.g., memory usage fraction, CPU run queue length, or thread pool exhaustion).
9. Step-by-Step Hands-On Project: Deploying an Application
To consolidate these foundational concepts into practice, complete this end-to-end hands-on exercise on a local workstation or development server. We will build a containerized Go microservice, configure automated GitHub Actions CI testing, and deploy it to a local Kubernetes cluster (such as Minikube or k3d).
Step 1: Write the Go Application Source Code
Create a directory named devops-starter and add main.go:
// main.go
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
type HealthResponse struct {
Status string `json:"status"`
Timestamp string `json:"timestamp"`
Version string `json:"version"`
}
func healthHandler(w http.ResponseWriter, r *http.Request) {
resp := HealthResponse{
Status: "healthy",
Timestamp: time.Now().UTC().Format(time.RFC3339),
Version: "1.0.0",
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(resp)
}
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
http.HandleFunc("/healthz", healthHandler)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "DevOps Tribune — Application Online!\n")
})
log.Printf("Starting HTTP server on port %s", port)
if err := http.ListenAndServe(":"+port, nil); err != nil {
log.Fatalf("Server startup failed: %s", err)
}
}
Step 2: Initialize Git and Build Container
# Initialize module and git
go mod init devops-starter
git init -b main
# Build and verify local Docker image
docker build -t devops-starter:1.0.0 .
docker run -d --name test-app -p 8080:8080 devops-starter:1.0.0
# Verify endpoint response
curl http://localhost:8080/healthz
# Clean up local test container
docker rm -f test-app
Step 3: Deploy to Local Kubernetes Cluster
# Load container image into local k3d or minikube cluster
k3d image import devops-starter:1.0.0 -c mycluster
# Apply Kubernetes deployment and service manifests
kubectl apply -f k8s/app-deployment.yaml
# Verify pod status and rolling deployment readiness
kubectl get pods -n production -l app=api-service
kubectl get svc -n production api-service
# Port-forward service to local machine for verification
kubectl port-forward svc/api-service 8080:80 -n production
10. Common Beginner Pitfalls and How to Avoid Them
Entering platform engineering involves navigating numerous architectural landmines. Avoid these common anti-patterns:
| Anti-Pattern | Operational Risk | Production Best Practice |
|---|---|---|
| Storing Secrets in Git | Leaked API keys and database credentials expose production data permanently in git history. | Use runtime secret managers (AWS Secrets Manager, HashiCorp Vault) and detect leaks via git pre-commit hooks (TruffleHog, Gitleaks). |
Using :latest Image Tags |
Unpredictable deployments, cache poisoning, and inability to rollback to known working versions. | Tag images with immutable semantic versions (v1.4.2) and immutable git commit SHAs. |
| Omitting Resource Limits | A single rogue pod experiencing a memory leak triggers node starvation, evicting healthy neighboring pods. | Always declare explicit CPU and memory requests and limits on every production container. |
| ClickOps Infrastructure | Cloud resources created manually drift silently and cannot be audited, reviewed, or rebuilt during outages. | Enforce 100% Infrastructure as Code via Terraform/OpenTofu and restrict console write access. |
11. Frequently Asked Questions
What programming languages should a DevOps beginner prioritize?
Beginners should prioritize Bash for operating system scripting and command-line automation, followed by Python or Go. Python is dominant in cloud automation, AWS Lambda functions, and data pipelines, while Go is the native programming language of the entire cloud-native ecosystem (Docker, Kubernetes, Terraform, Prometheus, and Helm are all written in Go).
Is DevOps a job title or a cultural philosophy?
Historically, DevOps originated as a cultural methodology emphasizing cross-functional collaboration between development and operations teams. In practice across modern industry, "DevOps Engineer" and "Platform Engineer" have evolved into formal technical roles responsible for architecting CI/CD pipelines, automating infrastructure, managing Kubernetes clusters, and building Internal Developer Platforms (IDPs).
Do I need to learn Kubernetes immediately when starting?
No. Attempting to learn Kubernetes before mastering Linux systems engineering, networking fundamentals, and Docker containerization often leads to confusion. Master the command line, POSIX permissions, Dockerfile multi-stage builds, and basic CI/CD automation before introducing distributed cluster orchestration.
Related Engineering Roadmaps & Architectural Guides
- DevOps Engineer Roadmap: From System Administrator to Senior Platform Architect →
- Linux Commands for DevOps Engineers: Diagnosing CPU, Memory & I/O →
- GitHub Actions Security Best Practices: Hardening CI/CD, OIDC & Supply Chain →
- Terraform Best Practices: Production Architecture, State Locking & CI/CD →