liveBook · Manning

Kubernetes Deployment

As explained in Google Anthos in Action

A Kubernetes Deployment is a resource that declaratively manages the desired state and rollout of replicated applications.

A Kubernetes Deployment declares an application’s desired state and provides a repeatable unit for placing a container image on selected clusters. Operational value comes from controlling where an application version runs and making that placement observable. section 11.3.3 section 12.3.1

A Deployment commonly coordinates these operational concerns:

  • Application placement: annotations select rollout-testers, non-testers, or country-specific clusters. section 11.3.3
  • Version control: separate Deployment definitions can use different container image tags for test and non-test environments. section 11.3.3
  • Local exposure: a Deployment can be exposed through a NodePort service and reached through kubectl port forwarding. section 12.3.1

Preview a Deployment locally

Start minikube, create a hello-minikube Deployment from echoserver:1.4, expose it on port 8080, inspect the service, and forward service traffic to localhost:8080. This provides a working preview, although repeated image builds and kubectl updates make manual iteration inefficient. section 12.3.1

---
apiVersion: apps/v1
kind: Deployment
metadata:
 name: foh-engine
 annotations:
   configmanagement.gke.io/cluster-selector: rollout-testers
spec:
 template:
   spec:
     containers:
     - name: engine
       image: gcr.io/ambiguous-rock/foh/engine:v2.1.0
       imagePullPolicy: IfNotPresent
---
apiVersion: apps/v1
kind: Deployment
metadata:
 name: foh-engine
 annotations:
   configmanagement.gke.io/cluster-selector: non-testers
spec:
 template:
   spec:
     containers:
     - name: engine
       image: gcr.io/ambiguous-rock/foh/engine:v2.0.3
       imagePullPolicy: IfNotPresent

Compare two apps/v1 Deployment definitions that target disjoint cluster groups and select different engine image versions. section 11.3.3

How Google Anthos in Action covers it

How deep it goes
Demonstrates manifests, selectors, image tags, service exposure, and port forwarding, but stops short of Deployment controller internals.
Examples
Uses rollout-tester and non-tester image variants, a country-specific deployment, and a hello-minikube NodePort preview.
What it assumes
Assumes familiarity with clusters, container images, kubectl, and services; requires an installed and running minikube cluster for the local workflow.
What you can do after
Apply it via Kubernetes manifests and kubectl to place container versions, expose them locally, and inspect deployment-related services.
How it connects
Connects Deployments with cluster labels, cluster selectors, container images, Services, NodePort, minikube, and Cloud Monitoring.

Also explained in

Compare how 10 books explain Kubernetes Deployment →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Google Anthos in Action. The section links point to the parts of the book it draws on.