DMCA.com Protection Status Trending Topics About Devops: 06/07/21

Monday, 7 June 2021

What are the components of nodes in Kubernetes? Basics on Kubernetes

 In this article on series basics on Kubernetes, we are going to talk about what is the component of nodes in Kubernetes and what are their tasks. Before that, if you have not read about the control plane in Kubernetes, you can read about it below.

Node components:

Node components are the process that will run on nodes to facilitate the working of Kubernetes. The components are kube-proxy, kubelet, and container runtime.

Kube-proxy:

Kube proxy helps in routing the traffic with help of iptables to the exact location when you call any service. It makes changes in iptables to help the packet reach a destination when a service is called. If you want to read more about it you can read the below article.

Kubelet:

Kubelet is a process that manages different tasks on a node, like join the Kubernetes cluster and launching the pods. Keeping the health on a node as well as pods. You can read about it more in below article

Container Runtime:

Container runtime is a process that takes care of containers. It launches the container as instructed by kubelet. In most cases, you must have seen or used docker. Containerd, CRI-O are other options that can be used. If you want to read what happens in container launch you can read the below article.

What is a process control block PCB and its components.

 Process control block (PCB) is a data structure used by a computer operating system to store all the information about a process.

The operating system used a data structure named Process Control Block(PCB) to store the information about a particular process, and this information is required by the CPU while executing the process. Each process is identified by its process block, the process control block is also known as a task control block.

When a process is created (initialized or installed), the operating system creates a corresponding process control block.
Information in a process control block is updated during the transition of process states.
When the process terminates, its PCB is returned to the pool from which new PCBs are drawn.
Each process has a single PCB.

Components of PCB are

What is a process control block PCB and its components.

Process state

Basically stores the respective stage of the program whether the process is in a new, ready, running, or terminated state, etc. So, to understand this process state clearly, we have to understand the process life cycle first.

What is a process control block PCB and its components.

In the process life cycle, we discuss how a process goes through various process states before its termination.


New: Process has just been created in this state. It is the initial state in the process life cycle.

Ready: In this process is ready and is waiting to be assigned to the processor so it can run.

Ready suspended: Process goes through this state when we have a lack of main memory and because of this, the process is going into a ready suspended process state(which is in secondary memory) and when space is created in the main memory it came back to the ready process state and then gets executed.

Running: After the ready process state process is dispatched into the running state and in this running state, we have three cases

Case 1: When the process is completed without any interruption and directly goes into a termination state.

Case 2: When interrupt takes place – Interrupts are signals sent to CPU by external devices. They tell the CPU  to stop its current activity. The controls then pass to a special piece of code called an interrupt handler. The interrupt handler will process the interrupt and resume the interrupted program.

Case3: I/O request When a process request for I/O for its completion then the process goes into a blocked process state until the I/O request is completed and when the request is completed the process came back to ready state and from there it goes to running and then to the terminated state after its execution.When a process request for I/O for its completion then the process goes into a blocked process state until the I/O request is completed and when the request is completed the process came back to ready state and from there it goes to running and then to the terminated state after its execution.

Blocked:Process comes to this state when it is waiting for some event to occur. For ex- I/O request.

Blocked Suspended:It is similar to a ready suspended state. Processes in a blocked suspended state are in secondary memory, a process in the blocked state is in main memory but due to lack of memory, they are forced to move in the blocked suspended state.

Terminated: The process is removed from the main memory and its process control block is deleted.

Process Counter

Process Counter is a special kind of register that is used by the processor to hold the address of the next instruction to be executed.

Process Number

A unique identifier for the process.

CPU Register

CPU register tells us about the different kinds of registers that are being used by a particular process. They may include accumulators, index registers, stack pointer, and general-purpose registers.

Memory Limit

It contains information about the memory management system used by the operating system. This may include page tables, segment tables, etc.

List of open files

It represents the files associated with the process. So the CPU should maintain a list of files that are being opened by a process to make sure that no other process can open the files at the same time.

Miscellaneous Accounting and Status data

This includes information about the amount of CPU used, time constraints, process number, etc.

This was very small article about PCB and its component. If you like the article please share and subscribe.

What is a pod?

 A pod is a group of containers and is the most basic deployable object in Kubernetes. As mentioned it is a group of containers. These mean containers share pod resources. Even though they share pod resources they cannot access each other’s processes as they are separated by namespaces.

Containers on the same pod can access each other on localhost. This is because they share the same network namespace.

They can also share storage if mentioned in their specifications.

You can consider pods as a host where you can deploy multiple containers and they can talk to each other.

Why are pods needed?

You can use a pod to run an instance of your application. You generally use replicaset to create a set of the pod to run your application. Replicaset can control how many pods of your specification will run and it can make sure they are running. If a pod dies, replicaset will launch another one to satisfy the threshold.

There can also be an init container that comes up before other containers and does some admin tasks. You can read about it below

What are the different stages in pod’s lifecycle?

Pending

The pod is created in the cluster but is not launched completely yet. It may be due to a resource issue that is not scheduled, maybe due to one of the containers not coming up due to some health check or maybe downloading the image of the container.

Running

In this state, the pod is running and is ready to take traffic or do its tasks. In this state, the containers are created and one of them is running properly.

Succeded

All the containers in the pod have completed their tasks and are terminated successfully.

Failed

One of the containers is terminated due to failure. Failure means non 0 exit code.

Unknown

As mentioned the state is not known.

There are other states that you can see but they are not actually pod’s lifecycle states. The states can be CRASHLOOPBACKOFFIMAGEPULLBACKOFF, etc.

Below is the spec that you can use to create a pod in Kubernetes.

apiVersion: v1
kind: Pod
metadata:
  name: example
spec:
  containers:
    - name: busybox
      image: busybox:1.25
      volumeMounts:
        - name: quobytevolume
          mountPath: /persistent
      command:
        - /bin/sh
        - sleep 30
  volumes:
  - name: quobytevolume
    quobyte:
      registry: ignored:7861
      volume: testVolume
      readOnly: false
      user: root
      group: root

In this spec. You can see different fields that you can use to launch the pod. In this pod, only one container is launched with an image busybox, and a volume is attached at /persistent path.

When you submit this YAML a pod will be launched with the above specifications. I am not going deep into each pod field. You can read the below documentation for reading more about these.

https://kubernetes.io/docs/tasks/configure-pod-container/

This was very basic of what is pod we can read more about how scheduled happens etc in our next articles.

If you like the article please share and subscribe.