[Kubernetes] Pod and Kubernetes Run
Pod and Kubernetes Run
- Pod
- Kubernetes Run
- Diagram for
kubectl run
Pod
- A unique k8s concept
- Layer of abstraction
- That is, a resource type that wraps around one or more containers
- that all share the same IP address
- and the same deployment mechanism.
- all containers in a pod will deploy together on the same node, having access to each other over localhost and a few things(e.g. IP addresses)
- Unlike Docker, a container cannot be created directly, but can create pods(via CLI, YAML, or API), and k8s then created the container inside the pods
- More specifically
kubelet
tells the container runtime(e.g. Docker, containerd, cri-o, etc.) to create the containers
- More specifically
Kubernetes Run
# kube version
kubectl version
kubectl version --short
# create a pod(kubectl run {pod_name} --image {image_name})
# k8s API receives the request and stored the entry(that my-nginx pod needs to be created) in its db(etcd)
kubectl run my-nginx --image nginx
# list the pods
kubectl get pods
# see all objects
# it doesn't list namely all objects, but the ones that a 'normal' developer will be interested in
kubectl get all
kubectl delete pod my-nginx
Diagram for kubectl run
- 1) request a pod to the control plane(api server + controller manager + etcd + more) ==
kubectl run my-nginx --image nginx
- 2) api server receives the request, store in the database as a pod request
- 3) the scheduler will assign it to a node
- 4) the kubelet agent, which has a persistent connection to the API, will see a new request for a pod on its node
- 5) the kubelet agent interprets how many containers to create
- 6) kubelet then tells the container runtime(e.g. docker, containerd, etc.)
- 7) container runtime creates the container