Skip to content

Commit

Permalink
add priorityclassname and use node selector for node scanning deploym…
Browse files Browse the repository at this point in the history
…ents

Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Mar 28, 2024
1 parent 207deba commit 4e90098
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/v1alpha2/mondooauditconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ type Nodes struct {
// +kubebuilder:validation:Enum=cronjob;deployment
// +kubebuilder:default=cronjob
Style NodeScanStyle `json:"style,omitempty"`
// PriorityClassName specifies the name of the PriorityClass for the node scanning workloads.
PriorityClassName string `json:"priorityClassName,omitempty"`
}

type Admission struct {
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/k8s.mondoo.com_mondooauditconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ spec:
node scanning. The default is "60". Only applicable for Deployment
style.
type: integer
priorityClassName:
description: PriorityClassName specifies the name of the PriorityClass
for the node scanning workloads.
type: string
resources:
description: ResourceRequirements describes the compute resource
requirements.
Expand Down
5 changes: 4 additions & 1 deletion controllers/nodes/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ func UpdateDeployment(
dep.Spec.Template.Annotations = map[string]string{
ignoreQueryAnnotationPrefix + "mondoo-kubernetes-security-pod-runasnonroot": ignoreAnnotationValue,
}
dep.Spec.Template.Spec.NodeName = node.Name
dep.Spec.Template.Spec.PriorityClassName = m.Spec.Nodes.PriorityClassName
dep.Spec.Template.Spec.NodeSelector = map[string]string{
"kubernetes.io/hostname": node.Name,
}
dep.Spec.Template.Spec.Tolerations = k8s.TaintsToTolerations(node.Spec.Taints)
// The node scanning does not use the Kubernetes API at all, therefore the service account token
// should not be mounted at all.
Expand Down

0 comments on commit 4e90098

Please sign in to comment.