Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 9e2a4a2

Browse files
Merge pull request #38 from secureCodeBox/resource-limits
Add Resource Limits to Scans
2 parents a2f2cfc + a7e29b1 commit 9e2a4a2

File tree

21 files changed

+86
-14
lines changed

21 files changed

+86
-14
lines changed

operator/controllers/execution/scan_controller.go

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
corev1 "k8s.io/api/core/v1"
3232
rbacv1 "k8s.io/api/rbac/v1"
3333
apierrors "k8s.io/apimachinery/pkg/api/errors"
34+
resource "k8s.io/apimachinery/pkg/api/resource"
3435
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3536
"k8s.io/apimachinery/pkg/runtime"
3637
"k8s.io/apimachinery/pkg/types"
@@ -440,6 +441,16 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
440441
findingsUploadURL,
441442
},
442443
ImagePullPolicy: "Always",
444+
Resources: corev1.ResourceRequirements{
445+
Requests: corev1.ResourceList{
446+
corev1.ResourceCPU: resource.MustParse("200m"),
447+
corev1.ResourceMemory: resource.MustParse("100Mi"),
448+
},
449+
Limits: corev1.ResourceList{
450+
corev1.ResourceCPU: resource.MustParse("400m"),
451+
corev1.ResourceMemory: resource.MustParse("200Mi"),
452+
},
453+
},
443454
},
444455
},
445456
AutomountServiceAccountToken: &automountServiceAccountToken,
@@ -599,19 +610,16 @@ func (r *ScanReconciler) constructJobForScan(scan *executionv1.Scan, scanType *e
599610
},
600611
},
601612
},
602-
// TODO Assign sane default limits for lurcher
603-
// Resources: corev1.ResourceRequirements{
604-
// Limits: map[corev1.ResourceName]resource.Quantity{
605-
// "": {
606-
// Format: "",
607-
// },
608-
// },
609-
// Requests: map[corev1.ResourceName]resource.Quantity{
610-
// "": {
611-
// Format: "",
612-
// },
613-
// },
614-
// },
613+
Resources: corev1.ResourceRequirements{
614+
Requests: corev1.ResourceList{
615+
corev1.ResourceCPU: resource.MustParse("20m"),
616+
corev1.ResourceMemory: resource.MustParse("20Mi"),
617+
},
618+
Limits: corev1.ResourceList{
619+
corev1.ResourceCPU: resource.MustParse("100m"),
620+
corev1.ResourceMemory: resource.MustParse("100Mi"),
621+
},
622+
},
615623
VolumeMounts: []corev1.VolumeMount{
616624
{
617625
Name: "scan-results",
@@ -1031,6 +1039,16 @@ func (r *ScanReconciler) createJobForHook(hook *executionv1.ScanCompletionHook,
10311039
Args: cliArgs,
10321040
Env: append(hook.Spec.Env, standardEnvVars...),
10331041
ImagePullPolicy: "IfNotPresent",
1042+
Resources: corev1.ResourceRequirements{
1043+
Requests: corev1.ResourceList{
1044+
corev1.ResourceCPU: resource.MustParse("200m"),
1045+
corev1.ResourceMemory: resource.MustParse("100Mi"),
1046+
},
1047+
Limits: corev1.ResourceList{
1048+
corev1.ResourceCPU: resource.MustParse("400m"),
1049+
corev1.ResourceMemory: resource.MustParse("200Mi"),
1050+
},
1051+
},
10341052
},
10351053
},
10361054
},

scanners/amass/templates/amass-scan-type.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ spec:
2626
- name: "amass-config"
2727
mountPath: "/amass/output/config.ini"
2828
subPath: "config.ini"
29+
resources:
30+
{{- toYaml .Values.scannerJob.resources | nindent 16 }}
2931
volumes:
3032
- name: "amass-config"
3133
configMap:

scanners/amass/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ parserImage:
22
registry: docker.io
33
repository: scbexperimental/parser-amass
44
tag: latest
5+
6+
scannerJob:
7+
resources: {}

scanners/kube-hunter/templates/kubehunter-scan-type.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ spec:
2020
- '/wrapper.sh'
2121
- '--report'
2222
- 'json'
23+
resources:
24+
{{- toYaml .Values.scannerJob.resources | nindent 16 }}

scanners/kube-hunter/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ parserImage:
22
registry: docker.io
33
repository: scbexperimental/parser-kube-hunter
44
tag: latest
5+
6+
scannerJob:
7+
resources: {}

scanners/nikto/templates/nikto-scan-type.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ spec:
2222
- '/wrapper.sh'
2323
- '-o'
2424
- '/home/securecodebox/nikto-results.json'
25+
resources:
26+
{{- toYaml .Values.scannerJob.resources | nindent 16 }}

scanners/nikto/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ parserImage:
22
registry: docker.io
33
repository: scbexperimental/parser-nikto
44
tag: latest
5+
6+
scannerJob:
7+
resources: {}

scanners/nmap/templates/nmap-scan-type.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ spec:
1717
- name: nmap
1818
image: scbexperimental/nmap:7.80
1919
command: ["nmap", "-oX", "/home/securecodebox/nmap-results.xml"]
20+
resources:
21+
{{- toYaml .Values.scannerJob.resources | nindent 16 }}

scanners/nmap/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ parserImage:
22
registry: docker.io
33
repository: scbexperimental/parser-nmap
44
tag: latest
5+
6+
scannerJob:
7+
resources: {}

scanners/ssh_scan/templates/ssh-scan-scan-type.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ spec:
2020
- "/app/bin/ssh_scan"
2121
- "--output"
2222
- "/home/securecodebox/ssh-scan-results.json"
23+
resources:
24+
{{- toYaml .Values.scannerJob.resources | nindent 16 }}

0 commit comments

Comments
 (0)