-
Notifications
You must be signed in to change notification settings - Fork 106
Description
I tried to run the kube-mgmt sidecar to opa on my Kubernetes cluster and granted it limited privileges. The role that the deployment was running with only had access to it's own namespace and nothing else.
I only had --replicate=v1/pods as the argument to kube-mgmt. I saw the following errors:
E0412 05:31:24.735947 1 reflector.go:201] github.com/open-policy-agent/kube-mgmt/pkg/policies/configmap.go:100: Failed to list *v1.ConfigMap: unknown (get configmaps)
If I understand the code right, it seems that kube-mgmt currently watches for resources across all namespaces.
File: pkg/policies/configmap.go
source := cache.NewListWatchFromClient(
client,
"configmaps",
v1.NamespaceAll, <<<---------------
fields.Everything())
File: ./pkg/data/generic.go
source := cache.NewListWatchFromClient(
client,
s.ns.Resource,
api.NamespaceAll, <<<--------------
fields.Everything())
As a result, kube-mgmt can only run if it is given a role that has cluster wide access to these resources.
I changed the cluster-binding to cluster-admin (basically, ran opa and kube-mgmt as root) and things worked fine.
It'll be good if, kube-mgmt can watch resources in the namespace that the user provides (and maybe default to all).