liveBook · Manning

Goal

As explained in Kubernetes in Action, Second Edition

Desired state is a declarative description of how an application or cluster resource should be configured and operated.

A goal, or desired state, describes how an application should be running without prescribing every action needed to get there. You state what you want through the Kubernetes API; Kubernetes works to achieve and maintain it. section 1.0

Run an application

Creating a Deployment named kiada with the image luksa/kiada:0.1 records a goal: that container image should run in the cluster. The Deployment object is stored in the API, and Kubernetes acts on it. Reading the object back shows its current status, which may initially indicate that the application is not ready. section 3.3.1

$ kubectl create deployment kiada --image=luksa/kiada:0.1
deployment.apps/kiada created

This command creates the Deployment object that states which image should run. section 3.3.1

A goal can change. Setting a Deployment to three replicas does not tell Kubernetes to add two particular pods; it sets the desired count to three. Kubernetes compares that count with the current state and decides how to reconcile the difference. Although `kubectl scale` looks like an instruction to perform a task, it modifies the Deployment object. section 3.3.3

$ kubectl scale deployment kiada --replicas=3
deployment.apps/kiada scaled

The scale command changes the desired replica count to three. section 3.3.3

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains desired state through Deployment creation and replica-count changes, including comparison with current state, without detailing controller internals.
Examples
Uses a container-image Deployment and a scale command that changes its desired count to three replicas.
What it assumes
Assumes no prior container, Docker, or Linux experience and introduces Kubernetes through application deployment.
What you can do after
Apply it via kubectl to create a Deployment, change its replica count, and inspect whether the application is ready.
How it connects
Connects desired state to the Kubernetes API, Deployments, pods, replicas, and reconciliation.

Also explained in

Compare how 11 books explain goal →

Related concepts

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