Kick off your book project in 3 hours! Live workshop on Zoom. You’ll leave with a real book project, progress on your first chapter, and a clear plan to keep going. Saturday, June 6, 2026. Learn more…

Leanpub Header

Skip to main content

Kubernetes for All

Build a Datacenter from Scratch

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

Most Kubernetes books teach you to use a cluster. This one teaches you to operate one — with a real production Bash script that provisions, builds, deploys, reloads, and tears down a full microservices environment from a single command. Eighteen chapters. Four hundred and fifty lines of explained code. No handwaving.

Minimum price

$20.00

$30.00

You pay

Author earns

$
PDF
EPUB
WEB
About

About

About the Book

Kubernetes for All: Build a Datacenter from Scratch

Most Kubernetes tutorials stop at the dashboard. This book starts where those tutorials end.

You have run kubectl apply enough times to know the commands, but you have never written the tooling that glues those commands together — the script that provisions a cluster from bare metal, builds and pushes your images, deploys your Helm charts, reloads services after a code change, and tears everything down cleanly when you are done. The kind of script that actually runs your platform.

This book builds that script from the first line of Bash to a complete 450-line production management system, across 18 chapters that never skip the "why."

What you will build

You will build datacenter.sh, a script to provision and run a production Kubernetes environment that can ran dozens of microservices. It handles two modes — a local Minikube cluster for development and a real datacenter server — using the same code path. By the end of the book you own it completely: every line explained, every design decision defended.

The book is organized in four parts. Part I covers the Bash foundation — safety options, lifecycle hooks, exit code conventions, cron mode, and terminal color output. Part II builds the script infrastructure — validation helpers, configuration file management, script locking, the library pattern, and complete parameter parsing. Part III covers Kubernetes operations: Minikube VM management, Docker image builds, kubectl resource management, Helm chart deployment, and service builds. Part IV walks through provisions from scratch, reload and recovery operations, and teardown.

Every chapter ends with hands-on exercises that run against the real source scripts.

Who this book is for

You are a developer or DevOps engineer who has used Kubernetes but wants to understand and own your own tooling rather than inherit someone else's undocumented scripts. You know enough Bash to read it but not enough to write production-quality automation from scratch. You want to see real code — not Hello World containers — and understand the engineering decisions behind it.

No Kubernetes certification required. No prior Bash mastery required. A working Docker and Minikube installation, 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.

Contents

Table of Contents

Introduction: Gluing Kubernetes Together with Bash

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

Safety Settings, Initialization, and Lifecycle Hooks

  1. Global Set Options
  2. Script Initialization
  3. The Main Controller
  4. Error Handler
  5. Exit Handler
  6. Putting It Together
  7. 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. vm_mode — 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

VM Mode and Minikube Management

  1. lib/vm.sh
  2. start_env — Starting Minikube
  3. stop_env — Stopping Minikube
  4. delete_env — Deleting Minikube
  5. mount_folders — Sharing Code into the VM
  6. Minikube Docker Environment
  7. 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. safe_docker_tag and safe_docker_push
  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_delete — Pod Reload Pattern
  6. DNS Management
  7. Deleting All Pods
  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 — Upgrades Without Reinstall
  8. Consul and Traefik
  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. The Full Provisioning Sequence
  2. Step by Step
  3. Supporting Functions
  4. Kubernetes Cluster Parameters
  5. Hands-On Exercises

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. Consul Updates
  7. 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 Full init Function
  8. The Complete Lifecycle
  9. Hands-On Exercises

Appendix: datacenter.sh Command Reference

  1. setup.sh
  2. datacenter.sh
  3. Exit Codes
  4. Chainable vs Non-Chainable Parameters
  5. Common Workflows

Glossary

Get the free sample chapters

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

Other books by this author

Other books by this 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.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

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