What is Apache Airflow
How to delete a Pod in Kubernetes - Beginner tutorial
Delete a pod using kubectl delete pod
- Using delete command
- Using delete command with force keyword
Create a pod
kubectl run nginx --image=nginx --restart=Never
kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx 0/1 ContainerCreating 0 8s
kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 2m6s
kubectl delete pods nginx
- The node object is deleted.
- The kubelet on unresponsive node starts responding ,kills the pod and removes the pod from apiserver.
- Force deletion of pod by user.
pod "nginx" force deleted
kubectl patch pod nginx -p '{"metadata":{"finalizers":null}}'
SQL query to find duplicate records
Introduction
These days data is growing massively and since the data is growing the amount of bad data is also growing. Today we'll talk about one form of bad data which we can call duplicate data. We use few database management systems to store and process the data ie sql server, postgresql, oracle etc. We store lot of data in these systems but sometimes we get lot duplicate data as well in our systems which can impact the true data and reporting on which lot of businesses and important decisions are dependent.
So for us working on data, it's very important to identify the duplicates and remove them from the database which help businesses towards better reporting.
Let's get into the practical to understand the duplicates. First we need to create a table with few columns.
In this tutorial I am using postgresql.
now let's insert some data with duplicates.
Query the data to see results:
Let's find the duplicates for entire row.
or
Using CTE as well to get the duplicates.
Above query will give you the count. You can remove the count in select list if you want and then you will get duplicate record without count number.
Sometimes we want to find duplicates based on one column. Sometime we don't have entire row is duplicate rather just one column have some duplicate values.
So we can definitely use partition by clause like below.
Conclusion
That was it about duplicates. Always test above code in lower environment before implementing in Production.
How Kubernetes works
Introduction
Kubernetes is a compact, extensible, open source stage for overseeing containerized jobs and administrations, that works with both explanatory setup and computerization. It has an enormous, quickly developing environment. Kubernetes administrations, backing, and instruments are broadly accessible.
The name Kubernetes begins from Greek, meaning helmsman or pilot. K8s as a condensing comes about because of counting the eight letters between the "K" and the "s". Google publicly released the Kubernetes project in 2014. Kubernetes consolidates more than 15 years of Google's experience running creation jobs at scale with best-of-breed thoughts and practices from the local area.
For associations that work at a gigantic scope, a solitary Linux compartment occasion isn't sufficient to fulfill their applications' all's necessities. It's normal for adequately complex applications, for example, ones that convey through microservices, to require different Linux containers that speak with one another. That design presents another scaling issue: how would you deal with that large number of individual containers? Designers will in any case have to deal with booking the organization of holders to explicit machines, dealing with the systems administration between them, developing the assets allotted under weighty burden, and significantly more.
Enter Kubernetes, a container orchestration framework — a method for dealing with the lifecycle of containerized applications across a whole armada. It's a kind of meta-process that gives the capacity to robotize the organization and scaling of a few compartments without a moment's delay. A few holders running a similar application are gathered together. These compartments go about as reproductions, and effectively load balance approaching solicitations. A compartment orchestrator, then, manages these gatherings, guaranteeing that they are working accurately.
Kubernetes architecture
Pods
Deployments
Service
Nodes
Control plane
Cluster
API Server
Scheduler
Controller manager
Kubelet
Kube proxy
etcd
How to search image name in multiple Pods on Kubernetes like a Pro?
Introduction
Sometimes we have a requirement to find a particular image which any pod is using. But you are not sure about the image. In that case we have the describe command to check and see all the information about the pod. The problem occurs when you have multiple pods and you can't write multiple describe commands to find that image. So we'll do it differently using a loop like Pro.
Prerequisites
Let's start
Conclusion
Default memory limits for a Kubernetes Pod
Understanding about memory and other resources consumption is very important in Kubernetes. Whenever we run a Pod it consumes some amount of memory and cpu depending on the load.
By default Pods run with unbounded CPU and memory limits. That means any Pod in the system will be able to consume as much CPU and memory on the node that executes the Pod. So to avoid these situations user can impose some restrictions on the amount of resource a single Pod can use for variety of reasons.
To impose a memory restrictions we have few options:
1. Either we can define our memory and cpu limits in deployment file
2. Or we can create a limit which will used to set default memory limit to Pods in specific namespace.
Let's create a namespace first by below command.
Now create a pod using yaml file.
We have provided a memory limit 200Mi. Save it as mempod.yaml and run below command to create the pod.
Note: Mi and MB are different but they are close in size.
Mi(Mebibyte) = 1024 KB
MB(Megabyte) = 1000 KB
Now let's check the memory consumption of above pod using below command.
O/P:
Let's try to understand what will happen when pod will exceed the memory limit. We'll create a pod again to exceed memory limits. Use the above mempod.yaml file and just change the memory limits to lower and see.
Before creating the same again again we need to delete the existing pod first using below command.
Check if new pod created is in running state? by running below command
So it's not running and it's failed. Let's debug why it's failed using kubectl describe command.
It says OOM killed means memory limit was exceeded and it was killed.
Instead of assigning memory limits and resources to individual pods we can create memory limits in namespace and every pod created in this namespace will have the default memory limit.
To do this we'll create a limit range in memory-demo namespace.
save it as limit.yaml
So limit range has been created and we can verify it by below command.
Now create a Pod using imperative command way
And check the memory limits for the container , it should be default limits by limit range.
That's how we can use the limit range to set default memory limits.
Note: If you think this helped you and you want to learn more stuff on devops, then I would recommend joining the Kodecloud devops course and go for the complete certification path by clicking this link
Understanding the replica set in Kubernetes.
Understanding the replica set in Kubernetes
What is Replica?
How does it work
ReplicaSet VS ReplicationController
Replication Controller
Replica-Set
Creating a Pod inside a Namespace
Creating a Pod inside a Namespace
Namespace
How to check all available namespaces?
kubectl get namespaces
NAME STATUS AGE
default Active 2d
kube-public Active 2d
kube-system Active 2d
How to create a namespace
kubectl create namespace test
namespace/test created
kubectl get namespaces
NAME STATUS AGE
default Active 82d
kube-public Active 82d
kube-system Active 82d
test Active 5s
- kube-system: Namespace for objects created by kubernetes system
- default: It's default namespace when you don't specify name then objects will be created in default namespace
- kube-public: This is created automatically and readable by all users. This namespace is mostly reserved for cluster usage.
kubectl run mypod --image=nginx -n test
pod/mypod created
kubectl get pods -n test
NAME READY STATUS RESTARTS AGE
mypod 1/1 Running 0 2m10s
kubectl run mypod --image=nginx -n prod
pod/mypod created
kubectl get pods -n prod
NAME READY STATUS RESTARTS AGE
mypod 1/1 Running 0 14s
Conclusion
Debugging your pod on Kubernetes?
Debugging the pods on Kubernetes
To start with it, we first need to run the pod. You can follow below command to run the pod.
kubectl run mypod --image=nginx
kubectl get pods
NAME READY STATUS RESTARTS AGE
mypod 0/1 ContainerCreating 0 5s
NAME READY STATUS RESTARTS AGE
mypod 1/1 Running 0 21s
To delete the Pod use below command:
kubectl delete pod mypod
pod "mypod" deleted
kubectl run mypod --image=nginx-myimage-123
kubectl get pods
NAME READY STATUS RESTARTS AGE
mypod 0/1 ErrImagePull 0 9s
To check the events we can use describe command:
kubectl describe pod mypod
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 34s default-scheduler Successfully assigned default/mypod to docker-desktop
Normal BackOff 26s kubelet Back-off pulling image "nginx-myimage-123"
Warning Failed 26s kubelet Error: ImagePullBackOff
Normal Pulling 12s (x2 over 33s) kubelet Pulling image "nginx-myimage-123"
Warning Failed 6s (x2 over 27s) kubelet Failed to pull image "nginx-myimage-123": rpc error: code = Unknown desc = Error response from daemon: pull access denied for nginx-myimage-123, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Warning Failed 6s (x2 over 27s) kubelet Error: ErrImagePull
kubectl logs mypod
Error from server (BadRequest): container "mypod" in pod "mypod" is waiting to start: trying and failing to pull image
kubectl logs --previous mypod container_name
Conclusion
Quantum Computing: The Future of Supercomputing Explained
Introduction Quantum computing is revolutionizing the way we solve complex problems that classical computers struggle with. Unlike tradi...

-
How to handle Out of memory error inside Docker Container Sometimes we face some special scenarios where we encounter insufficient memory o...
-
Are you looking to run microsoft sql server on Mac? Then you are at the right place. I am going to tell you how you can run sql server easil...
-
If you are running an application on Kubernetes, you may want to expose a specific port to a pod so that you can access it outside world. Ku...
-
Running docker container as non root account. Docker is revolutionary technology in the world of devops. Today docker is making applicatio...
-
Understanding about memory and other resources consumption is very important in Kubernetes. Whenever we run a Pod it consumes some amount of...