Default Resource Unit CPU MEM DISK 0.5 256Mi Default Resource Limit CPU MEM DISK 1 512Mi Lower Limit CPU MEM DISK 1m 256Mi 1 CPU as in Cloud Services Service Unit AWS 1 AWS vCPU Google 1 GCP Core Azure 1 Azure Core / 1 Hyperthread G vs Gi / M vs Mi / K vs Ki Unit Description Value 1 G Gigabyte 1,000,000,000 bytes 1 Gi Gibibyte 1,073,741,824 bytes 1 M Megabyte 1,000,000 bytes 1 Mi Mebibyte 1,048,576 bytes 1 K Kilobyte 1,000 bytes 1 Ki Kibibyte 1,024 bytes PODSpec 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 apiVersion: v1 kind: Pod metadata: name: myapp-pod labels: app: my-app spec: containers: - name: nginx-container image: nginx ports: - containerPort: 8080 resources: requests: memory: "1Gi" cpu: 1 limits: memory: "2Gi" cpu: 2 Exceed Limits Unit Action CPU The POD cannot use more CPU over the limit.
Taint and Tolerations Limit You can make a rule that does not schedule the PODs to the specific Node, but you can not make a rule that schedules always the PODs to the specific Node. Node Affinity Limit You can make a rule that schedules the PODs to the specific Node or does not schedule the PODs to the specific Node, but you cannot make a rule that avoids to schedule to the specific Node.
Why do you need Node Affinity? Node Affinity nodeSelector is not enough to set PODs on the specific Node.
If you want to make some limitations that are more complex than nodeSelector, you have to use affinity. Compare nodeSelector and affinity nodeSelctor node-selector.yml
1 2 3 4 5 6 7 8 9 10 apiVersion: v1 kind: Pod metadata: name: myapp-pod spec: containers: - name: nginx image: nginx nodeSelector: size: Large affinity affinity.
Add label to the Node Commands Add label to node command structure
1 kubectl label nodes [node-name] [label-key]=[label-value] Name Example [node-name] node-1 [label-key] size [label-value] Large Add label to node command
1 kubectl label nodes node-1 size=Large Select the Node in PODSpec pod-definition.yml
1 2 3 4 5 6 7 8 9 10 apiVersion: v1 kind: Pod metadata: name: myapp-pod spec: containers: - name: data-processor image: data-processor nodeSelector: size: Large 1 kubectl apply -f pod-definition.
You must know Taint and Toleration Usually it uses not to bind PODs to specific Node.
For example, there’s a Node that has GPU resources then you want not to bind PODs that don’t need GPU resources.
At this time, you can use taint and toleration. Taint taint taint is to apply to the Node. Commands Add taint command structure
1 kubectl taint nodes [node-name] [key]=[value]:[taint-effect] Name Example [node-name] node01 [key] app [value] myapp [taint-effect] NoSchedule / PreferNoSchedule / NoExecute Add taint
Labels POD A-frt Key Value app frontend color red shape triangle POD B-fyt Key Value app frontend color yellow shape triangle POD C-fgt Key Value app frontend color green shape triangle POD D-brt Key Value app backend color red shape triangle POD E-byt Key Value app backend color yellow shape triangle POD F-bgt Key Value app backend color green shape triangle POD G-frr Key Value app frontend color red shape rectangle POD H-byr Key Value app backend color yellow shape rectangle POD I-bgr Key Value app backend color green shape rectangle Selector Selector 1 1 kubectl get pods --selector app=backend,shape=rectangle Key Value app backend shape rectangle Selected PODs by Selector 1 POD POD H-byr POD I-bgr Selector 2 1 kubectl get pods --selector app=frontend,color=red Key Value app frontend color red Selected PODs by Selector 2 POD POD A-frt POD G-frr Selector 3 1 kubectl get pods --selector color=green,shape=rectangle Key Value color green shape rectangle Selected PODs by Selector 2 POD POD I-bgr YAML replicaset-definition.