Skip to content

From Compose to Swarm to Kubernetes

Select an icon to see what it is.

Step 5 of 6

Kubernetes: a Deployment and a Service

kubectl sends the desired state to the Kubernetes API, as a Deployment of three pods. Controllers create the pods, the scheduler picks nodes, and each node's kubelet asks containerd to run the containers. Underneath, runc still creates the namespaces and cgroups, just as in the earlier lessons.

$ kubectl create deployment api --image=nginx --replicas=3

POST /apis/apps/v1/namespaces/default/deployments (excerpt)

{
"metadata": {
"name": "api"
}
"spec": {
"replicas": 3
"selector": {
"matchLabels": {
"app": "api"
}
}
"template": {
"spec": {
"containers": [
{
"name": "nginx"
"image": "nginx"
}
]
}
}
}
}