-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support of Pod Autoscaling API #227
Comments
You can use In theory kubeclient should now support any resource in any API group. |
Hi, is this still a problem? Have you tried with an API group? |
Works for me, details below. $ oc autoscale -n mynamespace dc/postgresql --max=1
deploymentconfig "postgresql" autoscaled
$ oc get horizontalpodautoscalers -n mynamespace
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
postgresql DeploymentConfig/postgresql <unknown> / 80% 1 1 1 3m Then in ruby: client = Kubeclient::Client.new('http://master.example.com:8443/apis', 'autoscaling/v1', options)
client.get_horizontal_pod_autoscalers
as = c.get_horizontal_pod_autoscaler("postgresql", "mynamespace")
# => #<Kubeclient::Resource kind="HorizontalPodAutoscaler", apiVersion="autoscaling/v1", metadata={:name=>"postgresql", :namespace=>"mynamespace", :selfLink=>"/apis/autoscaling/v1/namespaces/mynamespace/horizontalpodautoscalers/postgresql", :uid=>"0f950927-61c4-11e8-a369-42010a8e0002", :resourceVersion=>"55349", :creationTimestamp=>"2018-05-27T15:38:53Z", :annotations=>{:"autoscaling.alpha.kubernetes.io/conditions"=>"[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2018-05-27T15:39:23Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2018-05-27T15:39:23Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: failed to get pod resource metrics: the server could not find the requested resource (get services https:heapster:)\"}]"}}, spec={:scaleTargetRef=>{:kind=>"DeploymentConfig", :name=>"postgresql", :apiVersion=>"v1"}, :minReplicas=>1, :maxReplicas=>1, :targetCPUUtilizationPercentage=>90}, status={:currentReplicas=>1, :desiredReplicas=>0}>
as.spec.targetCPUUtilizationPercentage
# => 80
as.spec.targetCPUUtilizationPercentage = 90
c.update_horizontal_pod_autoscaler(as) $ oc get horizontalpodautoscalers -n mynamespace
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
postgresql DeploymentConfig/postgresql <unknown> / 90% 1 1 1 2m Mimicking Note this object now also has v2beta1 version "which includes support for scaling on memory and custom metrics": |
Correction, please don't do:
even if that makes sense and appears to work (?), but instead do:
This is silly (#284, #318) but this is the current documented interface. |
I believe this works and I've answered the question, feel free to reopen if still a problem. |
kubectl provide Pod Autoscaling
The text was updated successfully, but these errors were encountered: