Skip to content

Commit 91c05c3

Browse files
authored
Merge pull request from GHSA-93xx-cvmc-9w3v
* Fix rbacs and limit CSI Plugin's node related access Signed-off-by: trafalgarzzz <[email protected]> * Update change log and chart version Signed-off-by: trafalgarzzz <[email protected]> * Fix fluid.namespace template rendering Signed-off-by: trafalgarzzz <[email protected]> * Remove leader election for fluid webhook Signed-off-by: trafalgarzzz <[email protected]> --------- Signed-off-by: trafalgarzzz <[email protected]>
1 parent 5588b1f commit 91c05c3

File tree

13 files changed

+215
-73
lines changed

13 files changed

+215
-73
lines changed

charts/fluid/fluid/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@
5454

5555
### 0.9.0
5656
* Support pass image pull secrets from fluid charts to alluxioruntime controller
57+
* Fix components rbacs and set Fluid CSI Plugin with node-authorized kube-client

charts/fluid/fluid/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ version: 0.8.6
1818

1919
# This is the version number of the application being deployed. This version number should be
2020
# incremented each time you make changes to the application.
21-
appVersion: 0.8.5-00f609e
21+
appVersion: 0.8.6-2131f34
2222
home: https://github.com/fluid-cloudnative/fluid
2323
keywords:
2424
- category:data

charts/fluid/fluid/templates/csi/daemonset.yaml

+24-4
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,16 @@ spec:
104104
- name: fluid-src-dir
105105
mountPath: {{ .Values.runtime.mountRoot | quote }}
106106
mountPropagation: "Bidirectional"
107-
- name: host-etc-dir
108-
mountPath: /host-etc
107+
- name: kubelet-kube-config
108+
mountPath: /etc/kubernetes/kubelet.conf
109+
readOnly: true
110+
- name: kubelet-cert-dir
111+
mountPath: {{ .Values.csi.kubelet.certDir | quote }}
112+
readOnly: true
113+
- name: updatedb-conf
114+
mountPath: /host-etc/updatedb.conf
115+
- name: updatedb-conf-bak
116+
mountPath: /host-etc/updatedb.conf.bak
109117
volumes:
110118
- name: kubelet-dir
111119
hostPath:
@@ -124,6 +132,18 @@ spec:
124132
type: DirectoryOrCreate
125133
name: fluid-src-dir
126134
- hostPath:
127-
path: /etc
135+
path: {{ .Values.csi.kubelet.kubeConfigFile | quote }}
136+
type: File
137+
name: kubelet-kube-config
138+
- hostPath:
139+
path: {{ .Values.csi.kubelet.certDir | quote }}
128140
type: Directory
129-
name: host-etc-dir
141+
name: kubelet-cert-dir
142+
- hostPath:
143+
path: /etc/updatedb.conf
144+
type: FileOrCreate
145+
name: updatedb-conf
146+
- hostPath:
147+
path: /etc/updatedb.conf.backup
148+
type: FileOrCreate
149+
name: updatedb-conf-bak

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@ rules:
3737
verbs: ["get"]
3838
- apiGroups: [""]
3939
resources: ["events"]
40-
verbs: ["get", "list", "watch", "create", "update", "patch"]
41-
- apiGroups: [""]
42-
resources: ["nodes"]
43-
verbs: ["get", "patch"]
44-
- apiGroups: [""]
45-
resources: ["nodes/proxy"]
46-
verbs: ["*"]
40+
verbs: ["create", "patch"]
4741
---
4842
kind: ClusterRoleBinding
4943
apiVersion: rbac.authorization.k8s.io/v1

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

