mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 13:57:38 +00:00
Merge pull request #134263 from ardaguclu/autoscale-dryrun-client
Add given namespace in dryrun=client output of HPA
This commit is contained in:
@@ -362,6 +362,10 @@ func (o *AutoscaleOptions) createHorizontalPodAutoscalerV2(refName string, mappi
|
||||
scaler.Spec.MinReplicas = &o.Min
|
||||
}
|
||||
|
||||
if o.enforceNamespace {
|
||||
scaler.ObjectMeta.Namespace = o.namespace
|
||||
}
|
||||
|
||||
metrics := []autoscalingv2.MetricSpec{}
|
||||
|
||||
// add CPU metric if any of the CPU targets are specified
|
||||
@@ -470,6 +474,10 @@ func (o *AutoscaleOptions) createHorizontalPodAutoscalerV1(refName string, mappi
|
||||
scaler.Spec.TargetCPUUtilizationPercentage = &c
|
||||
}
|
||||
|
||||
if o.enforceNamespace {
|
||||
scaler.ObjectMeta.Namespace = o.namespace
|
||||
}
|
||||
|
||||
return &scaler
|
||||
}
|
||||
|
||||
|
||||
@@ -811,6 +811,10 @@ run_rs_tests() {
|
||||
kube::test::if_has_string "${output_message}" 'kubectl-autoscale'
|
||||
# Clean up
|
||||
kubectl delete hpa frontend "${kube_flags[@]:?}"
|
||||
# autoscale with --dry-run=client should include namespace in output
|
||||
autoscale_namespace=$(kubectl get rs frontend "${kube_flags[@]:?}" -o jsonpath='{.metadata.namespace}')
|
||||
output_message=$(kubectl autoscale rs frontend "${kube_flags[@]:?}" --max=3 -n "$autoscale_namespace" --dry-run=client -o yaml 2>&1)
|
||||
kube::test::if_has_string "${output_message}" 'namespace:'
|
||||
# autoscale without specifying --max should fail
|
||||
! kubectl autoscale rs frontend "${kube_flags[@]:?}" || exit 1
|
||||
# Clean up
|
||||
|
||||
Reference in New Issue
Block a user