Deployments to work with specific namespaces instead of all namespaces (#2635)
* remove namespaceAll in deployments * remove GetNamespace function from informer * added logger and improvement for naming * move reaper logic to utils Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> Co-authored-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
co-authored by
Sanket Sudake
parent
0aec9e139e
commit
526b5f0beb
+3
-28
@@ -1,8 +1,6 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -13,37 +11,14 @@ import (
|
||||
"k8s.io/client-go/tools/cache"
|
||||
metricsapi "k8s.io/metrics/pkg/apis/metrics"
|
||||
|
||||
v1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
"github.com/fission/fission/pkg/generated/clientset/versioned"
|
||||
genInformer "github.com/fission/fission/pkg/generated/informers/externalversions"
|
||||
)
|
||||
|
||||
const additionalNamespaces string = "FISSION_RESOURCE_NAMESPACES"
|
||||
|
||||
func GetNamespaces() []string {
|
||||
envValue := os.Getenv(additionalNamespaces)
|
||||
if len(envValue) == 0 {
|
||||
return []string{
|
||||
metav1.NamespaceAll,
|
||||
}
|
||||
}
|
||||
|
||||
informerNS := make([]string, 0)
|
||||
lstNamespaces := strings.Split(envValue, ",")
|
||||
for _, namespace := range lstNamespaces {
|
||||
//check to handle string with additional comma at the end of string. eg- ns1,ns2,
|
||||
if namespace != "" {
|
||||
informerNS = append(informerNS, namespace)
|
||||
}
|
||||
}
|
||||
return informerNS
|
||||
}
|
||||
|
||||
func GetInformersForNamespaces(client versioned.Interface, defaultSync time.Duration, kind string) map[string]cache.SharedIndexInformer {
|
||||
informers := make(map[string]cache.SharedIndexInformer)
|
||||
for _, ns := range GetNamespaces() {
|
||||
for _, ns := range DefaultNSResolver().FissionResourceNS {
|
||||
factory := genInformer.NewFilteredSharedInformerFactory(client, defaultSync, ns, nil).Core().V1()
|
||||
switch kind {
|
||||
case fv1.CanaryConfigResource:
|
||||
@@ -79,8 +54,8 @@ func GetInformerFactoryByReadyPod(client kubernetes.Interface, namespace string,
|
||||
return informerFactory, nil
|
||||
}
|
||||
|
||||
func GetInformerFactoryByExecutor(client kubernetes.Interface, executorType v1.ExecutorType, defaultResync time.Duration) (k8sInformers.SharedInformerFactory, error) {
|
||||
executorLabel, err := labels.NewRequirement(v1.EXECUTOR_TYPE, selection.DoubleEquals, []string{string(executorType)})
|
||||
func GetInformerFactoryByExecutor(client kubernetes.Interface, executorType fv1.ExecutorType, defaultResync time.Duration) (k8sInformers.SharedInformerFactory, error) {
|
||||
executorLabel, err := labels.NewRequirement(fv1.EXECUTOR_TYPE, selection.DoubleEquals, []string{string(executorType)})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user