Skip to content

Commit

Permalink
Re-enable restricting controller watch to single namespace
Browse files Browse the repository at this point in the history
Adds the ability to restrict the seccomp controller to a single
namespace such that users can restrict permissions required to run the
operator in a cluster.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
  • Loading branch information
hasheddan committed Aug 12, 2020
1 parent 65acfe5 commit 1ea3286
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cmd/seccomp-operator/main.go
Expand Up @@ -30,7 +30,10 @@ import (
"sigs.k8s.io/seccomp-operator/internal/pkg/version"
)

const jsonFlag string = "json"
const (
jsonFlag string = "json"
restrictNSKey string = "RESTRICT_TO_NAMESPACE"
)

var (
sync = time.Second * 30
Expand Down Expand Up @@ -98,9 +101,15 @@ func run(*cli.Context) error {
return errors.Wrap(err, "get config")
}

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
ctrlOpts := ctrl.Options{
SyncPeriod: &sync,
})
}

if os.Getenv(restrictNSKey) != "" {
ctrlOpts.Namespace = os.Getenv(restrictNSKey)
}

mgr, err := ctrl.NewManager(cfg, ctrlOpts)
if err != nil {
return errors.Wrap(err, "create manager")
}
Expand Down

0 comments on commit 1ea3286

Please sign in to comment.