diff --git a/PROJECT b/PROJECT index fa68a4462..4083d9d53 100644 --- a/PROJECT +++ b/PROJECT @@ -60,4 +60,12 @@ resources: kind: DatadogAgentProfile path: github.com/DataDog/datadog-operator/apis/datadoghq/v1alpha1 version: v1alpha1 +- api: + crdVersion: v1 + namespaced: true + domain: com + group: datadoghq + kind: DatadogPodAutoscaler + path: github.com/DataDog/datadog-operator/apis/datadoghq/v1alpha1 + version: v1alpha1 version: "3" diff --git a/apis/datadoghq/v1alpha1/datadogpodautoscaler_types.go b/apis/datadoghq/v1alpha1/datadogpodautoscaler_types.go new file mode 100644 index 000000000..9a0dc9171 --- /dev/null +++ b/apis/datadoghq/v1alpha1/datadogpodautoscaler_types.go @@ -0,0 +1,579 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2016-present Datadog, Inc. + +package v1alpha1 + +import ( + autoscalingv2 "k8s.io/api/autoscaling/v2" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// spec: +// targetRef: +// apiVersion: apps/v1 +// kind: Deployment +// name: test +// owner: local +// remoteVersion: 1 +// policy: +// applyMode: All|Manual|None +// update: +// strategy: Auto|Disabled +// upscale: +// strategy: Max|Min|Disabled +// rules: +// - type: Pods|Percent +// value: 1 +// periodSeconds: 60 +// downscale: +// strategy: Max|Min|Disabled +// rules: +// - type: Pods|Percent +// value: 1 +// periodSeconds: 60 +// targets: +// - type: PodResource +// resource: +// name: cpu +// value: +// type: Absolute|Utilization +// absolute: 500m +// utilization: 80 +// - type: ContainerResource +// containerResource: +// name: cpu +// value: +// type: Absolute|Utilization +// absolute: 500m +// utilization: 80 +// constraints: +// minReplicas: 1 +// maxReplicas: 10 +// containers: +// - name: "*" +// enabled: true +// requests: +// minAllowed: +// maxAllowed: +// limits: +// minAllowed: +// maxAllowed: + +// DatadogPodAutoscalerOwner defines the source of truth for this object (local or remote) +// +kubebuilder:validation:Enum:=Local;Remote +type DatadogPodAutoscalerOwner string + +const ( + // DatadogPodAutoscalerLocalOwner states that this `DatadogPodAutoscaler` object is created/managed outside of Datadog app. + DatadogPodAutoscalerLocalOwner DatadogPodAutoscalerOwner = "Local" + + // DatadogPodAutoscalerLocalOwner states that this `DatadogPodAutoscaler` object is created/managed in Datadog app. + DatadogPodAutoscalerRemoteOwner DatadogPodAutoscalerOwner = "Remote" +) + +// DatadogPodAutoscalerSpec defines the desired state of DatadogPodAutoscaler +type DatadogPodAutoscalerSpec struct { + // TargetRef is the reference to the resource to scale. + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Modifying the targetRef is not allowed. Please delete and re-create the DatadogPodAutoscaler object." + TargetRef autoscalingv2.CrossVersionObjectReference `json:"targetRef"` + + // Owner defines the source of truth for this object (local or remote) + // Value needs to be set when a DatadogPodAutoscaler object is created. + Owner DatadogPodAutoscalerOwner `json:"owner"` + + // RemoteVersion is the version of the .Spec currently store in this object. + // Only set if the owner is Remote. + RemoteVersion *uint64 `json:"remoteVersion,omitempty"` + + // Policy defines how recommendations should be applied. + // +optional + // +kubebuilder:default={} + Policy *DatadogPodAutoscalerPolicy `json:"policy,omitempty"` + + // Targets are objectives to reach and maintain for the target resource. + // Default to a single target to maintain 80% POD CPU utilization. + // +listType=atomic + // +optional + Targets []DatadogPodAutoscalerTarget `json:"targets,omitempty"` + + // Constraints defines constraints that should always be respected. + Constraints *DatadogPodAutoscalerConstraints `json:"constraints,omitempty"` +} + +// DatadogPodAutoscalerOwner defines the source of truth for this object (local or remote) +// +kubebuilder:validation:Enum:=All;Manual;None +type DatadogPodAutoscalerApplyMode string + +const ( + // DatadogPodAutoscalerAllApplyMode allows the controller to apply all recommendations (regular and manual) + DatadogPodAutoscalerAllApplyMode DatadogPodAutoscalerApplyMode = "All" + + // DatadogPodAutoscalerManualApplyMode allows the controller to only apply manual recommendations (recommendations manually validated by user in the Datadog app) + DatadogPodAutoscalerManualApplyMode DatadogPodAutoscalerApplyMode = "Manual" + + // DatadogPodAutoscalerNoneApplyMode prevent the controller to apply any recommendations. Datadog will still produce and display recommendations + // but the controller will not apply them, even when they are manually validated. Similar to "DryRun" mode. + DatadogPodAutoscalerNoneApplyMode DatadogPodAutoscalerApplyMode = "None" +) + +// DatadogPodAutoscalerPolicy defines how recommendations should be applied. +type DatadogPodAutoscalerPolicy struct { + // ApplyMode determines recommendations that should be applied by the controller: + // - All: Apply all recommendations (regular and manual). + // - Manual: Apply only manual recommendations (recommendations manually validated by user in the Datadog app). + // - None: Prevent the controller to apply any recommendations. + // It's also possible to selectively deactivate upscale, downscale or update actions thanks to the `Upscale`, `Downscale` and `Update` fields. + // +optional + // +kubebuilder:default=All + ApplyMode DatadogPodAutoscalerApplyMode `json:"applyMode"` + + // Update defines the policy to update target resource. + Update *DatadogPodAutoscalerUpdatePolicy `json:"update,omitempty"` + + // Upscale defines the policy to scale up the target resource. + Upscale *DatadogPodAutoscalerScalingPolicy `json:"upscale,omitempty"` + + // Downscale defines the policy to scale down the target resource. + Downscale *DatadogPodAutoscalerScalingPolicy `json:"downscale,omitempty"` +} + +// DatadogPodAutoscalerUpdateStrategy defines the mode of the update policy. +// +kubebuilder:validation:Enum:=Auto;Disabled +type DatadogPodAutoscalerUpdateStrategy string + +const ( + // DatadogPodAutoscalerAutoUpdateStrategy is the default mode. + DatadogPodAutoscalerAutoUpdateStrategy DatadogPodAutoscalerUpdateStrategy = "Auto" + + // DatadogPodAutoscalerDisabledUpdateStrategy will disable the update of the target resource. + DatadogPodAutoscalerDisabledUpdateStrategy DatadogPodAutoscalerUpdateStrategy = "Disabled" +) + +// DatadogPodAutoscalerUpdatePolicy defines the policy to update target resource. +type DatadogPodAutoscalerUpdatePolicy struct { + // Mode defines the mode of the update policy. + Strategy DatadogPodAutoscalerUpdateStrategy `json:"strategy,omitempty"` +} + +// +// Scaling policy is inspired by the HorizontalPodAutoscalerV2 +// https://github.com/kubernetes/api/blob/master/autoscaling/v2/types.go +// Copyright 2021 The Kubernetes Authors. +// + +// DatadogPodAutoscalerScalingStrategySelect is used to specify which policy should be used while scaling in a certain direction +// +kubebuilder:validation:Enum:=Max;Min;Disabled +type DatadogPodAutoscalerScalingStrategySelect string + +const ( + // DatadogPodAutoscalerMaxChangeStrategySelect selects the policy with the highest possible change. + DatadogPodAutoscalerMaxChangeStrategySelect DatadogPodAutoscalerScalingStrategySelect = "Max" + + // DatadogPodAutoscalerMinChangeStrategySelect selects the policy with the lowest possible change. + DatadogPodAutoscalerMinChangeStrategySelect DatadogPodAutoscalerScalingStrategySelect = "Min" + + // DatadogPodAutoscalerDisabledStrategySelect disables the scaling in this direction. + DatadogPodAutoscalerDisabledStrategySelect DatadogPodAutoscalerScalingStrategySelect = "Disabled" +) + +// DatadogPodAutoscalerScalingPolicy defines the policy to scale the target resource. +type DatadogPodAutoscalerScalingPolicy struct { + // Strategy is used to specify which policy should be used. + // If not set, the default value Max is used. + // +optional + Strategy *DatadogPodAutoscalerScalingStrategySelect `json:"strategy,omitempty"` + + // Rules is a list of potential scaling polices which can be used during scaling. + // At least one policy must be specified, otherwise the DatadogPodAutoscalerScalingPolicy will be discarded as invalid + // +listType=atomic + // +optional + Rules []DatadogPodAutoscalerScalingRule `json:"rules,omitempty"` +} + +// DatadogPodAutoscalerScalingRuleType defines how scaling rule value should be interpreted. +// +kubebuilder:validation:Enum:=Pods;Percent +type DatadogPodAutoscalerScalingRuleType string + +const ( + // DatadogPodAutoscalerPodsScalingRuleType specifies a change in absolute number of pods compared to the starting number of PODs. + DatadogPodAutoscalerPodsScalingRuleType DatadogPodAutoscalerScalingRuleType = "Pods" + + // DatadogPodAutoscalerPercentScalingRuleType specifies a relative amount of change compared to the starting number of PODs. + DatadogPodAutoscalerPercentScalingRuleType DatadogPodAutoscalerScalingRuleType = "Percent" +) + +// DatadogPodAutoscalerScalingRuleMatch +// +kubebuilder:validation:Enum:=Always;IfScalingEvent +type DatadogPodAutoscalerScalingRuleMatch string + +const ( + // DatadogPodAutoscalerAlwaysScalingRuleMatch defines that the rule should always be considered in the calculation. + DatadogPodAutoscalerAlwaysScalingRuleMatch DatadogPodAutoscalerScalingRuleMatch = "Always" + + // DatadogPodAutoscalerIfScalingEventRuleMatch defines that rule should only be considered if at least one scaling event occurred. + // It allows to define behaviors such as forbidden windows (e.g. allow 0 PODs (Value) to be created in the next 5m (PeriodSeconds) after a scaling events). + DatadogPodAutoscalerIfScalingEventRuleMatch DatadogPodAutoscalerScalingRuleMatch = "IfScalingEvent" +) + +// DatadogPodAutoscalerScalingRule define rules for horizontal that should be true for a certain amount of time. +type DatadogPodAutoscalerScalingRule struct { + // Type is used to specify the scaling policy. + Type DatadogPodAutoscalerScalingRuleType `json:"type"` + + // Value contains the amount of change which is permitted by the policy. + // Setting it to 0 will prevent any scaling in this direction and should not be used unless Match is set to IfScalingEvent. + // +kubebuilder:validation:Minimum=0 + Value int32 `json:"value"` + + // PeriodSeconds specifies the window of time for which the policy should hold true. + // PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=1800 + PeriodSeconds int32 `json:"periodSeconds"` + + // Match defines if the rule should be considered or not in the calculation. + // Default to Always if not set. + Match *DatadogPodAutoscalerScalingRuleMatch `json:"match,omitempty"` +} + +// DatadogPodAutoscalerTargetType defines the type of the target. +// +kubebuilder:validation:Enum:=PodResource;ContainerResource +type DatadogPodAutoscalerTargetType string + +const ( + // DatadogPodAutoscalerResourceTargetType allows to set POD-level resources targets. + DatadogPodAutoscalerResourceTargetType DatadogPodAutoscalerTargetType = "PodResource" + + // DatadogPodAutoscalerContainerResourceTargetType allows to set container-level resources targets. + DatadogPodAutoscalerContainerResourceTargetType DatadogPodAutoscalerTargetType = "ContainerResource" +) + +// DatadogPodAutoscalerTarget defines the objectives to reach and maintain for the target resource. +type DatadogPodAutoscalerTarget struct { + // Type sets the type of the target. + Type DatadogPodAutoscalerTargetType `json:"type"` + + // PodResource allows to set a POD-level resource target. + PodResource *DatadogPodAutoscalerResourceTarget `json:"podResource,omitempty"` + + // ContainerResource allows to set a container-level resource target. + ContainerResource *DatadogPodAutoscalerContainerResourceTarget `json:"containerResource,omitempty"` +} + +// DatadogPodAutoscalerResourceTarget defines a POD-level resource target (for instance, CPU Utilization at 80%) +// For POD-level targets, resources are the sum of all containers resources. +// Utilization is computed from sum(usage) / sum(requests). +type DatadogPodAutoscalerResourceTarget struct { + // Name is the name of the resource. + // +kubebuilder:validation:Enum:=cpu + Name corev1.ResourceName `json:"name"` + + // Value is the value of the target. + Value DatadogPodAutoscalerTargetValue `json:"value"` +} + +// DatadogPodAutoscalerContainerResourceTarget defines a Container level resource target (for instance, CPU Utilization for container named "foo" at 80%) +type DatadogPodAutoscalerContainerResourceTarget struct { + // Name is the name of the resource. + // +kubebuilder:validation:Enum:=cpu + Name corev1.ResourceName `json:"name"` + + // Value is the value of the target. + Value DatadogPodAutoscalerTargetValue `json:"value"` + + // Container is the name of the container. + Container string `json:"container"` +} + +// DatadogPodAutoscalerTargetValue defines the value of the target. +type DatadogPodAutoscalerTargetValue struct { + // Type specifies how the value is expressed (Absolute or Utilization). + Type DatadogPodAutoscalerTargetValueType `json:"type"` + + // Absolute defines the absolute value of the target (for instance 500 millicores). + Absolute *resource.Quantity `json:"absolute,omitempty"` + + // Utilization defines a percentage of the target compared to requested resource + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=100 + Utilization *int32 `json:"utilization,omitempty"` +} + +// DatadogPodAutoscalerTargetValueType specifies the type of metric being targeted, and should be either +// kubebuilder:validation:Enum:=Absolute;Utilization +type DatadogPodAutoscalerTargetValueType string + +const ( + // DatadogPodAutoscalerAbsoluteTargetValueType is the target type for absolute values + DatadogPodAutoscalerAbsoluteTargetValueType DatadogPodAutoscalerTargetValueType = "Absolute" + + // DatadogPodAutoscalerUtilizationTargetValueType declares a MetricTarget is an AverageUtilization value + DatadogPodAutoscalerUtilizationTargetValueType DatadogPodAutoscalerTargetValueType = "Utilization" +) + +// DatadogPodAutoscalerConstraints defines constraints that should always be respected. +type DatadogPodAutoscalerConstraints struct { + // MinReplicas is the lower limit for the number of POD replicas. Needs to be >= 1. Default to 1. + // +kubebuilder:validation:Minimum=1 + MinReplicas *int32 `json:"minReplicas,omitempty"` + + // MaxReplicas is the upper limit for the number of POD replicas. Needs to be >= minReplicas. + MaxReplicas int32 `json:"maxReplicas"` + + // Containers defines constraints for the containers. + Containers []DatadogPodAutoscalerContainerConstraints `json:"containers,omitempty"` +} + +// DatadogPodAutoscalerContainerConstraints defines constraints that should always be respected for a container. +// If no constraints are set, it enables resources scaling for all containers without any constraints. +type DatadogPodAutoscalerContainerConstraints struct { + // Name is the name of the container. Can be "*" to apply to all containers. + Name string `json:"name"` + + // Enabled false allows to disable resources autoscaling for the container. Default to true. + Enabled *bool `json:"enabled,omitempty"` + + // Requests defines the constraints for the requests of the container. + Requests *DatadogPodAutoscalerContainerResourceConstraints `json:"requests,omitempty"` + + // Limits defines the constraints for the limits of the container. + Limits *DatadogPodAutoscalerContainerResourceConstraints `json:"limits,omitempty"` +} + +type DatadogPodAutoscalerContainerResourceConstraints struct { + // MinAllowed is the lower limit for the requests of the container. + // +optional + MinAllowed corev1.ResourceList `json:"minAllowed,omitempty"` + + // MaxAllowed is the upper limit for the requests of the container. + // +optional + MaxAllowed corev1.ResourceList `json:"maxAllowed,omitempty"` +} + +// DatadogPodAutoscalerStatus defines the observed state of DatadogPodAutoscaler +type DatadogPodAutoscalerStatus struct { + // Vertical is the status of the vertical scaling, if activated. + // +optional + Vertical *DatadogPodAutoscalerVerticalStatus `json:"vertical,omitempty"` + + // Horizontal is the status of the horizontal scaling, if activated. + // +optional + Horizontal *DatadogPodAutoscalerHorizontalStatus `json:"horizontal,omitempty"` + + // CurrentReplicas is the current number of PODs for the targetRef observed by the controller. + // +optional + CurrentReplicas *int32 `json:"currentReplicas,omitempty"` + + // Conditions describe the current state of the DatadogPodAutoscaler operations. + // +patchMergeKey=type + // +patchStrategy=merge + // +listType=map + // +listMapKey=type + // +optional + Conditions []DatadogPodAutoscalerCondition `json:"conditions,omitempty"` +} + +// DatadogPodAutoscalerValueSource defines the source of the value used to scale the target resource. +type DatadogPodAutoscalerValueSource string + +const ( + // DatadogPodAutoscalerAutoscalingValueSource is a recommendation that comes from active autoscaling. + DatadogPodAutoscalerAutoscalingValueSource DatadogPodAutoscalerValueSource = "Autoscaling" + + // DatadogPodAutoscalerManualValueSource is a recommendation that comes from manually applying a recommendation. + DatadogPodAutoscalerManualValueSource DatadogPodAutoscalerValueSource = "Manual" +) + +// DatadogPodAutoscalerHorizontalStatus defines the status of the horizontal scaling +type DatadogPodAutoscalerHorizontalStatus struct { + // Target is the current target of the horizontal scaling + Target *DatadogPodAutoscalerHorizontalTargetStatus `json:"target,omitempty"` + + // LastActions are the last successful actions done by the controller + LastActions []DatadogPodAutoscalerHorizontalAction `json:"lastActions,omitempty"` +} + +// DatadogPodAutoscalerHorizontalTargetStatus defines the current target of the horizontal scaling +type DatadogPodAutoscalerHorizontalTargetStatus struct { + // Source is the source of the value used to scale the target resource + Source DatadogPodAutoscalerValueSource `json:"source"` + + // GeneratedAt is the timestamp at which the recommendation was generated + GeneratedAt metav1.Time `json:"generatedAt,omitempty"` + + // Replicas is the desired number of replicas for the resource + Replicas int32 `json:"desiredReplicas"` +} + +// DatadogPodAutoscalerHorizontalAction represents an horizontal action done by the controller +type DatadogPodAutoscalerHorizontalAction struct { + // Time is the timestamp of the action + Time metav1.Time `json:"time"` + + // FromReplicas is the number of replicas before the action + FromReplicas int32 `json:"replicas"` + + // ToReplicas is the effective number of replicas after the action + ToReplicas int32 `json:"toReplicas"` + + // RecommendedReplicas is the original number of replicas recommended by Datadog + RecommendedReplicas *int32 `json:"recommendedReplicas,omitempty"` + + // LimitedReason is the reason why the action was limited (ToReplicas != RecommendedReplicas) + LimitedReason *string `json:"limitedReason,omitempty"` +} + +// DatadogPodAutoscalerVerticalStatus defines the status of the vertical scaling +type DatadogPodAutoscalerVerticalStatus struct { + // Target is the current target of the vertical scaling + Target *DatadogPodAutoscalerVerticalTargetStatus `json:"target,omitempty"` + + // LastAction is the last successful action done by the controller + LastAction *DatadogPodAutoscalerVerticalAction `json:"lastAction,omitempty"` +} + +// DatadogPodAutoscalerVerticalTargetStatus defines the current target of the vertical scaling +type DatadogPodAutoscalerVerticalTargetStatus struct { + // Source is the source of the value used to scale the target resource + Source DatadogPodAutoscalerValueSource `json:"source"` + + // GeneratedAt is the timestamp at which the recommendation was generated + GeneratedAt metav1.Time `json:"generatedAt,omitempty"` + + // Version is the current version of the received recommendation + Version string `json:"version"` + + // Scaled is the current number of PODs having desired resources + Scaled *int32 `json:"scaled,omitempty"` + + // DesiredResources is the desired resources for containers + DesiredResources []DatadogPodAutoscalerContainerResources `json:"desiredResources"` + + // PODCPURequest is the sum of CPU requests for all containers (used for display) + PODCPURequest resource.Quantity `json:"podCPURequest"` + + // PODMemoryRequest is the sum of memory requests for all containers (used for display) + PODMemoryRequest resource.Quantity `json:"podMemoryRequest"` +} + +// DatadogPodAutoscalerVerticalActionType represents the type of action done by the controller +type DatadogPodAutoscalerVerticalActionType string + +const ( + // DatadogPodAutoscalerRolloutTriggeredVerticalActionType is the action when the controller triggers a rollout of the targetRef + DatadogPodAutoscalerRolloutTriggeredVerticalActionType DatadogPodAutoscalerVerticalActionType = "RolloutTriggered" +) + +// DatadogPodAutoscalerVerticalAction represents a vertical action done by the controller +type DatadogPodAutoscalerVerticalAction struct { + // Time is the timestamp of the action + Time metav1.Time `json:"time"` + + // Version is the recommendation version used for the action + Version string `json:"version"` + + // Type is the type of action + Type DatadogPodAutoscalerVerticalActionType `json:"type"` +} + +type DatadogPodAutoscalerContainerResources struct { + // Name is the name of the container + Name string `json:"name"` + + // Limits describes the maximum amount of compute resources allowed. + // +optional + Limits corev1.ResourceList `json:"limits,omitempty"` + + // Requests describes target resources of compute resources allowed. + // +optional + Requests corev1.ResourceList `json:"requests,omitempty"` +} + +// DatadogPodAutoscalerConditionType type use to represent a DatadogMetric condition +type DatadogPodAutoscalerConditionType string + +const ( + // DatadogPodAutoscalerErrorCondition is true when a global error is encountered processing this DatadogPodAutoscaler. + DatadogPodAutoscalerErrorCondition DatadogPodAutoscalerConditionType = "Error" + + // DatadogPodAutoscalerActiveCondition is true when the DatadogPodAutoscaler can be used for autoscaling. + DatadogPodAutoscalerActiveCondition DatadogPodAutoscalerConditionType = "Active" + + // DatadogPodAutoscalerHorizontalAbleToRecommendCondition is true when we can get horizontal recommendation from Datadog. + DatadogPodAutoscalerHorizontalAbleToRecommendCondition DatadogPodAutoscalerConditionType = "HorizontalAbleToRecommend" + + // DatadogPodAutoscalerHorizontalAbleToScaleCondition is true when horizontal scaling is working correctly. + DatadogPodAutoscalerHorizontalAbleToScaleCondition DatadogPodAutoscalerConditionType = "HorizontalAbleToScale" + + // DatadogPodAutoscalerHorizontalScalingLimitedCondition is true when horizontal scaling is limited by constraints. + DatadogPodAutoscalerHorizontalScalingLimitedCondition DatadogPodAutoscalerConditionType = "HorizontalScalingLimited" + + // DatadogPodAutoscalerVerticalAbleToRecommendCondition is true when we can ge vertical recommendation from Datadog. + DatadogPodAutoscalerVerticalAbleToRecommendCondition DatadogPodAutoscalerConditionType = "VerticalAbleToRecommend" + + // DatadogPodAutoscalerVerticalAbleToApply is true when we can rollout the targetRef to pick up new resources. + DatadogPodAutoscalerVerticalAbleToApply DatadogPodAutoscalerConditionType = "VerticalAbleToApply" +) + +// DatadogPodAutoscalerCondition describes the state of DatadogPodAutoscaler. +type DatadogPodAutoscalerCondition struct { + // Type of DatadogMetric condition. + Type DatadogPodAutoscalerConditionType `json:"type"` + + // Status of the condition, one of True, False, Unknown. + Status corev1.ConditionStatus `json:"status"` + + // Last time the condition transitioned from one status to another. + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + + // The reason for the condition's last transition. + // +optional + Reason string `json:"reason,omitempty"` + + // A human readable message indicating details about the transition. + // +optional + Message string `json:"message,omitempty"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:resource:shortName=dpa +//+kubebuilder:subresource:status +//+kubebuilder:printcolumn:name="Apply Mode",type="string",JSONPath=".spec.policy.applyMode" +//+kubebuilder:printcolumn:name="Active",type="string",JSONPath=".status.conditions[?(@.type=='Active')].status" +//+kubebuilder:printcolumn:name="In Error",type="string",JSONPath=".status.conditions[?(@.type=='Error')].status" +//+kubebuilder:printcolumn:name="Desired Replicas",type="integer",JSONPath=".status.horizontal.target.desiredReplicas" +//+kubebuilder:printcolumn:name="Generated",type="date",JSONPath=".status.horizontal.target.generatedAt" +//+kubebuilder:printcolumn:name="Able to Scale",type="string",JSONPath=".status.conditions[?(@.type=='HorizontalAbleToScale')].status" +//+kubebuilder:printcolumn:name="Last Scale",type="date",JSONPath=".status.horizontal.lastAction.time" +//+kubebuilder:printcolumn:name="Target CPU Req",type="string",JSONPath=".status.vertical.target.podCPURequest" +//+kubebuilder:printcolumn:name="Target Memory Req",type="string",JSONPath=".status.vertical.target.podMemoryRequest" +//+kubebuilder:printcolumn:name="Generated",type="date",JSONPath=".status.vertical.target.generatedAt" +//+kubebuilder:printcolumn:name="Able to Apply",type="string",JSONPath=".status.conditions[?(@.type=='VerticalAbleToApply')].status" +//+kubebuilder:printcolumn:name="Last Trigger",type="date",JSONPath=".status.vertical.lastAction.time" + +// DatadogPodAutoscaler is the Schema for the datadogpodautoscalers API +type DatadogPodAutoscaler struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec DatadogPodAutoscalerSpec `json:"spec,omitempty"` + Status DatadogPodAutoscalerStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// DatadogPodAutoscalerList contains a list of DatadogPodAutoscaler +type DatadogPodAutoscalerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []DatadogPodAutoscaler `json:"items"` +} + +func init() { + SchemeBuilder.Register(&DatadogPodAutoscaler{}, &DatadogPodAutoscalerList{}) +} diff --git a/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go b/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go index a0cd87d4e..99ad36031 100644 --- a/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go +++ b/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go @@ -1696,6 +1696,585 @@ func (in *DatadogMonitorTriggeredState) DeepCopy() *DatadogMonitorTriggeredState return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscaler) DeepCopyInto(out *DatadogPodAutoscaler) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscaler. +func (in *DatadogPodAutoscaler) DeepCopy() *DatadogPodAutoscaler { + if in == nil { + return nil + } + out := new(DatadogPodAutoscaler) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DatadogPodAutoscaler) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerCondition) DeepCopyInto(out *DatadogPodAutoscalerCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerCondition. +func (in *DatadogPodAutoscalerCondition) DeepCopy() *DatadogPodAutoscalerCondition { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerConstraints) DeepCopyInto(out *DatadogPodAutoscalerConstraints) { + *out = *in + if in.MinReplicas != nil { + in, out := &in.MinReplicas, &out.MinReplicas + *out = new(int32) + **out = **in + } + if in.Containers != nil { + in, out := &in.Containers, &out.Containers + *out = make([]DatadogPodAutoscalerContainerConstraints, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerConstraints. +func (in *DatadogPodAutoscalerConstraints) DeepCopy() *DatadogPodAutoscalerConstraints { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerConstraints) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerContainerConstraints) DeepCopyInto(out *DatadogPodAutoscalerContainerConstraints) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.Requests != nil { + in, out := &in.Requests, &out.Requests + *out = new(DatadogPodAutoscalerContainerResourceConstraints) + (*in).DeepCopyInto(*out) + } + if in.Limits != nil { + in, out := &in.Limits, &out.Limits + *out = new(DatadogPodAutoscalerContainerResourceConstraints) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerContainerConstraints. +func (in *DatadogPodAutoscalerContainerConstraints) DeepCopy() *DatadogPodAutoscalerContainerConstraints { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerContainerConstraints) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerContainerResourceConstraints) DeepCopyInto(out *DatadogPodAutoscalerContainerResourceConstraints) { + *out = *in + if in.MinAllowed != nil { + in, out := &in.MinAllowed, &out.MinAllowed + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + if in.MaxAllowed != nil { + in, out := &in.MaxAllowed, &out.MaxAllowed + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerContainerResourceConstraints. +func (in *DatadogPodAutoscalerContainerResourceConstraints) DeepCopy() *DatadogPodAutoscalerContainerResourceConstraints { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerContainerResourceConstraints) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerContainerResourceTarget) DeepCopyInto(out *DatadogPodAutoscalerContainerResourceTarget) { + *out = *in + in.Value.DeepCopyInto(&out.Value) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerContainerResourceTarget. +func (in *DatadogPodAutoscalerContainerResourceTarget) DeepCopy() *DatadogPodAutoscalerContainerResourceTarget { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerContainerResourceTarget) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerContainerResources) DeepCopyInto(out *DatadogPodAutoscalerContainerResources) { + *out = *in + if in.Limits != nil { + in, out := &in.Limits, &out.Limits + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + if in.Requests != nil { + in, out := &in.Requests, &out.Requests + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerContainerResources. +func (in *DatadogPodAutoscalerContainerResources) DeepCopy() *DatadogPodAutoscalerContainerResources { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerContainerResources) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerHorizontalAction) DeepCopyInto(out *DatadogPodAutoscalerHorizontalAction) { + *out = *in + in.Time.DeepCopyInto(&out.Time) + if in.RecommendedReplicas != nil { + in, out := &in.RecommendedReplicas, &out.RecommendedReplicas + *out = new(int32) + **out = **in + } + if in.LimitedReason != nil { + in, out := &in.LimitedReason, &out.LimitedReason + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerHorizontalAction. +func (in *DatadogPodAutoscalerHorizontalAction) DeepCopy() *DatadogPodAutoscalerHorizontalAction { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerHorizontalAction) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerHorizontalStatus) DeepCopyInto(out *DatadogPodAutoscalerHorizontalStatus) { + *out = *in + if in.Target != nil { + in, out := &in.Target, &out.Target + *out = new(DatadogPodAutoscalerHorizontalTargetStatus) + (*in).DeepCopyInto(*out) + } + if in.LastActions != nil { + in, out := &in.LastActions, &out.LastActions + *out = make([]DatadogPodAutoscalerHorizontalAction, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerHorizontalStatus. +func (in *DatadogPodAutoscalerHorizontalStatus) DeepCopy() *DatadogPodAutoscalerHorizontalStatus { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerHorizontalStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerHorizontalTargetStatus) DeepCopyInto(out *DatadogPodAutoscalerHorizontalTargetStatus) { + *out = *in + in.GeneratedAt.DeepCopyInto(&out.GeneratedAt) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerHorizontalTargetStatus. +func (in *DatadogPodAutoscalerHorizontalTargetStatus) DeepCopy() *DatadogPodAutoscalerHorizontalTargetStatus { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerHorizontalTargetStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerList) DeepCopyInto(out *DatadogPodAutoscalerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]DatadogPodAutoscaler, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerList. +func (in *DatadogPodAutoscalerList) DeepCopy() *DatadogPodAutoscalerList { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DatadogPodAutoscalerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerPolicy) DeepCopyInto(out *DatadogPodAutoscalerPolicy) { + *out = *in + if in.Update != nil { + in, out := &in.Update, &out.Update + *out = new(DatadogPodAutoscalerUpdatePolicy) + **out = **in + } + if in.Upscale != nil { + in, out := &in.Upscale, &out.Upscale + *out = new(DatadogPodAutoscalerScalingPolicy) + (*in).DeepCopyInto(*out) + } + if in.Downscale != nil { + in, out := &in.Downscale, &out.Downscale + *out = new(DatadogPodAutoscalerScalingPolicy) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerPolicy. +func (in *DatadogPodAutoscalerPolicy) DeepCopy() *DatadogPodAutoscalerPolicy { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerResourceTarget) DeepCopyInto(out *DatadogPodAutoscalerResourceTarget) { + *out = *in + in.Value.DeepCopyInto(&out.Value) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerResourceTarget. +func (in *DatadogPodAutoscalerResourceTarget) DeepCopy() *DatadogPodAutoscalerResourceTarget { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerResourceTarget) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerScalingPolicy) DeepCopyInto(out *DatadogPodAutoscalerScalingPolicy) { + *out = *in + if in.Strategy != nil { + in, out := &in.Strategy, &out.Strategy + *out = new(DatadogPodAutoscalerScalingStrategySelect) + **out = **in + } + if in.Rules != nil { + in, out := &in.Rules, &out.Rules + *out = make([]DatadogPodAutoscalerScalingRule, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerScalingPolicy. +func (in *DatadogPodAutoscalerScalingPolicy) DeepCopy() *DatadogPodAutoscalerScalingPolicy { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerScalingPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerScalingRule) DeepCopyInto(out *DatadogPodAutoscalerScalingRule) { + *out = *in + if in.Match != nil { + in, out := &in.Match, &out.Match + *out = new(DatadogPodAutoscalerScalingRuleMatch) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerScalingRule. +func (in *DatadogPodAutoscalerScalingRule) DeepCopy() *DatadogPodAutoscalerScalingRule { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerScalingRule) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerSpec) DeepCopyInto(out *DatadogPodAutoscalerSpec) { + *out = *in + out.TargetRef = in.TargetRef + if in.RemoteVersion != nil { + in, out := &in.RemoteVersion, &out.RemoteVersion + *out = new(uint64) + **out = **in + } + if in.Policy != nil { + in, out := &in.Policy, &out.Policy + *out = new(DatadogPodAutoscalerPolicy) + (*in).DeepCopyInto(*out) + } + if in.Targets != nil { + in, out := &in.Targets, &out.Targets + *out = make([]DatadogPodAutoscalerTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Constraints != nil { + in, out := &in.Constraints, &out.Constraints + *out = new(DatadogPodAutoscalerConstraints) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerSpec. +func (in *DatadogPodAutoscalerSpec) DeepCopy() *DatadogPodAutoscalerSpec { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerStatus) DeepCopyInto(out *DatadogPodAutoscalerStatus) { + *out = *in + if in.Vertical != nil { + in, out := &in.Vertical, &out.Vertical + *out = new(DatadogPodAutoscalerVerticalStatus) + (*in).DeepCopyInto(*out) + } + if in.Horizontal != nil { + in, out := &in.Horizontal, &out.Horizontal + *out = new(DatadogPodAutoscalerHorizontalStatus) + (*in).DeepCopyInto(*out) + } + if in.CurrentReplicas != nil { + in, out := &in.CurrentReplicas, &out.CurrentReplicas + *out = new(int32) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]DatadogPodAutoscalerCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerStatus. +func (in *DatadogPodAutoscalerStatus) DeepCopy() *DatadogPodAutoscalerStatus { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerTarget) DeepCopyInto(out *DatadogPodAutoscalerTarget) { + *out = *in + if in.PodResource != nil { + in, out := &in.PodResource, &out.PodResource + *out = new(DatadogPodAutoscalerResourceTarget) + (*in).DeepCopyInto(*out) + } + if in.ContainerResource != nil { + in, out := &in.ContainerResource, &out.ContainerResource + *out = new(DatadogPodAutoscalerContainerResourceTarget) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerTarget. +func (in *DatadogPodAutoscalerTarget) DeepCopy() *DatadogPodAutoscalerTarget { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerTarget) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerTargetValue) DeepCopyInto(out *DatadogPodAutoscalerTargetValue) { + *out = *in + if in.Absolute != nil { + in, out := &in.Absolute, &out.Absolute + x := (*in).DeepCopy() + *out = &x + } + if in.Utilization != nil { + in, out := &in.Utilization, &out.Utilization + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerTargetValue. +func (in *DatadogPodAutoscalerTargetValue) DeepCopy() *DatadogPodAutoscalerTargetValue { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerTargetValue) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerUpdatePolicy) DeepCopyInto(out *DatadogPodAutoscalerUpdatePolicy) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerUpdatePolicy. +func (in *DatadogPodAutoscalerUpdatePolicy) DeepCopy() *DatadogPodAutoscalerUpdatePolicy { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerUpdatePolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerVerticalAction) DeepCopyInto(out *DatadogPodAutoscalerVerticalAction) { + *out = *in + in.Time.DeepCopyInto(&out.Time) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerVerticalAction. +func (in *DatadogPodAutoscalerVerticalAction) DeepCopy() *DatadogPodAutoscalerVerticalAction { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerVerticalAction) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerVerticalStatus) DeepCopyInto(out *DatadogPodAutoscalerVerticalStatus) { + *out = *in + if in.Target != nil { + in, out := &in.Target, &out.Target + *out = new(DatadogPodAutoscalerVerticalTargetStatus) + (*in).DeepCopyInto(*out) + } + if in.LastAction != nil { + in, out := &in.LastAction, &out.LastAction + *out = new(DatadogPodAutoscalerVerticalAction) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerVerticalStatus. +func (in *DatadogPodAutoscalerVerticalStatus) DeepCopy() *DatadogPodAutoscalerVerticalStatus { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerVerticalStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatadogPodAutoscalerVerticalTargetStatus) DeepCopyInto(out *DatadogPodAutoscalerVerticalTargetStatus) { + *out = *in + in.GeneratedAt.DeepCopyInto(&out.GeneratedAt) + if in.Scaled != nil { + in, out := &in.Scaled, &out.Scaled + *out = new(int32) + **out = **in + } + if in.DesiredResources != nil { + in, out := &in.DesiredResources, &out.DesiredResources + *out = make([]DatadogPodAutoscalerContainerResources, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + out.PODCPURequest = in.PODCPURequest.DeepCopy() + out.PODMemoryRequest = in.PODMemoryRequest.DeepCopy() +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerVerticalTargetStatus. +func (in *DatadogPodAutoscalerVerticalTargetStatus) DeepCopy() *DatadogPodAutoscalerVerticalTargetStatus { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerVerticalTargetStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DatadogSLO) DeepCopyInto(out *DatadogSLO) { *out = *in diff --git a/config/crd/bases/v1/datadoghq.com_datadogpodautoscalers.yaml b/config/crd/bases/v1/datadoghq.com_datadogpodautoscalers.yaml new file mode 100644 index 000000000..1007b3abc --- /dev/null +++ b/config/crd/bases/v1/datadoghq.com_datadogpodautoscalers.yaml @@ -0,0 +1,606 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: datadogpodautoscalers.datadoghq.com +spec: + group: datadoghq.com + names: + kind: DatadogPodAutoscaler + listKind: DatadogPodAutoscalerList + plural: datadogpodautoscalers + shortNames: + - dpa + singular: datadogpodautoscaler + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.policy.applyMode + name: Apply Mode + type: string + - jsonPath: .status.conditions[?(@.type=='Active')].status + name: Active + type: string + - jsonPath: .status.conditions[?(@.type=='Error')].status + name: In Error + type: string + - jsonPath: .status.horizontal.target.desiredReplicas + name: Desired Replicas + type: integer + - jsonPath: .status.horizontal.target.generatedAt + name: Generated + type: date + - jsonPath: .status.conditions[?(@.type=='HorizontalAbleToScale')].status + name: Able to Scale + type: string + - jsonPath: .status.horizontal.lastAction.time + name: Last Scale + type: date + - jsonPath: .status.vertical.target.podCPURequest + name: Target CPU Req + type: string + - jsonPath: .status.vertical.target.podMemoryRequest + name: Target Memory Req + type: string + - jsonPath: .status.vertical.target.generatedAt + name: Generated + type: date + - jsonPath: .status.conditions[?(@.type=='VerticalAbleToApply')].status + name: Able to Apply + type: string + - jsonPath: .status.vertical.lastAction.time + name: Last Trigger + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: DatadogPodAutoscaler is the Schema for the datadogpodautoscalers API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: DatadogPodAutoscalerSpec defines the desired state of DatadogPodAutoscaler + properties: + constraints: + description: Constraints defines constraints that should always be respected. + properties: + containers: + description: Containers defines constraints for the containers. + items: + description: |- + DatadogPodAutoscalerContainerConstraints defines constraints that should always be respected for a container. + If no constraints are set, it enables resources scaling for all containers without any constraints. + properties: + enabled: + description: Enabled false allows to disable resources autoscaling for the container. Default to true. + type: boolean + limits: + description: Limits defines the constraints for the limits of the container. + properties: + maxAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: MaxAllowed is the upper limit for the requests of the container. + type: object + minAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: MinAllowed is the lower limit for the requests of the container. + type: object + type: object + name: + description: Name is the name of the container. Can be "*" to apply to all containers. + type: string + requests: + description: Requests defines the constraints for the requests of the container. + properties: + maxAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: MaxAllowed is the upper limit for the requests of the container. + type: object + minAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: MinAllowed is the lower limit for the requests of the container. + type: object + type: object + required: + - name + type: object + type: array + maxReplicas: + description: MaxReplicas is the upper limit for the number of POD replicas. Needs to be >= minReplicas. + format: int32 + type: integer + minReplicas: + description: MinReplicas is the lower limit for the number of POD replicas. Needs to be >= 1. Default to 1. + format: int32 + minimum: 1 + type: integer + required: + - maxReplicas + type: object + owner: + description: |- + Owner defines the source of truth for this object (local or remote) + Value needs to be set when a DatadogPodAutoscaler object is created. + enum: + - Local + - Remote + type: string + policy: + default: {} + description: Policy defines how recommendations should be applied. + properties: + applyMode: + default: All + description: |- + ApplyMode determines recommendations that should be applied by the controller: + - All: Apply all recommendations (regular and manual). + - Manual: Apply only manual recommendations (recommendations manually validated by user in the Datadog app). + - None: Prevent the controller to apply any recommendations. + It's also possible to selectively deactivate upscale, downscale or update actions thanks to the `Upscale`, `Downscale` and `Update` fields. + enum: + - All + - Manual + - None + type: string + downscale: + description: Downscale defines the policy to scale down the target resource. + properties: + rules: + description: |- + Rules is a list of potential scaling polices which can be used during scaling. + At least one policy must be specified, otherwise the DatadogPodAutoscalerScalingPolicy will be discarded as invalid + items: + description: DatadogPodAutoscalerScalingRule define rules for horizontal that should be true for a certain amount of time. + properties: + match: + description: |- + Match defines if the rule should be considered or not in the calculation. + Default to Always if not set. + enum: + - Always + - IfScalingEvent + type: string + periodSeconds: + description: |- + PeriodSeconds specifies the window of time for which the policy should hold true. + PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). + format: int32 + maximum: 1800 + minimum: 1 + type: integer + type: + description: Type is used to specify the scaling policy. + enum: + - Pods + - Percent + type: string + value: + description: |- + Value contains the amount of change which is permitted by the policy. + Setting it to 0 will prevent any scaling in this direction and should not be used unless Match is set to IfScalingEvent. + format: int32 + minimum: 0 + type: integer + required: + - periodSeconds + - type + - value + type: object + type: array + x-kubernetes-list-type: atomic + strategy: + description: |- + Strategy is used to specify which policy should be used. + If not set, the default value Max is used. + enum: + - Max + - Min + - Disabled + type: string + type: object + update: + description: Update defines the policy to update target resource. + properties: + strategy: + description: Mode defines the mode of the update policy. + enum: + - Auto + - Disabled + type: string + type: object + upscale: + description: Upscale defines the policy to scale up the target resource. + properties: + rules: + description: |- + Rules is a list of potential scaling polices which can be used during scaling. + At least one policy must be specified, otherwise the DatadogPodAutoscalerScalingPolicy will be discarded as invalid + items: + description: DatadogPodAutoscalerScalingRule define rules for horizontal that should be true for a certain amount of time. + properties: + match: + description: |- + Match defines if the rule should be considered or not in the calculation. + Default to Always if not set. + enum: + - Always + - IfScalingEvent + type: string + periodSeconds: + description: |- + PeriodSeconds specifies the window of time for which the policy should hold true. + PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). + format: int32 + maximum: 1800 + minimum: 1 + type: integer + type: + description: Type is used to specify the scaling policy. + enum: + - Pods + - Percent + type: string + value: + description: |- + Value contains the amount of change which is permitted by the policy. + Setting it to 0 will prevent any scaling in this direction and should not be used unless Match is set to IfScalingEvent. + format: int32 + minimum: 0 + type: integer + required: + - periodSeconds + - type + - value + type: object + type: array + x-kubernetes-list-type: atomic + strategy: + description: |- + Strategy is used to specify which policy should be used. + If not set, the default value Max is used. + enum: + - Max + - Min + - Disabled + type: string + type: object + type: object + remoteVersion: + description: |- + RemoteVersion is the version of the .Spec currently store in this object. + Only set if the owner is Remote. + format: int64 + type: integer + targetRef: + description: TargetRef is the reference to the resource to scale. + properties: + apiVersion: + description: apiVersion is the API version of the referent + type: string + kind: + description: 'kind is the kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + name: + description: 'name is the name of the referent; More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + required: + - kind + - name + type: object + x-kubernetes-validations: + - message: Modifying the targetRef is not allowed. Please delete and re-create the DatadogPodAutoscaler object. + rule: self == oldSelf + targets: + description: |- + Targets are objectives to reach and maintain for the target resource. + Default to a single target to maintain 80% POD CPU utilization. + items: + description: DatadogPodAutoscalerTarget defines the objectives to reach and maintain for the target resource. + properties: + containerResource: + description: ContainerResource allows to set a container-level resource target. + properties: + container: + description: Container is the name of the container. + type: string + name: + description: Name is the name of the resource. + enum: + - cpu + type: string + value: + description: Value is the value of the target. + properties: + absolute: + anyOf: + - type: integer + - type: string + description: Absolute defines the absolute value of the target (for instance 500 millicores). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: Type specifies how the value is expressed (Absolute or Utilization). + type: string + utilization: + description: Utilization defines a percentage of the target compared to requested resource + format: int32 + maximum: 100 + minimum: 0 + type: integer + required: + - type + type: object + required: + - container + - name + - value + type: object + podResource: + description: PodResource allows to set a POD-level resource target. + properties: + name: + description: Name is the name of the resource. + enum: + - cpu + type: string + value: + description: Value is the value of the target. + properties: + absolute: + anyOf: + - type: integer + - type: string + description: Absolute defines the absolute value of the target (for instance 500 millicores). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: Type specifies how the value is expressed (Absolute or Utilization). + type: string + utilization: + description: Utilization defines a percentage of the target compared to requested resource + format: int32 + maximum: 100 + minimum: 0 + type: integer + required: + - type + type: object + required: + - name + - value + type: object + type: + description: Type sets the type of the target. + enum: + - PodResource + - ContainerResource + type: string + required: + - type + type: object + type: array + x-kubernetes-list-type: atomic + required: + - owner + - targetRef + type: object + status: + description: DatadogPodAutoscalerStatus defines the observed state of DatadogPodAutoscaler + properties: + conditions: + description: Conditions describe the current state of the DatadogPodAutoscaler operations. + items: + description: DatadogPodAutoscalerCondition describes the state of DatadogPodAutoscaler. + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status to another. + format: date-time + type: string + message: + description: A human readable message indicating details about the transition. + type: string + reason: + description: The reason for the condition's last transition. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of DatadogMetric condition. + type: string + required: + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + currentReplicas: + description: CurrentReplicas is the current number of PODs for the targetRef observed by the controller. + format: int32 + type: integer + horizontal: + description: Horizontal is the status of the horizontal scaling, if activated. + properties: + lastActions: + description: LastActions are the last successful actions done by the controller + items: + description: DatadogPodAutoscalerHorizontalAction represents an horizontal action done by the controller + properties: + limitedReason: + description: LimitedReason is the reason why the action was limited (ToReplicas != RecommendedReplicas) + type: string + recommendedReplicas: + description: RecommendedReplicas is the original number of replicas recommended by Datadog + format: int32 + type: integer + replicas: + description: FromReplicas is the number of replicas before the action + format: int32 + type: integer + time: + description: Time is the timestamp of the action + format: date-time + type: string + toReplicas: + description: ToReplicas is the effective number of replicas after the action + format: int32 + type: integer + required: + - replicas + - time + - toReplicas + type: object + type: array + target: + description: Target is the current target of the horizontal scaling + properties: + desiredReplicas: + description: Replicas is the desired number of replicas for the resource + format: int32 + type: integer + generatedAt: + description: GeneratedAt is the timestamp at which the recommendation was generated + format: date-time + type: string + source: + description: Source is the source of the value used to scale the target resource + type: string + required: + - desiredReplicas + - source + type: object + type: object + vertical: + description: Vertical is the status of the vertical scaling, if activated. + properties: + lastAction: + description: LastAction is the last successful action done by the controller + properties: + time: + description: Time is the timestamp of the action + format: date-time + type: string + type: + description: Type is the type of action + type: string + version: + description: Version is the recommendation version used for the action + type: string + required: + - time + - type + - version + type: object + target: + description: Target is the current target of the vertical scaling + properties: + desiredResources: + description: DesiredResources is the desired resources for containers + items: + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Limits describes the maximum amount of compute resources allowed. + type: object + name: + description: Name is the name of the container + type: string + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes target resources of compute resources allowed. + type: object + required: + - name + type: object + type: array + generatedAt: + description: GeneratedAt is the timestamp at which the recommendation was generated + format: date-time + type: string + podCPURequest: + anyOf: + - type: integer + - type: string + description: PODCPURequest is the sum of CPU requests for all containers (used for display) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + podMemoryRequest: + anyOf: + - type: integer + - type: string + description: PODMemoryRequest is the sum of memory requests for all containers (used for display) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + scaled: + description: Scaled is the current number of PODs having desired resources + format: int32 + type: integer + source: + description: Source is the source of the value used to scale the target resource + type: string + version: + description: Version is the current version of the received recommendation + type: string + required: + - desiredResources + - podCPURequest + - podMemoryRequest + - source + - version + type: object + type: object + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crd/bases/v1beta1/datadoghq.com_datadogpodautoscalers.yaml b/config/crd/bases/v1beta1/datadoghq.com_datadogpodautoscalers.yaml new file mode 100644 index 000000000..377924183 --- /dev/null +++ b/config/crd/bases/v1beta1/datadoghq.com_datadogpodautoscalers.yaml @@ -0,0 +1,566 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.6.1 + creationTimestamp: null + name: datadogpodautoscalers.datadoghq.com +spec: + additionalPrinterColumns: + - JSONPath: .spec.policy.applyMode + name: Apply Mode + type: string + - JSONPath: .status.conditions[?(@.type=='Active')].status + name: Active + type: string + - JSONPath: .status.conditions[?(@.type=='Error')].status + name: In Error + type: string + - JSONPath: .status.horizontal.target.desiredReplicas + name: Desired Replicas + type: integer + - JSONPath: .status.horizontal.target.generatedAt + name: Generated + type: date + - JSONPath: .status.conditions[?(@.type=='HorizontalAbleToScale')].status + name: Able to Scale + type: string + - JSONPath: .status.horizontal.lastAction.time + name: Last Scale + type: date + - JSONPath: .status.vertical.target.podCPURequest + name: Target CPU Req + type: string + - JSONPath: .status.vertical.target.podMemoryRequest + name: Target Memory Req + type: string + - JSONPath: .status.vertical.target.generatedAt + name: Generated + type: date + - JSONPath: .status.conditions[?(@.type=='VerticalAbleToApply')].status + name: Able to Apply + type: string + - JSONPath: .status.vertical.lastAction.time + name: Last Trigger + type: date + group: datadoghq.com + names: + kind: DatadogPodAutoscaler + listKind: DatadogPodAutoscalerList + plural: datadogpodautoscalers + shortNames: + - dpa + singular: datadogpodautoscaler + preserveUnknownFields: false + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + description: DatadogPodAutoscaler is the Schema for the datadogpodautoscalers API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: DatadogPodAutoscalerSpec defines the desired state of DatadogPodAutoscaler + properties: + constraints: + description: Constraints defines constraints that should always be respected. + properties: + containers: + description: Containers defines constraints for the containers. + items: + description: DatadogPodAutoscalerContainerConstraints defines constraints that should always be respected for a container. If no constraints are set, it enables resources scaling for all containers without any constraints. + properties: + enabled: + description: Enabled false allows to disable resources autoscaling for the container. Default to true. + type: boolean + limits: + description: Limits defines the constraints for the limits of the container. + properties: + maxAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: MaxAllowed is the upper limit for the requests of the container. + type: object + minAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: MinAllowed is the lower limit for the requests of the container. + type: object + type: object + name: + description: Name is the name of the container. Can be "*" to apply to all containers. + type: string + requests: + description: Requests defines the constraints for the requests of the container. + properties: + maxAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: MaxAllowed is the upper limit for the requests of the container. + type: object + minAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: MinAllowed is the lower limit for the requests of the container. + type: object + type: object + required: + - name + type: object + type: array + maxReplicas: + description: MaxReplicas is the upper limit for the number of POD replicas. Needs to be >= minReplicas. + format: int32 + type: integer + minReplicas: + description: MinReplicas is the lower limit for the number of POD replicas. Needs to be >= 1. Default to 1. + format: int32 + minimum: 1 + type: integer + required: + - maxReplicas + type: object + owner: + description: Owner defines the source of truth for this object (local or remote) Value needs to be set when a DatadogPodAutoscaler object is created. + enum: + - Local + - Remote + type: string + policy: + description: Policy defines how recommendations should be applied. + properties: + applyMode: + description: 'ApplyMode determines recommendations that should be applied by the controller: - All: Apply all recommendations (regular and manual). - Manual: Apply only manual recommendations (recommendations manually validated by user in the Datadog app). - None: Prevent the controller to apply any recommendations. It''s also possible to selectively deactivate upscale, downscale or update actions thanks to the `Upscale`, `Downscale` and `Update` fields.' + enum: + - All + - Manual + - None + type: string + downscale: + description: Downscale defines the policy to scale down the target resource. + properties: + rules: + description: Rules is a list of potential scaling polices which can be used during scaling. At least one policy must be specified, otherwise the DatadogPodAutoscalerScalingPolicy will be discarded as invalid + items: + description: DatadogPodAutoscalerScalingRule define rules for horizontal that should be true for a certain amount of time. + properties: + match: + description: Match defines if the rule should be considered or not in the calculation. Default to Always if not set. + enum: + - Always + - IfScalingEvent + type: string + periodSeconds: + description: PeriodSeconds specifies the window of time for which the policy should hold true. PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). + format: int32 + maximum: 1800 + minimum: 1 + type: integer + type: + description: Type is used to specify the scaling policy. + enum: + - Pods + - Percent + type: string + value: + description: Value contains the amount of change which is permitted by the policy. Setting it to 0 will prevent any scaling in this direction and should not be used unless Match is set to IfScalingEvent. + format: int32 + minimum: 0 + type: integer + required: + - periodSeconds + - type + - value + type: object + type: array + x-kubernetes-list-type: atomic + strategy: + description: Strategy is used to specify which policy should be used. If not set, the default value Max is used. + enum: + - Max + - Min + - Disabled + type: string + type: object + update: + description: Update defines the policy to update target resource. + properties: + strategy: + description: Mode defines the mode of the update policy. + enum: + - Auto + - Disabled + type: string + type: object + upscale: + description: Upscale defines the policy to scale up the target resource. + properties: + rules: + description: Rules is a list of potential scaling polices which can be used during scaling. At least one policy must be specified, otherwise the DatadogPodAutoscalerScalingPolicy will be discarded as invalid + items: + description: DatadogPodAutoscalerScalingRule define rules for horizontal that should be true for a certain amount of time. + properties: + match: + description: Match defines if the rule should be considered or not in the calculation. Default to Always if not set. + enum: + - Always + - IfScalingEvent + type: string + periodSeconds: + description: PeriodSeconds specifies the window of time for which the policy should hold true. PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). + format: int32 + maximum: 1800 + minimum: 1 + type: integer + type: + description: Type is used to specify the scaling policy. + enum: + - Pods + - Percent + type: string + value: + description: Value contains the amount of change which is permitted by the policy. Setting it to 0 will prevent any scaling in this direction and should not be used unless Match is set to IfScalingEvent. + format: int32 + minimum: 0 + type: integer + required: + - periodSeconds + - type + - value + type: object + type: array + x-kubernetes-list-type: atomic + strategy: + description: Strategy is used to specify which policy should be used. If not set, the default value Max is used. + enum: + - Max + - Min + - Disabled + type: string + type: object + type: object + remoteVersion: + description: RemoteVersion is the version of the .Spec currently store in this object. Only set if the owner is Remote. + format: int64 + type: integer + targetRef: + description: TargetRef is the reference to the resource to scale. + properties: + apiVersion: + description: API version of the referent + type: string + kind: + description: 'Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"' + type: string + name: + description: 'Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names' + type: string + required: + - kind + - name + type: object + targets: + description: Targets are objectives to reach and maintain for the target resource. Default to a single target to maintain 80% POD CPU utilization. + items: + description: DatadogPodAutoscalerTarget defines the objectives to reach and maintain for the target resource. + properties: + containerResource: + description: ContainerResource allows to set a container-level resource target. + properties: + container: + description: Container is the name of the container. + type: string + name: + description: Name is the name of the resource. + enum: + - cpu + type: string + value: + description: Value is the value of the target. + properties: + absolute: + anyOf: + - type: integer + - type: string + description: Absolute defines the absolute value of the target (for instance 500 millicores). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: Type specifies how the value is expressed (Absolute or Utilization). + type: string + utilization: + description: Utilization defines a percentage of the target compared to requested resource + format: int32 + maximum: 100 + minimum: 0 + type: integer + required: + - type + type: object + required: + - container + - name + - value + type: object + resource: + description: Resource allows to set a POD-level resource target. + properties: + name: + description: Name is the name of the resource. + enum: + - cpu + type: string + value: + description: Value is the value of the target. + properties: + absolute: + anyOf: + - type: integer + - type: string + description: Absolute defines the absolute value of the target (for instance 500 millicores). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: Type specifies how the value is expressed (Absolute or Utilization). + type: string + utilization: + description: Utilization defines a percentage of the target compared to requested resource + format: int32 + maximum: 100 + minimum: 0 + type: integer + required: + - type + type: object + required: + - name + - value + type: object + type: + description: Type sets the type of the target. + enum: + - Resource + - ContainerResource + type: string + required: + - type + type: object + type: array + x-kubernetes-list-type: atomic + required: + - owner + - targetRef + type: object + status: + description: DatadogPodAutoscalerStatus defines the observed state of DatadogPodAutoscaler + properties: + conditions: + description: Conditions describe the current state of the DatadogPodAutoscaler operations. + items: + description: DatadogPodAutoscalerCondition describes the state of DatadogPodAutoscaler. + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status to another. + format: date-time + type: string + message: + description: A human readable message indicating details about the transition. + type: string + reason: + description: The reason for the condition's last transition. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of DatadogMetric condition. + type: string + required: + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + currentReplicas: + description: CurrentReplicas is the current number of PODs for the targetRef observed by the controller. + format: int32 + type: integer + horizontal: + description: Horizontal is the status of the horizontal scaling, if activated. + properties: + lastAction: + description: LastAction is the last successful action done by the controller + properties: + limitedReason: + description: LimitedReason is the reason why the action was limited (ToReplicas != RecommendedReplicas) + type: string + recommendedReplicas: + description: RecommendedReplicas is the original number of replicas recommended by Datadog + format: int32 + type: integer + replicas: + description: FromReplicas is the number of replicas before the action + format: int32 + type: integer + time: + description: Time is the timestamp of the action + format: date-time + type: string + toReplicas: + description: ToReplicas is the effective number of replicas after the action + format: int32 + type: integer + required: + - replicas + - time + - toReplicas + type: object + target: + description: Target is the current target of the horizontal scaling + properties: + desiredReplicas: + description: Replicas is the desired number of replicas for the resource + format: int32 + type: integer + generatedAt: + description: GeneratedAt is the timestamp at which the recommendation was generated + format: date-time + type: string + source: + description: Source is the source of the value used to scale the target resource + type: string + required: + - desiredReplicas + - source + type: object + type: object + vertical: + description: Vertical is the status of the vertical scaling, if activated. + properties: + lastAction: + description: LastAction is the last successful action done by the controller + properties: + time: + description: Time is the timestamp of the action + format: date-time + type: string + type: + description: Type is the type of action + type: string + version: + description: Version is the recommendation version used for the action + type: string + required: + - time + - type + - version + type: object + target: + description: Target is the current target of the vertical scaling + properties: + desiredResources: + description: DesiredResources is the desired resources for containers + items: + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Limits describes the maximum amount of compute resources allowed. + type: object + name: + description: Name is the name of the container + type: string + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes target resources of compute resources allowed. + type: object + required: + - name + type: object + type: array + generatedAt: + description: GeneratedAt is the timestamp at which the recommendation was generated + format: date-time + type: string + podCPURequest: + anyOf: + - type: integer + - type: string + description: PODCPURequest is the sum of CPU requests for all containers (used for display) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + podMemoryRequest: + anyOf: + - type: integer + - type: string + description: PODMemoryRequest is the sum of memory requests for all containers (used for display) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + scaled: + description: Scaled is the current number of PODs having desired resources + format: int32 + type: integer + source: + description: Source is the source of the value used to scale the target resource + type: string + version: + description: Version is the current version of the received recommendation + type: string + required: + - desiredResources + - podCPURequest + - podMemoryRequest + - source + - version + type: object + type: object + type: object + type: object + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 35544a69b..b69056a00 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -7,6 +7,7 @@ resources: - bases/v1/datadoghq.com_datadogmonitors.yaml - bases/v1/datadoghq.com_datadogslos.yaml - bases/v1/datadoghq.com_datadogagentprofiles.yaml +- bases/v1/datadoghq.com_datadogpodautoscalers.yaml # +kubebuilder:scaffold:crdkustomizeresource # patchesStrategicMerge: @@ -16,6 +17,7 @@ resources: #- patches/webhook_in_datadogmetrics.yaml #- patches/webhook_in_datadogmonitors.yaml #- patches/webhook_in_datadogagentprofiles.yaml +#- patches/webhook_in_datadogpodautoscalers.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. @@ -24,6 +26,7 @@ resources: #- patches/cainjection_in_datadogmetrics.yaml #- patches/cainjection_in_datadogmonitors.yaml #- patches/cainjection_in_datadogagentprofiles.yaml +#- patches/cainjection_in_datadogpodautoscalers.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/crd/patches/cainjection_in_datadoghq_datadogpodautoscalers.yaml b/config/crd/patches/cainjection_in_datadoghq_datadogpodautoscalers.yaml new file mode 100644 index 000000000..766cff891 --- /dev/null +++ b/config/crd/patches/cainjection_in_datadoghq_datadogpodautoscalers.yaml @@ -0,0 +1,7 @@ +# The following patch adds a directive for certmanager to inject CA into the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + name: datadogpodautoscalers.datadoghq.com diff --git a/config/crd/patches/webhook_in_datadoghq_datadogpodautoscalers.yaml b/config/crd/patches/webhook_in_datadoghq_datadogpodautoscalers.yaml new file mode 100644 index 000000000..c0657a783 --- /dev/null +++ b/config/crd/patches/webhook_in_datadoghq_datadogpodautoscalers.yaml @@ -0,0 +1,16 @@ +# The following patch enables a conversion webhook for the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: datadogpodautoscalers.datadoghq.com +spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + namespace: system + name: webhook-service + path: /convert + conversionReviewVersions: + - v1 diff --git a/config/rbac/datadoghq_datadogpodautoscaler_editor_role.yaml b/config/rbac/datadoghq_datadogpodautoscaler_editor_role.yaml new file mode 100644 index 000000000..978a1c2f0 --- /dev/null +++ b/config/rbac/datadoghq_datadogpodautoscaler_editor_role.yaml @@ -0,0 +1,24 @@ +# permissions for end users to edit datadogpodautoscalers. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: datadogpodautoscaler-editor-role +rules: +- apiGroups: + - datadoghq.com + resources: + - datadogpodautoscalers + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - datadoghq.com + resources: + - datadogpodautoscalers/status + verbs: + - get diff --git a/config/rbac/datadoghq_datadogpodautoscaler_viewer_role.yaml b/config/rbac/datadoghq_datadogpodautoscaler_viewer_role.yaml new file mode 100644 index 000000000..9bed75e4a --- /dev/null +++ b/config/rbac/datadoghq_datadogpodautoscaler_viewer_role.yaml @@ -0,0 +1,20 @@ +# permissions for end users to view datadogpodautoscalers. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: datadogpodautoscaler-viewer-role +rules: +- apiGroups: + - datadoghq.com + resources: + - datadogpodautoscalers + verbs: + - get + - list + - watch +- apiGroups: + - datadoghq.com + resources: + - datadogpodautoscalers/status + verbs: + - get diff --git a/config/samples/datadoghq_v1alpha1_datadogpodautoscaler.yaml b/config/samples/datadoghq_v1alpha1_datadogpodautoscaler.yaml new file mode 100644 index 000000000..a3b1d97dd --- /dev/null +++ b/config/samples/datadoghq_v1alpha1_datadogpodautoscaler.yaml @@ -0,0 +1,6 @@ +apiVersion: datadoghq.com/v1alpha1 +kind: DatadogPodAutoscaler +metadata: + name: datadogpodautoscaler-sample +spec: + # TODO(user): Add fields here diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index 9f8baceff..f8209c0e4 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -5,4 +5,5 @@ resources: - datadoghq_v1alpha1_datadogmonitor.yaml - datadoghq_v1alpha1_datadogagentprofile.yaml - datadoghq_v1alpha1_datadogslo.yaml +- datadoghq_v1alpha1_datadogpodautoscaler.yaml # +kubebuilder:scaffold:manifestskustomizesamples diff --git a/hack/patch-crds.sh b/hack/patch-crds.sh index f3be2130f..331e987c0 100755 --- a/hack/patch-crds.sh +++ b/hack/patch-crds.sh @@ -23,8 +23,6 @@ done $YQ -i 'del(.spec.validation.openAPIV3Schema.properties.status.properties.defaultOverride)' "$ROOT/$v1beta1/datadoghq.com_datadogagents.yaml" $YQ -i 'del(.spec.versions[].schema.openAPIV3Schema.properties.status.properties.defaultOverride)' "$ROOT/$v1/datadoghq.com_datadogagents.yaml" - - # Pretty print CRD files so they they all have same formatting for crd in "$ROOT/$v1beta1"/*.yaml do