In this post we will see how to scale an application deployment on Openshift.
There are essentially two ways to scale an application:
The previous command creates a HorizontalPodAutoscaler resource that changes the number of replicas of myapplication deployment configuration, in order to keep its pods under 90% of their total requested CPU usage.
To use the HorizontalPodAutoscaler resource, you have to define resource requests for the reference performance metric of your services.
There are essentially two ways to scale an application:
- manually increasing the number of replicas of pods
- configuring an autoscaling policy to automatically react and increase and decrease the number of pods based on traffic or resources consumption
Manually control the number of replicas of a pod.
The number of replicas can be changed dynamically using the oc scale command.
First of all, get the name of your deployment configuration:
Configure an Autoscaling policy.
OpenShift can autoscale a deployment configuration based on current load on the application pods, thanks to a HorizontalPodAutoscaler resource type, that uses performance metrics.
The number of replicas can be changed dynamically using the oc scale command.
First of all, get the name of your deployment configuration:
$ oc get dc
NAME REVISION DESIRED CURRENT TRIGGERED BY
myapplication 1 3 3 config,image(scaling:latest)
Scale the deployment to 5 replicas for the pods:
Check the number of replicas:
$ oc scale --replicas=5 dc myapplication
$ oc describe dc myapplication | grep Replicas
Replicas: 5
Replicas: 5 current / 5 desired
To create a HorizontalPodAutoscaler you can use the oc autoscale command, for example:
$ oc autoscale dc/myapplication --min 2 --max 8 --cpu-percent=90
The previous command creates a HorizontalPodAutoscaler resource that changes the number of replicas of myapplication deployment configuration, in order to keep its pods under 90% of their total requested CPU usage.
To use the HorizontalPodAutoscaler resource, you have to define resource requests for the reference performance metric of your services.
No comments:
Post a Comment