Skip to content

Commit 32bfed1

Browse files
committed
use crd instead of cm
Signed-off-by: xliuqq <xlzq1992@gmail.com>
1 parent 3fe427e commit 32bfed1

16 files changed

Lines changed: 391 additions & 80 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Copyright 2025 The Fluid Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// PersistentPodStateSpec defines the desired state of PersistentPodState
24+
type PersistentPodStateSpec struct {
25+
}
26+
27+
type PodState struct {
28+
NodeName string `json:"nodeName"`
29+
}
30+
31+
// PersistentPodStateStatus defines the observed state of PersistentPodState
32+
type PersistentPodStateStatus struct {
33+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
34+
// Important: Run "make" to regenerate code after modifying this file
35+
36+
// PodStates is the pod name mapping to state.
37+
PodStates map[string]PodState `json:"podStates,omitempty"`
38+
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
39+
}
40+
41+
// PersistentPodState is the Schema for the PersistentPodState API
42+
// +kubebuilder:object:root=true
43+
// +kubebuilder:subresource:status
44+
// +kubebuilder:resource:scope=Namespaced
45+
type PersistentPodState struct {
46+
metav1.TypeMeta `json:",inline"`
47+
metav1.ObjectMeta `json:"metadata,omitempty"`
48+
49+
Spec PersistentPodStateSpec `json:"spec,omitempty"`
50+
Status PersistentPodStateStatus `json:"status,omitempty"`
51+
}
52+
53+
//+kubebuilder:object:root=true
54+
55+
// PersistentPodStateList contains a list of PersistentPodState
56+
type PersistentPodStateList struct {
57+
metav1.TypeMeta `json:",inline"`
58+
metav1.ListMeta `json:"metadata,omitempty"`
59+
Items []PersistentPodState `json:"items"`
60+
}
61+
62+
func init() {
63+
SchemeBuilder.Register(&PersistentPodState{}, &PersistentPodStateList{})
64+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.14.0
7+
name: persistentpodstates.data.fluid.io
8+
spec:
9+
group: data.fluid.io
10+
names:
11+
kind: PersistentPodState
12+
listKind: PersistentPodStateList
13+
plural: persistentpodstates
14+
singular: persistentpodstate
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha1
18+
schema:
19+
openAPIV3Schema:
20+
description: PersistentPodState is the Schema for the PersistentPodState API
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: PersistentPodStateSpec defines the desired state of PersistentPodState
41+
type: object
42+
status:
43+
description: PersistentPodStateStatus defines the observed state of PersistentPodState
44+
properties:
45+
lastUpdateTime:
46+
format: date-time
47+
type: string
48+
podStates:
49+
additionalProperties:
50+
properties:
51+
nodeName:
52+
type: string
53+
required:
54+
- nodeName
55+
type: object
56+
description: "\tPodStates is the pod name mapping to state."
57+
type: object
58+
type: object
59+
type: object
60+
served: true
61+
storage: true
62+
subresources:
63+
status: {}

charts/fluid/fluid/templates/role/juicefs/rbac.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ rules:
9595
- datasets
9696
- juicefsruntimes/status
9797
- datasets/status
98+
- persistentpodstates
99+
- persistentpodstates/status
98100
verbs:
99101
- get
100102
- list

charts/fluid/fluid/templates/role/webhook/rabc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ rules:
6565
- thinruntimes
6666
- efcruntimes
6767
- vineyardruntimes
68+
- persistentpodstates
6869
verbs:
6970
- get
7071
- list

charts/juicefs/templates/worker/configmap.yaml renamed to charts/juicefs/templates/worker/persistent_podstate.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
apiVersion: v1
2-
kind: ConfigMap
1+
apiVersion: data.fluid.io/v1alpha1
2+
kind: PersistentPodState
33
metadata:
44
name: {{ template "juicefs.fullname" . }}-pod-state
55
labels:

cmd/webhook/app/webhook.go

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

1919
import (
2020
"flag"
21-
v1 "k8s.io/api/core/v1"
22-
"k8s.io/apimachinery/pkg/labels"
2321
"os"
2422

2523
"github.com/spf13/cobra"
@@ -135,12 +133,6 @@ func handle() {
135133
&admissionregistrationv1.MutatingWebhookConfiguration{}: {
136134
Field: fields.SelectorFromSet(fields.Set{"metadata.name": common.WebhookName}),
137135
},
138-
// restrict the number of configmap to be cached.
139-
&v1.ConfigMap{}: {
140-
Label: labels.SelectorFromSet(labels.Set{
141-
common.LabelConfigMapType: common.RuntimeWorkerStateConfigMapTypeName,
142-
}),
143-
},
144136
},
145137
},
146138
})
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.14.0
7+
name: persistentpodstates.data.fluid.io
8+
spec:
9+
group: data.fluid.io
10+
names:
11+
kind: PersistentPodState
12+
listKind: PersistentPodStateList
13+
plural: persistentpodstates
14+
singular: persistentpodstate
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha1
18+
schema:
19+
openAPIV3Schema:
20+
description: PersistentPodState is the Schema for the PersistentPodState API
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: PersistentPodStateSpec defines the desired state of PersistentPodState
41+
type: object
42+
status:
43+
description: PersistentPodStateStatus defines the observed state of PersistentPodState
44+
properties:
45+
lastUpdateTime:
46+
format: date-time
47+
type: string
48+
podStates:
49+
additionalProperties:
50+
properties:
51+
nodeName:
52+
type: string
53+
required:
54+
- nodeName
55+
type: object
56+
description: "\tPodStates is the pod name mapping to state."
57+
type: object
58+
type: object
59+
type: object
60+
served: true
61+
storage: true
62+
subresources:
63+
status: {}

pkg/common/constants.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,3 @@ const (
219219
const (
220220
SkipPrecheckAnnotationKey = "sidecar.fluid.io/skip-precheck"
221221
)
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: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,6 @@ const (
127127
RuntimePodType = "fluid.io/runtime-pod-type"
128128
RuntimeWorkerPod = "worker"
129129

130-
// LabelConfigMapType fluid.io/configmap-type is the label key for runtime configmap type
131-
LabelConfigMapType = LabelAnnotationPrefix + "configmap-type"
132-
// RuntimeWorkerStateConfigMapTypeName is the label value of the configmap type for runtime worker state
133-
RuntimeWorkerStateConfigMapTypeName = "worker-state"
134-
135130
// AnnotationRuntimeName is the annotation key for the runtime name
136131
AnnotationRuntimeName = LabelAnnotationPrefix + "runtime-name"
137132
)

0 commit comments

Comments
 (0)