Learning: Kubernetes (POD)

# before v1.18
kubectl run my-nginx --image nginx
# on & after v1.18
kubectl create deployment nginx --image nginx

kubectl run

When we run the above command using run to create the pod there are several steps that happen. It uses the Deployment Controller to initiate this process. We can look at the specification in order to learn how to do that using this official document. Deployment Controller is used for meeting following requirements:

  1. Since you can have more than 1 replica of your container, it creates a ReplicatSet Controller. ReplicatSet Controller is what that creates the pod and ensures it has the same number of pods running your container as you have asked it to do.
  2. Maybe you want to update the configs of your container application — this initiates a need to create a new ReplicaSet Controller. That is, declaring a new state of the pods by updating the pod spec template.
  3. Oops! There was a mistake in the deployment. We need to rollback to the previous version of the deployment.
  4. For more we can refer to the official doc.

Pod Creation

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
  • Deployment ensuring replication using ReplicaSet.
  • ReplicaSet ensuring the orders received from the deployment controller is adhered on all pods it manages.
  • Pods ensuring the your container application is functioning as you had coded and configured using perhaps docker-compose.yml.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Karan Gupta

Karan Gupta

Just a curious developer, a proud uncle, a weightlifter, & your neighborhood yogi.