update kubernetes doc
This commit is contained in:
@@ -1,64 +1,107 @@
|
||||
# 🌐 Kubernetes Pod Management Guide
|
||||
|
||||
## Pod Management
|
||||
A concise guide for managing Kubernetes Pods using `kubectl` and YAML manifests.
|
||||
|
||||
### Listing Pods
|
||||
---
|
||||
|
||||
- **List Pods in the Default Namespace**
|
||||
## 📋 Listing Pods
|
||||
|
||||
```bash
|
||||
kubectl get pods
|
||||
```
|
||||
### 🔹 Default Namespace
|
||||
|
||||
- **List Pods with Detailed Information (Wide Output)**
|
||||
List all Pods in the **default** namespace:
|
||||
|
||||
```bash
|
||||
kubectl get pods -o wide
|
||||
```
|
||||
```bash
|
||||
kubectl get pods
|
||||
```
|
||||
|
||||
- **List Pods in a Specific Namespace**
|
||||
### 🔹 Wide Output (More Info)
|
||||
|
||||
```bash
|
||||
kubectl get pods -o wide -n <namespace-name>
|
||||
```
|
||||
List Pods with extended details (e.g., IP, node, etc.):
|
||||
|
||||
### Running a Pod
|
||||
```bash
|
||||
kubectl get pods -o wide
|
||||
```
|
||||
|
||||
> **Note:** The `kubectl run` command is best suited for running single pods. For more complex deployments, consider using YAML manifests.
|
||||
### 🔹 Specific Namespace
|
||||
|
||||
List Pods in a specific namespace:
|
||||
|
||||
```bash
|
||||
kubectl get pods -o wide -n <namespace-name>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 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 <pod-name> --image=<image-name>
|
||||
```
|
||||
|
||||
### 🔹 Run a Pod in a Specific Namespace
|
||||
|
||||
```bash
|
||||
kubectl run <pod-name> --image=<image-name> -n <namespace>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ❌ Deleting Pods
|
||||
|
||||
### 🔹 Standard Delete
|
||||
|
||||
```bash
|
||||
kubectl delete pod <pod-name> -n <namespace-name>
|
||||
```
|
||||
|
||||
### 🔹 Force Delete
|
||||
|
||||
```bash
|
||||
kubectl delete pod <pod-name> -n <namespace-name> --force
|
||||
```
|
||||
|
||||
### 🔹 Immediate Force Delete (No Grace Period)
|
||||
|
||||
```bash
|
||||
kubectl delete pod <pod-name> -n <namespace-name> --force --grace-period 0
|
||||
kubectl delete pod <pod-name> -n <namespace-name> --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 <namepsace> <podname>
|
||||
kubectl edit pod -n <namespace> <pod-name>
|
||||
```
|
||||
Pod Can not been edit (not editable)
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Executing into a Pod
|
||||
|
||||
Use this to start a shell or run commands inside a container:
|
||||
|
||||
```bash
|
||||
kubectl exec -it -n <namespace> <podname> -- <command or shell>
|
||||
kubectl exec -it -n <namespace> <pod-name> -- <command>
|
||||
```
|
||||
|
||||
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
|
||||
@@ -74,13 +117,13 @@ 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"]
|
||||
command: ["/bin/bash", "-c", "while true; do echo hello-world; sleep 5; done"]
|
||||
resources:
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
|
||||
Reference in New Issue
Block a user