Allow empty namespace for fission function and builder (#2621)

Currently, we create Fission resources in the default namespace, function-related resources are created in the fission-function namespace, whereas builder resources are created in the fission-builder namespace. This causes confusion for a lot of users.
In this fix, we allow the user to set the function and builder namespace empty so that function and builder resources are created in the same namespace as the function resource always.

If the user desires older behaviour they can functionNamespace and builderNamespace the same previous before the upgrade.

* use default namespace for fission  function and builder
* support for existing fission namespaces
* Replace builder and function namespace with template
* Fix namespace creation template

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Shubham Bansal
2022-11-16 22:16:05 +05:30
committed by GitHub
parent 70a0afd624
commit 6d117ad43a
31 changed files with 357 additions and 199 deletions
+6 -4
View File
@@ -184,7 +184,8 @@ func CleanupHpa(ctx context.Context, logger *zap.Logger, client kubernetes.Inter
// CleanupRoleBindings periodically lists rolebindings across all namespaces and removes Service Accounts from them or
// deletes the rolebindings completely if there are no Service Accounts in a rolebinding object.
func CleanupRoleBindings(ctx context.Context, logger *zap.Logger, client kubernetes.Interface, fissionClient versioned.Interface, functionNs, envBuilderNs string, cleanupRoleBindingInterval time.Duration) {
func CleanupRoleBindings(ctx context.Context, logger *zap.Logger, client kubernetes.Interface, fissionClient versioned.Interface, cleanupRoleBindingInterval time.Duration) {
nsResolver := utils.DefaultNSResolver()
for {
// some sleep before the next reaper iteration
time.Sleep(cleanupRoleBindingInterval)
@@ -238,8 +239,8 @@ func CleanupRoleBindings(ctx context.Context, logger *zap.Logger, client kuberne
// so now we need to look for the objects in default namespace.
saNs := subj.Namespace
isInReservedNS := false
if subj.Namespace == functionNs ||
subj.Namespace == envBuilderNs {
if subj.Namespace == nsResolver.FunctionNamespace ||
subj.Namespace == nsResolver.BuiderNamespace {
saNs = metav1.NamespaceDefault
isInReservedNS = true
}
@@ -249,7 +250,8 @@ func CleanupRoleBindings(ctx context.Context, logger *zap.Logger, client kuberne
for _, fn := range funcList.Items {
if fn.Spec.Environment.Namespace == saNs ||
// For the case that the environment is created in the reserved namespace.
(isInReservedNS && (fn.Spec.Environment.Namespace == functionNs || fn.Spec.Environment.Namespace == envBuilderNs)) {
(isInReservedNS && (fn.Spec.Environment.Namespace == nsResolver.FunctionNamespace ||
fn.Spec.Environment.Namespace == nsResolver.BuiderNamespace)) {
funcEnvReference = true
break
}