Configuring the number of replicas
To configure the number of replicas for Che operands using Kubernetes HorizontalPodAutoscaler
(HPA), you can define an HPA
resource for deployment. The HPA
dynamically adjusts the number
of replicas based on specified metrics.
Procedure
-
Create an
HPA
resource for a deployment, specifying the target metrics and desired replica count.apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: scaler namespace: eclipse-che spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: <deployment_name> (1) ...
1 The <deployment_name>
corresponds to the one following deployments:-
che
-
che-gateway
-
che-dashboard
-
plugin-registry
-
devfile-registry
-
Example 1. Create a
HorizontalPodAutoscaler
for che deployment:apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: che-scaler
namespace: eclipse-che
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: che
minReplicas: 2
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 75
In this example, the HPA is targeting the Deployment named che, with a minimum of 2 replicas, a maximum of 5 replicas and scaling based on CPU utilization.
Additional resources