0.12.3
resource "kubernetes_horizontal_pod_autoscaler" "source-file-processing" {
metadata {
name = "${terraform.workspace}-drawboard-services-source-file-processing"
}
spec {
max_replicas = 3
min_replicas = 2
target_cpu_utilization_percentage = 50
scale_target_ref {
kind = "Deployment"
name = "${terraform.workspace}-drawboard-services-source-file-processing"
}
}
}
(from kubectl.exe describe hpa)
AbleToScale True SucceededRescale the HPA controller was able to update the target scale to 2
I get an autoscaler that doesn't work
(from kubectl.exe describe hpa)
AbleToScale False FailedGetScale the HPA controller was unable to get the target's current scale: no matches for kind "Deployment" in group ""
Try and setup an autoscaler for a resource of type Deployment. Do not specify api_version
Kubernetes is in my case running on azure.
When i set up the same using the cli I got something that worked. So I exported the yaml of two the resources created a different way and found the terraform one had in the scale target no apiVersion defined. The resource created by the command line had apiVersion: extensions/v1beta1. So i explicitly set that in my terraform config and i got a working resource.
I don't know if this is a bug per-se, my high degree of ignorance or perhaps this is a quirk of Azure's kubernetes offering but couldn't the provider have set the (optional) api_version field for me? Or maybe a hint in the docs?
In scale_target_ref object add api_version = "extensions/v1beta1"
scale_target_ref {
api_version = "extensions/v1beta1"
kind = "deployment"
name = "${terraform.workspace}-drawboard-services-source-file-processing"
}
Ensure in your deployment you have resources block on container https://www.terraform.io/docs/providers/kubernetes/r/deployment.html#resources-1
EDIT: take care of @lucaskjaero comment
+1
If you're coming across this in google now, you might also want to try apps/v1 as the api_version depending on your Kubernetes version.
Closing since the question appears to have been answered here.
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!
Most helpful comment
If you're coming across this in google now, you might also want to try
apps/v1as theapi_versiondepending on your Kubernetes version.