Skip to content

Commit

Permalink
Allow provisioner to be namespaced
Browse files Browse the repository at this point in the history
In the Grafana Federal Cloud we have clusters where we cannot create ClusterRole/ClusterRoleBinding
due to an increased security posture.  To ensure we can deploy the provisioner in these clusters,
this PR conditionally generates Role instead of ClusterRole if enterprise and enterprise.provisioner
are enabled and rbac.namespaced is true.

This PR also updates the provisioner job helm hooks to allow it to be customized to run on other hookTypes.
This still defaults to post-install and should have no impact to current usage.  This will allow the Grafana
Federal Cloud to use the provisioner after helm post-upgrades to attempt to create tenants as required.

Closes deployment_tools/#185454

Signed-off-by: Ryan Brady <[email protected]>
  • Loading branch information
rbrady committed Feb 4, 2025
1 parent 9ddc756 commit 1c6f271
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions docs/sources/setup/install/helm/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3075,6 +3075,7 @@ null
"enabled": true,
"env": [],
"extraVolumeMounts": [],
"hookType": "post-install",
"image": {
"digest": null,
"pullPolicy": "IfNotPresent",
Expand Down Expand Up @@ -3263,6 +3264,7 @@ null
"enabled": true,
"env": [],
"extraVolumeMounts": [],
"hookType": "post-install",
"image": {
"digest": null,
"pullPolicy": "IfNotPresent",
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Helm chart for Grafana Loki and Grafana Enterprise Logs supporting both simple,
| Repository | Name | Version |
|------------|------|---------|
| https://charts.min.io/ | minio(minio) | 5.4.0 |
| https://grafana.github.io/helm-charts | grafana-agent-operator(grafana-agent-operator) | 0.5.0 |
| https://grafana.github.io/helm-charts | grafana-agent-operator(grafana-agent-operator) | 0.5.1 |
| https://grafana.github.io/helm-charts | rollout_operator(rollout-operator) | 0.23.0 |

Find more information in the Loki Helm Chart [documentation](https://grafana.com/docs/loki/next/installation/helm).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ metadata:
{{- with .Values.enterprise.provisioner.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
"helm.sh/hook": post-install
"helm.sh/hook": {{ .Values.enterprise.provisioner.hookType | default "post-install" | quote }}
"helm.sh/hook-weight": "15"
spec:
backoffLimit: 6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ if and (and .Values.enterprise.provisioner.enabled .Values.enterprise.enabled) (not .Values.rbac.namespaced)}}
{{ if and .Values.enterprise.provisioner.enabled .Values.enterprise.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
kind: {{ if not .Values.rbac.namespaced }}Cluster{{ end }}Role
metadata:
name: {{ template "enterprise-logs.provisionerFullname" . }}
namespace: {{ $.Release.Namespace }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ if and (and .Values.enterprise.provisioner.enabled .Values.enterprise.enabled) (not .Values.rbac.namespaced)}}
{{ if and .Values.enterprise.provisioner.enabled .Values.enterprise.enabled}}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
kind: {{ if not .Values.rbac.namespaced }}Cluster{{ else }}Role{{ end }}Binding
metadata:
name: {{ template "enterprise-logs.provisionerFullname" . }}
namespace: {{ $.Release.Namespace }}
Expand All @@ -17,7 +17,7 @@ metadata:
"helm.sh/hook": post-install
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
kind: {{ if not .Values.rbac.namespaced }}Cluster{{ end }}Role
name: {{ template "enterprise-logs.provisionerFullname" . }}
subjects:
- kind: ServiceAccount
Expand Down
2 changes: 2 additions & 0 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ enterprise:
enabled: true
# -- Name of the secret to store provisioned tokens in
provisionedSecretPrefix: null
#-- Hook type(s) to customize when the job runs. defaults to post-install

Check failure on line 578 in production/helm/loki/values.yaml

View workflow job for this annotation

GitHub Actions / Test Helm Chart

578:6 [comments] missing starting space in comment
hookType: "post-install"
# -- Additional tenants to be created. Each tenant will get a read and write policy
# and associated token. Tenant must have a name and a namespace for the secret containting
# the token to be created in. For example
Expand Down

0 comments on commit 1c6f271

Please sign in to comment.