Skip to content

Commit 2233e55

Browse files
committed
Fix scc issues with VMFR
Fixes issue #53 Signed-off-by: Michal Pryc <mpryc@redhat.com>
1 parent 21b8a2b commit 2233e55

File tree

10 files changed

+35
-18
lines changed

10 files changed

+35
-18
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ help: ## Display this help.
5555

5656
.PHONY: manifests
5757
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
58-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
58+
$(CONTROLLER_GEN) rbac:roleName=oadp-vmfr-controller-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
5959

6060
.PHONY: generate
6161
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
@@ -263,4 +263,4 @@ endif
263263
for file_name in $(shell ls $(shell pwd)/hack/extra-crds);do \
264264
cp $(OADP_OPERATOR_PATH)/config/crd/bases/$$file_name $(shell pwd)/hack/extra-crds/$$file_name && \
265265
sed -i "1s%^%# Code generated by make update-velero-manifests. DO NOT EDIT.\n%" $(shell pwd)/hack/extra-crds/$$file_name;done ;\
266-
}
266+
}

config/default/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace: openshift-adp
66
# "wordpress" becomes "alices-wordpress".
77
# Note that it should also match with the prefix (text before '-') of the namespace
88
# field above.
9-
namePrefix: oadp-vm-file-restore-
9+
namePrefix:
1010

1111
# Labels to add to all resources and selectors.
1212
#labels:

config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ spec:
101101
memory: 64Mi
102102
volumeMounts: []
103103
volumes: []
104-
serviceAccountName: controller-manager
104+
serviceAccountName: oadp-vmfr-controller
105105
terminationGracePeriodSeconds: 10

config/rbac/leader_election_role_binding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ roleRef:
1111
name: leader-election-role
1212
subjects:
1313
- kind: ServiceAccount
14-
name: controller-manager
14+
name: oadp-vmfr-controller
1515
namespace: system

config/rbac/metrics_auth_role_binding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ roleRef:
88
name: metrics-auth-role
99
subjects:
1010
- kind: ServiceAccount
11-
name: controller-manager
11+
name: oadp-vmfr-controller
1212
namespace: system

config/rbac/role.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:
5-
name: manager-role
5+
name: oadp-vmfr-controller-role
66
rules:
77
- apiGroups:
88
- ""
@@ -93,6 +93,14 @@ rules:
9393
- patch
9494
- update
9595
- watch
96+
- apiGroups:
97+
- security.openshift.io
98+
resourceNames:
99+
- privileged
100+
resources:
101+
- securitycontextconstraints
102+
verbs:
103+
- use
96104
- apiGroups:
97105
- velero.io
98106
resources:

config/rbac/role_binding.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRoleBinding
33
metadata:
44
labels:
5-
app.kubernetes.io/name: oadp-vm-file-restore
5+
app.kubernetes.io/name: clusterrolebinding
6+
app.kubernetes.io/instance: oadp-vmfr-controller-rolebinding
7+
app.kubernetes.io/component: rbac
8+
app.kubernetes.io/created-by: oadp-operator
9+
app.kubernetes.io/part-of: oadp-operator
610
app.kubernetes.io/managed-by: kustomize
7-
name: manager-rolebinding
11+
name: oadp-vmfr-controller-rolebinding
812
roleRef:
913
apiGroup: rbac.authorization.k8s.io
1014
kind: ClusterRole
11-
name: manager-role
15+
name: oadp-vmfr-controller-role
1216
subjects:
1317
- kind: ServiceAccount
14-
name: controller-manager
18+
name: oadp-vmfr-controller
1519
namespace: system

config/rbac/service_account.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ apiVersion: v1
22
kind: ServiceAccount
33
metadata:
44
labels:
5-
app.kubernetes.io/name: oadp-vm-file-restore
5+
app.kubernetes.io/name: serviceaccount
6+
app.kubernetes.io/instance: oadp-vmfr-controller-sa
7+
app.kubernetes.io/component: rbac
8+
app.kubernetes.io/created-by: oadp-operator
9+
app.kubernetes.io/part-of: oadp-operator
610
app.kubernetes.io/managed-by: kustomize
7-
name: controller-manager
11+
name: oadp-vmfr-controller
812
namespace: system

internal/controller/virtualmachinefilerestore_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (e ErrUnsupportedBackup) Error() string {
9595
// +kubebuilder:rbac:groups="",resources=persistentvolumeclaims,verbs=get;list;watch
9696
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;patch;delete
9797
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=rolebindings,verbs=get;list;watch;create;update;patch;delete
98+
// +kubebuilder:rbac:groups=security.openshift.io,resources=securitycontextconstraints,resourceNames=privileged,verbs=use
9899
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
99100
// +kubebuilder:rbac:groups=velero.io,resources=restores,verbs=get;list;watch;create;update;patch;delete
100101
// +kubebuilder:rbac:groups=velero.io,resources=backups,verbs=get;list;watch

test/e2e/e2e_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ import (
3737
const namespace = "openshift-adp"
3838

3939
// serviceAccountName created for the project
40-
const serviceAccountName = "oadp-vm-file-restore-controller-manager"
40+
const serviceAccountName = "oadp-vmfr-controller"
4141

4242
// metricsServiceName is the name of the metrics service of the project
43-
const metricsServiceName = "oadp-vm-file-restore-controller-manager-metrics-service"
43+
const metricsServiceName = "controller-manager-metrics-service"
4444

4545
// metricsRoleBindingName is the name of the RBAC that will be created to allow get the metrics data
46-
const metricsRoleBindingName = "oadp-vm-file-restore-metrics-binding"
46+
const metricsRoleBindingName = "metrics-binding"
4747

4848
var _ = Describe("Manager", Ordered, func() {
4949
var controllerPodName string
@@ -76,7 +76,7 @@ var _ = Describe("Manager", Ordered, func() {
7676

7777
By("patching the deployment to use IfNotPresent imagePullPolicy for e2e tests")
7878
cmd = exec.Command("kubectl", "patch", "deployment",
79-
"oadp-vm-file-restore-controller-manager",
79+
"controller-manager",
8080
"-n", namespace,
8181
"-p", `{"spec":{"template":{"spec":{"containers":[{"name":"manager","imagePullPolicy":"IfNotPresent"}]}}}}`)
8282
_, err = utils.Run(cmd)
@@ -195,7 +195,7 @@ var _ = Describe("Manager", Ordered, func() {
195195

196196
// Now create the ClusterRoleBinding
197197
cmd = exec.Command("kubectl", "create", "clusterrolebinding", metricsRoleBindingName,
198-
"--clusterrole=oadp-vm-file-restore-metrics-reader",
198+
"--clusterrole=metrics-reader",
199199
fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName),
200200
)
201201
_, err := utils.Run(cmd)

0 commit comments

Comments
 (0)