Skip to content

Commit

Permalink
support dataflow affinity (#3829)
Browse files Browse the repository at this point in the history
* support dataflow affinity

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* support databackup

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* fix check

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* revert dockerfile and use nodeAffinity

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* fix conflict and use nodeAffinity

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* fix: add apireader for get node

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* revert apireader to cache client

Signed-off-by: xliuqq <xlzq1992@gmail.com>

---------

Signed-off-by: xliuqq <xlzq1992@gmail.com>
  • Loading branch information
xliuqq authored May 14, 2024
1 parent c8ccac2 commit 84029c5
Show file tree
Hide file tree
Showing 56 changed files with 3,283 additions and 118 deletions.
33 changes: 33 additions & 0 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,35 @@ const (
DataProcessType OperationType = "DataProcess"
)

// AffinityPolicy the strategy for the affinity between Data Operation Pods.
type AffinityPolicy string

const (
DefaultAffinityStrategy AffinityPolicy = ""
RequireAffinityStrategy AffinityPolicy = "Require"
PreferAffinityStrategy AffinityPolicy = "Prefer"
)

type AffinityStrategy struct {
// Policy one of: "", "Require", "Prefer"
// +optional
Policy AffinityPolicy `json:"policy,omitempty"`

Prefer []Prefer `json:"prefer,omitempty"`
Require []Require `json:"require,omitempty"`
}

// Prefer defines the label key and weight for generating a PreferredSchedulingTerm.
type Prefer struct {
Name string `json:"name"`
Weight int32 `json:"weight"`
}

// Require defines the label key for generating a NodeSelectorTerm.
type Require struct {
Name string `json:"name"`
}

type OperationRef struct {
// API version of the referent operation
// +optional
Expand All @@ -272,6 +301,10 @@ type OperationRef struct {
// Namespace specifies the namespace of the referent operation.
// +optional
Namespace string `json:"namespace,omitempty"`

// AffinityStrategy specifies the pod affinity strategy with the referent operation.
// +optional
AffinityStrategy AffinityStrategy `json:"affinityStrategy,omitempty"`
}

type WaitingStatus struct {
Expand Down
116 changes: 115 additions & 1 deletion api/v1alpha1/openapi_generated.go

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

3 changes: 3 additions & 0 deletions api/v1alpha1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ type OperationStatus struct {
LastSuccessfulTime *metav1.Time `json:"lastSuccessfulTime,omitempty"`
// WaitingStatus stores information about waiting operation.
WaitingFor WaitingStatus `json:"waitingFor,omitempty"`

// NodeAffinity records the node affinity for operation pods
NodeAffinity *corev1.NodeAffinity `json:"nodeAffinity,omitempty"`
}

type RuntimePhase string
Expand Down
69 changes: 65 additions & 4 deletions api/v1alpha1/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions charts/fluid-databackup/alluxio/templates/databackup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ spec:
mountPath: /etc/group
readOnly: true
{{- end}}
{{- if .Values.dataBackup.affinity }}
affinity:
{{ toYaml .Values.dataBackup.affinity | indent 4 }}
{{- end }}

restartPolicy: Never
volumes:
{{- if .Values.dataBackup.workdir }}
Expand Down
2 changes: 2 additions & 0 deletions charts/fluid-databackup/alluxio/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ dataBackup:
# Description: optional image pull secrets on DataLoad pods
imagePullSecrets: []

affinity:

initUsers:
enabled: false
image: registry.cn-hangzhou.aliyuncs.com/fluid/init-users
Expand Down
4 changes: 4 additions & 0 deletions charts/fluid-dataprocess/common/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ spec:
{{- if .Values.dataProcess.scriptProcessor.volumeMounts }}
{{- toYaml .Values.dataProcess.scriptProcessor.volumeMounts | nindent 12 }}
{{- end }}
{{- if .Values.dataProcess.scriptProcessor.affinity }}
affinity:
{{ toYaml .Values.dataProcess.scriptProcessor.affinity | indent 8 }}
{{- end }}
volumes:
- name: script-cm-vol
configMap:
Expand Down
Loading

0 comments on commit 84029c5

Please sign in to comment.