Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions porch/controllers/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ rules:
verbs:
- create
- patch
- apiGroups:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the porch make targets doesn't use this file directly, but rather use the rbac from https://github.com/GoogleContainerTools/kpt/blob/main/porch/deployments/porch/9-controllers.yaml#L57. I'm meaning to fix this, but until that is fixed we need to update the rbac rules directly in that file.

- ""
resources:
- namespaces
verbs:
- get
- list
- watch
- apiGroups:
- config.porch.kpt.dev
resources:
Expand Down Expand Up @@ -116,3 +124,15 @@ rules:
- patch
- update
- watch
- apiGroups:
- iam.cnrm.cloud.google.com
resources:
- iampolicymembers
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ type WorkloadIdentityBindingReconciler struct {
//+kubebuilder:rbac:groups=config.porch.kpt.dev,resources=workloadidentitybindings/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=config.porch.kpt.dev,resources=workloadidentitybindings/finalizers,verbs=update

// Needs to read namespace to get project-id annotation
//+kubebuilder:rbac:groups="",resources=namespaces,verbs=get;list;watch

// Creates iampolicymembers (using server-side-apply)
//+kubebuilder:rbac:groups=iam.cnrm.cloud.google.com,resources=iampolicymembers,verbs=get;list;watch;create;update;patch;delete
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, this looks really cool!


// Reconcile implements the main kubernetes reconciliation loop.
func (r *WorkloadIdentityBindingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
var subject api.WorkloadIdentityBinding
Expand Down Expand Up @@ -121,7 +127,6 @@ func updateStatus(subject *api.WorkloadIdentityBinding, results *applyset.ApplyR
}

func (r *WorkloadIdentityBindingReconciler) applyToClusterRef(ctx context.Context, subject *api.WorkloadIdentityBinding) (*applyset.ApplyResults, error) {

ns := &corev1.Namespace{}
if err := r.Get(ctx, types.NamespacedName{Name: subject.GetNamespace()}, ns); err != nil {
return nil, fmt.Errorf("error getting namespace %q: %w", subject.GetNamespace(), err)
Expand Down