DataDog / watermarkpodautoscaler

Custom controller that extends the Horizontal Pod Autoscaler
Apache License 2.0
210 stars 25 forks source link

Introducing Lifecycle Control support #202

Closed CharlyF closed 7 months ago

CharlyF commented 7 months ago

What does this PR do?

Introduce the ability to pair a WPA object with a DatadogMonitor. With this first version, if a user enables the option on a per WPA basis using an annotation (see below) they will need to provide a DatadogMonitor object with the same name as their WPA (in the same namespace). If the DatadogMonitor is not in a OK state, we will not reconcile the given WPA.

Use cases:

For now it's fairly basic, but depending on adoption, we could introduce:

Motivation

Improving the feature set of the WPA controller.

Additional Notes

This depends on the DatadogMonitor CRD to be installed, I updated the associated helm chart proactively, but we will release 0.7.0 and merge accordingly.

Describe your test plan (when 0.7 RC is released)

With the helm chart:

helm install wpa --set lifecycleControl.enabled=true --set image.tag=0.7.0 . 

^ this will deploy the DatadogMonitor CRD, if the CRD is already deployed, use datadogCRDs.crds.datadogMonitors=false. Make sure you have the Operator running (since it reconciles the DatadogMonitor object):

helm install datadog-operator datadog/datadog-operator --set datadogMonitor.enabled=true --set apiKey=XXX --set appKey=XXX --set installCRDs=false

if you are deploying the Agent and Cluster Agent with the Operator, use these options:

apiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
  name: datadog
spec:
[...]
  features:
    externalMetricsServer:
      enabled: true
      wpaController: true
      useDatadogMetrics: true

if you are deploying with the helm chart:

helm install datadog --set clusterAgent.metricsProvider.enabled=true --set clusterAgent.metricsProvider.wpaController=true  --set clusterAgent.metricsProvider.enabled=true --set clusterAgent.metricsProvider.useDatadogMetrics=true  [... credentials...]  datadog/datadog

Create your WPA with the following annotation:

apiVersion: datadoghq.com/v1alpha1
kind: WatermarkPodAutoscaler
metadata:
  name: example-watermarkpodautoscaler-monitor
  namespace: default
  annotations:
    wpa.datadoghq.com/lifecycle-control.enabled: "true"
spec:
  algorithm: absolute
  downscaleDelayBelowWatermarkSeconds: 300
[...]
clamoriniere commented 7 months ago

It would be nice to add a metrics when the monitor is triggered to understand why the controller doesn't reconcile the WPA instance