Skip to content

Commit

Permalink
fix namespace's label wrt pod security standards (#747)
Browse files Browse the repository at this point in the history
Fixes #746

Signed-off-by: Bala.FA <bala@minio.io>
  • Loading branch information
balamurugana committed Apr 4, 2023
1 parent 7ed0aea commit b96bd25
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pkg/installer/namespace.go
Expand Up @@ -67,11 +67,21 @@ func createNamespace(ctx context.Context, args *Args) (err error) {
}
}
}()
annotations := map[string]string{}
if args.podSecurityAdmission {

labels := func() map[string]string {
if !args.podSecurityAdmission {
return defaultLabels
}

labels := map[string]string{}
for key, value := range defaultLabels {
labels[key] = value
}

// Policy violations will cause the pods to be rejected
annotations[podsecurityadmissionapi.EnforceLevelLabel] = string(podsecurityadmissionapi.LevelPrivileged)
}
labels[podsecurityadmissionapi.EnforceLevelLabel] = string(podsecurityadmissionapi.LevelPrivileged)
return labels
}()

ns := &corev1.Namespace{
TypeMeta: metav1.TypeMeta{
Expand All @@ -81,8 +91,8 @@ func createNamespace(ctx context.Context, args *Args) (err error) {
ObjectMeta: metav1.ObjectMeta{
Name: namespace,
Namespace: metav1.NamespaceNone,
Annotations: annotations,
Labels: defaultLabels,
Annotations: map[string]string{},
Labels: labels,
Finalizers: []string{metav1.FinalizerDeleteDependents},
},
}
Expand Down

0 comments on commit b96bd25

Please sign in to comment.