Skip to content

Commit

Permalink
fix: restrict permissions to only access specific CRB (#436)
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
  • Loading branch information
bacherfl authored Apr 3, 2023
1 parent 9ef25a0 commit 6f1f93c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ rules:
- update
- apiGroups:
- rbac.authorization.k8s.io
resourceNames:
- open-feature-operator-flagd-kubernetes-sync
resources:
- clusterrolebindings
verbs:
- get
- list
- update
- watch
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"context"
"flag"
"fmt"
v1 "k8s.io/api/rbac/v1"
"os"
"sigs.k8s.io/controller-runtime/pkg/client"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -166,13 +168,16 @@ func main() {
os.Exit(1)
}

disableCacheFor := []client.Object{&v1.ClusterRoleBinding{}}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "131bf64c.openfeature.dev",
ClientDisableCacheFor: disableCacheFor,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down
2 changes: 1 addition & 1 deletion webhooks/pod_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const (
//+kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:webhook:path=/mutate-v1-pod,mutating=true,failurePolicy=Ignore,groups="",resources=pods,verbs=create;update,versions=v1,name=mutate.openfeature.dev,admissionReviewVersions=v1,sideEffects=NoneOnDryRun
//+kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;
//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterrolebindings,verbs=get;list;watch;update;
//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterrolebindings,verbs=get;update,resourceNames=open-feature-operator-flagd-kubernetes-sync;

// PodMutator annotates Pods
type PodMutator struct {
Expand Down

0 comments on commit 6f1f93c

Please sign in to comment.