Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/v1beta1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ const (
// AllowGuestWebhooksServiceLabel marks a service deployed in the control plane as a valid target
// for validating/mutating webhooks running in the guest cluster.
AllowGuestWebhooksServiceLabel = "hypershift.openshift.io/allow-guest-webhooks"

// PodSecurityAdmissionLabelOverrideAnnotation allows overriding the pod security admission label on
// hosted control plane namespacces. The default is 'Restricted'. Valid values are 'Restricted', 'Baseline', or 'Privileged'
// See https://github.com/openshift/enhancements/blob/master/enhancements/authentication/pod-security-admission.md
PodSecurityAdmissionLabelOverrideAnnotation = "hypershift.openshift.io/pod-security-admission-label-override"
)

// HostedClusterSpec is the desired behavior of a HostedCluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,12 @@ func (r *HostedClusterReconciler) reconcile(ctx context.Context, req ctrl.Reques
controlPlaneNamespace.Labels["hypershift.openshift.io/hosted-control-plane"] = "true"

// Set pod security labels on HCP namespace
if useRestrictedPSA {
psaOverride := hcluster.Annotations[hyperv1.PodSecurityAdmissionLabelOverrideAnnotation]
if psaOverride != "" {
controlPlaneNamespace.Labels["pod-security.kubernetes.io/enforce"] = psaOverride
controlPlaneNamespace.Labels["pod-security.kubernetes.io/audit"] = psaOverride
controlPlaneNamespace.Labels["pod-security.kubernetes.io/warn"] = psaOverride
} else if useRestrictedPSA {
controlPlaneNamespace.Labels["pod-security.kubernetes.io/enforce"] = "restricted"
controlPlaneNamespace.Labels["pod-security.kubernetes.io/audit"] = "restricted"
controlPlaneNamespace.Labels["pod-security.kubernetes.io/warn"] = "restricted"
Expand Down