Skip to content

Commit

Permalink
Merge pull request #531 from Disper/rbac_least_priviligates
Browse files Browse the repository at this point in the history
Rbac least priviligates
  • Loading branch information
kyma-bot authored Dec 3, 2024
2 parents 85841f0 + 7b79f76 commit 0c9f028
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 31 deletions.
28 changes: 8 additions & 20 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
kind: Role
metadata:
name: infrastructure-manager-role
namespace: kcp-system
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -31,37 +32,24 @@ rules:
- infrastructuremanager.kyma-project.io
resources:
- gardenerclusters/finalizers
verbs:
- update
- apiGroups:
- infrastructuremanager.kyma-project.io
resources:
- gardenerclusters/status
verbs:
- update
- apiGroups:
- infrastructuremanager.kyma-project.io
resources:
- runtimes
- runtimes/finalizers
- runtimes/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- infrastructuremanager.kyma-project.io
resources:
- runtimes/finalizers
verbs:
- update
- apiGroups:
- infrastructuremanager.kyma-project.io
resources:
- runtimes/status
- runtimes
verbs:
- create
- get
- list
- patch
- update
- watch
7 changes: 4 additions & 3 deletions config/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
kind: RoleBinding
metadata:
labels:
app.kubernetes.io/name: clusterrolebinding
app.kubernetes.io/name: rolebinding
app.kubernetes.io/instance: infrastructure-manager-rolebinding
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: infrastructure-manager
app.kubernetes.io/part-of: infrastructure-manager
app.kubernetes.io/managed-by: kustomize
name: infrastructure-manager-rolebinding
namespace: kcp-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
kind: Role
name: infrastructure-manager-role
subjects:
- kind: ServiceAccount
Expand Down
2 changes: 1 addition & 1 deletion config/rbac/service_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ metadata:
app.kubernetes.io/part-of: infrastructure-manager
app.kubernetes.io/managed-by: kustomize
name: infrastructure-manager
namespace: system
namespace: kcp-system
8 changes: 4 additions & 4 deletions internal/controller/kubeconfig/gardener_cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ type KubeconfigProvider interface {
Fetch(ctx context.Context, shootName string) (string, error)
}

//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=gardenerclusters,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;delete
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=gardenerclusters/finalizers,verbs=update
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=gardenerclusters/status,verbs=update
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=gardenerclusters,verbs=get;list;watch;create;update;patch;delete,namespace=kcp-system
//+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;delete,namespace=kcp-system
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=gardenerclusters/finalizers,verbs=get;list;delete;create;update;patch,namespace=kcp-system
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=gardenerclusters/status,verbs=get;list;delete;create;update;patch,namespace=kcp-system

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/runtime/runtime_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ type RuntimeReconciler struct {
RequestID atomic.Uint64
}

//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=runtimes,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=runtimes/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=runtimes/finalizers,verbs=update
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=runtimes,verbs=get;list;watch;create;update;patch,namespace=kcp-system
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=runtimes/status,verbs=get;list;delete;create;update;patch,namespace=kcp-system
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=runtimes/finalizers,verbs=get;list;delete;create;update;patch,namespace=kcp-system

func (r *RuntimeReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
r.Log.Info(request.String())
Expand Down

0 comments on commit 0c9f028

Please sign in to comment.