From 949a7fb407ebabd84f264a1a4b80ad26f7acce30 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 | 383 ++++++++++++++ .../v1alpha1/zz_generated.deepcopy.go | 476 ++++++++++++++++++ .../datadoghq.com_datadogpodautoscalers.yaml | 373 ++++++++++++++ .../datadoghq.com_datadogpodautoscalers.yaml | 375 ++++++++++++++ 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 + 12 files changed, 1693 insertions(+) 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 317d4eab8c..593792948c 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 0000000000..ee60aa24b7 --- /dev/null +++ b/apis/datadoghq/v1alpha1/datadogpodautoscaler_types.go @@ -0,0 +1,383 @@ +// 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" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// spec: +// targetRef: +// apiVersion: apps/v1 +// kind: Deployment +// name: test +// owner: local +// policy: +// update: +// mode: Auto|DryRun +// recommender: +// name: containerMetrics +// containerMetrics: +// cpuUtilizationTarget: 60 +// constraints: +// minReplicas: 1 +// maxReplicas: 10 +// containers: +// - name: "*" +// enabled: true +// requests: +// minAllowed: +// maxAllowed: +// limits: +// minAllowed: +// maxAllowed: + +// DatadogPodAutoscalerSpec defines the desired state of DatadogPodAutoscaler +type DatadogPodAutoscalerSpec struct { + // TargetRef is the reference to the resource to scale. + 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. + 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:=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" +) + +// DatadogPodAutoscalerPolicy defines how recommendations should be applied. +type DatadogPodAutoscalerPolicy struct { + // 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"` +} + +// DatadogPodAutoscalerUpdateMode defines the mode of the update policy. +// +kubebuilder:validation:Enum:=Auto;DryRun +type DatadogPodAutoscalerUpdateMode string + +const ( + // DatadogPodAutoscalerAutoMode is the default mode. + DatadogPodAutoscalerAutoMode DatadogPodAutoscalerUpdateMode = "Auto" + + // DatadogPodAutoscalerDrynRunMode will skip the update of the target resource. + DatadogPodAutoscalerDrynRunMode DatadogPodAutoscalerUpdateMode = "DryRun" +) + +// DatadogPodAutoscalerUpdatePolicy defines the policy to update target resource. +type DatadogPodAutoscalerUpdatePolicy struct { + // Mode defines the mode of the update policy. + Mode DatadogPodAutoscalerUpdateMode `json:"mode,omitempty"` +} + +// +// Scaling policy is inspired by the HorizontalPodAutoscalerV2 +// https://github.com/kubernetes/api/blob/master/autoscaling/v2/types.go +// Copyright 2021 The Kubernetes Authors. +// + +// DatadogPodAutoscalerScalingPolicySelect is used to specify which policy should be used while scaling in a certain direction +type DatadogPodAutoscalerScalingPolicySelect string + +const ( + // MaxChangePolicySelect selects the policy with the highest possible change. + MaxChangePolicySelect DatadogPodAutoscalerScalingPolicySelect = "Max" + + // MinChangePolicySelect selects the policy with the lowest possible change. + MinChangePolicySelect DatadogPodAutoscalerScalingPolicySelect = "Min" + + // DisabledPolicySelect disables the scaling in this direction. + DisabledPolicySelect DatadogPodAutoscalerScalingPolicySelect = "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 *DatadogPodAutoscalerScalingPolicySelect `json:"selectPolicy,omitempty"` + + // Rules is a list of potential scaling polices which can be used during scaling. + // At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid + // +listType=atomic + // +optional + Rules []DatadogPodAutoscalerScalingRule `json:"policies,omitempty"` +} + +// DatadogPodAutoscalerScalingRuleType is the type of the policy which could be used while making scaling decisions. +type DatadogPodAutoscalerScalingRuleType string + +const ( + // PodsScalingPolicy is a policy used to specify a change in absolute number of pods. + PodsScalingPolicy DatadogPodAutoscalerScalingRuleType = "Pods" + + // PercentScalingPolicy is a policy used to specify a relative amount of change with respect to + // the current number of pods. + PercentScalingPolicy 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 { + // RecommendationsVersion holds the version of the recommendation + // +optional + RecommendationsVersion *uint64 `json:"recommendationsVersion,omitempty"` + + // UpdateTime is the timestamp at which the last recommendation was received + // +optional + UpdateTime *metav1.Time `json:"updateTime,omitempty"` + + // 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 + // +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"` +} + +// DatadogPodAutoscalerHorizontalStatus defines the status of the horizontal scaling +type DatadogPodAutoscalerHorizontalStatus struct { + // DesiredReplicas is the desired number of replicas for the resource + DesiredReplicas int32 `json:"desiredReplicas"` + + // LastAction is the last successful action done by the controller + LastAction *DatadogPodAutoscalerHorizontalAction `json:"lastAction,omitempty"` +} + +// 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 { + // Scaled is the current number of PODs having desired resources + Scaled *int32 `json:"scaled"` + + // DesiredResources is the desired resources for containers + DesiredResources []DatadogPodAutoscalerContainerResources `json:"desiredResources"` + + // LastAction is the last successful action done by the controller + LastAction *DatadogPodAutoscalerVerticalAction `json:"lastAction,omitempty"` +} + +// DatadogPodAutoscalerVerticalActionType represents the type of action done by the controller +type DatadogPodAutoscalerVerticalActionType string + +const ( + // RolloutTriggered is the action when the controller triggers a rollout of the targetRef + RolloutTriggered 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"` + + // 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 by the controller. + DatadogPodAutoscalerErrorCondition DatadogPodAutoscalerConditionType = "Error" + + // DatadogPodAutoscalerHorizontalAbleToScaleCondition is true when horizontal scaling is working correctly. + DatadogPodAutoscalerHorizontalAbleToScaleCondition DatadogPodAutoscalerConditionType = "HorizontalAbleToScale" + + // DatadogPodAutoscalerVerticalAbleToRollout is true when we can rollout the targetRef to pick up patched resources. + DatadogPodAutoscalerVerticalAbleToRollout DatadogPodAutoscalerConditionType = "VerticalAbleToRollout" +) + +// 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:subresource:status + +// 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 2f04982ece..75f75da1a5 100644 --- a/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go +++ b/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go @@ -1663,6 +1663,482 @@ 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.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 *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(DatadogPodAutoscalerScalingPolicySelect) + **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.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.RecommendationsVersion != nil { + in, out := &in.RecommendationsVersion, &out.RecommendationsVersion + *out = new(uint64) + **out = **in + } + if in.UpdateTime != nil { + in, out := &in.UpdateTime, &out.UpdateTime + *out = (*in).DeepCopy() + } + 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.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]) + } + } + 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 *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 0000000000..69a99bde7b --- /dev/null +++ b/config/crd/bases/v1/datadoghq.com_datadogpodautoscalers.yaml @@ -0,0 +1,373 @@ + +--- +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 + singular: datadogpodautoscaler + scope: Namespaced + versions: + - 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: + downscale: + description: Downscale defines the policy to scale up the target resource. + properties: + policies: + description: Rules is a list of potential scaling polices which can be used during scaling. At least one policy must be specified, otherwise the HPAScalingRules 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. + 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 + selectPolicy: + description: Strategy is used to specify which policy should be used. If not set, the default value Max is used. + type: string + type: object + update: + description: Update defines the policy to update target resource. + properties: + mode: + description: Mode defines the mode of the update policy. + enum: + - Auto + - DryRun + type: string + type: object + upscale: + description: Upscale defines the policy to scale up the target resource. + properties: + policies: + description: Rules is a list of potential scaling polices which can be used during scaling. At least one policy must be specified, otherwise the HPAScalingRules 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. + 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 + selectPolicy: + description: Strategy is used to specify which policy should be used. If not set, the default value Max is used. + 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 + format: int32 + type: integer + horizontal: + description: Horizontal is the status of the horizontal scaling, if activated. + properties: + desiredReplicas: + description: DesiredReplicas is the desired number of replicas for the resource + format: int32 + type: integer + 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 + required: + - desiredReplicas + type: object + recommendationsVersion: + description: RecommendationsVersion holds the version of the recommendation + format: int64 + type: integer + updateTime: + description: UpdateTime is the timestamp at which the last recommendation was received + format: date-time + type: string + vertical: + description: Vertical is the status of the vertical scaling, if activated. + 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 + 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 + required: + - time + - type + type: object + scaled: + description: Scaled is the current number of PODs having desired resources + format: int32 + type: integer + required: + - desiredResources + - scaled + 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 0000000000..2ee18d847a --- /dev/null +++ b/config/crd/bases/v1beta1/datadoghq.com_datadogpodautoscalers.yaml @@ -0,0 +1,375 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +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 + 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: + downscale: + description: Downscale defines the policy to scale up the target resource. + properties: + policies: + description: Rules is a list of potential scaling polices which can be used during scaling. At least one policy must be specified, otherwise the HPAScalingRules 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. + 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 + selectPolicy: + description: Strategy is used to specify which policy should be used. If not set, the default value Max is used. + type: string + type: object + update: + description: Update defines the policy to update target resource. + properties: + mode: + description: Mode defines the mode of the update policy. + enum: + - Auto + - DryRun + type: string + type: object + upscale: + description: Upscale defines the policy to scale up the target resource. + properties: + policies: + description: Rules is a list of potential scaling polices which can be used during scaling. At least one policy must be specified, otherwise the HPAScalingRules 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. + 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 + selectPolicy: + description: Strategy is used to specify which policy should be used. If not set, the default value Max is used. + 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 + format: int32 + type: integer + horizontal: + description: Horizontal is the status of the horizontal scaling, if activated. + properties: + desiredReplicas: + description: DesiredReplicas is the desired number of replicas for the resource + format: int32 + type: integer + 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 + required: + - desiredReplicas + type: object + recommendationsVersion: + description: RecommendationsVersion holds the version of the recommendation + format: int64 + type: integer + updateTime: + description: UpdateTime is the timestamp at which the last recommendation was received + format: date-time + type: string + vertical: + description: Vertical is the status of the vertical scaling, if activated. + 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 + 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 + required: + - time + - type + type: object + scaled: + description: Scaled is the current number of PODs having desired resources + format: int32 + type: integer + required: + - desiredResources + - scaled + 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 4af5fc3112..5fbc4ca73b 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 0000000000..766cff8911 --- /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 0000000000..c0657a7838 --- /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 0000000000..978a1c2f05 --- /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 0000000000..9bed75e4af --- /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 0000000000..a3b1d97dd4 --- /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 3308947a59..6095faa9ca 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