Add service account to manage deployments in nextcloud

This commit is contained in:
Waqar Ahmed 2020-12-11 20:31:59 +05:00
parent efd1cb8a81
commit 0283799700
2 changed files with 46 additions and 0 deletions

View File

@ -113,3 +113,10 @@ Postgres Selector labels
app.kubernetes.io/name: {{ include "nextcloud.name" . }}-postgres
app.kubernetes.io/instance: {{ .Release.Name }}-postgres
{{- end }}
{{/*
Nextcloud service account
*/}}
{{- define "nextcloud.serviceAccountName" -}}
{{- printf "%s-service-account" .Release.Name -}}
{{- end -}}

View File

@ -0,0 +1,39 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "nextcloud.serviceAccountName" }}
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Release.Name }}-service-account-role-binding
subjects:
- kind: ServiceAccount
name: {{ template "nextcloud.serviceAccountName" }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: spinupcontainers
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ .Release.Name }}-service-account-role
namespace: {{ .Release.Namespace }}
rules:
- apiGroups:
- ""
- "apps"
resources:
- pods
- deployments
verbs:
- delete
- get
- list