July 2018
Intermediate to advanced
504 pages
11h 34m
English
Unlike autoscaling based on CPU utilization, memory-based autoscaling can only be enabled by creating a HorizontalPodAutoscaler from a raw YAML/JSON definition:
# cat hpa-memory.yml kind: HorizontalPodAutoscalerapiVersion: autoscaling/v1metadata: name: hpa-httpd-memoryspec: scaleTargetRef: apiVersion: v1 kind: DeploymentConfig name: httpd minReplicas: 2 maxReplicas: 4 metrics: - type: Resource resource: name: memory targetAverageUtilization: 10
Let's enable autoscaling now:
# oc create -f hpa-memory.yml horizontalpodautoscaler "hpa-httpd-memory" created
Give it a minute or two to pick up the metrics from Heapster and you will be able to see how the current memory utilization is different from the target:
# oc get ...