update kuber doc
This commit is contained in:
@@ -0,0 +1,67 @@
|
|||||||
|
# 📈 Horizontal Pod Autoscaler (HPA)
|
||||||
|
|
||||||
|
The Horizontal Pod Autoscaler automatically scales the number of pods in a deployment based on observed CPU utilization (or other select metrics).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ⚙️ Basic Commands
|
||||||
|
|
||||||
|
### 🚀 Create an HPA
|
||||||
|
Create an HPA for a deployment, scaling based on CPU usage:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -n <namespace> autoscale deployment <deployment-name> --cpu-percent=20 --min=4 --max=10
|
||||||
|
````
|
||||||
|
|
||||||
|
### 📊 View Existing HPAs
|
||||||
|
|
||||||
|
List all HPAs in a specific namespace:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl get hpa -n <namespace>
|
||||||
|
```
|
||||||
|
|
||||||
|
### ❌ Delete an HPA
|
||||||
|
|
||||||
|
Remove a Horizontal Pod Autoscaler:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl delete hpa -n <namespace> <hpa-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🛠️ Edit an HPA
|
||||||
|
|
||||||
|
Manually edit an existing HPA configuration:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl edit hpa -n <namespace> <hpa-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🧾 Example HPA Manifest
|
||||||
|
|
||||||
|
You can define an HPA using a YAML file for more control:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: autoscaling/v2
|
||||||
|
kind: HorizontalPodAutoscaler
|
||||||
|
metadata:
|
||||||
|
name: hpa-test
|
||||||
|
namespace: dev
|
||||||
|
spec:
|
||||||
|
minReplicas: 1
|
||||||
|
maxReplicas: 10
|
||||||
|
metrics:
|
||||||
|
- type: Resource
|
||||||
|
resource:
|
||||||
|
name: cpu
|
||||||
|
target:
|
||||||
|
type: Utilization
|
||||||
|
averageUtilization: 50
|
||||||
|
```
|
||||||
|
|
||||||
|
> ℹ️ **Note:** The above manifest uses API version `autoscaling/v2` for enhanced metric support.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# 🧩 DaemonSet in Kubernetes
|
||||||
|
|
||||||
|
A **DaemonSet** ensures that a copy of a specific pod runs on **every (or some) node** in the cluster. It’s typically used for background system-level services like log collection, monitoring, or networking tools.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📌 Key Characteristics
|
||||||
|
|
||||||
|
- Automatically deploys one pod per worker node.
|
||||||
|
- Ensures the pod stays on each node as long as the DaemonSet exists.
|
||||||
|
- Automatically adds pods to new nodes when they join the cluster.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📄 Example DaemonSet YAML
|
||||||
|
|
||||||
|
Below is a simple DaemonSet example that deploys `nginx` to every node in the `web` namespace:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: DaemonSet
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
namespace: web
|
||||||
|
labels:
|
||||||
|
app: web-servers
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: web-servers
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: web-servers
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx:1.27
|
||||||
|
````
|
||||||
|
|
||||||
@@ -1,44 +1,63 @@
|
|||||||
|
# 🌐 Node Management with Kubernetes
|
||||||
|
|
||||||
## Node Management
|
Efficient management of Kubernetes nodes ensures cluster stability and workload flexibility. Below are key commands for listing and maintaining nodes.
|
||||||
|
|
||||||
### Listing Nodes
|
---
|
||||||
|
|
||||||
- **Show All Nodes**
|
## 📋 Listing Nodes
|
||||||
|
|
||||||
|
### 🔹 Show All Nodes
|
||||||
|
```bash
|
||||||
|
kubectl get nodes
|
||||||
|
````
|
||||||
|
|
||||||
|
### 🔹 Show Nodes with Labels
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl get nodes --show-labels
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔧 Node Maintenance (Cordon / Drain)
|
||||||
|
|
||||||
|
### 🚫 Cordon a Node
|
||||||
|
|
||||||
|
Prevent new pods from being scheduled on the node.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl cordon <node-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
### ✅ Uncordon a Node
|
||||||
|
|
||||||
|
Mark the node as schedulable again.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl uncordon <node-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🧹 Drain a Node
|
||||||
|
|
||||||
|
Evict all pods from the node (excluding those managed by DaemonSets).
|
||||||
|
|
||||||
|
* Forcefully drain the node:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl get nodes
|
kubectl drain <node-name> --ignore-daemonsets --force
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* Drain and delete local data:
|
||||||
```bash
|
|
||||||
kubectl get nodes --show-lables
|
|
||||||
```
|
|
||||||
|
|
||||||
### Node Maintenance (Cordon/Drain)
|
|
||||||
|
|
||||||
- **Cordon a Node**
|
|
||||||
Prevent new pods from being scheduled on the node.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl cordon <node-name>
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Uncordon a Node**
|
|
||||||
Mark the node as schedulable again.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl uncordon <node-name>
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Drain a Node**
|
|
||||||
Evict all pods from the node (excluding those managed by DaemonSets).
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl drain <node-name> --ignore-daemonsets --delete-local-data
|
kubectl drain <node-name> --ignore-daemonsets --delete-local-data
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Warning:** Draining a node will evict running pods. Ensure that you plan this action to avoid service disruption.
|
#### 🔄 Undo Drain (Uncordon)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl uncordon <node-name>
|
||||||
|
```
|
||||||
|
|
||||||
---
|
> ⚠️ **Warning:** Draining a node will evict running pods. Ensure that this is planned to avoid service disruption.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user