Skip to content

fix(vm): skip pss check #1202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ const (
// LabelVirtualMachineIPAddressUID is a label to link VirtualMachineIPAddressLease to VirtualMachineIPAddress.
LabelVirtualMachineIPAddressUID = LabelsPrefix + "/virtual-machine-ip-address-uid"

// SkipPodSecurityStandardsCheckLabel is a label to skip the check for PodSecurityStandards to avoid irrelevant alerts related to a privileged virtual machine pod.
SkipPodSecurityStandardsCheckLabel = "security.deckhouse.io/skip-pss-check"

UploaderServiceLabel = "service"

// AppKubernetesManagedByLabel is the Kubernetes recommended managed-by label.
Expand Down
11 changes: 11 additions & 0 deletions images/virtualization-artifact/pkg/controller/kvbuilder/kvvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ func NewEmptyKVVM(name types.NamespacedName, opts KVVMOptions) *KVVM {
}
}

func (b *KVVM) SetKVVMILabel(labelKey, labelValue string) {
labels := b.Resource.Spec.Template.ObjectMeta.GetLabels()
if labels == nil {
labels = make(map[string]string)
}

labels[labelKey] = labelValue

b.Resource.Spec.Template.ObjectMeta.SetLabels(labels)
}

func (b *KVVM) SetKVVMIAnnotation(annoKey, annoValue string) {
anno := b.Resource.Spec.Template.ObjectMeta.GetAnnotations()
if anno == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
virtv1 "kubevirt.io/api/core/v1"

"github.com/deckhouse/virtualization-controller/pkg/common"
"github.com/deckhouse/virtualization-controller/pkg/common/annotations"
"github.com/deckhouse/virtualization-controller/pkg/common/imageformat"
"github.com/deckhouse/virtualization-controller/pkg/common/pointer"
"github.com/deckhouse/virtualization-controller/pkg/controller/ipam"
Expand Down Expand Up @@ -239,6 +240,7 @@ func ApplyVirtualMachineSpec(
kvvm.SetKVVMIAnnotation(ipam.AnnoIPAddressCNIRequest, ipAddress)
// Set live migration annotation.
kvvm.SetKVVMIAnnotation(virtv1.AllowPodBridgeNetworkLiveMigrationAnnotation, "true")

// Set label to skip the check for PodSecurityStandards to avoid irrelevant alerts related to a privileged virtual machine pod.
kvvm.SetKVVMILabel(annotations.SkipPodSecurityStandardsCheckLabel, "true")
return nil
}
Loading