(existingVPA *vpav1.VerticalPodAutoscaler, ns *corev1.Namespace, controller Controller, updateMode *vpav1.UpdateMode, resourcePolicy *vpav1.PodResourcePolicy, minReplicas *int32)
| 336 | } |
| 337 | |
| 338 | func (r Reconciler) getVPAObject(existingVPA *vpav1.VerticalPodAutoscaler, ns *corev1.Namespace, controller Controller, updateMode *vpav1.UpdateMode, resourcePolicy *vpav1.PodResourcePolicy, minReplicas *int32) vpav1.VerticalPodAutoscaler { |
| 339 | var desiredVPA vpav1.VerticalPodAutoscaler |
| 340 | |
| 341 | // create a brand new vpa with the correct information |
| 342 | if existingVPA == nil { |
| 343 | desiredVPA = vpav1.VerticalPodAutoscaler{ |
| 344 | ObjectMeta: metav1.ObjectMeta{ |
| 345 | Name: "goldilocks-" + controller.Name, |
| 346 | Namespace: ns.Name, |
| 347 | }, |
| 348 | } |
| 349 | } else { |
| 350 | // or use the existing VPA as a template to update from |
| 351 | desiredVPA = *existingVPA |
| 352 | } |
| 353 | |
| 354 | // update the labels on the VPA |
| 355 | desiredVPA.Labels = utils.VPALabels |
| 356 | |
| 357 | // update the spec on the VPA |
| 358 | desiredVPA.Spec = vpav1.VerticalPodAutoscalerSpec{ |
| 359 | TargetRef: &autoscaling.CrossVersionObjectReference{ |
| 360 | APIVersion: controller.APIVersion, |
| 361 | Kind: controller.Kind, |
| 362 | Name: controller.Name, |
| 363 | }, |
| 364 | UpdatePolicy: &vpav1.PodUpdatePolicy{ |
| 365 | UpdateMode: updateMode, |
| 366 | }, |
| 367 | ResourcePolicy: resourcePolicy, |
| 368 | } |
| 369 | |
| 370 | if minReplicas != nil { |
| 371 | if *minReplicas > 0 { |
| 372 | desiredVPA.Spec.UpdatePolicy.MinReplicas = minReplicas |
| 373 | } |
| 374 | |
| 375 | } |
| 376 | |
| 377 | return desiredVPA |
| 378 | } |
| 379 | |
| 380 | var allowedUpdateModes = []vpav1.UpdateMode{ |
| 381 | vpav1.UpdateModeOff, |
no outgoing calls