first commit
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
2025-12-13 18:06:23 +08:00
commit 8a87b699ba
333 changed files with 27094 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
> 本文作者:丁辉
# Pod配置资源请求
**CPU配置基本表示法**
- **1 个完整的 CPU 核心** = `1``1000m`
- **100m** = `0.1` 个 CPU 核心100 毫核)
- **500m** = `0.5` 个 CPU 核心(半个核心)
- **250m** = `0.25` 个 CPU 核心
**Requests 和 Limits 核心区别**
- **`requests`****预约/保证的资源量** - 调度器保证 Pod 能获得这么多资源
- **`limits`****资源使用上限** - 容器不能超过这个硬性限制
## Deployment配置资源请求
1. 编写 Yaml
```bash
vi nginx-deployment.yaml
```
内容如下(最小化 Yaml)
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:alpine
ports:
- containerPort: 80
resources:
requests: # 必须定义,供 HPA 计算使用率
cpu: 50m # 例如0.1 个 CPU 核心
memory: 128Mi
limits: # 限制是可选的,但建议设置
cpu: 100m
memory: 256Mi
---
apiVersion: v1
kind: Service
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
ports:
- port: 80
selector:
app: nginx
```
2. 部署
```bash
kubectl apply -f nginx-deployment.yaml
```
3. 验证
```bash
kubectl get deployments
```
4. 等一会查看资源使用量
```bash
kubectl top pod
```