DMCA.com Protection Status Trending Topics About Devops: 05/25/21

Tuesday, 25 May 2021

Create Pods with CPU Limit and Range in the default namespace

 

Pod with limit

Create a pod definition that requests for CPU more than 200m and less than 800m

vim pod-with-cpu-within-range.yml
apiVersion: v1
kind: Pod
metadata:
  name: pod-with-cpu-within-range
spec:
  containers:
  - name: pod-with-cpu-within-range
    image: nginx
    resources:
      limits:
        cpu: "800m"
      requests:
        cpu: "500m"

pod-with-cpu-within-range-definition

List the existing pods and create a new pod with the file created in the above step.

kubectl get pods
kubectl create -f pod-with-cpu-within-range.yml
kubectl get pods
kubectl describe pod pod-with-cpu-within-range

create-pod-with-cpu-within-range

Create a LimitRange in the default namespace

 vim set-limit-range.yml

apiVersion: v1
kind: LimitRange
metadata:
  name: set-limit-range
spec:
  limits:
  - max:
      cpu: "800m"
    min:
      cpu: "200m"
    type: Container

set-limit-range-definition

Get a list of existing limit ranges in the default namespace and create the one using the file created in the above step.

kubectl get limitrange
kubectl create -f set-limit-range.yml
kubectl get limitrange
kubectl describe limitrange set-limit-range

create-limit-range

Kubernetes Resource Quota

apiVersion: v1

kind: ResourceQuota

metadata:

   name: quota1

   namespace: developer

spec:

 hard:

   pods: "2"

   configmaps: "10"

   secrets: "10"

   services: "10"

   persistentvolumeclaims: "55"

   limits.memory: "1800Mi"

   limits.cpu: "10"






CONTAINER DEPLOYMENT 



apiVersion: v1

kind: Pod

metadata:

  name: moon-serverr

  namespace: developer

spec:

  containers:

    - image: nginx

      name: moon-serverr

      resources:

        limits:

          memory: "300Mi"

          cpu: "2"