How to Create Static Pod on the Kubeadm Cluster
- Last Updated On: January 26, 2024
- By: Aswin Vijayan
In this example, I am going to show you how to create a static pod on the Kubedam cluster for the nginx web server.
Step 1: Create a Manifest file
First, we need to create a YAML manifest file for the nginx static pod, to create the manifest file run the following command
kubectl run nginx --image=nginx --dry-run=client -o yaml > nginx.yaml
This command will create a manifest file for nginx to run as a static pod. If you need to make any changes to the manifest file use the command below
vi nginx.yaml
A small portion of the nginx.yaml file is shown below.
Step 2: Validate the Manifest file
The next step is to validate the manifest file, to validate we can use the Kubeval utility.
If you don’t have Kubeval installed in your system run the following command to install it.
wget https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz
tar xf kubeval-linux-amd64.tar.gz
sudo cp kubeval /usr/local/bin
To verify if Kubeval is installed properly run the below command
kubeval --version
You will get the following output.
Now, run the following command to validate the manifest file.
kubeval nginx.yaml
You will get the following output if the manifest file is created according to the Kubernetes requirements.
Step 3: Deploy the Nginx Static pod
To deploy the static pod, you have to copy the nginx.yaml manifest to the static pod manifest location.
/etc/kubernetes/manifests/ is the location where every static pod manifest file is present.
The manifest files in this directory are deployed by Kubectl, Kubectl deploys the static pod during the booting time and keeps it running without the involvement of Controlplane.
Now, run the following command to move the nginx manifest file to the /etc/kubernetes/manifests/ directory.
sudo mv nginx.yaml /etc/kubernetes/manifests/
Step 4: Verifying Static Pod
Verify if your nginx pod has been deployed automatically without giving the apply command. Use the below command to check if the pod is up and running
kubectl get po
Static pods cannot be deleted until the manifest file is removed from the /etc/kubernetes/manifests/ directory.
Even if you delete the static pod using the delete pod command, a new pod will be created within a minute.
The only way to delete a static pod is to remove the static pod manifest file from the /etc/kubernetes/manifests/ directory.
You can see in the above image, that the static pod cannot be deleted until the static pod manifest file is removed from the /etc/kubernetes/manifests/ directory.
Conclusion
In summary, we learned about Kubernetes static pod, their manifest file location, and how it is created.
I believe this blog gives you simple knowledge about Kubernetes Static Pods.
Aswin Vijayan
Other Interesting Blogs
CKA Certification Study Guide (Certified Kubernetes Administrator)
This comprehensive CKA certification exam study guide covers all the important aspects of the Certified Kubernetes Administrator exam and useful resources. Passing
[40% OFF] Linux Foundation LFCA, LFCS & LFCT Exam Voucher Codes
Linux Foundation has announced up to a $284 discount on its Linux certification programs Linux Foundation Certified IT Associate (LFCA) and Linux
Linux Foundation Coupon for September 2024
Hi Techies, I wanted to let you know about a pretty sweet deal with the Linux Foundation Coupon that is running now.