Docs/CloudNative/Kubernetes/Base/Namespace/ns中单个Pod的资源限额-内存.md
2022-10-18 16:59:37 +08:00

50 lines
No EOL
761 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 创建命名空间
```
kubectl create namespace demo-ns
```
### 创建LimitRange, memory-limit.yaml
```
apiVersion: v1
kind: LimitRange
metadata:
name: mem-limit-range
spec:
limits:
- default:
memory: 512Mi
defaultRequest:
memory: 256Mi
type: Container
```
### 命名空间上施加限制
```
kubectl apply memory-limit.yaml --namespace demo-ns
```
### 在该命名空间下创建pod定义pod-limit-m-demo1.yaml
```
apiVersion: v1
kind: Pod
metadata:
name: pod-lm-demo1
namespace: demo-ns
labels:
app: pod-lm
version: v1
spec:
containers:
- name: pod-demo1-m
image: busybox
ports:
- name: demo1-m-http
containerPort: 80
```
### 创建pod
```
kubectl apply pod-limit-m-demo1.yaml
```