alpha ver. of deployments resource controller
Some checks failed
Lint / Run on Ubuntu (push) Failing after 53s
Tests / Run on Ubuntu (push) Successful in 55s

This commit is contained in:
2025-05-01 18:00:10 +05:00
parent fc5f580243
commit 23b333c07d
7 changed files with 315 additions and 0 deletions

View File

@@ -23,6 +23,22 @@ import (
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// ResourceDefaults defines the default resource requests and limits.
type ResourceDefaults struct {
// Default CPU request (e.g., "100m"). Applied if a container has no CPU request.
// +optional
CPURequest string `json:"cpuRequest,omitempty"`
// Default Memory request (e.g., "128Mi"). Applied if a container has no Memory request.
// +optional
MemoryRequest string `json:"memoryRequest,omitempty"`
// Default CPU limit (e.g., "500m"). Applied if a container has no CPU limit.
// +optional
CPULimit string `json:"cpuLimit,omitempty"`
// Default Memory limit (e.g., "512Mi"). Applied if a container has no Memory limit.
// +optional
MemoryLimit string `json:"memoryLimit,omitempty"`
}
// NodeTainterConfigSpec defines the desired state of NodeTainterConfig.
type NodeTainterConfigSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
@@ -38,7 +54,20 @@ type NodeTainterConfigSpec struct {
// +kubebuilder:validation:Optional
// +kubebuilder:validation:MinProperties=1
// +optional
LabelRules map[string]string `json:"labelRules,omitempty"`
// ResourceDefaults contains the default requests/limits to apply.
// If this section is omitted, resource defaulting is disabled.
// +optional
ResourceDefaults *ResourceDefaults `json:"resourceDefaults,omitempty"`
// OptOutLabelKey is the label key used to exempt Deployments from resource defaulting.
// If a Deployment has a label with this key (any value), defaults won't be applied.
// If empty or omitted, the opt-out mechanism is disabled.
// Example: "my-operator.example.com/skip-resource-defaults"
// +optional
OptOutLabelKey string `json:"optOutLabelKey,omitempty"`
}
// NodeTainterConfigStatus defines the observed state of NodeTainterConfig.

View File

@@ -114,6 +114,11 @@ func (in *NodeTainterConfigSpec) DeepCopyInto(out *NodeTainterConfigSpec) {
(*out)[key] = val
}
}
if in.ResourceDefaults != nil {
in, out := &in.ResourceDefaults, &out.ResourceDefaults
*out = new(ResourceDefaults)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeTainterConfigSpec.
@@ -154,3 +159,18 @@ func (in *NodeTainterConfigStatus) DeepCopy() *NodeTainterConfigStatus {
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceDefaults) DeepCopyInto(out *ResourceDefaults) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceDefaults.
func (in *ResourceDefaults) DeepCopy() *ResourceDefaults {
if in == nil {
return nil
}
out := new(ResourceDefaults)
in.DeepCopyInto(out)
return out
}