743 B
743 B
创建命名空间
kubectl create namespace demo-ns
创建LimitRange, cpu-limit.yaml
apiVersion: v1
kind: LimitRange
metadata:
name: cpu-limit-range
spec:
limits:
- default:
cpu: 1
defaultRequest:
cpu: 0.5
type: Container
命名空间上施加限制
kubectl apply cpu-limit.yaml --namespace demo-ns
在该命名空间下创建pod定义,pod-limit-c-demo1.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-lc-demo1
namespace: demo-ns
labels:
app: pod-lc
version: v1
spec:
containers:
- name: pod-demo1-c
image: busybox
ports:
- name: demo1-c-http
containerPort: 80
创建pod
kubectl apply pod-limit-c-demo1.yaml