Static Pods
Overview:
Static pods are Kubernetes pods that are managed directly by the kubelet on a node. They are not part of the Kubernetes control plane, making them suitable for running system-level daemons or essential services on individual nodes.
Usage:
Create a Static Pod:
- Write a pod manifest file.
- Place the file in the kubelet's specified directory (e.g., /etc/kubernetes/manifests).
- Restart the kubelet to start the static pod.
sudo systemctl restart kubelet
Check the status of the static pod using kubectl or kubelet logs.
kubectl get pods
kubectl describe pod my-static-pod
Cleanup:
Delete the manifest file and restart the kubelet.
sudo rm /etc/kubernetes/manifests/my-static-pod.yaml
sudo systemctl restart kubelet
Pods
Overview:
Pods are the smallest deployable units in Kubernetes. They represent one or more containers that share storage, network, and specifications.
Usage:
Create a Pod:
Write a pod manifest file (YAML) defining containers, volumes, and metadata.
Apply the manifest using kubectl.
kubectl apply -f my-pod.yaml
Monitor Pod:
Check the status of the pod.
kubectl get pods
kubectl describe pod my-pod
Update Pod:
Modify the manifest file and apply the changes.
kubectl apply -f my-updated-pod.yaml
Deployments
Overview:
Deployments provide a declarative way to manage pod replicas, enabling easy updates and rollbacks.
Usage:
Create a Deployment:
Write a deployment manifest file specifying the desired state.
Apply the manifest using kubectl.
kubectl apply -f my-deployment.yaml
Scale Deployment:
Update the replica count in the deployment manifest.
kubectl scale deployment my-deployment --replicas=3
Update Deployment:
Modify the container image or other specifications in the deployment manifest.
kubectl apply -f my-updated-deployment.yaml
StatefulSets
Overview:
StatefulSets manage the deployment and scaling of stateful applications, maintaining stable network identities and storage.
Usage:
Create a StatefulSet:
Write a StatefulSet manifest file specifying pod templates and persistent volume claims.
Apply the manifest using kubectl.
kubectl apply -f my-statefulset.yaml
Scale StatefulSet:
Update the replica count in the StatefulSet manifest.
kubectl scale statefulset my-statefulset --replicas=3
Update StatefulSet:
Modify the pod template or other specifications in the StatefulSet manifest.
kubectl apply -f my-updated-statefulset.yaml
DaemonSets
Overview:
DaemonSets ensure that a copy of a pod runs on every node in the cluster, typically for system daemons or logging agents.
Usage:
Create a DaemonSet:
Write a DaemonSet manifest file specifying pod templates.
Apply the manifest using kubectl.
kubectl apply -f my-daemonset.yaml
Update DaemonSet:
Modify the pod template or other specifications in the DaemonSet manifest.
kubectl apply -f my-updated-daemonset.yaml
Monitor DaemonSet:
Check the status of the DaemonSet and the pods on each node.
kubectl get daemonset
kubectl get pods -l app=my-daemon
This document provides a basic understanding of key Kubernetes resources and commands, including static pods, pods, deployments, StatefulSets, and DaemonSets. Each section includes an overview, usage examples, and common operations.
Top comments (0)