Skip to content

Commit

Permalink
Add SeccompProfile for PodSecurityStandards "restricted" to avoid Pod…
Browse files Browse the repository at this point in the history
… Security Violations on restricted namespaces (#1288)

* Add SeccompProfile for PSA restricted

It is necessary to set the seccompProfile to RuntimeDefault to meet the
PodSecurityStandards of restricted, which will be a common default in
clusters.
Otherwise the workloads will be evaluated as baseline and rejected, if
not set otherwise in the namespace metadata.

* fix: failing test

Signed-off-by: iam-veeramalla <[email protected]>

---------

Signed-off-by: iam-veeramalla <[email protected]>
Co-authored-by: iam-veeramalla <[email protected]>
  • Loading branch information
ibihim and iam-veeramalla authored Jun 6, 2024
1 parent b7e6666 commit e2a991b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
22 changes: 22 additions & 0 deletions controllers/argocd/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ func (r *ReconcileArgoCD) reconcileRedisDeployment(cr *argoproj.ArgoCD, useTLS b
},
RunAsNonRoot: boolPtr(true),
RunAsUser: int64Ptr(999),
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down Expand Up @@ -659,6 +662,9 @@ func (r *ReconcileArgoCD) reconcileRedisHAProxyDeployment(cr *argoproj.ArgoCD) e
},
},
RunAsNonRoot: boolPtr(true),
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down Expand Up @@ -695,6 +701,10 @@ func (r *ReconcileArgoCD) reconcileRedisHAProxyDeployment(cr *argoproj.ArgoCD) e
"ALL",
},
},
RunAsNonRoot: boolPtr(true),
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down Expand Up @@ -760,6 +770,9 @@ func (r *ReconcileArgoCD) reconcileRedisHAProxyDeployment(cr *argoproj.ArgoCD) e
RunAsNonRoot: boolPtr(true),
RunAsUser: int64Ptr(1000),
FSGroup: int64Ptr(1000),
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
}
AddSeccompProfileForOpenShift(r.Client, &deploy.Spec.Template.Spec)

Expand Down Expand Up @@ -866,6 +879,9 @@ func (r *ReconcileArgoCD) reconcileRepoDeployment(cr *argoproj.ArgoCD, useTLSFor
},
},
RunAsNonRoot: boolPtr(true),
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down Expand Up @@ -960,6 +976,9 @@ func (r *ReconcileArgoCD) reconcileRepoDeployment(cr *argoproj.ArgoCD, useTLSFor
},
},
RunAsNonRoot: boolPtr(true),
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
},
VolumeMounts: repoServerVolumeMounts,
}}
Expand Down Expand Up @@ -1201,6 +1220,9 @@ func (r *ReconcileArgoCD) reconcileServerDeployment(cr *argoproj.ArgoCD, useTLSF
},
},
RunAsNonRoot: boolPtr(true),
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down
9 changes: 9 additions & 0 deletions controllers/argocd/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,9 @@ func TestReconcileArgoCD_reconcileServerDeployment(t *testing.T) {
},
},
RunAsNonRoot: boolPtr(true),
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
},
VolumeMounts: serverDefaultVolumeMounts(),
},
Expand Down Expand Up @@ -1364,6 +1367,9 @@ func TestReconcileArgoCD_reconcileServerDeploymentWithInsecure(t *testing.T) {
},
},
RunAsNonRoot: boolPtr(true),
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
},
VolumeMounts: serverDefaultVolumeMounts(),
},
Expand Down Expand Up @@ -1468,6 +1474,9 @@ func TestReconcileArgoCD_reconcileServerDeploymentChangedToInsecure(t *testing.T
},
},
RunAsNonRoot: boolPtr(true),
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
},
VolumeMounts: serverDefaultVolumeMounts(),
},
Expand Down

0 comments on commit e2a991b

Please sign in to comment.