Kick off your book project in 2 hours, get started with GhostAI in 2 hours, or do both! Free live workshops, on Zoom. You’ll leave with a real book project and a clear plan to keep going. Saturday, June 27, 2026.

Leanpub Header

Skip to main content

Kubernetes for All

Build a Datacenter from Scratch

This book is 100% completeLast updated on 2026-06-05

Most Kubernetes books teach you YAML. This one teaches you to build a datacenter.

You start with #!/usr/bin/env bash. You finish with one command that provisions, reloads, and tears down a complete multi-service cluster. No magic. No black boxes. Just you, Bash, and the cloud-native platform you built yourself.

Minimum price

$20.00

$30.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
About

About

About the Book

Developer experience is infrastructure. The difference between a team that ships every day and a team that dreads deployments is rarely talent. More often, it is tooling. Fast feedback loops. Immutable deployments. Self-healing clusters. Observable systems. These are not luxuries reserved for large organizations—they are the foundation of reliable software delivery.

Most Kubernetes tutorials stop at kubectl apply. By now, you probably know the commands. What is often missing is the system that ties them together: a repeatable workflow that provisions a cluster in seconds, rebuilds images with the cache you expect, reloads services without dropping connections, and tells you exactly what went wrong when something fails.

This book is about building that system.

Kubernetes for All teaches Kubernetes from the ground up by having you build a complete cloud-native platform yourself. Instead of deploying to a managed cluster and accepting the magic, you'll create your own datacenter from scratch using a single Bash script that provisions a full multi-node Kubernetes environment.

Across 21 chapters, you'll discover not just how Kubernetes works, but why it works the way it does. You'll build the cluster, deploy applications, automate operations, implement GitOps workflows, add observability with Prometheus and Grafana, and follow requests through distributed systems with OpenTelemetry. Every layer is introduced by building it yourself.

No prior Kubernetes experience is required.

You'll work with Kind, Helm, Pods, Deployments, Services, Ingress, ConfigMaps, Secrets, Persistent Volumes, StatefulSets, and the Kubernetes API. Every command is explained. Every concept is demonstrated. By the end, you'll have a production-style environment running real microservices—and the understanding needed to operate it with confidence.

This is a book about cloud-native engineering in practice.

Not slides. Not architecture diagrams disconnected from reality. Not vendor marketing.

Bash. Docker. Helm. Kind.

Real tools solving real problems, guided by five principles that appear throughout the book:

  • Infrastructure as Code
  • Immutable Deployments
  • Fast Feedback
  • Fail Loudly and Self-Heal
  • Observability

What You Will Build

At the heart of the book is datacenter.sh, a single script that provisions and operates an entire Kubernetes environment.

By the time you're finished, that script will deploy 16 microservices, PostgreSQL, Kafka running in KRaft mode, and a web frontend. Whether the target is a local Kind cluster or a bare-metal datacenter, the deployment path remains the same. The infrastructure changes. The workflow does not.

You write every line.

You understand every decision.

You own the result.

Who This Book Is For

This book is for engineers who want Kubernetes tooling they can understand, modify, and trust.

You deploy applications. You write scripts. You value systems that are version-controlled, observable, reproducible, and fast.

You want your inner development loop—change code, build, deploy, verify—to take seconds instead of minutes.

Most of all, you want to understand what is happening beneath the abstractions.

No certification is required.

Just Docker, Kind, a terminal, and the desire to build something real.

Share this book

Author

About the Author

Joel Bryan Juliano

Hi, I'm Joel.

I am Senior Software Engineer with 20+ years of experience.

And with over 20 years in the game, I’ve seen it all and loved every minute of it.

Originally from the Philippines, I am now a Dutchman living in Amsterdam together with my family.

My journey has taken me through a variety of industries, from sports streaming to cybersecurity, and everything in between.

Along the way, I’ve picked up a diverse set of skills and experiences, in which I document into books.

Translations

Translations

Contents

Table of Contents

Introduction: Gluing Kubernetes Together with Bash

  1. Prerequisites
  2. Why Bash?
  3. What We Are Building
  4. How the Book Is Organized
  5. The Entry Point: setup.sh
  6. Starting datacenter.sh
  7. Hands-On Exercises

Safety Settings, Initialization, and Lifecycle Hooks

  1. Global Set Options
  2. Lint Your Shell Scripts: shellcheck
  3. Script Initialization
  4. The Main Controller
  5. Error Handler
  6. Exit Handler
  7. Putting It Together
  8. Hands-On Exercises

Exit Codes and Controlled Exits

  1. The script_exit Function
  2. Exit Code Conventions
  3. Bash Safety Patterns in Review
  4. Updated Script
  5. Hands-On Exercises

Cron Mode and IO Redirection

  1. What Cron Mode Does
  2. File Descriptors
  3. Redirecting for Cron Mode
  4. Updating the Error Handler
  5. Updating the Exit Handler
  6. Registering cron_init in main
  7. Updated Script
  8. Hands-On Exercises

The Library Pattern: Organizing a Bash Codebase

  1. The lib/ Directory
  2. Loading Libraries in main
  3. Writing a Library File
  4. Naming Conventions
  5. The Dependency Graph
  6. Two Utility Libraries Worth Knowing Now
  7. Hands-On Exercises

Terminal Colors and Logging

  1. The Logging Library
  2. Colour Initialization
  3. The log Function
  4. verbose_print — Verbose Mode Output
  5. Updating init
  6. Updating main
  7. Updating the Error Handler
  8. Hands-On Exercises

