给命名空间配置pod配额

目录

1、创建一个命名空间

2、创建一个配额

 


1、创建一个命名空间


kubectl create namespace quota-pod-example

2、创建一个配额 


apiVersion: v1
kind: ResourceQuota
metadata:
  name: pod-demo
spec:
  hard:
    pods: "2"
kubectl create -f quota-pod.yaml --namespace=quota-pod-example

查看配额详情 

kubectl get resourcequota pod-demo --namespace=quota-pod-example --output=yaml

查询结果如下 

spec:
  hard:
    pods: "2"
status:
  hard:
    pods: "2"
  used:
    pods: "0"

部署一个3个pod 副本

apiVersion: apps/v1
kind: Deployment
metadata:
  name: pod-quota-demo
spec:
  selector:
    matchLabels:
      purpose: quota-demo
  replicas: 3
  template:
    metadata:
      labels:
        purpose: quota-demo
    spec:
      containers:
      - name: pod-quota-demo
        image: nginx
kubectl create -f quota-pod-deployment.yaml --namespace=quota-pod-example

查询部署配额信息得出资源超限,创建失败!

kubectl get deployment pod-quota-demo --namespace=quota-pod-example --output=yaml
spec:
  ...
  replicas: 3
...
status:
  availableReplicas: 2
...
lastUpdateTime: 2017-07-07T20:57:05Z
    message: 'unable to create pods: pods "pod-quota-demo-1650323038-" is forbidden:
      exceeded quota: pod-demo, requested: pods=1, used: pods=2, limited: pods=2'

 

 

 

 

 

 

 

你可能感兴趣的:(给命名空间配置pod配额)