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

Adding RBAC for Betydb Helm components #4

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ maintainers:
email: [email protected]
- name: Aju Tamang
email: [email protected]
- name: Sagar Utekar
email: [email protected]

# location of source code
sources:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Bety is a Web-interface to the Biofuel Ecophysiological Traits and Yields Databa

```
helm repo add ncsa https://opensource.ncsa.illinois.edu/charts/
helm dependency build
```

To install the chart with the release name my-release:
Expand Down
2 changes: 2 additions & 0 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ spec:
name: {{ include "betydb.fullname" . }}-logos
{{- end }}
{{- end }}
serviceAccountName: {{ include "betydb.fullname" . }}
automountServiceAccountToken: false
initContainers:
- name: check-postgresql
image: "{{ $.Values.image.checks }}"
Expand Down
2 changes: 2 additions & 0 deletions templates/hooks/add-user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "betydb.fullname" . }}-hooks
automountServiceAccountToken: false
initContainers:
#{{- if or .Values.dburl .Values.dbtag }}
# - name: check-job
Expand Down
2 changes: 2 additions & 0 deletions templates/hooks/load-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- include "betydb.postgresqlEnv" . | nindent 12 }}
serviceAccountName: {{ include "betydb.fullname" . }}-hooks
automountServiceAccountToken: false
containers:
- name: bety-init
{{- if .Values.dburl }}
Expand Down
16 changes: 16 additions & 0 deletions templates/hooks/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "betydb.fullname" . }}-hooks
labels:
{{- include "betydb.labels" . | nindent 4 }}
rules:
- apiGroups: [""]
resources: ["pods"]
verbs:
- list
- watch
- get
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["get", "list", "watch"]
13 changes: 13 additions & 0 deletions templates/hooks/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "betydb.fullname" . }}-hooks
labels:
{{- include "betydb.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "betydb.fullname" . }}-hooks
subjects:
- kind: ServiceAccount
name: {{ include "betydb.fullname" . }}-hooks
4 changes: 4 additions & 0 deletions templates/hooks/serviceAccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "betydb.fullname" . }}-hooks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a separate account for the hooks? Not sure we need all the permissions listed below for the hooks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using separate service account as permissions required for bety and bety hooks are different.
Will remove endpoint, service access from bety hook role.

21 changes: 21 additions & 0 deletions templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "betydb.fullname" . }}
labels:
{{- include "betydb.labels" . | nindent 4 }}
rules:
- apiGroups: [""]
resources: ["pods", "endpoints", "Services", "configmaps"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be

Suggested change
resources: ["pods", "endpoints", "Services", "configmaps"]
resources: ["pods", "endpoints", "services", "configmaps"]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed extra permissions from bety hook role

verbs:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need any permissions? I don't think right now BETY needs permissions to any of these endpoints services.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Endpoint access added for BETY role as we're accessing them in ingress config and readiness probe.

- list
- watch
- get
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- list
- watch
- get
13 changes: 13 additions & 0 deletions templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "betydb.fullname" . }}
labels:
{{- include "betydb.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "betydb.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "betydb.fullname" . }}
4 changes: 4 additions & 0 deletions templates/serviceAccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "betydb.fullname" . }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this service account be used in the deployment file (and maybe others).