+45-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,59 @@
11
{{ if .Values.webhook.enabled -}}
22
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: Role
4+
metadata:
5+
name: fluid-webhook
6+
namespace: fluid-system
7+
rules:
8+
- apiGroups:
9+
- ""
10+
resources:
11+
- secrets
12+
verbs:
13+
- get
14+
- update
15+
resourceNames:
16+
- fluid-webhook-certs
17+
# resourceNames won't protect create verb, so individually specify it for readability
18+
- apiGroups:
19+
- ""
20+
resources:
21+
- secrets
22+
verbs:
23+
- create
24+
---
25+
apiVersion: rbac.authorization.k8s.io/v1
26+
kind: RoleBinding
27+
metadata:
28+
name: fluid-webhook-rolebinding
29+
namespace: fluid-system
30+
roleRef:
31+
apiGroup: rbac.authorization.k8s.io
32+
kind: Role
33+
name: fluid-webhook
34+
subjects:
35+
- kind: ServiceAccount
36+
name: fluid-webhook
37+
namespace: fluid-system
38+
---
39+
apiVersion: rbac.authorization.k8s.io/v1
340
kind: ClusterRole
441
metadata:
542
name: fluid-webhook
643
rules:
44+
# Can only list and watch secret `mutatingwebhookconfiguration` with a metadata.name field selector
45+
# See https://kubernetes.io/docs/reference/access-authn-authz/rbac/#referring-to-resources
746
- apiGroups:
847
- admissionregistration.k8s.io
948
resources:
10-
- validatingwebhookconfigurations
1149
- mutatingwebhookconfigurations
50+
resourceNames:
51+
- fluid-pod-admission-webhook
1252
verbs:
13-
- '*'
53+
- get
54+
- patch
55+
- list
56+
- watch
1457
- apiGroups:
1558
- data.fluid.io
1659
resources:
@@ -36,9 +79,7 @@ rules:
3679
- apiGroups:
3780
- ""
3881
resources:
39-
- secrets
4082
- configmaps
41-
- events
4283
verbs:
4384
- get
4485
- create
@@ -54,12 +95,6 @@ rules:
5495
- get
5596
- list
5697
- watch
57-
- apiGroups:
58-
- coordination.k8s.io
59-
resources:
60-
- leases
61-
verbs:
62-
- '*'
6398
---
6499
apiVersion: rbac.authorization.k8s.io/v1
65100
kind: ClusterRoleBinding

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ spec:
1616
labels:
1717
control-plane: fluid-webhook
1818
spec:
19+
tolerations:
20+
- operator: Exists
1921
{{- with .Values.image.imagePullSecrets }}
2022
imagePullSecrets:
2123
{{- toYaml . | nindent 8 }}
@@ -29,7 +31,6 @@ spec:
2931
- --development=false
3032
- --full-go-profile=false
3133
- --pprof-addr=:6060
32-
- --enable-leader-election
3334
env:
3435
- name: MY_POD_NAMESPACE
3536
valueFrom:

charts/fluid/fluid/values.yaml

+14-12
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
workdir: /tmp
66
crdUpgrade:
7-
image: fluidcloudnative/fluid-crd-upgrader:v0.8.5-00f609e
7+
image: fluidcloudnative/fluid-crd-upgrader:v0.8.6-2131f34
88

99
image:
1010
imagePullSecrets: []
1111

1212
dataset:
1313
replicas: 1
1414
controller:
15-
image: fluidcloudnative/dataset-controller:v0.8.5-00f609e
15+
image: fluidcloudnative/dataset-controller:v0.8.6-2131f34
1616

1717
csi:
1818
featureGates: "FuseRecovery=false"
@@ -21,8 +21,10 @@ csi:
2121
registrar:
2222
image: registry.aliyuncs.com/acs/csi-node-driver-registrar:v2.3.0-038aeb6-aliyun
2323
plugins:
24-
image: fluidcloudnative/fluid-csi:v0.8.5-00f609e
24+
image: fluidcloudnative/fluid-csi:v0.8.6-2131f34
2525
kubelet:
26+
kubeConfigFile: /etc/kubernetes/kubelet.conf
27+
certDir: /var/lib/kubelet/pki
2628
rootDir: /var/lib/kubelet
2729
pruneFs: fuse.alluxio-fuse,fuse.jindofs-fuse,fuse.juicefs,fuse.goosefs-fuse,ossfs
2830

