Skip to content

Commit 87b7751

Browse files
authored
Reduce privileges required to install Vizier (#1356)
Summary: Cleans up RBAC rules for Vizier in order to reduce the privileges required to install it. Removes `pl-updater` service account and its RBAC, which included non-functional `ClusterRole` and `ClusterRoleBinding` and doesn't appear to be used by the current operator-based upgrade workflow. Type of change: /kind cleanup Test Plan: Tested new yamls on a local minikube using `skaffold` as suggested in DEVELOPMENT.md, deleted `proxy-tls-certs` manually and re-ran the cert-provisioner-job successfully. Tested change to vizier_yaml.go by running the template generator against a local build of the base yaml tar, observed that the new binding's subject namespace is templated as expected. Fixes: #634 and #1353 Signed-off-by: Gabriel Rosenhouse <grosenhouse@vmware.com>
1 parent d8931cf commit 87b7751

File tree

7 files changed

+127
-49
lines changed

7 files changed

+127
-49
lines changed

k8s/vizier/base/metadata_role.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,24 @@ metadata:
1111
rules:
1212
- apiGroups:
1313
- ""
14-
- "apps"
1514
resources:
1615
- pods
1716
- services
1817
- endpoints
1918
- namespaces
20-
- replicasets
21-
- deployments
2219
verbs:
2320
- "watch"
2421
- "get"
2522
- "list"
23+
- apiGroups:
24+
- apps
25+
resources:
26+
- replicasets
27+
- deployments
28+
verbs:
29+
- watch
30+
- get
31+
- list
2632
---
2733
apiVersion: rbac.authorization.k8s.io/v1
2834
kind: ClusterRoleBinding
@@ -72,7 +78,10 @@ rules:
7278
- ""
7379
resources:
7480
- endpoints
75-
verbs: ["*"]
81+
verbs:
82+
- get
83+
- list
84+
- watch
7685
- apiGroups:
7786
- coordination.k8s.io
7887
resources:

k8s/vizier/bootstrap/cert_provisioner_job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ spec:
88
metadata:
99
name: cert-provisioner-job
1010
spec:
11-
serviceAccountName: pl-updater-service-account
11+
serviceAccountName: pl-cert-provisioner-service-account
1212
containers:
1313
- name: provisioner
1414
image: gcr.io/pixie-oss/pixie-dev/vizier/cert_provisioner_image:latest
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: pl-cert-provisioner-service-account
6+
---
7+
apiVersion: rbac.authorization.k8s.io/v1
8+
kind: Role
9+
metadata:
10+
name: pl-cert-provisioner-role
11+
rules:
12+
- apiGroups:
13+
- ""
14+
resources:
15+
- secrets
16+
verbs:
17+
- create
18+
- delete
19+
- get
20+
- list
21+
- patch
22+
- update
23+
- watch
24+
---
25+
apiVersion: rbac.authorization.k8s.io/v1
26+
kind: RoleBinding
27+
metadata:
28+
name: pl-cert-provisioner-binding
29+
roleRef:
30+
apiGroup: rbac.authorization.k8s.io
31+
kind: Role
32+
name: pl-cert-provisioner-role
33+
subjects:
34+
- kind: ServiceAccount
35+
name: pl-cert-provisioner-service-account
36+
namespace: pl

k8s/vizier/bootstrap/cloud_connector_role.yaml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,38 @@ rules:
5858
resources:
5959
- jobs
6060
verbs:
61-
- "*"
61+
- create
62+
- delete
63+
- get
64+
- list
65+
- patch
66+
- update
67+
- watch
6268
- apiGroups:
6369
- ""
64-
- px.dev
6570
resources:
6671
- secrets
6772
- pods
73+
verbs:
74+
- create
75+
- delete
76+
- get
77+
- list
78+
- patch
79+
- update
80+
- watch
81+
- apiGroups:
82+
- px.dev
83+
resources:
6884
- viziers
6985
verbs:
70-
- "*"
86+
- create
87+
- delete
88+
- get
89+
- list
90+
- patch
91+
- update
92+
- watch
7193
- apiGroups:
7294
- coordination.k8s.io
7395
resources:

k8s/vizier/bootstrap/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ resources:
1212
- cloud_connector_service.yaml
1313
- updater_role.yaml
1414
- cloud_connector_role.yaml
15+
- cert_provisioner_role.yaml
1516
- cert_provisioner_job.yaml
1617
- vizier_crd_role.yaml

k8s/vizier/bootstrap/updater_role.yaml

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,67 @@ metadata:
55
name: pl-updater-service-account
66
---
77
apiVersion: rbac.authorization.k8s.io/v1
8-
kind: ClusterRoleBinding
9-
metadata:
10-
name: pl-updater-cluster-binding
11-
roleRef:
12-
apiGroup: rbac.authorization.k8s.io
13-
kind: ClusterRole
14-
name: pl-updater-role
15-
subjects:
16-
- kind: ServiceAccount
17-
name: pl-updater-service-account
18-
namespace: pl
19-
---
20-
apiVersion: rbac.authorization.k8s.io/v1
21-
kind: ClusterRole
22-
metadata:
23-
name: pl-updater-cluster-role
24-
rules:
25-
# Allow actions on Kubernetes objects
26-
- apiGroups:
27-
- rbac.authorization.k8s.io
28-
- etcd.database.coreos.com
29-
- nats.io
30-
resources:
31-
- clusterroles
32-
- clusterrolebindings
33-
- persistentvolumes
34-
- etcdclusters
35-
- natsclusters
36-
verbs: ["*"]
37-
---
38-
apiVersion: rbac.authorization.k8s.io/v1
398
kind: Role
409
metadata:
4110
name: pl-updater-role
4211
rules:
4312
- apiGroups:
4413
- ""
45-
- apps
46-
- rbac.authorization.k8s.io
47-
- extensions
48-
- batch
49-
- policy
5014
resources:
5115
- configmaps
5216
- secrets
5317
- pods
5418
- services
55-
- deployments
56-
- daemonsets
5719
- persistentvolumes
58-
- roles
59-
- rolebindings
6020
- serviceaccounts
21+
verbs:
22+
- create
23+
- delete
24+
- get
25+
- list
26+
- patch
27+
- update
28+
- watch
29+
- apiGroups:
30+
- apps
31+
resources:
32+
- deployments
33+
- daemonsets
6134
- statefulsets
35+
verbs:
36+
- create
37+
- delete
38+
- get
39+
- list
40+
- patch
41+
- update
42+
- watch
43+
- apiGroups:
44+
- batch
45+
resources:
6246
- cronjobs
6347
- jobs
64-
verbs: ["*"]
48+
verbs:
49+
- create
50+
- delete
51+
- get
52+
- list
53+
- patch
54+
- update
55+
- watch
56+
- apiGroups:
57+
- rbac.authorization.k8s.io
58+
resources:
59+
- roles
60+
- rolebindings
61+
verbs:
62+
- create
63+
- delete
64+
- get
65+
- list
66+
- patch
67+
- update
68+
- watch
6569
---
6670
apiVersion: rbac.authorization.k8s.io/v1
6771
kind: RoleBinding

src/utils/template_generator/vizier_yamls/vizier_yamls.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ func generateVzYAMLs(yamlMap map[string]string) ([]*yamls.YAMLFile, error) {
364364
Placeholder: ".pl.svc",
365365
TemplateValue: fmt.Sprintf(".%s.svc", nsTmpl),
366366
},
367+
{
368+
TemplateMatcher: yamls.GenerateResourceNameMatcherFn("pl-cert-provisioner-binding"),
369+
Patch: `{ "subjects": [{ "name": "pl-cert-provisioner-service-account", "namespace": "__PX_SUBJECT_NAMESPACE__", "kind": "ServiceAccount" }] }`,
370+
Placeholder: "__PX_SUBJECT_NAMESPACE__",
371+
TemplateValue: nsTmpl,
372+
},
367373
{
368374
TemplateMatcher: yamls.GenerateResourceNameMatcherFn("pl-updater-binding"),
369375
Patch: `{ "subjects": [{ "name": "pl-updater-service-account", "namespace": "__PX_SUBJECT_NAMESPACE__", "kind": "ServiceAccount" }] }`,

0 commit comments

Comments
 (0)