Create roles for custom resource in function and builder namespace (#2695)

* create roles for custom resource in function and builder namespace
* Create roles for CR for builder in function and builder namespace
* convert warn to info to remove error stack trace
This commit is contained in:
Shubham Bansal
2023-01-17 22:15:04 +05:30
committed by GitHub
parent 0edf2640b1
commit 5db09a899a
5 changed files with 31 additions and 5 deletions
@@ -12,6 +12,15 @@ rules:
- list
- watch
- patch
- apiGroups:
- ""
resources:
- configmaps
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
@@ -5,3 +5,9 @@
{{ include "fission-role-generator" (merge (dict "namespace" $namespace "component" "buildermgr") $) }}
{{- end }}
{{- end }}
{{- if .Values.builderNamespace -}}
{{ include "fission-role-generator" (merge (dict "namespace" .Values.builderNamespace "component" "buildermgr") $) }}
{{- end }}
{{- if .Values.functionNamespace -}}
{{ include "fission-role-generator" (merge (dict "namespace" .Values.functionNamespace "component" "buildermgr") $) }}
{{- end }}
@@ -5,3 +5,9 @@
{{ include "fission-role-generator" (merge (dict "namespace" $namespace "component" "executor") $) }}
{{- end }}
{{- end }}
{{- if .Values.builderNamespace -}}
{{ include "fission-role-generator" (merge (dict "namespace" .Values.builderNamespace "component" "executor") $) }}
{{- end }}
{{- if .Values.functionNamespace -}}
{{ include "fission-role-generator" (merge (dict "namespace" .Values.functionNamespace "component" "executor") $) }}
{{- end }}
+1 -2
View File
@@ -63,8 +63,7 @@ routerPort: 31314
## defaultNamespace represents the namespace in which Fission custom resources will be created by the Fission user.
## This is different from the release namespace.
## Please consider setting `singleDefaultNamespace` and `additionalFissionNamespaces` if you want
## more than one namespace to be used for Fission custom resources.
## Please consider setting `additionalFissionNamespaces` if you want more than one namespace to be used for Fission custom resources.
##
defaultNamespace: default
+9 -3
View File
@@ -145,11 +145,17 @@ func setupSAAndRoleBindings(ctx context.Context, client kubernetes.Interface, lo
for _, permission := range ps.permissions {
permission.exists, err = checkPermission(ctx, client, SAObj, permission.gvr, permission.verb)
if err != nil {
// some error occurred while checking permission
// now assume permission not exists and will add this permission in rules, insted of return
logger.Error("error while checking permission", zap.Error(err))
// some error occurred while checking permission, log error as warning message and continue to create new permissions
logger.Info(err.Error())
}
if !permission.exists {
logger.Info("creating new permission",
zap.String("service_account", SAObj.Name),
zap.String("namespace", SAObj.Namespace),
zap.String("group", permission.gvr.Group),
zap.String("resource", permission.gvr.Resource),
zap.String("verb", permission.verb))
rules = append(rules, rbac.PolicyRule{
APIGroups: []string{permission.gvr.Group},
Resources: []string{permission.gvr.Resource},