mvp of Node Tainter

This commit is contained in:
2025-04-29 22:54:55 +05:00
parent ac36dd70b6
commit 01b75983e3
8 changed files with 700 additions and 21 deletions

View File

@@ -29,16 +29,37 @@ type NodeTainterConfigSpec struct {
// Important: Run "make" to regenerate code after modifying this file
// Foo is an example field of NodeTainterConfig. Edit nodetainterconfig_types.go to remove/update
Foo string `json:"foo,omitempty"`
// Foo string `json:"foo,omitempty"`
// Rules defines the mapping between keywords found in node names
// and the taints that should be applied.
// The key is the keyword (e.g., "gpu", "priority", "svc").
// The value is the taint string (e.g., "nvidia.com/gpu=present:NoSchedule").
// +kubebuilder:validation:Optional
// +kubebuilder:validation:MinProperties=1
LabelRules map[string]string `json:"labelRules,omitempty"`
}
// NodeTainterConfigStatus defines the observed state of NodeTainterConfig.
type NodeTainterConfigStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
// +optional
NodeTaintStatus []NodeTaintInfo `json:"nodeTaintStatus,omitempty"` // every Node status
}
// NodeTaintInfo holds Taint status for Node
type NodeTaintInfo struct {
NodeName string `json:"nodeName"`
AppliedTaints []string `json:"appliedTaints,omitempty"` // String representation of applied Taints
Error string `json:"error,omitempty"` // Error for this Node
}
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster,shortName=ntc
// +kubebuilder:subresource:status
// NodeTainterConfig is the Schema for the nodetainterconfigs API.

View File

@@ -21,16 +21,37 @@ limitations under the License.
package v1alpha1
import (
"k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeTaintInfo) DeepCopyInto(out *NodeTaintInfo) {
*out = *in
if in.AppliedTaints != nil {
in, out := &in.AppliedTaints, &out.AppliedTaints
*out = make([]string, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeTaintInfo.
func (in *NodeTaintInfo) DeepCopy() *NodeTaintInfo {
if in == nil {
return nil
}
out := new(NodeTaintInfo)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeTainterConfig) DeepCopyInto(out *NodeTainterConfig) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
out.Status = in.Status
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeTainterConfig.
@@ -86,6 +107,13 @@ func (in *NodeTainterConfigList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeTainterConfigSpec) DeepCopyInto(out *NodeTainterConfigSpec) {
*out = *in
if in.LabelRules != nil {
in, out := &in.LabelRules, &out.LabelRules
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeTainterConfigSpec.
@@ -101,6 +129,20 @@ func (in *NodeTainterConfigSpec) DeepCopy() *NodeTainterConfigSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeTainterConfigStatus) DeepCopyInto(out *NodeTainterConfigStatus) {
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]v1.Condition, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.NodeTaintStatus != nil {
in, out := &in.NodeTaintStatus, &out.NodeTaintStatus
*out = make([]NodeTaintInfo, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeTainterConfigStatus.