Leanpub Header

Skip to main content

Keycloak in Practice

A Hands-On Lab Guide to Single Sign-On with Active Directory, Kubernetes, and Vault

Keycloak in Practice
This book is 100% completeLast updated on 2026-10-14

Twenty-four chapters, each ending in a working lab on your laptop. Perform an OpenID Connect login by hand, put Active Directory, kubectl and Vault behind one login, then take your own access away on purpose and get it back.

Minimum price

$14.99

$24.99

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
About

About

About the Book

You can have single sign-on working by lunchtime. Explaining what the token says takes longer.

The gap is not the product. Keycloak installs in minutes and the admin console explains itself. Then come the questions no tutorial answers: why the login worked but the API said 401, which claim the cluster is actually reading, why the logout did not log anyone out, and who lets you back in when the login server is down.

This book closes that gap the only way it can be closed. You type, and then you read what came back.

Twenty-four chapters, each ending in a working lab that runs on your laptop — in containers and in Kubernetes. No cloud account. No spare server. And, unusually for a book that covers Active Directory, no Windows licence: the directory is Samba, in a container, and the book says exactly where it differs from the real thing.

  • Perform a complete OpenID Connect login by hand — a browser, curl and openssl, no library anywhere
  • Decode an access token claim by claim and say why an API rejected one that was perfectly valid
  • Federate an Active Directory over LDAPS, then broker to an upstream provider instead, and know which to recommend
  • Sign in to kubectl with a directory group instead of a certificate
  • Put Grafana, a registry and an application that cannot speak the protocol at all behind one login — then disable one person in the directory and time how long each application keeps letting them in
  • Let Vault trust Keycloak, then let Keycloak keep its secrets in Vault, then cut the power and watch Keycloak refuse to start
  • Grow a token until a gateway silently refuses it
  • Turn a realm you built by hand into Terraform, and read the drift you created without noticing

Two chapters take away your access on purpose. In Chapter 16 you let a Kubernetes cluster trust the Keycloak running inside it, lose that Keycloak, and discover that every command you would use to repair it requires the thing you just broke. In Chapter 20 you watch two systems wait for each other.

Every chapter includes a Break it on purpose section: you cause the failure, read the real error text, then fix it — with as much attention to which system is actually complaining as to the remedy.

Who this is for: platform engineers, SREs, DevOps engineers and security engineers who will be responsible for how everyone else logs in. You do not need prior Keycloak experience, and the book teaches OAuth2 and OpenID Connect from the wire up.

Includes nine appendices, among them every token type decoded in full, a troubleshooting index sorted by error message, and a production readiness review to run against your own installation.

Keycloak and Red Hat are trademarks of Red Hat, Inc. Microsoft and Active Directory are trademarks of Microsoft Corporation. This book is an independent publication and is not affiliated with, authorized by, or endorsed by any of them.

Author

About the Author

Thomas Zachmann

Thomas Zachmann has spent more than twenty years building systems, and the last several of them building Kubernetes platforms for organisations where security and auditability are the requirement rather than the aspiration: on-premises, on bare metal, in air-gapped networks, and in European sovereign clouds — under European regulatory and audit regimes.

His work is the hardening of container platforms and everything that has to hold up when an auditor asks: policy enforcement with Kyverno, identity and access with Keycloak, supply-chain evidence with Harbor, Trivy and Dependency Track — and secrets management with HashiCorp Vault, which he has been deploying and operating since 2017. He works in the public clouds as well, which is what makes the on-premises argument in these books a comparison rather than a preference.

He is a Certified Kubernetes Security Specialist (CKS), Certified Kubernetes Administrator (CKA) and Certified Kubernetes Application Developer (CKAD). Those twenty years began in software engineering — performance and systems programming at SAP in C and C++, database performance analysis at IBM, and Go since. That background is why the automation in his platforms is written rather than bought, and why his books ask you to type rather than to read.

He is based in Hamburg and works across the DACH region.

Get the free sample chapters

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

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.)

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