Skip to content

Commit 1f8b4f4

Browse files
committed
support inplace update for runtime workers
Signed-off-by: xliuqq <xlzq1992@gmail.com>
1 parent f9b05dc commit 1f8b4f4

18 files changed

Lines changed: 356 additions & 21 deletions

File tree

api/v1alpha1/constant.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,14 @@ const (
5656
// OnFuseChangedCleanPolicy cleans fuse pod when the fuse in runtime is updated and the fuse pod on some node is not needed
5757
OnFuseChangedCleanPolicy FuseCleanPolicy = "OnFuseChanged"
5858
)
59+
60+
type UpdateStrategy string
61+
62+
const (
63+
// ReCreate is the default update strategy.
64+
ReCreate UpdateStrategy = "ReCreate"
65+
66+
InPlace UpdateStrategy = "InPlace"
67+
68+
InPlaceIfPossible UpdateStrategy = "InPlaceIfPossible"
69+
)

api/v1alpha1/juicefsruntime_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ type JuiceFSRuntimeSpec struct {
8080
// CleanCachePolicy defines cleanCache Policy
8181
// +optional
8282
CleanCachePolicy CleanCachePolicy `json:"cleanCachePolicy,omitempty"`
83+
84+
// UpdateStrategy defines the update policy for worker pod.
85+
// +kubebuilder:validation:Enum=ReCreate;InPlace;InPlaceIfPossible
86+
// +kubebuilder:default=ReCreate
87+
// +optional
88+
UpdateStrategy UpdateStrategy `json:"updateStrategy,omitempty"`
8389
}
8490

8591
// JuiceFSCompTemplateSpec is a description of the JuiceFS components

api/v1alpha1/openapi_generated.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/fluid/fluid/crds/data.fluid.io_juicefsruntimes.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,14 @@ spec:
28672867
type: object
28682868
type: array
28692869
type: object
2870+
updateStrategy:
2871+
default: ReCreate
2872+
description: UpdateStrategy defines the update policy for worker pod.
2873+
enum:
2874+
- ReCreate
2875+
- InPlace
2876+
- InPlaceIfPossible
2877+
type: string
28702878
volumes:
28712879
description: Volumes is the list of Kubernetes volumes that can be
28722880
mounted by the alluxio runtime components and/or fuses.

charts/fluid/fluid/templates/webhook/webhookconfiguration.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,25 @@ webhooks:
4646
objectSelector:
4747
matchLabels:
4848
fuse.serverful.fluid.io/inject: "true"
49+
- name: inplaceupdate.worker.fluid.io
50+
rules:
51+
- apiGroups: [ "" ]
52+
apiVersions: [ "v1" ]
53+
operations: [ "CREATE" ]
54+
resources: [ "pods" ]
55+
clientConfig:
56+
service:
57+
namespace: {{ include "fluid.namespace" . }}
58+
name: fluid-pod-admission-webhook
59+
path: "/mutate-fluid-io-v1alpha1-schedulepod"
60+
port: 9443
61+
caBundle: Cg==
62+
timeoutSeconds: {{ .Values.webhook.timeoutSeconds }}
63+
failurePolicy: Fail
64+
reinvocationPolicy: {{ .Values.webhook.reinvocationPolicy }}
65+
sideEffects: None
66+
admissionReviewVersions: [ "v1","v1beta1" ]
67+
objectSelector:
68+
matchLabels:
69+
fluid.io/runtime-pod-type: "worker"
4970
{{- end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ template "juicefs.fullname" . }}-pod-state
5+
labels:
6+
app: {{ template "juicefs.name" . }}
7+
chart: {{ template "juicefs.chart" . }}
8+
release: {{ .Release.Name }}
9+
heritage: {{ .Release.Service }}
10+
{{- include "library.fluid.labels" . | nindent 4 }}
11+
ownerReferences:
12+
{{- if .Values.owner.enabled }}
13+
- apiVersion: {{ .Values.owner.apiVersion }}
14+
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
15+
controller: {{ .Values.owner.controller }}
16+
kind: {{ .Values.owner.kind }}
17+
name: {{ .Values.owner.name }}
18+
uid: {{ .Values.owner.uid }}
19+
{{- end }}

cmd/webhook/app/webhook.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package app
1818

1919
import (
2020
"flag"
21+
v1 "k8s.io/api/core/v1"
22+
"k8s.io/apimachinery/pkg/labels"
2123
"os"
2224

2325
"github.com/spf13/cobra"
@@ -133,6 +135,12 @@ func handle() {
133135
&admissionregistrationv1.MutatingWebhookConfiguration{}: {
134136
Field: fields.SelectorFromSet(fields.Set{"metadata.name": common.WebhookName}),
135137
},
138+
// restrict the number of configmap to be cached.
139+
&v1.ConfigMap{}: {
140+
Label: labels.SelectorFromSet(labels.Set{
141+
common.LabelAnnotationManagedBy: common.Fluid,
142+
}),
143+
},
136144
},
137145
},
138146
})

config/crd/bases/data.fluid.io_juicefsruntimes.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,14 @@ spec:
28672867
type: object
28682868
type: array
28692869
type: object
2870+
updateStrategy:
2871+
default: ReCreate
2872+
description: UpdateStrategy defines the update policy for worker pod.
2873+
enum:
2874+
- ReCreate
2875+
- InPlace
2876+
- InPlaceIfPossible
2877+
type: string
28702878
volumes:
28712879
description: Volumes is the list of Kubernetes volumes that can be
28722880
mounted by the alluxio runtime components and/or fuses.

pkg/common/constants.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ const (
190190
InjectAppPostStart = "app.poststart" + inject // app.poststart.fluid.io/inject
191191
InjectSidecarPostStart = "fuse.sidecar.poststart" + inject // fuse.sidecar.poststart.fluid.io/inject
192192

193+
InjectWorkerPodDone = "done.worker" + inject // done.worker.fluid.io/inject
194+
193195
injectServerful = ".serverful" + inject
194196
InjectServerfulFuse = "fuse" + injectServerful
195197

@@ -217,3 +219,8 @@ const (
217219
const (
218220
SkipPrecheckAnnotationKey = "sidecar.fluid.io/skip-precheck"
219221
)
222+
223+
const (
224+
// WorkerStatesKey is the key of the pod states in the runtime related config map.
225+
WorkerStatesKey = "workerStates"
226+
)

pkg/common/label.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const (
3535
LabelAnnotationDataset = LabelAnnotationPrefix + "dataset"
3636

3737
// LabelAnnotationDatasetId indicates the uuid of the dataset
38-
// i.e. fluid.io/dataset-uuid
38+
// i.e. fluid.io/dataset-id
3939
LabelAnnotationDatasetId = LabelAnnotationDataset + "-id"
4040

4141
// LabelAnnotationDatasetNum indicates the number of the dataset in specific node
@@ -122,6 +122,15 @@ var (
122122
LabelAnnotationPodSchedRegex = regexp.MustCompile(`^fluid\.io/dataset\.([A-Za-z0-9.-]*)\.sched$`)
123123
)
124124

125+
const (
126+
// RuntimePodType is the label key for runtime pod type
127+
RuntimePodType = "fluid.io/runtime-pod-type"
128+
RuntimeWorkerPod = "worker"
129+
130+
// AnnotationRuntimeName is the annotation key for the runtime name
131+
AnnotationRuntimeName = LabelAnnotationPrefix + "runtime-name"
132+
)
133+
125134
type OperationType string
126135

127136
const (

0 commit comments

Comments
 (0)