python: Error: Initialization of V2beta1HorizontalPodAutoscalerStatus

When we use create_namespaced_horizontal_pod_autoscaler of AutoscalingV2beta1Api, the response always throws an exception since it doesn’t set conditions in V2beta1HorizontalPodAutoscalerStatus .

Likewise, the response of read_namespaced_horizontal_pod_autoscaler throws an exception since it doesn’t set current_metrics .

I will create a PR for this.

Situaltion

  • Kubernetes 1.9 via Rancher 1.6.16
  • Python 3.6.3
  • python kubernetes 5.0.0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (2 by maintainers)

Most upvoted comments

for those of us trying to get an HPA launched in a production environment where manual mods to the python modules are otherwise unreasonable, adding an annotation in the metadata has been enough to get past this issue for me.

resource_hpa['metadata']['annotations'] = { "autoscaling.alpha.kubernetes.io/conditions": "[ {\"type\":\"ScalingLimited\",\"status\":\"True\",\"reason\":\"TooFewReplicas\",\"message\":\"who needs messages\"}]" }

so, for reference, the whole dict looks like


>>> print( cc.json.dumps( resource_hpa, indent=2 ) )
{ 
  "apiVersion": "autoscaling/v2beta1",
  "kind": "HorizontalPodAutoscaler",
  "metadata": {
    "name": "my-serviceHPA",
    "annotations": {
      "autoscaling.alpha.kubernetes.io/conditions": "[ {\"type\":\"ScalingLimited\",\"status\":\"True\",\"reason\":\"TooFewReplicas\",\"message\":\"who needs messages\"}]"
    }
  },
  "spec": {
    "scaleTargetRef": {
      "apiVersion": "extensions/v1beta1",
      "kind": "Deployment",
      "name": "my-serviceHPA"
    },
    "minReplicas": 1,
    "maxReplicas": 10,
    "metrics": [
      { 
        "pods": {
          "targetAverageValue": 60,
          "metricName": "utilizationRate"
        },
        "type": "Pods"
      }
    ]
  }
}