Kubernetes And its Features

Pods

In Kubernetes, a pod is the smallest deployable unit that represents a single instance of a running process in a cluster. A pod encapsulates one or more containers, storage resources, and a unique network IP, and it represents the basic building block of a Kubernetes application.

Differences between Containers and Pods

ContainerPods
A container is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software, including the code, runtime, libraries, and system tools.A pod is the smallest deployable and scalable unit in Kubernetes. It is a logical grouping of one or more containers that share the same network namespace, storage, and IP address.
Containers provide a consistent and isolated environment for running applications, ensuring that they can run reliably across different computing environments.Containers within a pod are tightly coupled and can communicate with each other using localhost. They also share the same storage volumes, facilitating data sharing.
Containers are often based on container images, which are read-only snapshots of a filesystem with a specific application and its dependencies.Pods are the basic building blocks of applications in Kubernetes, and they encapsulate the application's containers, storage resources, and unique network IP.

In summary, a container is a lightweight, standalone, and executable software package, while a pod is a higher-level abstraction in Kubernetes that represents one or more containers working together as a unit.

First pod in my Minikube cluster

Running my nginx container

run my pod

Pod is running fine

nginx container running

Deployment

In Kubernetes, a Deployment is a resource object that provides declarative updates to applications. It allows you to define, manage, and scale applications in a Kubernetes cluster. Deployments enable you to describe the desired state of your application, and the Kubernetes system ensures that the current state matches the desired state.

Differences between Containers , Pod , Deployment

ContainersPodsDeployment
Container can be created by docker or by another container engine, so for that, we can use the command i.e docker run -d -p <port> <image_name> -v <voumne_name>So, for what Kubernetes said that, let modify this process and bring enterprise model to this. So instead of writing in the command line, we can create a yaml manifest. Inside the manifest, we can define all the commands in yaml format. So pod.yml is nothing but a running specification of the docker container. So the only difference is pod can be a single or multiple containers.Kubernetes offers you something like auto-scaling and auto-healing behaviors. So pod doesn't have these behaviors. So deployment will help you deploy pods with features like auto-scaling and auto-healing with the help of replicas set.
A container is a lightweight, portable, and executable unit that encapsulates an application along with its dependencies and runtimeA pod is the smallest deployable unit in Kubernetes and represents a logical group of one or more containers that share the same network namespace, storage, and IP address.A deployment is a higher-level abstraction in Kubernetes that manages the deployment and scaling of pods. It enables declarative updates to applications, making it easier to manage and scale containerized applications.
Containers provide isolation and consistency across different environments, ensuring that applications run reliably regardless of the underlying infrastructure.Containers within a pod are tightly coupled and can communicate with each other using localhost. They share the same lifecycle and can easily share data through shared volumes.Deployments allow you to define the desired state of your application, specifying the number of replicas (pod instances) and the container images to use.
Container images are the static, immutable packages that contain the application code, runtime, libraries, and other dependencies.Pods are designed to co-locate and co-manage containers that need to work together, such as those forming a microservices architecture.Deployments provide features such as rolling updates and rollback capabilities, making it easier to update applications without downtime and to recover from failures.

In summary:

Do not create a pod directly, instead use deployment to create pods which will help to create a pod with the help of auto-healing and auto-scaling features. So when we create deployment first it will create a replica set(which is a Kubernetes controller). And this replica set will roll out your pod.

Creating my first deployment file

created deployment file i.e deployment.yml(took example of nginx )

running my deployment yaml file

after applying the deploment file, it creates 3 things like deployment, replica set, and pods.

when we delete one pod then auto healing features will enable and automatically create pods.

Before deleting pods

After deleting one pod

replica set automatically starts a new pod.

Services

In Kubernetes, a Service is an abstraction that defines a logical set of pods and a policy by which to access them. Services allow you to expose your applications to the network or other services in a consistent and reliable way, regardless of the underlying infrastructure.

labels:-

In Kubernetes, labels are key-value pairs that are attached to objects such as pods, services, deployments, and nodes. Labels are a mechanism for organizing and selecting subsets of objects based on their characteristics. They provide metadata that can be used for various purposes, including grouping, filtering, and selecting resources.

Node Port:-

In Kubernetes, a NodePort is a type of service that allows exposing a service externally to the cluster by allocating a port on each node in the cluster. This means that the service becomes accessible on a specific port on every node's IP address. It provides a way to access services from outside the cluster, typically for development or testing purposes.

ClusterIP:-

In Kubernetes, a ClusterIP is a type of service that exposes a set of pods within the cluster to other pods or services in the same cluster. It provides an internal, stable IP address and DNS name that can be used by other components within the cluster to communicate with the service. ClusterIP services are typically used for communication between different parts of an application within the cluster.