Skip to content

Commit

Permalink
feat: support to specify k8s scheduling policies in cluster API
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf committed Apr 16, 2024
1 parent 7a0c30f commit 5fa60b7
Show file tree
Hide file tree
Showing 9 changed files with 11,421 additions and 1,761 deletions.
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"
50 changes: 50 additions & 0 deletions apis/apps/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ type ClusterSpec struct {
// +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 @@ -542,6 +547,11 @@ type ClusterComponentSpec struct {
// +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 +771,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
7 changes: 6 additions & 1 deletion apis/apps/v1alpha1/component_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ 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.
//
// +optional
Expand All @@ -107,6 +107,11 @@ type ComponentSpec struct {
// +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

0 comments on commit 5fa60b7

Please sign in to comment.