From e83dd785258a2b46ca7a5e5133bd7cf602a2636c Mon Sep 17 00:00:00 2001 From: Vincent Boulineau Date: Mon, 25 Mar 2024 17:19:46 +0100 Subject: [PATCH] Add DatadogPodAutoscaler resource --- PROJECT | 8 + .../v1alpha1/datadogpodautoscaler_types.go | 489 +++++++++++++++++ .../v1alpha1/zz_generated.deepcopy.go | 516 ++++++++++++++++++ .../datadoghq.com_datadogpodautoscalers.yaml | 474 ++++++++++++++++ .../datadoghq.com_datadogpodautoscalers.yaml | 474 ++++++++++++++++ config/crd/kustomization.yaml | 4 + ...on_in_datadoghq_datadogpodautoscalers.yaml | 7 + ...ok_in_datadoghq_datadogpodautoscalers.yaml | 16 + ...oghq_datadogpodautoscaler_editor_role.yaml | 24 + ...oghq_datadogpodautoscaler_viewer_role.yaml | 20 + ...tadoghq_v1alpha1_datadogpodautoscaler.yaml | 6 + config/samples/kustomization.yaml | 1 + hack/patch-crds.sh | 3 +- 13 files changed, 2041 insertions(+), 1 deletion(-) create mode 100644 apis/datadoghq/v1alpha1/datadogpodautoscaler_types.go create mode 100644 config/crd/bases/v1/datadoghq.com_datadogpodautoscalers.yaml create mode 100644 config/crd/bases/v1beta1/datadoghq.com_datadogpodautoscalers.yaml create mode 100644 config/crd/patches/cainjection_in_datadoghq_datadogpodautoscalers.yaml create mode 100644 config/crd/patches/webhook_in_datadoghq_datadogpodautoscalers.yaml create mode 100644 config/rbac/datadoghq_datadogpodautoscaler_editor_role.yaml create mode 100644 config/rbac/datadoghq_datadogpodautoscaler_viewer_role.yaml create mode 100644 config/samples/datadoghq_v1alpha1_datadogpodautoscaler.yaml diff --git a/PROJECT b/PROJECT index 317d4eab8..593792948 100644 --- a/PROJECT +++ b/PROJECT @@ -52,4 +52,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..f96e4da77 --- /dev/null +++ b/apis/datadoghq/v1alpha1/datadogpodautoscaler_types.go @@ -0,0 +1,489 @@ +// 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 +// recommender: +// name: containerMetrics +// containerMetrics: +// cpuUtilizationTarget: 60 +// 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"` + + // Recommender defines the recommender to use for the autoscaler and its settings. + // Default to the `containerMetrics` recommender. + Recommender *DatadogPodAutoscalerRecommender `json:"recommender,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" + + // DatadogPodAutoscalerAllApplyNone 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. + DatadogPodAutoscalerAllApplyNone 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 up 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 is the type of the policy which could be used while making scaling decisions. +// +kubebuilder:validation:Enum:=Pods;Percent +type DatadogPodAutoscalerScalingRuleType string + +const ( + // DatadogPodAutoscalerPodsScalingRuleType is a policy used to specify a change in absolute number of pods. + DatadogPodAutoscalerPodsScalingRuleType DatadogPodAutoscalerScalingRuleType = "Pods" + + // DatadogPodAutoscalerPercentScalingRuleType is a policy used to specify a relative amount of change with respect to + // the current number of pods. + DatadogPodAutoscalerPercentScalingRuleType DatadogPodAutoscalerScalingRuleType = "Percent" +) + +// 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. + // It must be greater than zero + 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). + PeriodSeconds int32 `json:"periodSeconds"` +} + +// DatadogPodAutoscalerUpdateMode defines the mode of the update policy. +// +kubebuilder:validation:Enum:=ContainerMetrics +type DatadogPodAutoscalerRecommenderName string + +const ( + // DatadogPodAutoscalerContainerMetricsRecommender uses container resources metrics. + DatadogPodAutoscalerContainerMetricsRecommender DatadogPodAutoscalerRecommenderName = "ContainerMetrics" +) + +// DatadogPodAutoscalerRecommender defines the recommender to use for the autoscaler and its settings. +type DatadogPodAutoscalerRecommender struct { + // Name is the name of the recommender to use. + Name DatadogPodAutoscalerRecommenderName `json:"name"` + + // ContainerMetrics is the settings for the ContainerMetrics recommender. + ContainerMetrics *DatadogPodAutoscalerContainerMetricsRecommenderSettings `json:"containerMetrics,omitempty"` +} + +// DatadogPodAutoscalerContainerMetricsRecommenderSettings defines the settings for the ContainerMetrics recommender. +type DatadogPodAutoscalerContainerMetricsRecommenderSettings struct { + // CPUUtilizationTarget is the target CPU utilization for the containers. + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=100 + CPUUtilizationTarget *int32 `json:"cpuUtilizationTarget,omitempty"` +} + +// 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"` + + // LastAction is the last successful action done by the controller + LastAction *DatadogPodAutoscalerHorizontalAction `json:"lastAction,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 number of replicas after the action + ToReplicas int32 `json:"toReplicas"` +} + +// 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" + + // 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 2f04982ec..d1f8e699a 100644 --- a/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go +++ b/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go @@ -1663,6 +1663,522 @@ 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 *DatadogPodAutoscalerContainerMetricsRecommenderSettings) DeepCopyInto(out *DatadogPodAutoscalerContainerMetricsRecommenderSettings) { + *out = *in + if in.CPUUtilizationTarget != nil { + in, out := &in.CPUUtilizationTarget, &out.CPUUtilizationTarget + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerContainerMetricsRecommenderSettings. +func (in *DatadogPodAutoscalerContainerMetricsRecommenderSettings) DeepCopy() *DatadogPodAutoscalerContainerMetricsRecommenderSettings { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerContainerMetricsRecommenderSettings) + 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 *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) +} + +// 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.LastAction != nil { + in, out := &in.LastAction, &out.LastAction + *out = new(DatadogPodAutoscalerHorizontalAction) + (*in).DeepCopyInto(*out) + } +} + +// 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 *DatadogPodAutoscalerRecommender) DeepCopyInto(out *DatadogPodAutoscalerRecommender) { + *out = *in + if in.ContainerMetrics != nil { + in, out := &in.ContainerMetrics, &out.ContainerMetrics + *out = new(DatadogPodAutoscalerContainerMetricsRecommenderSettings) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatadogPodAutoscalerRecommender. +func (in *DatadogPodAutoscalerRecommender) DeepCopy() *DatadogPodAutoscalerRecommender { + if in == nil { + return nil + } + out := new(DatadogPodAutoscalerRecommender) + 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)) + copy(*out, *in) + } +} + +// 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 +} + +// 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.Recommender != nil { + in, out := &in.Recommender, &out.Recommender + *out = new(DatadogPodAutoscalerRecommender) + (*in).DeepCopyInto(*out) + } + 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 *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..80b30457e --- /dev/null +++ b/config/crd/bases/v1/datadoghq.com_datadogpodautoscalers.yaml @@ -0,0 +1,474 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.6.1 + creationTimestamp: null + 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: + 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 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: + 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 + 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. It must be greater than zero + format: int32 + 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: + 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 + 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. It must be greater than zero + format: int32 + 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 + default: {} + recommender: + description: Recommender defines the recommender to use for the autoscaler and its settings. Default to the `containerMetrics` recommender. + properties: + containerMetrics: + description: ContainerMetrics is the settings for the ContainerMetrics recommender. + properties: + cpuUtilizationTarget: + description: CPUUtilizationTarget is the target CPU utilization for the containers. + format: int32 + maximum: 100 + minimum: 0 + type: integer + type: object + name: + description: Name is the name of the recommender to use. + enum: + - ContainerMetrics + type: string + required: + - name + 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 + 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: + 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 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 + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] 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..594573332 --- /dev/null +++ b/config/crd/bases/v1beta1/datadoghq.com_datadogpodautoscalers.yaml @@ -0,0 +1,474 @@ + +--- +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 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: + 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 + 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. It must be greater than zero + format: int32 + 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: + 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 + 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. It must be greater than zero + format: int32 + 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 + recommender: + description: Recommender defines the recommender to use for the autoscaler and its settings. Default to the `containerMetrics` recommender. + properties: + containerMetrics: + description: ContainerMetrics is the settings for the ContainerMetrics recommender. + properties: + cpuUtilizationTarget: + description: CPUUtilizationTarget is the target CPU utilization for the containers. + format: int32 + maximum: 100 + minimum: 0 + type: integer + type: object + name: + description: Name is the name of the recommender to use. + enum: + - ContainerMetrics + type: string + required: + - name + 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 + 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: + 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 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 4af5fc311..5fbc4ca73 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -7,6 +7,8 @@ resources: - bases/v1/datadoghq.com_datadogmonitors.yaml - bases/v1/datadoghq.com_datadogslos.yaml - bases/v1/datadoghq.com_datadogagentprofiles.yaml +# Currently not shipping DPA +# - bases/v1/datadoghq.com_datadogpodautoscalers.yaml # +kubebuilder:scaffold:crdkustomizeresource patchesStrategicMerge: @@ -16,6 +18,7 @@ patchesStrategicMerge: #- 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 +27,7 @@ patchesStrategicMerge: #- 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 3308947a5..6095faa9c 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -5,4 +5,5 @@ resources: - datadogmetric-v1alpha1.yaml - datadoghq_v1alpha1_datadogmonitor.yaml - datadoghq_v1alpha1_datadogagentprofile.yaml +- datadoghq_v1alpha1_datadogpodautoscaler.yaml # +kubebuilder:scaffold:manifestskustomizesamples diff --git a/hack/patch-crds.sh b/hack/patch-crds.sh index f3be2130f..73e123edf 100755 --- a/hack/patch-crds.sh +++ b/hack/patch-crds.sh @@ -23,7 +23,8 @@ 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" - +# Patch DatadogPodAutoscaler policy field as `controller-gen` v0.6.2 does not support `+kubebuilder:default={}` on objects +$YQ -i '.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.policy.default = {}' "$ROOT/$v1/datadoghq.com_datadogpodautoscalers.yaml" # Pretty print CRD files so they they all have same formatting for crd in "$ROOT/$v1beta1"/*.yaml