How it works...

This recipe showed you how to manually and automatically scale the number of pods in a deployment dynamically based on the Kubernetes metric.

In this recipe, in Step 2, we created an Autoscaler that adjusts the number of replicas between the defined minimum using minReplicas: 1 and maxReplicas: 5. As shown in the following example, the adjustment criteria are triggered by the targetCPUUtilizationPercentage: 50 metric:

spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-ch7-app-node
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 50

targetCPUUtilizationPercentage was used with the autoscaling/v1 APIs. You will soon see that targetCPUUtilizationPercentage will be replaced with an array called metrics. 

To understand the new metrics and custom metrics, run the following command. This will return the manifest we created with V1 APIs into a new manifest using V2 APIs:

$ kubectl get hpa.v2beta2.autoscaling my-ch7-app-node -o yaml

This enables you to specify additional resource metrics. By default, CPU and memory are the only supported resource metrics. In addition to these resource metrics, v2 APIs enable two other types of metrics, both of which are considered custom metrics: per-pod custom metrics and object metrics. You can read more about this by going to the Kubernetes HPA documentation link mentioned in the See also section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.200.71