Configure multidimensional Pod autoscaling

Stay organized with collections Save and categorize content based on your preferences.

Multidimensional Pod autoscaling frees you from choosing a single way to scale your clusters. With multidimensional Pod autoscaling, you can use horizontal scaling based on CPU and vertical scaling based on memory at the same time.

A MultidimPodAutoscaler object modifies memory requests and adds replicas so that the average CPU utilization of each replica matches your target utilization.


Using multidimensional Pod autoscaling

This example shows you how to create a Deployment and a MultidimPodAutoscaler object to autoscale your Deployment.

Creating a Deployment

Before you can create a MultidimPodAutoscaler, you must create the workload it monitors. The following file, php-apache.yaml, specifies a value for the CPU requests:

apiVersion: apps/v1
kind: Deployment
  name: php-apache
      run: php-apache
  replicas: 1
        run: php-apache
      - name: php-apache
        - containerPort: 80
        # Since MPA does not specify CPU requests, you must specify a request in
        # the Deployment
            cpu: 500m
            cpu: 200m

To create the Deployment, apply the php-apache.yaml manifest:

kubectl apply -f php-apache.yaml

Creating a MultidimPodAutoscaler

Once you have created the Deployment, you can create a MultidimPodAutoscaler object. The following MultidimPodAutoscaler manifest automatically adjusts the number of replicas and memory requests based on the values you specify.

For more information on the fields in this example, see the API reference section.

kind: MultidimPodAutoscaler
  name: php-apache-autoscaler
    apiVersion: apps/v1
    kind: Deployment
    name: php-apache
    - type: Resource
      # Define the target CPU utilization request here
        name: cpu
          type: Utilization
          averageUtilization: 60
      minReplicas: 1
      maxReplicas: 5
    containerControlledResources: [ memory ]
    - name: '*'
    # Define boundaries for the memory request here
          memory: 1Gi
          memory: 2Gi
    updateMode: Auto

To create the MultidimPodAutoscaler, apply the php-apache-autoscaler.yaml manifest:

kubectl apply -f php-apache-autoscaler.yaml

Viewing a MultidimPodAutoscaler

View all MultidimPodAutoscaler objects by using the kubectl get command:

kubectl get mpa

Deleting a MultidimPodAutoscaler

Delete a MultidimPodAutoscaler object by using the kubectl delete command:

kubectl delete -f php-apache-autoscaler.yaml

API reference

The following sections provide information on the possible fields you can add to your MultidimPodAutoscaler object.

All fields are for apiVersion v1beta1


MultidimPodAutoscaler is the configuration for a multidimensional Pod autoscaler, which automatically manages Pod resources and their count based on historical and real-time resource utilization.

Field Type Description
metadata ObjectMeta Standard object metadata.
spec MultidimPodAutoscalerSpec The desired behavior of the multidimensional Pod autoscaler.
status MultidimPodAutoscalerStatus The most recently observed status of the multidimensional Pod autoscaler.


MultidimPodAutoscalerSpec is the specification that defines the behavior of the autoscaler.

Field Type Description
ScaleTargetRef autoscaling.CrossVersionObjectReference A reference that points to a target resource to scale (with the Scale subresource).
Goals *MultidimGoals Goals that the multidimensional Pod autoscaler tries to achieve and maintain.
Constraints *MultidimConstraints Describes the constraints for autoscaling. Constraints outweigh goals. If constraints block some goal, then the goal will not be reached. For example, reaching the maximum replica count prevents further scale up even if the replicas might need to scale.
Policy *MultidimPolicy Policy allows you to specify how the recommendations are applied.


MultidimGoals are goals that the multidimensional Pod autoscaler tries to achieve.

Field Type Description
Metrics []MetricSpec Contains the list of metrics along with the desired value. Multidimensional Pod autoscaler tries to stay close to the desired values.


MultidimConstraints describe the constraints for autoscaling. Constraints take precedence over goals.

Field Type Description
Global *GlobalConstraints Constraints that apply to the autoscaled application as a whole.
ContainerControlledResources []ResourceName Container Resources that should be controlled by the autoscaler. memory is the only supported value.
Container []ContainerConstraints Constraints that apply to Pods' containers.


ResourceConstraints define the minimum and maximum amount of resources that you can assign to a container, Pod, or application.

Field Type Description
MinAllowed ResourceList Minimum amount of resources that you can assign. If not provided, 0 is used.
MaxAllowed []ResourceName Maximum amount of resources that you can assign. If not provided, there are no limits on the maximum amount of resources.
Requests *ResourceConstraints Minimum and maximum amount of resources that an application can request, summed over all Pods.


ContainerConstraints are constraints that apply to Pods' containers.

Fields Type Description
Name String Name of the container for which the constraints are specified. You can also use * to specify constraints for all containers in a Pod.
Requests *ResourceConstraints Minimum and maximum amount of resources that the specified container can request.


Use UpdateMode to control how the calculated recommendations are applied.

Fields Type Description
AutoUpdates UpdateMode = "Auto" AutoUpdates means that all autoscaler recommendations can be applied at any time.


Fields Type Description
Update UpdateMode Defines how the recommendations should be applied. An empty value fails validation.


MultidimPodAutoscalerStatus describes the runtime state of the autoscaler.

Fields Type Description
RecommendedPodResources *RecommendedPodResources The most recently computed amount of resources recommended by the autoscaler for the controlled Pods.
CurrentReplicas Int32 CurrentReplicas is the current number of replicas of Pods managed by this autoscaler, as last seen by the autoscaler.
DesiredReplicas Int32 DesiredReplicas is the desired number of replicas of Pods managed by this autoscaler, as last calculated by the autoscaler.
Conditions []metav1.Condition Conditions is the set of conditions required for this autoscaler to scale its target, and indicates whether or not those conditions are met.

What's next