@@ -37,9 +39,9 @@ runtime:
3739
portAllocatePolicy: random
3840
enabled: false
3941
init:
40-
image: fluidcloudnative/init-users:v0.8.5-00f609e
42+
image: fluidcloudnative/init-users:v0.8.6-2131f34
4143
controller:
42-
image: fluidcloudnative/alluxioruntime-controller:v0.8.5-00f609e
44+
image: fluidcloudnative/alluxioruntime-controller:v0.8.6-2131f34
4345
runtime:
4446
# image: fluidcloudnative/alluxio:release-2.7.3-SNAPSHOT-a7154f1
4547
image: fluidcloudnative/alluxio:release-2.8.1-SNAPSHOT-0433ade
@@ -59,21 +61,21 @@ runtime:
5961
fuse:
6062
image: registry.cn-shanghai.aliyuncs.com/jindofs/jindo-fuse:4.5.1
6163
controller:
62-
image: fluidcloudnative/jindoruntime-controller:v0.8.5-00f609e
64+
image: fluidcloudnative/jindoruntime-controller:v0.8.6-2131f34
6365
init:
6466
portCheck:
6567
enabled: false
66-
image: fluidcloudnative/init-users:v0.8.5-00f609e
68+
image: fluidcloudnative/init-users:v0.8.6-2131f34
6769
goosefs:
6870
replicas: 1
6971
runtimeWorkers: 3
7072
portRange: 26000-32000
7173
portAllocatePolicy: random
7274
enabled: false
7375
init:
74-
image: fluidcloudnative/init-users:v0.8.5-00f609e
76+
image: fluidcloudnative/init-users:v0.8.6-2131f34
7577
controller:
76-
image: fluidcloudnative/goosefsruntime-controller:v0.8.5-00f609e
78+
image: fluidcloudnative/goosefsruntime-controller:v0.8.6-2131f34
7779
runtime:
7880
image: ccr.ccs.tencentyun.com/qcloud/goosefs:v1.2.0
7981
fuse:
@@ -82,18 +84,18 @@ runtime:
8284
replicas: 1
8385
enabled: false
8486
controller:
85-
image: fluidcloudnative/juicefsruntime-controller:v0.8.5-00f609e
87+
image: fluidcloudnative/juicefsruntime-controller:v0.8.6-2131f34
8688
fuse:
8789
image: juicedata/juicefs-fuse:v1.0.0-4.8.0
8890

8991
webhook:
9092
enabled: true
91-
image: fluidcloudnative/fluid-webhook:v0.8.5-00f609e
93+
image: fluidcloudnative/fluid-webhook:v0.8.6-2131f34
9294
replicas: 1
9395
reinvocationPolicy: Never
9496

9597
fluidapp:
9698
enabled: true
9799
replicas: 1
98100
controller:
99-
image: fluidcloudnative/application-controller:v0.8.5-00f609e
101+
image: fluidcloudnative/application-controller:v0.8.6-2131f34

cmd/csi/app/csi.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ import (
3939
)
4040

4141
var (
42-
endpoint string
43-
nodeID string
44-
metricsAddr string
45-
pprofAddr string
46-
pruneFs []string
47-
prunePath string
42+
endpoint string
43+
nodeID string
44+
metricsAddr string
45+
pprofAddr string
46+
pruneFs []string
47+
prunePath string
48+
kubeletKubeConfigPath string
4849
)
4950

5051
var scheme = runtime.NewScheme()
@@ -81,6 +82,7 @@ func init() {
8182
startCmd.Flags().StringVarP(&prunePath, "prune-path", "", "/runtime-mnt", "Prune path to add in /etc/updatedb.conf")
8283
startCmd.Flags().StringVarP(&metricsAddr, "metrics-addr", "", ":8080", "The address the metrics endpoint binds to.")
8384
startCmd.Flags().StringVarP(&pprofAddr, "pprof-addr", "", "", "The address for pprof to use while exporting profiling results")
85+
startCmd.Flags().StringVarP(&kubeletKubeConfigPath, "kubelet-kube-config", "", "/etc/kubernetes/kubelet.conf", "The file path to kubelet kube config")
8486
utilfeature.DefaultMutableFeatureGate.AddFlag(startCmd.Flags())
8587
startCmd.Flags().AddGoFlagSet(flag.CommandLine)
8688
}
@@ -109,10 +111,11 @@ func handle() {
109111
}
110112

