Skip to content

Commit

Permalink
fix: add missing helm hook annotations to test objects
Browse files Browse the repository at this point in the history
Previously the test role and rolebinding were being installed
unconditionally. With this change they are only installed when running
helm test and then removed.

Having the role and rolebinding installed unconditionally would mean
that any serviceaccount (including the default) would be able to view
service objects in the lagoon-logging namespace. This is an unnecessary
elevation of privilege, but these service objects do not contain
anything sensitive.
  • Loading branch information
smlx committed Feb 21, 2024
1 parent 1e57969 commit 4db1425
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: service-reader
annotations:
"helm.sh/hook": test
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["services"]
Expand All @@ -12,6 +15,9 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-services
annotations:
"helm.sh/hook": test
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
subjects:
- kind: Group
name: system:serviceaccounts # all serviceaccounts
Expand All @@ -29,6 +35,7 @@ metadata:
{{- include "lagoon-logging.logsDispatcher.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
containers:
- name: kubectl
Expand Down
1 change: 1 addition & 0 deletions charts/lagoon-logging/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
{{- include "lagoon-logging.logsDispatcher.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
containers:
- name: nc
Expand Down

0 comments on commit 4db1425

Please sign in to comment.