123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- ---
- apiVersion: v1
- kind: ServiceAccount
- metadata:
- name: {{ .Release.Name }}-init
- namespace: {{ .Release.Namespace }}
- annotations:
- "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade,post-delete
- "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
- "helm.sh/hook-weight": "-100"
- {{- if or .Values.serviceAccount.repoCredentials .Values.imagePullSecrets }}
- imagePullSecrets:
- {{- with .Values.serviceAccount.repoCredentials }}
- {{- range . }}
- - name: {{ . }}
- {{- end }}
- {{- end }}
- {{- with .Values.imagePullSecrets }}
- {{ . | toYaml }}
- {{- end }}
- {{- end }}
- ---
- apiVersion: rbac.authorization.k8s.io/v1
- kind: ClusterRole
- metadata:
- annotations:
- "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade,post-delete
- "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
- "helm.sh/hook-weight": "-100"
- name: {{ .Release.Name }}-init
- {{- with .Values.clusterOwnerRefereces }}
- ownerReferences:
- {{- toYaml . | nindent 4 }}
- {{- end }}
- rules:
- - apiGroups: ["apiextensions.k8s.io"]
- resources:
- - customresourcedefinitions
- verbs:
- - create
- - apiGroups: ["apiextensions.k8s.io"]
- resources:
- - customresourcedefinitions
- resourceNames:
- - sgconfigs.stackgres.io
- verbs:
- - get
- - update
- {{- if eq "true" (include "unmodificableWebapiAdminClusterRoleBinding" .) }}
- - apiGroups: ["rbac.authorization.k8s.io"]
- resources:
- - clusterrolebindings
- resourceNames:
- - stackgres-restapi-admin
- verbs:
- - get
- - delete
- {{- end }}
- {{- if .Values.allowedNamespaces }}
- {{- $allowedNamespaces := regexSplit " " (include "allowedNamespaces" .) -1 }}
- - apiGroups: [""]
- resources: ["namespaces"]
- verbs:
- - patch
- - get
- resourceNames:
- {{- with $allowedNamespaces }}
- {{ toYaml . | nindent 2 }}
- {{- end }}
- {{- end }}
- {{- if or .Values.disableClusterRole .Values.disableCrdsAndWebhooksUpdate }}
- - apiGroups: ["apiextensions.k8s.io"]
- resources:
- - customresourcedefinitions
- resourceNames:
- - sgconfigs.stackgres.io
- - sgclusters.stackgres.io
- - sginstanceprofiles.stackgres.io
- - sgpgconfigs.stackgres.io
- - sgpoolconfigs.stackgres.io
- - sgbackups.stackgres.io
- - sgbackupconfigs.stackgres.io
- - sgobjectstorages.stackgres.io
- - sgdbops.stackgres.io
- - sgdistributedlogs.stackgres.io
- - sgshardedclusters.stackgres.io
- - sgshardedbackups.stackgres.io
- - sgshardeddbops.stackgres.io
- - sgscripts.stackgres.io
- verbs:
- - get
- - patch
- - update
- - apiGroups:
- - stackgres.io
- resources:
- - sgclusters
- - sgpgconfigs
- - sginstanceprofiles
- - sgpoolconfigs
- - sgbackupconfigs
- - sgbackups
- - sgdistributedlogs
- - sgdbops
- - sgobjectstorages
- - sgscripts
- - sgshardedclusters
- - sgshardedbackups
- - sgshardeddbops
- - sgconfigs
- verbs:
- - get
- - list
- - update
- - patch
- - apiGroups:
- - admissionregistration.k8s.io
- resources:
- - mutatingwebhookconfigurations
- - validatingwebhookconfigurations
- resourceNames:
- - {{ .Release.Name }}
- verbs:
- - get
- - patch
- {{- end }}
- ---
- apiVersion: rbac.authorization.k8s.io/v1
- kind: ClusterRoleBinding
- metadata:
- name: {{ .Release.Name }}-init
- annotations:
- "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade,post-delete
- "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
- "helm.sh/hook-weight": "-100"
- {{- with .Values.clusterOwnerRefereces }}
- ownerReferences:
- {{- toYaml . | nindent 4 }}
- {{- end }}
- subjects:
- - kind: ServiceAccount
- name: {{ .Release.Name }}-init
- namespace: {{ .Release.Namespace }}
- roleRef:
- kind: ClusterRole
- name: {{ .Release.Name }}-init
- apiGroup: rbac.authorization.k8s.io
- ---
- apiVersion: rbac.authorization.k8s.io/v1
- kind: Role
- metadata:
- annotations:
- "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade,post-delete
- "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
- "helm.sh/hook-weight": "-100"
- name: {{ .Release.Name }}-init
- namespace: {{ .Release.Namespace }}
- rules:
- - apiGroups: ["stackgres.io"]
- resources:
- - sgconfigs
- verbs:
- - create
- - apiGroups: ["stackgres.io"]
- resources:
- - sgconfigs
- resourceNames:
- - {{ .Release.Name }}
- verbs:
- - get
- - update
- - patch
- - delete
- {{- if or .Values.disableClusterRole .Values.disableCrdsAndWebhooksUpdate }}
- - apiGroups:
- - ""
- resources:
- - secrets
- verbs:
- - create
- - apiGroups:
- - ""
- resources:
- - secrets
- resourceNames:
- - {{ default (.Values.cert).secretName (printf "%s-certs" .Release.Name) }}
- verbs:
- - get
- - apiGroups:
- - ""
- resources:
- - pods
- verbs:
- - get
- - apiGroups:
- - stackgres.io
- resources:
- - sgconfigs/status
- resourceNames:
- - {{ .Release.Name }}
- verbs:
- - update
- - patch
- {{- end }}
- ---
- apiVersion: rbac.authorization.k8s.io/v1
- kind: RoleBinding
- metadata:
- {{- with .Values.clusterOwnerRefereces }}
- ownerReferences:
- {{- toYaml . | nindent 4 }}
- {{- end }}
- name: {{ .Release.Name }}-init
- namespace: {{ .Release.Namespace }}
- annotations:
- "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade,post-delete
- "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
- "helm.sh/hook-weight": "-100"
- subjects:
- - kind: ServiceAccount
- name: {{ .Release.Name }}-init
- namespace: {{ .Release.Namespace }}
- roleRef:
- kind: Role
- name: {{ .Release.Name }}-init
- apiGroup: rbac.authorization.k8s.io
|