k8s-为容器和pods分配CPU资源
1、创建一个命名空间
创建一个命名空间,以便将本节练习中创建的资源与集群的其余部分资源隔离
kubectl create namespace cpu-example
apiVersion: v1
kind: Pod
metadata:
name: cpu-demo
namespace: cpu-example
spec:
containers:
- name: cpu-demo-ctr
image: nginx
resources:
limits:
cpu: "1"
requests:
cpu: "0.5"
args:
- -cpus
- "2"
创建pod
kubectl apply -f cpu-request-limit.yaml --namespace=cpu-example