111113
config := config.Config{
112-
NodeId: nodeID,
113-
Endpoint: endpoint,
114-
PruneFs: pruneFs,
115-
PrunePath: prunePath,
114+
NodeId: nodeID,
115+
Endpoint: endpoint,
116+
PruneFs: pruneFs,
117+
PrunePath: prunePath,
118+
KubeletConfigPath: kubeletKubeConfigPath,
116119
}
117120

118121
if err = csi.SetupWithManager(mgr, config); err != nil {

pkg/csi/config/config.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ limitations under the License.
1717
package config
1818

1919
type Config struct {
20-
NodeId string
21-
Endpoint string
22-
PruneFs []string
23-
PrunePath string
20+
NodeId string
21+
Endpoint string
22+
PruneFs []string
23+
PrunePath string
24+
KubeletConfigPath string
2425
}

pkg/csi/plugins/driver.go

+20-15
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ import (
2020
"fmt"
2121
"os"
2222
"path/filepath"
23+
"strings"
24+
25+
"k8s.io/client-go/kubernetes"
2326
"sigs.k8s.io/controller-runtime/pkg/client"
2427
"sigs.k8s.io/controller-runtime/pkg/manager"
25-
"strings"
2628

2729
"github.com/container-storage-interface/spec/lib/go/csi"
2830
"github.com/fluid-cloudnative/fluid/pkg/utils"
@@ -36,15 +38,16 @@ const (
3638
)
3739

3840
type driver struct {
39-
client client.Client
40-
apiReader client.Reader
41-
csiDriver *csicommon.CSIDriver
42-
nodeId, endpoint string
41+
client client.Client
42+
apiReader client.Reader
43+
nodeAuthorizedClient *kubernetes.Clientset
44+
csiDriver *csicommon.CSIDriver
45+
nodeId, endpoint string
4346
}
4447

4548
var _ manager.Runnable = &driver{}
4649

47-
func NewDriver(nodeID, endpoint string, client client.Client, apiReader client.Reader) *driver {
50+
func NewDriver(nodeID, endpoint string, client client.Client, apiReader client.Reader, nodeAuthorizedClient *kubernetes.Clientset) *driver {
4851
glog.Infof("Driver: %v version: %v", driverName, version)
4952

5053
proto, addr := utils.SplitSchemaAddr(endpoint)
@@ -66,11 +69,12 @@ func NewDriver(nodeID, endpoint string, client client.Client, apiReader client.R
6669
csiDriver.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER})
6770

6871
return &driver{
69-
nodeId: nodeID,
70-
endpoint: endpoint,
71-
csiDriver: csiDriver,
72-
client: client,
73-
apiReader: apiReader,
72+
nodeId: nodeID,
73+
endpoint: endpoint,
74+
csiDriver: csiDriver,
75+
client: client,
76+
nodeAuthorizedClient: nodeAuthorizedClient,
77+
apiReader: apiReader,
7478
}
7579
}
7680

@@ -82,10 +86,11 @@ func (d *driver) newControllerServer() *controllerServer {
8286

8387
func (d *driver) newNodeServer() *nodeServer {
8488
return &nodeServer{
85-
nodeId: d.nodeId,
86-
DefaultNodeServer: csicommon.NewDefaultNodeServer(d.csiDriver),
87-
client: d.client,
88-
apiReader: d.apiReader,
89+
nodeId: d.nodeId,
90+
DefaultNodeServer: csicommon.NewDefaultNodeServer(d.csiDriver),
91+
client: d.client,
92+
apiReader: d.apiReader,
93+
nodeAuthorizedClient: d.nodeAuthorizedClient,
8994
}
9095
}
9196

0 commit comments

Comments
 (0)