Skip to content

Commit

Permalink
Create appropriate role/rolebinding for tenant in OpenShift (#74)
Browse files Browse the repository at this point in the history
When running in OpenShift, tenant cointainer
is dumping errors when being started. This fix
sets appropriate role and rolebinding to use
anyuid service account only for OpenShift deployment

Resolves: #73

Signed-off-by: Sergio Arroutbi <[email protected]>
  • Loading branch information
sarroutbi authored Mar 20, 2024
1 parent b88f824 commit 7306f8b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
14 changes: 14 additions & 0 deletions build/helm/keylime/charts/keylime-tenant/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,17 @@ Define a custom image pullpolicy.
{{- toYaml .Values.image.pullPolicy }}
{{- end }}
{{- end }}

{{/*
Create the name of the role to use
*/}}
{{- define "tenant.roleName" -}}
{{- default (include "tenant.fullname" .) .Values.role.name }}
{{- end }}

{{/*
Create the name of the role binding to use
*/}}
{{- define "tenant.roleBindingName" -}}
{{- default (include "tenant.fullname" .) .Values.roleBinding.name }}
{{- end }}
15 changes: 15 additions & 0 deletions build/helm/keylime/charts/keylime-tenant/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{ if .Values.global.openshift }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "tenant.roleName" . }}
rules:
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
resourceNames:
- anyuid
verbs:
- use
{{ end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ if .Values.global.openshift }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "tenant.roleBindingName" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "tenant.roleName" . }}
subjects:
- kind: ServiceAccount
name: {{ include "tenant.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{ end }}
5 changes: 5 additions & 0 deletions build/helm/keylime/charts/keylime-tenant/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ nodeSelector: {}
tolerations: []

affinity: {}

role:
name: ""
roleBinding:
name: ""

0 comments on commit 7306f8b

Please sign in to comment.