One Resource constraints -pod

By default ,Pod Run without CPU And memory limits . This means anything in the system Pod Will be able to execute the Pod The node is the same , Consume enough CPU And memory .

In general, it will be for some applications pod Resources to limit resources , This resource limitation is through resources Of requests and limits To achieve

1.1 resources Of requests and limits

give an example :

spec:
containers:
- image: xxxx
imagePullPolicy: Always
name: auth
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: "4"
memory: 2Gi
requests:
cpu: 250m
memory: 250Mi

requests The resources to be allocated ,limits Is the highest requested resource value . It can be simply understood as the initial value and the maximum value

1.2 To configure CPU and Memory LimitRange

 

apiVersion: v1
kind: LimitRange
metadata:
  name: mem-limit-range
spec:
  limits:
  - default: # Most allow
      memory: 50Gi
      cpu: 5
    defaultRequest:  # Default
      memory: 1Gi
      cpu: 1
    type: Container

default namely limit Value

defaultRequest namely request Value

 

Two Resource constraints - Namespace

2.1 Calculate resource quotas

 

apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute-resources
  namespace: spark-cluster
spec:
  hard:
    pods: "20" #pod20 individual
    requests.cpu: "20"
    requests.memory: 100Gi    
    limits.cpu: "40"
    limits.memory: 200Gi

2.2 Configure object quota limit

 

apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-counts
  namespace: spark-cluster
spec:
  hard:
    configmaps: "10"
    persistentvolumeclaims: "4" #pvc
    replicationcontrollers: "20" #rc
    secrets: "10" 
    services: "10"
    services.loadbalancers: "2"

This represents the maximum number allowed