Book Image

Kubernetes in Production Best Practices

By : Aly Saleh, Murat Karslioglu
Book Image

Kubernetes in Production Best Practices

By: Aly Saleh, Murat Karslioglu

Overview of this book

Although out-of-the-box solutions can help you to get a cluster up and running quickly, running a Kubernetes cluster that is optimized for production workloads is a challenge, especially for users with basic or intermediate knowledge. With detailed coverage of cloud industry standards and best practices for achieving scalability, availability, operational excellence, and cost optimization, this Kubernetes book is a blueprint for managing applications and services in production. You'll discover the most common way to deploy and operate Kubernetes clusters, which is to use a public cloud-managed service from AWS, Azure, or Google Cloud Platform (GCP). This book explores Amazon Elastic Kubernetes Service (Amazon EKS), the AWS-managed version of Kubernetes, for working through practical exercises. As you get to grips with implementation details specific to AWS and EKS, you'll understand the design concepts, implementation best practices, and configuration applicable to other cloud-managed services. Throughout the book, you’ll also discover standard and cloud-agnostic tools, such as Terraform and Ansible, for provisioning and configuring infrastructure. By the end of this book, you’ll be able to leverage Kubernetes to operate and manage your production environments confidently.
Table of Contents (12 chapters)

Creating the cluster infrastructure

In this section, you will develop the following Terraform modules:

  • An EKS module
  • A Kubernetes worker module
  • A Kubernetes cluster module that wraps both the EKS control plan and the workers

After that, you will use these modules to Terraform your first cluster, Packt cluster, and then provision it in your AWS account.

Developing the EKS Terraform module

Under the terraform/modules directory, create a subdirectory with the name eks-cp. This directory will contain the following Terraform source code files for the EKS control plane module:

  • variables.tf
  • main.tf
  • security-groups.tf
  • iam.tf
  • outputs.tf

The previous list of files together comprises the EKS Terraform module. You will learn about each of these code and configuration files in the following subsections.

Input variables

The variables.tf file defines the input variables that are accepted in the EKS module. The module user should provide...