Defining Pods through Declarative Syntax
Explore how to define Kubernetes Pods using declarative YAML syntax. Understand the key components such as apiVersion, metadata, and spec for containers. Learn to create, view, and describe Pods to effectively manage containerized applications in a cluster environment.
We'll cover the following...
Pods as wrappers for containers
Even though a Pod can contain any number of containers, the most common use case is to use the single-container-in-a-Pod model. In such a case, a Pod is a wrapper around one container. From Kubernetes’ perspective, a Pod is the smallest unit. We cannot tell Kubernetes to run a container. Instead, we ask it to create a Pod that wraps around a container.
Looking into a Pod’s definition
Let’s look at a simple Pod db.yml
definition:
Let’s analyze the various sections in the output definition of a Pod:
-
Lines 1–2: We use
v1of Kubernetes Pods API. BothapiVersionandkindare mandatory. That way, Kubernetes knows what we want to do (create a Pod) and which API version to use. -
Lines 3–7: The next ...