Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support to specify k8s scheduling policy in cluster API #7071

Merged
merged 6 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/utils/typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ AKS = "AKS"
ons = "ons"
HashiCorp = "HashiCorp"
Hashi = "Hashi"
Ded = "Ded"
54 changes: 54 additions & 0 deletions apis/apps/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,22 @@ type ClusterSpec struct {

// A group of affinity scheduling rules.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 0.10.0"
// +optional
Affinity *Affinity `json:"affinity,omitempty"`

// Attached to tolerate any taint that matches the triple `key,value,effect` using the matching operator `operator`.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 0.10.0"
// +kubebuilder:pruning:PreserveUnknownFields
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// Specifies the scheduling policy for the cluster.
//
// +optional
SchedulingPolicy *SchedulingPolicy `json:"schedulingPolicy,omitempty"`

// Cluster backup configuration.
//
// +optional
Expand Down Expand Up @@ -533,15 +540,22 @@ type ClusterComponentSpec struct {

// A group of affinity scheduling rules.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 0.10.0"
// +optional
Affinity *Affinity `json:"affinity,omitempty"`

// Attached to tolerate any taint that matches the triple `key,value,effect` using the matching operator `operator`.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 0.10.0"
// +kubebuilder:pruning:PreserveUnknownFields
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// Specifies the scheduling policy for the component.
//
// +optional
SchedulingPolicy *SchedulingPolicy `json:"schedulingPolicy,omitempty"`

// Specifies the resources requests and limits of the workload.
//
// +kubebuilder:pruning:PreserveUnknownFields
Expand Down Expand Up @@ -761,6 +775,46 @@ type Affinity struct {
Tenancy TenancyType `json:"tenancy,omitempty"`
}

type SchedulingPolicy struct {
// If specified, the pod will be dispatched by specified scheduler.
// If not specified, the pod will be dispatched by default scheduler.
//
// +optional
SchedulerName string `json:"schedulerName,omitempty"`

// NodeSelector is a selector which must be true for the pod to fit on a node.
// Selector which must match a node's labels for the pod to be scheduled on that node.
// More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
//
// +optional
// +mapType=atomic
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// NodeName is a request to schedule this pod onto a specific node. If it is non-empty,
// the scheduler simply schedules this pod onto that node, assuming that it fits resource
// requirements.
//
// +optional
NodeName string `json:"nodeName,omitempty"`

// If specified, the cluster's scheduling constraints.
//
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`

// Attached to tolerate any taint that matches the triple `key,value,effect` using the matching operator `operator`.
//
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// TopologySpreadConstraints describes how a group of pods ought to spread across topology
// domains. Scheduler will schedule pods in a way which abides by the constraints.
// All topologySpreadConstraints are ANDed.
//
// +optional
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
}

type TLSConfig struct {
// +kubebuilder:default=false
// +optional
Expand Down
9 changes: 8 additions & 1 deletion apis/apps/v1alpha1/component_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,25 @@ type ComponentSpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// Specifies the scheduling constraints for the component's workload.
// Specifies the scheduling constraints for the component.
// If specified, it will override the cluster-wide affinity.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 0.10.0"
// +optional
Affinity *Affinity `json:"affinity,omitempty"`

// Specify the tolerations for the component's workload.
// If specified, they will override the cluster-wide toleration settings.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 0.10.0"
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// Specifies the scheduling policy for the component.
//
// +optional
SchedulingPolicy *SchedulingPolicy `json:"schedulingPolicy,omitempty"`

// Specifies the TLS configuration for the component.
//
// +optional
Expand Down
56 changes: 56 additions & 0 deletions apis/apps/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading