Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete all deployed resources without a extra rbac role when using he… #2208

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions charts/graphscope/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ See [*helm repo*](https://helm.sh/docs/helm/helm_repo/) for command documentatio

## Install Chart

GraphScope rely on some permissions to delete resources.

```shell
# example for `default` ServiceAccount with `default` namespace
$ wget https://raw.githubusercontent.com/alibaba/GraphScope/main/charts/role_and_binding.yaml
$ kubectl create -f ./role_and_binding.yaml
```

```shell
# Helm 3
$ helm install [RELEASE_NAME] graphscope/graphscope
Expand Down
13 changes: 11 additions & 2 deletions charts/graphscope/templates/coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,17 @@ spec:
preStop:
exec:
command:
- python3
- /usr/local/bin/pre_stop.py
- /bin/bash
- -c
- |
kubectl patch role/{{ include "graphscope.fullname" . }}-role \
-n {{ .Release.Namespace }} \
--type json \
--patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]' && \
kubectl patch rolebinding/{{ include "graphscope.fullname" . }}-role-binding \
-n {{ .Release.Namespace }} \
--type json \
--patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'
command:
- python3
- "-m"
Expand Down
7 changes: 7 additions & 0 deletions charts/graphscope/templates/role_and_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ kind: Role
metadata:
name: {{ include "graphscope.fullname" . }}-role
namespace: {{ .Release.Namespace }}
finalizers:
- kubernetes
rules:
- apiGroups: ["apps", "extensions", ""]
resources: ["configmaps", "deployments", "deployments/status", "endpoints", "events", "pods", "pods/log", "pods/exec", "pods/status", "services", "replicasets"]
verbs: ["*"]
- apiGroups: ["rbac.authorization.k8s.io"]
resources: ["roles", "rolebindings"]
verbs: ["patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "graphscope.fullname" . }}-role-binding
namespace: {{ .Release.Namespace }}
finalizers:
- kubernetes
subjects:
- kind: ServiceAccount
name: default
Expand Down