Skip to content

Commit 7ae2a2b

Browse files
authored
Merge pull request #285 from davidz627/feature/updateRBAC
Pull deployment scripting and RBAC rule fixes into v0.5.0 release branch
2 parents ebd0c0f + d1538d7 commit 7ae2a2b

File tree

4 files changed

+46
-30
lines changed

4 files changed

+46
-30
lines changed

deploy/kubernetes/base/setup-cluster.yaml

+9-6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,15 @@ rules:
5454
- apiGroups: ["storage.k8s.io"]
5555
resources: ["storageclasses"]
5656
verbs: ["get", "list", "watch"]
57+
- apiGroups: [""]
58+
resources: ["events"]
59+
verbs: ["list", "watch", "create", "update", "patch"]
5760
- apiGroups: ["storage.k8s.io"]
5861
resources: ["csinodes"]
5962
verbs: ["get", "list", "watch"]
6063
- apiGroups: [""]
61-
resources: ["events"]
62-
verbs: ["list", "watch", "create", "update", "patch"]
64+
resources: ["nodes"]
65+
verbs: ["get", "list", "watch"]
6366

6467
---
6568

@@ -85,16 +88,16 @@ metadata:
8588
rules:
8689
- apiGroups: [""]
8790
resources: ["persistentvolumes"]
88-
verbs: ["get", "list", "watch", "update"]
91+
verbs: ["get", "list", "watch", "update", "patch"]
8992
- apiGroups: [""]
9093
resources: ["nodes"]
9194
verbs: ["get", "list", "watch"]
92-
- apiGroups: ["csi.storage.k8s.io"]
93-
resources: ["csinodeinfos"]
95+
- apiGroups: ["storage.k8s.io"]
96+
resources: ["csinodes"]
9497
verbs: ["get", "list", "watch"]
9598
- apiGroups: ["storage.k8s.io"]
9699
resources: ["volumeattachments"]
97-
verbs: ["get", "list", "watch", "update"]
100+
verbs: ["get", "list", "watch", "update", "patch"]
98101

99102
---
100103

deploy/kubernetes/deploy-driver.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ function check_service_account()
5050
# Using bash magic to parse JSON for IAM
5151
# Grepping for a line with client email returning anything quoted after the colon
5252
readonly IAM_NAME=$(grep -Po '"client_email": *\K"[^"]*"' ${GCE_PD_SA_DIR}/cloud-sa.json | tr -d '"')
53-
# Grepping anything after the @ tell the first . as the project name
54-
readonly PROJECT=$(grep -Po '.*@\K[^.]+'<<<${IAM_NAME})
53+
readonly PROJECT=$(grep -Po '"project_id": *\K"[^"]*"' ${GCE_PD_SA_DIR}/cloud-sa.json | tr -d '"')
5554
readonly GOTTEN_BIND_ROLES=$(gcloud projects get-iam-policy ${PROJECT} --flatten="bindings[].members" --format='table(bindings.role)' --filter="bindings.members:${IAM_NAME}")
5655
readonly BIND_ROLES=$(get_needed_roles)
5756
MISSING_ROLES=false

deploy/kubernetes/overlays/alpha/rbac_add_snapshotter.yaml

+25-21
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@ kind: ClusterRole
44
metadata:
55
name: external-snapshotter-role
66
rules:
7-
- apiGroups: ["snapshot.storage.k8s.io"]
8-
resources: ["volumesnapshotclasses"]
9-
verbs: ["get", "list", "watch"]
10-
- apiGroups: ["snapshot.storage.k8s.io"]
11-
resources: ["volumesnapshotcontents"]
12-
verbs: ["create", "get", "list", "watch", "update", "delete"]
13-
- apiGroups: ["snapshot.storage.k8s.io"]
14-
resources: ["volumesnapshots"]
15-
verbs: ["get", "list", "watch", "update"]
16-
- apiGroups: ["apiextensions.k8s.io"]
17-
resources: ["customresourcedefinitions"]
18-
verbs: ["create", "list", "watch", "delete"]
19-
- apiGroups: [""]
20-
resources: ["events"]
21-
verbs: ["list", "watch", "create", "update", "patch"]
22-
- apiGroups: ["storage.k8s.io"]
23-
resources: ["storageclasses"]
24-
verbs: ["watch", "get", "list"]
25-
- apiGroups: ["admissionregistration.k8s.io"]
26-
resources: ["mutatingwebhookconfigurations"]
27-
verbs: ["create"]
7+
- apiGroups: [""]
8+
resources: ["persistentvolumes"]
9+
verbs: ["get", "list", "watch"]
10+
- apiGroups: [""]
11+
resources: ["persistentvolumeclaims"]
12+
verbs: ["get", "list", "watch", "update"]
13+
- apiGroups: ["storage.k8s.io"]
14+
resources: ["storageclasses"]
15+
verbs: ["get", "list", "watch"]
16+
- apiGroups: [""]
17+
resources: ["events"]
18+
verbs: ["list", "watch", "create", "update", "patch"]
19+
# Secrets resource ommitted since GCE PD snapshots does not require them
20+
- apiGroups: ["snapshot.storage.k8s.io"]
21+
resources: ["volumesnapshotclasses"]
22+
verbs: ["get", "list", "watch"]
23+
- apiGroups: ["snapshot.storage.k8s.io"]
24+
resources: ["volumesnapshotcontents"]
25+
verbs: ["create", "get", "list", "watch", "update", "delete"]
26+
- apiGroups: ["snapshot.storage.k8s.io"]
27+
resources: ["volumesnapshots"]
28+
verbs: ["get", "list", "watch", "update"]
29+
- apiGroups: ["apiextensions.k8s.io"]
30+
resources: ["customresourcedefinitions"]
31+
verbs: ["create", "list", "watch", "delete"]
2832

2933
---
3034

deploy/setup-project.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,19 @@ ensure_var PROJECT
2525
ensure_var GCE_PD_SA_NAME
2626
ensure_var GCE_PD_SA_DIR
2727

28+
# If the project id includes the org name in the format "org-name:project", the
29+
# gCloud api will format the project part of the iam email domain as
30+
# "project.org-name"
31+
if [[ $PROJECT == *":"* ]]; then
32+
IFS=':' read -ra SPLIT <<< "$PROJECT"
33+
readonly IAM_PROJECT="${SPLIT[1]}.${SPLIT[0]}"
34+
else
35+
readonly IAM_PROJECT="${PROJECT}"
36+
fi
37+
2838
readonly KUBEDEPLOY="${PKGDIR}/deploy/kubernetes"
2939
readonly BIND_ROLES=$(get_needed_roles)
30-
readonly IAM_NAME="${GCE_PD_SA_NAME}@${PROJECT}.iam.gserviceaccount.com"
40+
readonly IAM_NAME="${GCE_PD_SA_NAME}@${IAM_PROJECT}.iam.gserviceaccount.com"
3141

3242
# Check if SA exists
3343
CREATE_SA=true

0 commit comments

Comments
 (0)