How to Limit the Minimum and Maximum Amount of Resources Apps Can Use in AKS

In AKS, you can limit the minimum and maximum amount of resources that apps can use.

This is a great way to ensure that your apps don’t consume too many resources and impact the performance of your AKS cluster. In this blog post, we will show you how to do this!

To limit the minimum and maximum amount of resources that apps can use, you first need to create a resource quota. You can do this by using the Azure CLI or Azure portal. In this example, we will show you how to do this using the Azure CLI.

Kubernetes Manifest file

A Kubernetes manifest file is a text file that contains the configuration for a Kubernetes deployment. The manifest file contains all of the information needed to deploy an application, including the name of the application, the image to use, and the number of replicas. In addition, the manifest file can also contain information about the resources that the application requires, such as CPU and memory.

In AKS, you can use a Kubernetes manifest file to specify the resources that your applications require. This is a great way to ensure that your applications don’t consume too many resources and impact the performance of your AKS cluster.

In this example, we will show you how to use a Kubernetes manifest file to limit the maximum amount of resources that an application can use. We will use a simple web application as our example. Our web application requires 256 MB of memory and 0.25 CPU cores (max).

In the manifest file, we specify the name of our application, the image to use, and the number of replicas. In addition, we need to specify the resources that our application requires.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-deploy
spec:
  replicas: 5
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
        - name: web-app
          image: nginx
          resources:
            requests: # Set minimum
              cpu: 100m
              memory: 128Mi
            limits: # Set maximum
              cpu: 250m
              memory: 256Mi    
      restartPolicy: Always
         

To deploy the application use the following command

kubectl apply -f deployment_limit.yaml

Posted

in

,

by