Configuring autoscaling
Managed Service for Kubernetes has 3 autoscaling methods available:
For more information, see Automatic scaling.
Before you begin
-
Create a cluster with any suitable configuration.
-
Install kubectl
and configure it to work with the created cluster.
Configuring cluster autoscaling
Warning
You can only enable automatic scaling of this type when creating a node group.
To create an autoscalable node group:
Create a node group with the following parameters:
- Type of scaling:
Automatic
. - Minimum number of nodes: Specify the number of nodes that the group must include at minimum load.
- Maximum number of nodes: Specify the maximum number of nodes allowed in the group.
- Initial number of nodes: The number of nodes to create along with the group (must be between the minimum and the maximum number of nodes in the group).
-
If you don't have the Nebius AI command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the
--folder-name
or--folder-id
parameter. -
Review the command to create a node group:
ncp managed-kubernetes node-group create --help
-
Create an autoscalable node group:
ncp managed-kubernetes node-group create \ ... --auto-scale min=<minimum number of nodes>,max=<maximum number of nodes>,initial=<initial number of nodes>
For more information about Cluster Autoscaler, see Cluster autoscaling.
Configuring horizontal pod autoscaling
-
Create a Horizontal Pod Autoscaler for your application, for example:
kubectl autoscale deployment/<application name> --cpu-percent=50 --min=1 --max=3
Where:
--cpu-percent
: The desired pod load on the vCPU.--min
: The minimum number of pods.--max
: The maximum number of pods.
-
Check the Horizontal Pod Autoscaler status:
kubectl describe hpa/<application name>
For more information about Horizontal Pod Autoscaler, see Horizontal pod autoscaling.
Configuring vertical pod autoscaling
-
Install Vertical Pod Autoscaler from the following repository
:cd /tmp && \ git clone https://github.com/kubernetes/autoscaler.git && \ cd autoscaler/vertical-pod-autoscaler/hack && \ ./vpa-up.sh
-
Create a configuration file called
vpa.yaml
for your application:apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: name: <application name> spec: targetRef: apiVersion: "apps/v1" kind: Deployment name: <application name> updatePolicy: updateMode: "<VPA runtime mode: Auto or Off>"
Set the Vertical Pod Autoscaler runtime mode in the
updateMode
parameter:Auto
orOff
. -
Create a Vertical Pod Autoscaler for your application:
kubectl apply -f vpa.yaml
-
Check the Vertical Pod Autoscaler status:
kubectl describe vpa <application name>
For more information about Vertical Pod Autoscaler, see Vertical pod autoscaling.