Validation Helpers and Binary Checks

  1. lib/script.sh
  2. check_binary — Required Tool Detection
  3. check_required_binaries — System Preconditions
  4. is_kind — Mode Detection
  5. check_arguments — Variable Presence Validation
  6. check_directories — Path Validation
  7. check_files — File Presence Validation
  8. check_repos — Repository Presence Guard
  9. build_path — PATH Construction
  10. Using the Helpers in the init Chain
  11. Hands-On Exercises

Configuration Management

  1. The Configuration File
  2. lib/config.sh
  3. get_configurations — Interactive Setup
  4. Reading Configuration in main
  5. Docker Network Modes
  6. Hands-On Exercises

Script Locking: Preventing Concurrent Runs

  1. Why a Directory, Not a File
  2. lock_init
  3. Stale Lock Handling
  4. Hands-On Exercises

Complete Parameter Parsing

  1. parse_params
  2. script_usage — The Help Text
  3. Connecting parse_params to main
  4. Hands-On Exercises

Local Mode and Kind Cluster Management

  1. Why Kind
  2. lib/kind.sh
  3. start_env — Creating a Kind Cluster
  4. stop_env — Stopping the Cluster
  5. delete_env — Destroying the Cluster
  6. Loading Images into Kind
  7. No Docker Environment Switching
  8. Hands-On Exercises

Docker Operations

  1. lib/docker.sh
  2. safe_docker — The Base Wrapper
  3. safe_docker_build — Building Images
  4. safe_docker_run — Running Containers
  5. loading Images into Kind
  6. Docker Compose Operations
  7. docker_cleanup — Removing Dead Containers and Images
  8. Hands-On Exercises

Kubernetes with kubectl

  1. lib/kubectl.sh
  2. safe_kubectl — The Base Wrapper
  3. kubectl_install_resource_from_file
  4. kubectl_install_database — PostgreSQL Setup
  5. kubectl_restart — Rolling Restart
  6. DNS Management
  7. Restarting All Deployments
  8. Hands-On Exercises

Helm: Package Management for Kubernetes

  1. lib/helm.sh
  2. safe_helm — The Base Wrapper
  3. Helm Charts in k8s/
  4. helm_install_service — Generic Service Installer
  5. helm_install_core_service — Template-Based Services
  6. Install Config Releases
  7. Update Functions — In-Place Upgrades
  8. Traefik — The Ingress Controller
  9. Hands-On Exercises

Building Services

  1. The Build Pipeline
  2. lib/build.sh
  3. build_service — The Core Build Function
  4. Service Group Functions
  5. build_images_init — The Build Dispatcher
  6. lib/install_deps.sh
  7. check_registry
  8. Hands-On Exercises

Provisions from Scratch

  1. System Architecture
  2. The Full Provisioning Sequence
  3. Step by Step
  4. Supporting Functions
  5. Kubernetes Cluster Parameters
  6. Kubernetes Manifests Reference
  7. Hands-On Exercises
  8. What Success Looks Like

Reload and Recovery Operations

  1. lib/reload_services.sh
  2. reload_services — Lightweight Service Refresh
  3. reload_services_init — The Reload Dispatcher
  4. lib/reload_kubernetes.sh
  5. reload_all_kubernetes — Full Cluster Rebuild
  6. Hands-On Exercises

Teardown and Cleanup

  1. Stopping the Environment
  2. Deleting the Environment
  3. Full Kubernetes Teardown
  4. Docker Cleanup
  5. The Exit Handler: Complete Version
  6. Putting the Complete Script Together
  7. The Complete main() Function
  8. The Full init Function
  9. The Complete Lifecycle
  10. The Developer Experience You Built
  11. Hands-On Exercises

GitOps with ArgoCD

  1. lib/argocd.sh
  2. safe_argocd — The Base Wrapper
  3. helm_install_argocd — Installing the Controller
  4. argocd_wait_ready — Confirming Startup
  5. argocd_login — Authenticating the CLI
  6. argocd_create_app — Registering an Application
  7. argocd_sync — Triggering a Sync
  8. argocd_wait_healthy — Waiting for Sync Completion
  9. argocd_delete_app — Removing an Application
  10. Integrating ArgoCD into datacenter.sh
  11. A Note on OpenShift
  12. Hands-On Exercises

Metrics and Dashboards with Prometheus and Grafana

  1. lib/monitoring.sh
  2. helm_install_monitoring — The Full Stack
  3. monitoring_wait_ready — Confirming Startup
  4. monitoring_port_forward — Local Access
  5. monitoring_apply_servicemonitor — Scraping Your Services
  6. monitoring_get_grafana_password — Credential Retrieval
  7. Integrating Monitoring into datacenter.sh
  8. What kube-prometheus-stack Gives You
  9. Hands-On Exercises

Distributed Tracing with OpenTelemetry

  1. lib/otel.sh
  2. safe_otel — The Base Wrapper
  3. helm_install_otel_operator — Installing the Operator
  4. otel_wait_ready — Confirming the Operator is Running
  5. otel_apply_collector — Deploying the Collector
  6. otel_apply_instrumentation — Zero-Code Auto-Instrumentation
  7. otel_wait_collector_ready — Confirming the Collector
  8. Grafana Tempo — The Trace Backend
  9. Integrating OTel into datacenter.sh
  10. Connecting Traces, Metrics, and Logs
  11. Hands-On Exercises

Appendix: datacenter.sh Command Reference

  1. setup.sh
  2. datacenter.sh
  3. Library Files
  4. Exit Codes
  5. Chainable vs Non-Chainable Parameters
  6. Common Workflows
  7. Troubleshooting

Glossary

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

Also by the Author

Also by the Author

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub