liveBook · Manning

Kubernetes

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

An open-source platform for orchestrating containerized workloads and services across a cluster of computers.

Kubernetes is a container orchestration platform for deploying, scaling, and managing container-based applications. For a microservices application, it provides the production cluster where independently built services run together. The cluster presents a group of computers as a shared pool of computing power; Kubernetes automates the work of managing services on it. section 6.4 section 1.6

A small deployment uses a few core pieces:

  • Nodes are the virtual machines in the cluster. Pods are Kubernetes’ units of computation and can host containers. section 6.15
  • A deployment keeps a microservice’s pods running, replacing a pod if it crashes or becomes unresponsive. section 6.15
  • A service creates a DNS record for a microservice inside the cluster and can also expose it externally. section 6.15

Start locally if the goal is to learn or check a deployment. Enable the Kubernetes instance bundled with Docker Desktop, then use kubectl to apply a YAML deployment configuration. A local instance can use locally built Docker images without a container registry. Reset the cluster to clear experiments or recover an unresponsive instance; disable it when idle to free computer resources. section 6.5 section 6.15 section 6.8.2

For a cloud deployment, build and publish the image to a container registry, create a managed Kubernetes cluster on Azure, connect to it with kubectl, and deploy the microservice. The cluster needs permission to pull images from the registry. Azure’s portal provides a manual route; Terraform can define the cluster and its registry permission in code. Check which Kubernetes versions are currently available in the chosen Azure region rather than relying on an example version number. section 6.9 section 7.11.2 section 7.6

From one service to an application

Deploy a single video-streaming microservice to local Kubernetes first, then to a managed Azure cluster. Once that path works, deploy the complete microservices application through a GitHub Actions continuous deployment pipeline. Shell scripts build, publish, and deploy its services; envsubst fills values into deployment configuration files. section 6.4 section 10.13

Local Kubernetes is also a valid development option, but deploying many services and switching projects requires more work than using Docker Compose. A practical split is Docker Compose for routine local development and testing, local Kubernetes for experimentation, and managed Kubernetes for production. This is a working introduction, not a tour of Kubernetes’ full feature set. section 6.8.8 section 6.14

Listing 7.8 Creating our Kubernetes cluster
resource "azurerm_kubernetes_cluster" "cluster" {     #1
  name = var.app_name
  location = var.location
  resource_group_name = azurerm_resource_group.flixtube.name
  dns_prefix = var.app_name
  kubernetes_version = var.kubernetes_version         #2
 
  default_node_pool {                                 #3
    name = "default"
    node_count = 1
    vm_size = "Standard_B2s"
  }
 
  identity {
      type = "SystemAssigned"                         #4
  }
}
 
--snip--

The Terraform listing shows a concrete Azure cluster definition, including its Kubernetes version and a one-node VM pool. section 7.11.1

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Works through local and Azure deployments, cluster configuration, and registry access, while stopping short of Kubernetes’ full feature set.
Examples
Uses a video-streaming microservice, Docker Desktop’s local cluster, an Azure managed cluster, and a Terraform cluster definition.
What it assumes
Builds on Docker images and a microservice; introduces Kubernetes through its local instance before moving to a cloud cluster.
What you can do after
Operate/configure it to deploy a microservice locally and on Azure, then automate infrastructure and application deployment.
How it connects
Connects Docker images, pods, deployments, services, container registries, Terraform, and continuous deployment.

Also explained in

Compare how 22 books explain Kubernetes →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.