# ๐ŸŒ Kubernetes Pod Management Guide A concise guide for managing Kubernetes Pods using `kubectl` and YAML manifests. --- ## ๐Ÿ“‹ Listing Pods ### ๐Ÿ”น Default Namespace List all Pods in the **default** namespace: ```bash kubectl get pods ``` ### ๐Ÿ”น Wide Output (More Info) List Pods with extended details (e.g., IP, node, etc.): ```bash kubectl get pods -o wide ``` ### ๐Ÿ”น Specific Namespace List Pods in a specific namespace: ```bash kubectl get pods -o wide -n ``` --- ## ๐Ÿš€ Running a Pod > **Note:** `kubectl run` is ideal for quick tests or running **single** Pods. For production workloads, use **YAML manifests** or **Deployments**. ### ๐Ÿ”น Run a Pod in Default Namespace ```bash kubectl run --image= ``` ### ๐Ÿ”น Run a Pod in a Specific Namespace ```bash kubectl run --image= -n ``` --- ## โŒ Deleting Pods ### ๐Ÿ”น Standard Delete ```bash kubectl delete pod -n ``` ### ๐Ÿ”น Force Delete ```bash kubectl delete pod -n --force ``` ### ๐Ÿ”น Immediate Force Delete (No Grace Period) ```bash kubectl delete pod -n --force --grace-period=0 ``` --- ## โœ๏ธ Editing a Pod > **Warning:** Pods are **not directly editable**. Attempting to edit a running pod will result in a temporary patch but not persistent changes. ```bash kubectl edit pod -n ``` --- ## ๐Ÿ”ง Executing into a Pod Use this to start a shell or run commands inside a container: ```bash kubectl exec -it -n -- ``` Example for a shell: ```bash kubectl exec -it -n dev my-pod -- /bin/bash ``` --- ## ๐Ÿงพ Example Pod YAML Manifest A multi-container Pod with resource limits and node selector: ```yaml apiVersion: v1 kind: Pod metadata: namespace: dev name: pod-1 labels: label1: test label2: test2 app.kubernetes.io/label3: test3 app.kubernetes.io/label4: test4 spec: containers: - name: nginx-server image: nginx - name: nginx-exporter image: nginx-exporter - name: ubuntu-c0 image: ubuntu command: ["/bin/bash", "-c", "while true; do echo hello-world; sleep 5; done"] resources: limits: memory: "256Mi" cpu: "250m" requests: memory: "128Mi" cpu: "125m" nodeSelector: hostname: k3s app.kubernetes.io/disk: ssd ```