Defining Pods through declarative syntax

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.

Let's take a look at a simple Pod definition:

cat pod/db.yml  

The output is as follows:

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

We're using v1 of Kubernetes Pods API. Both apiVersion and kind are mandatory. ...

Get The DevOps 2.3 Toolkit now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.