Hello everyone,
about the lab of ch06 in step 3, it is using yaml file to create hpa , i tried doing this using cli but got error about --memory-percent , obviously there's no such option and i used --help for the command but only found --cpu-percent.
so is there anyway to deploy the hpa using cli ?
Thanks
Hi,
You mean using kubectl|oc autoscale? Yes, it only has options for CPU-based autoscaling; if you want to use other metrics, you must create a manifest.
Not everything that can be done through a full manifest can be done from the CLI, I guess they only add support for the most common operations to keep the tools simple.
The lack of memory autoscaling options does not surprise me- I suspect it's used much less frequently, and it must be harder to get working correctly.
Cheers,
Álex
Hi,
You mean using kubectl|oc autoscale? Yes, it only has options for CPU-based autoscaling; if you want to use other metrics, you must create a manifest.
Not everything that can be done through a full manifest can be done from the CLI, I guess they only add support for the most common operations to keep the tools simple.
The lack of memory autoscaling options does not surprise me- I suspect it's used much less frequently, and it must be harder to get working correctly.
Cheers,
Álex
Thanks for your reply, and yes that's what i meant, i expected to see the same option for memory as it exists for cpu.
I shall use the web console then.
Thanks again.
One additional point here that might be worth mentioning. The `oc autoscale` command runs `kubectl autoscale` which leverages apiversion autoscale/v1. This is an older api-version one that didn't include a memory target. That was added in autoscale/v2.
It's interesting to inspect the type of resource created by `oc autoscale`:
```
[student@workstation ~]$ oc autoscale deployment.apps/myscale --min 2 --max 10 --cpu-percent=50 --dry-run=client -o yaml
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
creationTimestamp: null
name: myscale
spec:
maxReplicas: 10
minReplicas: 2
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: myscale
targetCPUUtilizationPercentage: 50
```
Notice the `apiVersion` there, v1.
After creating,however, you can inspect the resource using the different apiversions.
```
[student@workstation ~]$ oc get hpa.v1.autoscaling myscale -o yaml
[student@workstation ~]$ oc get hpa.v2.autoscaling myscale -o yaml
```
With autoscaling/v2 you can do more stuff like triggering on memory as you asked, but even other stuff like configuring a different scaledown stablization window (see behavior field) and triggering based on multiple metrics. All those goodies are not going to be possible with the CLI since it is using the older autoscaling/v1.
https://docs.openshift.com/container-platform/4.13/nodes/pods/nodes-pods-autoscaling.html
Thanks for the valuable information
Hi, Also another thing in the same lab that i noticed when you try to use the console to setup the HPA it does complain about setting up the limit for CPU/Memory but when i use the CLI or the manifest it doesn't complain, is this normal? is a limit necessary before setting up the HPA ? Thanks
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.