Home > other >  Verifying resources in a deployment yaml
Verifying resources in a deployment yaml

Time:02-14

In a deployment yaml, how we can verify that the resources we need for the running pods are guaranteed by the k8s?

Is there a way to figure that out?

CodePudding user response:

Specify your resource request in the deployment YAML. The kube-scheduler will ensure the resources even before scheduling the pods.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
spec:
  selector:
    matchLabels:
      app: guestbook
      tier: frontend
  replicas: 3
  template:
    metadata:
      labels:
        app: guestbook
        tier: frontend
    spec:
      containers:
      - name: php-redis
        image: gcr.io/google-samples/gb-frontend:v4
        resources:
          requests:
            cpu: 100m
            memory: 100Mi

How Pods with resource requests are scheduled? Ref

When you create a Pod, the Kubernetes scheduler selects a node for the Pod to run on. Each node has a maximum capacity for each of the resource types: the amount of CPU and memory it can provide for Pods. The scheduler ensures that, for each resource type, the sum of the resource requests of the scheduled Containers is less than the capacity of the node. Note that although actual memory or CPU resource usage on nodes is very low, the scheduler still refuses to place a Pod on a node if the capacity check fails. This protects against a resource shortage on a node when resource usage later increases, for example, during a daily peak in request rate.

N.B.: However, if you want a container not to use more than its allowed resources, specify the limit too.

CodePudding user response:

There is QoS (Quality of Service) Classes for running pods in k8s. There is an option that is guaranteing and restricting request and limits. This option is qosClass: Guaranteed.

To be able to make your pods' QoS's Guaranteed;

Every Container in the Pod must have a memory limit and a memory request.
For every Container in the Pod, the memory limit must equal the memory request.
Every Container in the Pod must have a CPU limit and a CPU request.
For every Container in the Pod, the CPU limit must equal the CPU request.
These restrictions apply to init containers and app containers equally.

also check out the reference page for more info : https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod/

  • Related