Leanpub Header

Skip to main content

Ansible for Kubernetes

Automate app deployment on any scale with Ansible and K8s

Ansible is a powerful infrastructure automation tool. Kubernetes is a powerful application deployment platform. Learn how to use these tools to automate massively-scalable, highly-available infrastructure.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
33,127
Readers
186
Pages
32,453Words
About

About

About the Book

This book takes users on an automation journey—from building your first Kubernetes cluster with Ansible's help, to deploying and maintaining real-world, massively-scalable and highly-available applications.

Price

Pick Your Price...

Minimum price

$9.99

$19.99

You pay

$19.99

Author earns

$15.99
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 1)

1
The author will earn $12.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Jeff Geerling

Jeff Geerling is a developer who has worked in programming and DevOps-related positions for companies with thousands of servers. He also manages infrastructure for services offered by Midwestern Mac, LLC, and has been using Ansible to manage infrastructure since early 2013, and Kubernetes since 2017.

Leanpub Podcast

Episode 25

An Interview with Jeff Geerling

Contents

Table of Contents

Preface

  1. Who is this book for?
  2. Typographic conventions
  3. Please help improve this book!
  4. Current Published Book Version Information
  5. About the Author

Introduction

  1. In the beginning, there were servers
  2. The move to containers
  3. Ansible by Red Hat
  4. Kubernetes and the CNCF
  5. Examples Repository
  6. Other resources
  7. Ansible resources
  8. Kubernetes resources

Chapter 1 - Hello World!

  1. Hello, Go!
  2. Installing Go
  3. Creating a ‘Hello world’ app in Go
  4. Building Hello Go
  5. Deploying Hello Go in a container
  6. Running Hello Go in Docker
  7. Building the container
  8. Running the container
  9. Hello Go app summary
  10. Deploying Hello Go in Kubernetes
  11. Installing Minikube
  12. Building the Hello Go container in Minikube
  13. Running Hello Go in Minikube
  14. Scaling Hello Go in Kubernetes
  15. Clean up Hello Go
  16. Summary

Chapter 2 - Automation brings DevOps bliss

  1. Ansible 101
  2. Installing Ansible
  3. Hello, Ansible!
  4. Running your first Ansible playbook
  5. Ansible 101 summary
  6. Managing Kubernetes with Ansible
  7. Managing Minikube
  8. Building container images in Minikube with Ansible
  9. Managing Kubernetes resources with Ansible
  10. Scaling Hello Go with Ansible
  11. Scaling via the existing Deployment spec
  12. Scaling with Ansible’s k8s_scale module
  13. Scaling with k8s and strategic_merge
  14. Cleaning up Kubernetes resources with Ansible
  15. Summary

Chapter 3 - Ansible manages containers

  1. Ansible’s Docker modules
  2. docker_image module
  3. docker_container module
  4. Pushing the container image to a registry
  5. Running a local container registry
  6. docker_login module
  7. Pushing an image to a Docker registry with docker_image
  8. Ansible Docker module summary
  9. Building images using Ansible without a Dockerfile
  10. Relying on Roles from Ansible Galaxy
  11. Writing a Playbook to Build a Container Image
  12. Writing a Playbook to Test the Container Image
  13. Apache Solr container build summary
  14. Summary

Chapter 4 - Building K8s clusters with Ansible

  1. Building a local Kubernetes cluster on VMs
  2. Prerequisites - Vagrant and VirtualBox
  3. A small Kubernetes cluster architecture
  4. A Vagrantfile for local Infrastructure-as-Code
  5. Building a Kubernetes cluster with Ansible
  6. Describing hosts with an inventory
  7. Becoming root in a playbook
  8. Building a server with roles
  9. Role configuration
  10. Running the cluster build playbook
  11. Testing the cluster with a deployment using Ansible
  12. Debugging cluster networking issues
  13. Fixing issues with Flannel and iptables
  14. Switching nftables to iptables-legacy
  15. Patching Flannel to use the right network interface
  16. Local VM cluster summary
  17. Building a cluster using Kubespray
  18. Building a cluster on VPSes using Kubespray
  19. Building a bare metal cluster using Raspberry Pis
  20. Summary

Chapter 5 - Build an AWS EKS Cluster with CloudFormation and Ansible

  1. Managing AWS EKS clusters with CloudFormation
  2. CloudFormation Templates
  3. CloudFormation template for VPC Networking
  4. CloudFormation template for an EKS Cluster
  5. CloudFormation template for an EKS Node Group
  6. Applying CloudFormation Templates with Ansible
  7. Authenticating to the EKS Cluster via kubeconfig
  8. Deploying WordPress to the EKS Cluster
  9. Build the WordPress Kubernetes manifests
  10. Build an Ansible Playbook to deploy the manifests to EKS
  11. Point a custom domain at the WordPress ELB
  12. Run the playbook to deploy WordPress
  13. Summary

Chapter 6 - Manage a GKE Cluster with Terraform and Ansible

  1. Managing Google Cloud GKE clusters with Terraform
  2. Summary

Chapter 7 - Development and CI Testing with Molecule, Kind, and Ansible

  1. Ansible playbook to deploy a Kubernetes Job
  2. Add Molecule for development and testing
  3. Manage Kind with Molecule
  4. Test a playbook in Kind with Molecule
  5. Verify the playbook worked with Molecule
  6. Kubernetes CI Testing in GitHub Actions
  7. Summary

Chapter 8 - Ansible’s Kubernetes integration

  1. k8s module
  2. k8s_info module
  3. k8s inventory plugin
  4. k8s_scale module
  5. k8s_exec module
  6. k8s_service module
  7. k8s_log module
  8. geerlingguy.k8s collection
  9. Summary

Chapter 9 - Hello Operator

  1. The Operator Pattern
  2. Operator SDK
  3. Go vs. Ansible-based Operators
  4. Your first Ansible-based Operator
  5. End-to-end testing for an Ansible-based Operator with Molecule
  6. Example: WordPress in EKS with an Operator
  7. Summary

Chapter 10 - The first real-world application

Afterword

Appendix A - Using Ansible on Windows workstations

  1. Method 1 - Use the Windows Subsystem for Linux / Bash on Ubuntu
  2. Installing Ansible inside Bash on Ubuntu
  3. Method 2 - When WSL is not an option
  4. Prerequisites
  5. Set up an Ubuntu Linux Virtual Machine
  6. Log into the Virtual Machine
  7. Install Ansible
  8. Summary

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 $14 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