Skip to content

Commit 8679734

Browse files
Remove creation/usage of velero-privileged SCC (#877 OADP-290)
Co-authored-by: hhpatel14 <[email protected]>
1 parent e8de6eb commit 8679734

File tree

4 files changed

+0
-98
lines changed

4 files changed

+0
-98
lines changed

bundle/manifests/oadp-operator.clusterserviceversion.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,6 @@ spec:
620620
- security.openshift.io
621621
resourceNames:
622622
- privileged
623-
- velero-privileged
624623
resources:
625624
- securitycontextconstraints
626625
verbs:

config/rbac/role.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ rules:
149149
- use
150150
resourceNames:
151151
- privileged
152-
- velero-privileged
153152
- apiGroups:
154153
- ""
155154
resources:

controllers/dpa_controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ func (r *DPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
8686

8787
_, err := ReconcileBatch(r.Log,
8888
r.ValidateDataProtectionCR,
89-
r.ReconcileVeleroSecurityContextConstraint,
9089
r.ReconcileResticRestoreHelperConfig,
9190
r.ValidateBackupStorageLocations,
9291
r.ReconcileBackupStorageLocations,

controllers/velero.go

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
//"sigs.k8s.io/controller-runtime/pkg/client"
1818

1919
"github.com/go-logr/logr"
20-
security "github.com/openshift/api/security/v1"
2120
oadpv1alpha1 "github.com/openshift/oadp-operator/api/v1alpha1"
2221
"github.com/openshift/oadp-operator/pkg/common"
2322
"github.com/vmware-tanzu/velero/pkg/install"
@@ -203,54 +202,6 @@ func (r *DPAReconciler) ReconcileVeleroClusterRoleBinding(log logr.Logger) (bool
203202
return true, nil
204203
}
205204

206-
func (r *DPAReconciler) ReconcileVeleroSecurityContextConstraint(log logr.Logger) (bool, error) {
207-
dpa := oadpv1alpha1.DataProtectionApplication{}
208-
if err := r.Get(r.Context, r.NamespacedName, &dpa); err != nil {
209-
return false, err
210-
}
211-
sa := corev1.ServiceAccount{}
212-
nsName := types.NamespacedName{
213-
Namespace: dpa.Namespace,
214-
Name: common.Velero,
215-
}
216-
if err := r.Get(r.Context, nsName, &sa); err != nil {
217-
return false, err
218-
}
219-
220-
veleroSCC := &security.SecurityContextConstraints{
221-
ObjectMeta: metav1.ObjectMeta{
222-
Name: "velero-privileged",
223-
},
224-
}
225-
op, err := controllerutil.CreateOrPatch(r.Context, r.Client, veleroSCC, func() error {
226-
// Setting controller owner reference on the velero SCC
227-
// TODO: HOW DO I DO THIS?? ALAY HALP PLZ
228-
/*err := controllerutil.SetControllerReference(&velero, veleroSCC, r.Scheme)
229-
if err != nil {
230-
return err
231-
}*/
232-
233-
// update the SCC template
234-
return r.privilegedSecurityContextConstraints(veleroSCC, &dpa, &sa)
235-
})
236-
237-
if err != nil {
238-
return false, err
239-
}
240-
241-
//TODO: Review velero SCC status and report errors and conditions
242-
243-
if op == controllerutil.OperationResultCreated || op == controllerutil.OperationResultUpdated {
244-
// Trigger event to indicate velero SCC was created or updated
245-
r.EventRecorder.Event(veleroSCC,
246-
corev1.EventTypeNormal,
247-
"VeleroSecurityContextConstraintsReconciled",
248-
fmt.Sprintf("performed %s on velero scc %s", op, veleroSCC.Name),
249-
)
250-
}
251-
return true, nil
252-
}
253-
254205
func (r *DPAReconciler) ReconcileVeleroDeployment(log logr.Logger) (bool, error) {
255206
dpa := oadpv1alpha1.DataProtectionApplication{}
256207
if err := r.Get(r.Context, r.NamespacedName, &dpa); err != nil {
@@ -326,52 +277,6 @@ func (r *DPAReconciler) veleroClusterRoleBinding(dpa *oadpv1alpha1.DataProtectio
326277
return crb, nil
327278
}
328279

329-
func (r *DPAReconciler) privilegedSecurityContextConstraints(scc *security.SecurityContextConstraints, dpa *oadpv1alpha1.DataProtectionApplication, sa *corev1.ServiceAccount) error {
330-
// ObjectMeta set from prior step.
331-
332-
scc.AllowHostDirVolumePlugin = true
333-
scc.AllowHostIPC = true
334-
scc.AllowHostNetwork = true
335-
scc.AllowHostPID = true
336-
scc.AllowHostPorts = true
337-
scc.AllowPrivilegeEscalation = pointer.BoolPtr(true)
338-
scc.AllowPrivilegedContainer = true
339-
scc.AllowedCapabilities = []corev1.Capability{
340-
security.AllowAllCapabilities,
341-
}
342-
scc.AllowedUnsafeSysctls = []string{
343-
"*",
344-
}
345-
scc.DefaultAddCapabilities = nil
346-
scc.FSGroup = security.FSGroupStrategyOptions{
347-
Type: security.FSGroupStrategyRunAsAny,
348-
}
349-
scc.Priority = nil
350-
scc.ReadOnlyRootFilesystem = false
351-
scc.RequiredDropCapabilities = nil
352-
scc.RunAsUser = security.RunAsUserStrategyOptions{
353-
Type: security.RunAsUserStrategyRunAsAny,
354-
}
355-
scc.SELinuxContext = security.SELinuxContextStrategyOptions{
356-
Type: security.SELinuxStrategyRunAsAny,
357-
}
358-
scc.SeccompProfiles = []string{
359-
"*",
360-
}
361-
scc.SupplementalGroups = security.SupplementalGroupsStrategyOptions{
362-
Type: security.SupplementalGroupsStrategyRunAsAny,
363-
}
364-
scc.Users = []string{
365-
"system:admin",
366-
fmt.Sprintf("system:serviceaccount:%s:%s", sa.Namespace, sa.Name),
367-
}
368-
scc.Volumes = []security.FSType{
369-
security.FSTypeAll,
370-
}
371-
372-
return nil
373-
}
374-
375280
// Build VELERO Deployment
376281
func (r *DPAReconciler) buildVeleroDeployment(veleroDeployment *appsv1.Deployment, dpa *oadpv1alpha1.DataProtectionApplication) error {
377282

0 commit comments

Comments
 (0)