Skip to content

Instantly share code, notes, and snippets.

@treacher treacher/controller.go
Last active Sep 12, 2017

What would you like to do?
Namespace Rolebinding Operator
// NamespaceController watches the kubernetes api for changes to namespaces and
// creates a RoleBinding for that particular namespace.
type NamespaceController struct {
namespaceInformer cache.SharedIndexInformer
kclient *kubernetes.Clientset
// NewNamespaceController creates a new NewNamespaceController
func NewNamespaceController(kclient *kubernetes.Clientset) *NamespaceController {
namespaceWatcher := &NamespaceController{}
// Create informer for watching Namespaces
namespaceInformer := cache.NewSharedIndexInformer(
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return kclient.Core().Namespaces().List(options)
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return kclient.Core().Namespaces().Watch(options)
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
AddFunc: namespaceWatcher.createRoleBinding,
namespaceWatcher.kclient = kclient
namespaceWatcher.namespaceInformer = namespaceInformer
return namespaceWatcher

This comment has been minimized.

Copy link

pik4ez commented Sep 12, 2017

// NewNamespaceController creates a new NamespaceController

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.