...

>

Defining Pods through Declarative Syntax

Defining Pods through Declarative Syntax

Learn to create Pods using declarative syntax.

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:

YAML
apiVersion: v1
kind: Pod
metadata:
name: db
labels:
type: db
vendor: MongoLabs
spec:
containers:
- name: db
image: mongo:3.3
command: ["mongod"]
args: ["--rest", "--httpinterface"]

...

Let’s analyze the various sections in the output definition ...