About your API versions: that is fine, with autoscaling/v2beta1 you can even autoscale based on external metrics (e.g. Stackdriver).
About your question: I am not sure what do you mean by "I cannot enable it".
From the same page you linked, you can find 80% of the manifest you need:
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: php-apache
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: php-apache
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
This manifest says "have between 1 and 10 replicas, based on the CPU utilisation scale more the thing described on scaleTargetRef". You could add also based on memory, and it will work in an "OR" fashion (if one of the two metric will pass the threshold, the scaling will happen). You could finally also add a metric of type: External
that would be your Stackdriver source (e.g. number of HTTP requests, number of messages in a queue..). This is generally advised as scaling based on CPU is ineffective.
Once you have the manifest, simply have kubectl apply -f hpa.yaml and you have enabled it.
This is why I am saying I don't get fully your question, do you mean to say you couldn't find a proper manifest? (the one I wrote here is also not 'proper')
I couldn't find the source (it was an article about HPA with external metrics), but here's the manifest for my HPA:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
namespace: myapp
spec:
minReplicas: 3
maxReplicas: 15
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: myapp
metrics:
- type: Resource
resource:
name: memory
targetAverageUtilization: 60
- type: External
external:
metricName: loadbalancing.googleapis.com|https|request_count
metricSelector:
matchLabels:
resource.labels.url_map_name: k8s-um-myapp-myapp-ingress--64658eaf6b9dce0
targetAverageValue: 100
I scale based on the RAM and on the requests.
HTH