Kubernetes is inherently a declarative system. In prior chapters, we have explored Kubernetes and some of its key concepts using commands such as kubectl run and kubectl expose. These commands are all imperative: do this thing now. Kubernetes does this by managing these resources as objects themselves. kubectl and the API server translate these requests into resource representations, and then store them, and it is the job of the various controllers to understand the current state and make it as requested.
We can take advantage of the declarative structures directly—all the Services, Pods, and more can be represented by either JSON or YAML files. In this chapter, we will move to define your applications as a declarative infrastructure. We will take the existing simple Kubernetes Pods and put them into declarations that you can manage...