func Synchronizer() {
	client := GetKubernetesClient()
	for {
		time.Sleep(time.Hour)
		handlers.NamespaceSynchronize(client)
		handlers.StatefulSetSynchronize(client)
		handlers.DeploymentSynchronize(client)
		handlers.ReplicaSetSynchronize(client)
		handlers.PodSynchronize(client)
		handlers.ServiceSynchronize(client)
		handlers.IngressSynchronize(client)
	}
}
Synchronizer periodically sync resources with database
package main
import (
	"os"
	"os/signal"
	"syscall"
	"time"
	log "github.com/Sirupsen/logrus"
	handlers "github.com/intuit/katlas/controller/handlers"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/rest"
	cache "k8s.io/client-go/tools/cache"
	"k8s.io/client-go/tools/clientcmd"
	"k8s.io/client-go/util/workqueue"
)
func GetKubernetesClient() kubernetes.Interface {
	kubeConfigPath := os.Getenv("HOME") + "/.kube/config"
	var config *rest.Config
	config, err := clientcmd.BuildConfigFromFlags("", kubeConfigPath)
	if err != nil {
		log.Infof("getClusterConfig: %v", err)
		var err2 error
		config, err2 = rest.InClusterConfig()
		if err2 != nil {
			panic(err.Error())
		}
	}
	client, err := kubernetes.NewForConfig(config)
	if err != nil {
		log.Fatalf("getClusterConfig: %v", err)
	}
	log.Info("Successfully constructed k8s client")
	return client
}
func CreateController(objType string) *Controller {
	client := GetKubernetesClient()
	var informer cache.SharedIndexInformer
	var handlerc handlers.Handler
	queue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter())
	switch objType {
	case "Pod":
		informer = handlers.GetPodInformer(client)
		handlerc = &handlers.PodHandler{}
	case "Service":
		informer = handlers.GetServiceInformer(client)
		handlerc = &handlers.ServiceHandler{}
	case "Namespace":
		informer = handlers.GetNamespaceInformer(client)
		handlerc = &handlers.NamespaceHandler{}
	case "Deployment":
		informer = handlers.GetDeploymentInformer(client)
		handlerc = &handlers.DeploymentHandler{}
	case "ReplicaSet":
		informer = handlers.GetReplicaSetInformer(client)
		handlerc = &handlers.ReplicaSetHandler{}
	case "Ingress":
		informer = handlers.GetIngressInformer(client)
		handlerc = &handlers.IngressHandler{}
	case "StatefulSet":
		informer = handlers.GetStatefulSetInformer(client)
		handlerc = &handlers.StatefulSetHandler{}
	}
	informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc: func(obj interface{}) {
			key, err := cache.MetaNamespaceKeyFunc(obj)
			log.Infof("Add %s: %s", objType, key)
			if err == nil {
				queue.Add(key)
			}
		},
		UpdateFunc: func(oldObj, newObj interface{}) {
			key, err := cache.MetaNamespaceKeyFunc(newObj)
			log.Infof("Update %s: %s", objType, key)
			if err == nil {
				queue.Add(key)
			}
		},
		DeleteFunc: func(obj interface{}) {
			key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
			log.Infof("Delete %s: %s", objType, key)
			if err == nil {
				queue.Add(key)
			}
		},
	})
	controller := Controller{
		logger:    log.NewEntry(log.New()),
		clientset: client,
		informer:  informer,
		queue:     queue,
		handler:   handlerc,
		name:      objType,
	}
	return &controller
}