Open In App

How to Careate Static Pod in Kubernetes ?

Static pods in Kubernetes make it simple to run pods directly on individual cluster nodes without the Kubernetes API server being involved. Not at all like ordinary pods oversaw by the Kubernetes control plane, static pods are characterized and overseen straight by the Kubelet, the essential node agent answerable for overseeing units.

Creating a static pod involves defining a pod manifest file and placing it in a designated directory on the node’s file system. Upon startup, the Kubelet autonomously identifies and manages static pods based on the pod manifest files present in the specified directory. static means not movable and changing until external force applies static-pod servers like nginx, httpd, etc. Static pods are ideal for running infrastructure-related services, such as networking plugins or monitoring agents, that need to be tightly coupled with the node’s operation. Now, we are going to take you through the topics of Kubernetes, KOps, and Kubectl. In this guide, we will learn how to create a static pod in Kubernetes. In this article, we look forward to learning how to create a static pod in Kubernetes and how to access the pod.



What is Kubernetes?

As of now, many companies have already harnessed the power of Kubernetes. Kubernetes, also known as K8s,. In the digital world, managing applications efficiently is crucial. Kubernetes is an open-source container orchestration platform that excels at orchestrating containers, automating their deployment, scaling, and operations. Kubernetes offers advanced futures like auto-scaling, self-healing techniques, and load balancing. It simply handles the complex, containerized applications, making them manageable regardless of the infrastructure they reside on. In our own words, Kubernetes is a very powerful tool for managing containerized applications and can deploy containerized applications very simply and more securely. Here’s a breakdown of the key concepts and components of Kubernetes.

Static Pods vs. Demon Sets

Characteristics

Static Pods

Daemon Sets

Definition

Manually defined and managed by users

Automatically managed by Kubernetes

Pod Placement

Runs on specific nodes specified by user

Runs on all or specific nodes in the cluster

Management

managed by kubectl

managed by kubernetes API Automatically

Use Case

Testing, troubleshooting, specialized workloads

Running a single pod on every node, log collection, monitoring

Scaling

Not scalable

Scalable

Maintenance

Requires manual updates

Automatically updates

controlling

Not controlled by kubernetes master

Controlled by kubernetes master

Step by step to Create Static Pod in Kubernetes

Step 1: Login into AWS account



Step 2: Launch an EC2 instance

ssh -i "keypair" ec2-user2@<instance-public-ip address>compute-1.amazonaws.com

Step 3: Install kubectl and kubelet

sudo yum install -y kubectl

sudo yum install -y kubelet

Step 4: Create a YAML File to create static pod

sudo vi static-pod.yml
apiVersion: v1
kind: Pod
metadata:
name: nginx-static-pod
spec:
containers:
- name: nginx
image: nginx:latest

Step 5: Move or Copy the Manifest

sudo mv static-pod.yml  /etc/kubernetes/manifest/

cd /etc/kubernetes/manifest/
ls

Step 6: Verifying the created pod

kubectl get pods

Step 7: Edit the static pod

sudo vi static-pod.yml

apiVersion: v1
kind: Pod
metadata:
name: httpd-static-pod
spec:
containers:
- name: httpd
image: httpd:latest

Step 8: Delete the Static-pod

cd /etc/kubernetes/manifest/
sudo rm static-pod.yml

kubectl delete pod <pod_name>

Static Pod in Kubernetes – FAQs

What is means static pod in kubernetes?

The smallest deployable unit in Kubernetes is a pod. Creating a static pod involves defining a pod manifest file and placing it in a designated directory on the node’s filesystem. Upon startup, the kubelet autonomously identifies and manages static pods based on the pod manifest files present in the specified directory.They are ephemeral,meaning they can be replaced or scaled as needed.

How do i create a static pod in kubernetes?

To create a static pod in kubernetes we need to download KOps and kubectl keys and repos from K8s official site and install kubectl in your system and then create a pod manifest file in a yaml format to describe your pod and finally apply this pod manifest file

How can i delete static pod in kubernetes?

we are able to delete static pod in kubernetes you need to remove its pod manifest file from the directory where the kubelet monitors for static pod definitions. after removing the manifest file the kubectl will stop managing the static pod.

Can we get the full information about the specified static pod in kubernetes?

Yes, we can get the all the about any specified pod or static pod in kubernetes by using.

  • kubectl describe pod <pod_name>
  • kubectl get pods –all-namespaces

Article Tags :