Skip to content

Commit 1c1d870

Browse files
authored
Extend Cache runtime framework Phase 1: add reconcile logic, left main functions to implement in next phase (#5738)
* add code for reconciler framework, rbac, helm charts, make file Signed-off-by: xliuqq <xlzq1992@gmail.com> * do not push cache runtime controller image as it is not ready Signed-off-by: xliuqq <xlzq1992@gmail.com> * fix lint Signed-off-by: xliuqq <xlzq1992@gmail.com> * fix gofmt Signed-off-by: xliuqq <xlzq1992@gmail.com> * make todo not implement Signed-off-by: xliuqq <xlzq1992@gmail.com> --------- Signed-off-by: xliuqq <xlzq1992@gmail.com>
1 parent 30d225b commit 1c1d870

43 files changed

Lines changed: 1872 additions & 15 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ JINDORUNTIME_CONTROLLER_IMG ?= ${IMG_REPO}/jindoruntime-controller
3939
GOOSEFSRUNTIME_CONTROLLER_IMG ?= ${IMG_REPO}/goosefsruntime-controller
4040
JUICEFSRUNTIME_CONTROLLER_IMG ?= ${IMG_REPO}/juicefsruntime-controller
4141
THINRUNTIME_CONTROLLER_IMG ?= ${IMG_REPO}/thinruntime-controller
42+
CACHERUNTIME_CONTROLLER_IMG ?= ${IMG_REPO}/cacheruntime-controller
4243
EFCRUNTIME_CONTROLLER_IMG ?= ${IMG_REPO}/efcruntime-controller
4344
VINEYARDRUNTIME_CONTROLLER_IMG ?= ${IMG_REPO}/vineyardruntime-controller
4445
CSI_IMG ?= ${IMG_REPO}/fluid-csi
@@ -55,6 +56,7 @@ JINDORUNTIME_DOCKERFILE ?= docker/Dockerfile.jindoruntime
5556
GOOSEFSRUNTIME_DOCKERFILE ?= docker/Dockerfile.goosefsruntime
5657
JUICEFSRUNTIME_DOCKERFILE ?= docker/Dockerfile.juicefsruntime
5758
THINRUNTIME_DOCKERFILE ?= docker/Dockerfile.thinruntime
59+
CACHERUNTIME_DOCKERFILE ?= docker/Dockerfile.cacheruntime
5860
EFCRUNTIME_DOCKERFILE ?= docker/Dockerfile.efcruntime
5961
VINEYARDRUNTIME_DOCKERFILE ?= docker/Dockerfile.vineyardruntime
6062
CSI_DOCKERFILE ?= docker/Dockerfile.csi
@@ -72,6 +74,7 @@ JINDORUNTIME_BINARY ?= bin/jindoruntime-controller
7274
GOOSEFSRUNTIME_BINARY ?= bin/goosefsruntime-controller
7375
JUICEFSRUNTIME_BINARY ?= bin/juicefsruntime-controller
7476
THINRUNTIME_BINARY ?= bin/thinruntime-controller
77+
CACHERUNTIME_BINARY ?= bin/cacheruntime-controller
7578
EFCRUNTIME_BINARY ?= bin/efcruntime-controller
7679
VINEYARDRUNTIME_BINARY ?= bin/vineyardruntime-controller
7780
WEBHOOK_BINARY ?= bin/fluid-webhook
@@ -87,6 +90,7 @@ BINARY_BUILD += alluxioruntime-controller-build
8790
BINARY_BUILD += jindoruntime-controller-build
8891
BINARY_BUILD += juicefsruntime-controller-build
8992
BINARY_BUILD += thinruntime-controller-build
93+
BINARY_BUILD += cacheruntime-controller-build
9094
BINARY_BUILD += efcruntime-controller-build
9195
BINARY_BUILD += vineyardruntime-controller-build
9296
BINARY_BUILD += csi-build
@@ -104,6 +108,7 @@ DOCKER_BUILD += docker-build-csi
104108
DOCKER_BUILD += docker-build-webhook
105109
DOCKER_BUILD += docker-build-juicefsruntime-controller
106110
DOCKER_BUILD += docker-build-thinruntime-controller
111+
DOCKER_BUILD += docker-build-cacheruntime-controller
107112
DOCKER_BUILD += docker-build-efcruntime-controller
108113
DOCKER_BUILD += docker-build-vineyardruntime-controller
109114
DOCKER_BUILD += docker-build-init-users
@@ -120,6 +125,7 @@ DOCKER_PUSH += docker-push-webhook
120125
DOCKER_PUSH += docker-push-goosefsruntime-controller
121126
DOCKER_PUSH += docker-push-juicefsruntime-controller
122127
DOCKER_PUSH += docker-push-thinruntime-controller
128+
#DOCKER_PUSH += docker-push-cacheruntime-controller
123129
DOCKER_PUSH += docker-push-efcruntime-controller
124130
DOCKER_PUSH += docker-push-vineyardruntime-controller
125131
# Not need to push init-users image by default
@@ -137,6 +143,7 @@ DOCKER_BUILDX_PUSH += docker-buildx-push-csi
137143
DOCKER_BUILDX_PUSH += docker-buildx-push-webhook
138144
DOCKER_BUILDX_PUSH += docker-buildx-push-juicefsruntime-controller
139145
DOCKER_BUILDX_PUSH += docker-buildx-push-thinruntime-controller
146+
#DOCKER_BUILDX_PUSH += docker-buildx-push-cacheruntime-controller
140147
DOCKER_BUILDX_PUSH += docker-buildx-push-efcruntime-controller
141148
DOCKER_BUILDX_PUSH += docker-buildx-push-vineyardruntime-controller
142149
# Not need to push init-users image by default
@@ -238,6 +245,10 @@ juicefsruntime-controller-build:
238245
thinruntime-controller-build:
239246
CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${ARCH} GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o ${THINRUNTIME_BINARY} -ldflags '-s -w ${LDFLAGS}' cmd/thin/main.go
240247

248+
.PHONY: cacheruntime-controller-build
249+
cacheruntime-controller-build:
250+
CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${ARCH} GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o ${CACHERUNTIME_BINARY} -ldflags '-s -w ${LDFLAGS}' cmd/cache/main.go
251+
241252
.PHONY: vineyardruntime-controller-build
242253
vineyardruntime-controller-build:
243254
CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${ARCH} GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o ${VINEYARDRUNTIME_BINARY} -ldflags '-s -w ${LDFLAGS}' cmd/vineyard/main.go
@@ -283,6 +294,10 @@ docker-build-juicefsruntime-controller:
283294
docker-build-thinruntime-controller:
284295
docker build ${DOCKER_NO_CACHE_OPTION} --build-arg TARGETARCH=${ARCH} ${DOCKER_BUILD_ARGS} . -f ${THINRUNTIME_DOCKERFILE} -t ${THINRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
285296

297+
.PHONY: docker-build-cacheruntime-controller
298+
docker-build-cacheruntime-controller:
299+
docker build ${DOCKER_NO_CACHE_OPTION} --build-arg TARGETARCH=${ARCH} ${DOCKER_BUILD_ARGS} . -f ${CACHERUNTIME_DOCKERFILE} -t ${CACHERUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
300+
286301
.PHONY: docker-build-efcruntime-controller
287302
docker-build-efcruntime-controller:
288303
docker build ${DOCKER_NO_CACHE_OPTION} --build-arg TARGETARCH=${ARCH} ${DOCKER_BUILD_ARGS} . -f ${EFCRUNTIME_DOCKERFILE} -t ${EFCRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
@@ -340,6 +355,10 @@ docker-push-juicefsruntime-controller: docker-build-juicefsruntime-controller
340355
docker-push-thinruntime-controller: docker-build-thinruntime-controller
341356
docker push ${THINRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
342357

358+
.PHONY: docker-push-cacheruntime-controller
359+
docker-push-cacheruntime-controller: docker-build-cacheruntime-controller
360+
docker push ${CACHERUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
361+
343362
.PHONY: docker-push-efcruntime-controller
344363
docker-push-efcruntime-controller: docker-build-efcruntime-controller
345364
docker push ${EFCRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
@@ -397,6 +416,11 @@ docker-buildx-push-juicefsruntime-controller:
397416
docker-buildx-push-thinruntime-controller:
398417
docker buildx build --push ${DOCKER_BUILD_ARGS} --platform ${DOCKER_PLATFORM} ${DOCKER_NO_CACHE_OPTION} . -f ${THINRUNTIME_DOCKERFILE} -t ${THINRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
399418

419+
.PHONY: docker-buildx-push-cacheruntime-controller
420+
docker-buildx-push-cacheruntime-controller:
421+
docker buildx build --push ${DOCKER_BUILD_ARGS} --platform ${DOCKER_PLATFORM} ${DOCKER_NO_CACHE_OPTION} . -f ${CACHERUNTIME_DOCKERFILE} -t ${CACHERUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
422+
423+
400424
.PHONY: docker-buildx-push-efcruntime-controller
401425
docker-buildx-push-efcruntime-controller:
402426
docker buildx build --push ${DOCKER_BUILD_ARGS} --platform ${DOCKER_PLATFORM} ${DOCKER_NO_CACHE_OPTION} . -f ${EFCRUNTIME_DOCKERFILE} -t ${EFCRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

api/v1alpha1/cacheruntime_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,7 @@ type VolumeMediumSource struct {
308308
// +optional
309309
Ephemeral *corev1.EphemeralVolumeSource `json:"ephemeral,omitempty"`
310310
}
311+
312+
func (runtime *CacheRuntime) GetStatus() *CacheRuntimeStatus {
313+
return &runtime.Status
314+
}

api/v1alpha1/cacheruntimeclass_types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ type RuntimeExtraResources struct {
142142
// CacheRuntimeClass is the Schema for the cacheruntimeclasses API.
143143
// CacheRuntimeClass defines a class of cache runtime implementations with specific configurations.
144144
// +kubebuilder:object:root=true
145-
// +kubebuilder:resource:scope=Cluster
146-
// +kubebuilder:resource:categories={fluid}
145+
// +kubebuilder:resource:scope=Cluster,categories={fluid}
147146
// +genclient
148147
// +genclient:nonNamespaced
149148
type CacheRuntimeClass struct {

charts/fluid/fluid/crds/data.fluid.io_cacheruntimeclasses.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ spec:
1414
listKind: CacheRuntimeClassList
1515
plural: cacheruntimeclasses
1616
singular: cacheruntimeclass
17-
scope: Namespaced
17+
scope: Cluster
1818
versions:
1919
- name: v1alpha1
2020
schema:
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: cacheruntime-controller
6+
namespace: {{ include "fluid.namespace" . }}
7+
labels:
8+
control-plane: cacheruntime-controller
9+
spec:
10+
selector:
11+
matchLabels:
12+
control-plane: cacheruntime-controller
13+
{{ if .Values.runtime.cache.enabled -}}
14+
replicas: {{ .Values.runtime.cache.replicas }}
15+
{{- else }}
16+
replicas: 0
17+
{{- end }}
18+
template:
19+
metadata:
20+
labels:
21+
control-plane: cacheruntime-controller
22+
annotations:
23+
{{ if gt (.Values.runtime.cache.replicas | int) 1 -}}
24+
controller.runtime.fluid.io/replicas: {{ .Values.runtime.cache.replicas | quote }}
25+
{{- end }}
26+
spec:
27+
{{- with .Values.image.imagePullSecrets }}
28+
imagePullSecrets:
29+
{{- toYaml . | nindent 8 }}
30+
{{- end }}
31+
serviceAccountName: cacheruntime-controller
32+
{{ include "fluid.controlplane.affinity" . | nindent 6 }}
33+
{{- if .Values.runtime.cache.tolerations }}
34+
tolerations:
35+
{{ toYaml .Values.runtime.cache.tolerations | indent 6 }}
36+
{{- end }}
37+
#hostNetwork: true
38+
containers:
39+
- image: {{ include "fluid.controlplane.imageTransform" (list .Values.runtime.cache.controller.imagePrefix .Values.runtime.cache.controller.imageName .Values.runtime.cache.controller.imageTag . ) }}
40+
imagePullPolicy: IfNotPresent
41+
name: manager
42+
args:
43+
- --development=false
44+
- --pprof-addr=:6060
45+
- --enable-leader-election
46+
- --runtime-workers={{ .Values.runtime.cache.runtimeWorkers }}
47+
- --kube-api-qps={{ .Values.runtime.cache.kubeClientQPS }}
48+
- --kube-api-burst={{ .Values.runtime.cache.kubeClientBurst }}
49+
- --workqueue-qps={{ .Values.runtime.cache.workQueueQPS }}
50+
- --workqueue-burst={{ .Values.runtime.cache.workQueueBurst }}
51+
- --leader-election-namespace={{ include "fluid.namespace" . }}
52+
command: ["cacheruntime-controller", "start"]
53+
env:
54+
{{- if .Values.image.imagePullSecrets }}
55+
- name: IMAGE_PULL_SECRETS
56+
{{- $secretList := list }}
57+
{{- range .Values.image.imagePullSecrets }}
58+
{{- range $name,$v := . }}
59+
{{- $secretList = append $secretList $v }}
60+
{{- end }}
61+
{{- end }}
62+
value: {{ join "," $secretList | quote }}
63+
{{- end }}
64+
65+
{{- if .Values.runtime.mountRoot }}
66+
- name: MOUNT_ROOT
67+
value: {{ .Values.runtime.mountRoot | quote }}
68+
{{- end }}
69+
{{- if .Values.runtime.criticalFusePod }}
70+
- name: CRITICAL_FUSE_POD
71+
value: {{ ternary "true" "false" (semverCompare ">=1.16.0-0" .Capabilities.KubeVersion.Version) | quote }}
72+
{{- end }}
73+
{{- if .Values.runtime.syncRetryDuration }}
74+
- name: FLUID_SYNC_RETRY_DURATION
75+
value: {{ .Values.runtime.syncRetryDuration | quote }}
76+
{{- end }}
77+
{{- include "fluid.controllers.envs.syncScheduleInfoNodeExcludeSelector" . | nindent 10 }}
78+
- name: HELM_DRIVER
79+
value: {{ template "fluid.helmDriver" . }}
80+
{{- if .Values.runtime.cache.env }}
81+
{{ toYaml .Values.runtime.cache.env | nindent 10 }}
82+
{{- end }}
83+
ports:
84+
- containerPort: 8080
85+
name: metrics
86+
protocol: TCP
87+
resources:
88+
{{- include "fluid.controlplane.resources" (list $ .Values.runtime.cache.resources) | nindent 10 }}
89+
terminationGracePeriodSeconds: 10

0 commit comments

Comments
 (0)