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

743 B
Raw Blame History

创建命名空间

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