Kubernetes essentials-Part1

Puneet Khanna
2 min readSep 27, 2021

Kubernetes is an orchestration/management service that helps you to deploy, maintain and un-deploy the containers.

Architecture:-

Node is a server/machine(managed by master node)where the containers are deployed. A Node was called a minion initially. A group of nodes is called a cluster.

Where is the cluster information stored:- on the master node. The master node(s) has the database service etcd which keeps the cluster information.

How to spin the containers:- through API server(runs on master), This service helps the user to interact i.e to deploy the containers.

The scheduler is responsible for assigning nodes to the containers.(runs on master)

The controllers(Brains behind k8) watch the cluster, they deploy the containers when they see a change as per rules.(runs on master)

What is a Pod? A logical & encapsulated wrapper for a group of or a single container. The container is a live docker image that is tasked to run a piece of code and destroy itself after its job is done. Mostly, pods with a single container are used. The containers inside a pod can communicate to each other without any additional network settings.Different containers/pods have storage of two types 1) which have the lifetime of the life of the pod , the volumes cannot be referred back once the container is stopped /killed , a restart would not make the data recover 2) The persistent volumes- these volumes preserve the changes even if a pod is killed — think of these as a NFS/ shared drive mounted on different VMs ( if you come from VM’s world) .

Kubelet is the agent that runs on each Node. It communicates with the master as well, shares node’s information, and works on commands by the master node (runs on master & worker nodes)

How to interact with the master through the command line: Through kubectl.

The Kube control is used to gather information about clusters/nodes and deploy objects / destroy them through the command line.

The sample command and output to gather the node info is below :

user@kmaster:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
kmaster Ready control-plane,master 193d v1.20.4
node1 NotReady worker 193d v1.20.4
node2 Ready worker 193d v1.20.4

Understanding basic YAML for Object creations in Kubernetes.

apiVersion: apps/v1
kind:
metadata:
name: Name
spec:
selector:
matchLabels:
app: appName
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80

The details of the following key values are used in the YAML which layouts the work to be done for Kubernetes when you ask it to run the code inside them. Remember the string “AKMS” when you start writing a YAML file.

apiVersion: version of API server you want to talk to

Kind: The kind of object you want to edit or create .Possible values : Pod,Deployment, ReplicaSet etc ( we will talk about Deployment and replicaSet later)

Metadata: You can add labels/tags to the object to manage them.

Spec: used to define which (list of ) images to deploy and their other details.

--

--