Skip to content

Commit

Permalink
Add RBAC permissions for finalizers (#1458)
Browse files Browse the repository at this point in the history
Signed-off-by: hossainemruz <[email protected]>
  • Loading branch information
Emruz Hossain authored Jul 9, 2022
1 parent 76df41c commit 85d6c50
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -489,5 +489,9 @@ push-to-kind: container
@kind load docker-image $(REGISTRY)/stash:$(TAG)
@echo "Image has been pushed successfully into kind cluster."

restart:
@echo "Restarting operator pod....."
kubectl delete pod -n $(KUBE_NAMESPACE) -l 'app.kubernetes.io/name=stash-community,app.kubernetes.io/instance=stash'

.PHONY: deploy-to-kind
deploy-to-kind: uninstall push-to-kind install
3 changes: 0 additions & 3 deletions hack/kubernetes/kind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ nodes:
- role: control-plane
kubeadmConfigPatches:
- |
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
metadata:
name: config
apiServer:
extraArgs:
enable-admission-plugins: "NodeRestriction,OwnerReferencesPermissionEnforcement"
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/backup_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func (c *StashController) ensureBackupJob(inv invoker.BackupInvoker, targetInfo
c.kubeClient,
jobMeta,
func(in *batchv1.Job) *batchv1.Job {
// set BackupSession as owner of this Job so that the it get cleaned automatically
// set BackupSession as owner of this Job so that it get cleaned automatically
// when the BackupSession gets deleted according to backupHistoryLimit
core_util.EnsureOwnerReference(&in.ObjectMeta, ownerBackupSession)
// pass offshoot labels to job's pod
Expand Down Expand Up @@ -528,7 +528,7 @@ func (c *StashController) ensureVolumeSnapshotterJob(inv invoker.BackupInvoker,
c.kubeClient,
jobMeta,
func(in *batchv1.Job) *batchv1.Job {
// set BackupSession as owner of this Job so that the it get cleaned automatically
// set BackupSession as owner of this Job so that it get cleaned automatically
// when the BackupSession gets deleted according to backupHistoryLimit
core_util.EnsureOwnerReference(&in.ObjectMeta, ownerBackupSession)

Expand Down
26 changes: 23 additions & 3 deletions pkg/rbac/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,29 @@ func (opt *RBACOptions) ensureSidecarClusterRole() error {
},
{
APIGroups: []string{apps.GroupName},
Resources: []string{"deployments", "statefulsets"},
Resources: []string{"deployments", "statefulsets", "daemonsets", "replicasets"},
Verbs: []string{"get", "list", "patch"},
},
{
APIGroups: []string{apps.GroupName},
Resources: []string{"daemonsets", "replicasets"},
Verbs: []string{"get", "list", "patch"},
Resources: []string{
"deployments/finalizers",
"statefulsets/finalizers",
"daemonsets/finalizers",
"replicasets/finalizers",
},
Verbs: []string{"update"},
},
{
APIGroups: []string{core.GroupName},
Resources: []string{"replicationcontrollers"},
Verbs: []string{"get", "list", "patch"},
},
{
APIGroups: []string{core.GroupName},
Resources: []string{"replicationcontrollers/finalizers"},
Verbs: []string{"update"},
},
{
APIGroups: []string{core.GroupName},
Resources: []string{"secrets", "pods"},
Expand Down Expand Up @@ -127,6 +137,16 @@ func (opt *RBACOptions) ensureSidecarClusterRole() error {
Resources: []string{"leases"},
Verbs: []string{"*"},
},
{
APIGroups: []string{"apps.openshift.io"},
Resources: []string{"deploymentconfigs"},
Verbs: []string{"get", "list", "patch"},
},
{
APIGroups: []string{"apps.openshift.io"},
Resources: []string{"deploymentconfigs/finalizers"},
Verbs: []string{"update"},
},
}
return in
}, metav1.PatchOptions{})
Expand Down

0 comments on commit 85d6c50

Please sign in to comment.