Skip to content

Commit 10a33b7

Browse files
committed
feat: add support for workerResources, nodeSelector, affinity, and tolerations in Plugin CRD
1 parent 4559e5f commit 10a33b7

File tree

11 files changed

+2195
-14
lines changed

11 files changed

+2195
-14
lines changed

api/zora/v1alpha1/plugin_types.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,22 @@ type PluginSpec struct {
6767
// Cannot be updated.
6868
Annotations map[string]string `json:"annotations,omitempty"`
6969

70-
// Compute Resources required by this container.
71-
// Cannot be updated.
72-
// More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
70+
// Compute Resources required by this plugin.
7371
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
7472

73+
// Compute Resources required by Worker.
74+
WorkerResources *corev1.ResourceRequirements `json:"workerResources,omitempty"`
75+
76+
// NodeSelector is a selector which must be true for the pod to fit on a node.
77+
// Selector which must match a node's labels for the pod to be scheduled on that node.
78+
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
79+
80+
// If specified, the pod's scheduling constraints
81+
Affinity *corev1.Affinity `json:"affinity,omitempty"`
82+
83+
// If specified, the pod's tolerations.
84+
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
85+
7586
// Image pull policy.
7687
// One of Always, Never, IfNotPresent.
7788
// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
@@ -88,6 +99,13 @@ type PluginSpec struct {
8899
MountCustomChecksVolume *bool `json:"mountCustomChecksVolume,omitempty"`
89100
}
90101

102+
func (in *PluginSpec) WorkerResourcesOrDefault() corev1.ResourceRequirements {
103+
if in.WorkerResources != nil {
104+
return *in.WorkerResources
105+
}
106+
return in.Resources
107+
}
108+
91109
func (in *PluginSpec) GetImagePullPolicy() corev1.PullPolicy {
92110
if in.ImagePullPolicy == "" {
93111
return corev1.PullIfNotPresent

api/zora/v1alpha1/zz_generated.deepcopy.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/zora/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ The following table lists the configurable parameters of the Zora chart and thei
100100
| scan.worker.image.repository | string | `"ghcr.io/undistro/zora/worker"` | worker image repository |
101101
| scan.worker.image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion |
102102
| scan.plugins.annotations | object | `{}` | Annotations added to the plugin service account |
103+
| scan.plugins.marvin.nodeSelector | object | `{}` | [Node selection](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node) to constrain a Pod to only be able to run on particular Node(s) |
104+
| scan.plugins.marvin.tolerations | list | `[]` | [Tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) for pod assignment |
105+
| scan.plugins.marvin.affinity | object | `{}` | Map of node/pod [affinities](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) |
103106
| scan.plugins.marvin.resources | object | `{"limits":{"cpu":"500m","memory":"500Mi"},"requests":{"cpu":"250m","memory":"256Mi"}}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) to add to `marvin` container |
107+
| scan.plugins.marvin.workerResources | object | `{"limits":{"cpu":"500m","memory":"256Mi"},"requests":{"cpu":"10m","memory":"64Mi"}}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) to add to `worker` container |
104108
| scan.plugins.marvin.podAnnotations | object | `{}` | Annotations added to the marvin pods |
105109
| scan.plugins.marvin.image.repository | string | `"ghcr.io/undistro/marvin"` | marvin plugin image repository |
106110
| scan.plugins.marvin.image.tag | string | `"v0.2"` | marvin plugin image tag |
@@ -112,7 +116,11 @@ The following table lists the configurable parameters of the Zora chart and thei
112116
| scan.plugins.trivy.ignoreDescriptions | bool | `false` | Specifies whether vulnerability descriptions should be ignored |
113117
| scan.plugins.trivy.dbRepository | string | `""` | Specifies a custom OCI repository(ies) to retrieve vulnerability database. |
114118
| scan.plugins.trivy.javaDbRepository | string | `""` | Specifies a custom OCI repository(ies) to retrieve Java vulnerability database. |
119+
| scan.plugins.trivy.nodeSelector | object | `{}` | [Node selection](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node) to constrain a Pod to only be able to run on particular Node(s) |
120+
| scan.plugins.trivy.tolerations | list | `[]` | [Tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) for pod assignment |
121+
| scan.plugins.trivy.affinity | object | `{}` | Map of node/pod [affinities](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) |
115122
| scan.plugins.trivy.resources | object | `{"limits":{"cpu":"1500m","memory":"4096Mi"},"requests":{"cpu":"500m","memory":"2048Mi"}}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) to add to `trivy` container |
123+
| scan.plugins.trivy.workerResources | object | `{"limits":{"cpu":"500m","memory":"256Mi"},"requests":{"cpu":"10m","memory":"64Mi"}}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) to add to `worker` container |
116124
| scan.plugins.trivy.podAnnotations | object | `{}` | Annotations added to the trivy pods |
117125
| scan.plugins.trivy.image.repository | string | `"ghcr.io/undistro/trivy"` | trivy plugin image repository |
118126
| scan.plugins.trivy.image.tag | float | `0.67` | trivy plugin image tag |
@@ -128,7 +136,11 @@ The following table lists the configurable parameters of the Zora chart and thei
128136
| scan.plugins.trivy.persistence.storageRequest | string | `"2Gi"` | Persistence storage size |
129137
| scan.plugins.trivy.persistence.downloadJavaDB | bool | `false` | Specifies whether Java vulnerability database should be downloaded on helm install/upgrade |
130138
| scan.plugins.popeye.skipInternalResources | bool | `false` | Specifies whether the following resources should be skipped by `popeye` scans. 1. resources from `kube-system`, `kube-public` and `kube-node-lease` namespaces; 2. kubernetes system reserved RBAC (prefixed with `system:`); 3. `kube-root-ca.crt` configmaps; 4. `default` namespace; 5. `default` serviceaccounts; 6. Helm secrets (prefixed with `sh.helm.release`); 7. Zora components. See `popeye` configuration file that is used for this case: https://github.com/undistro/zora/blob/main/charts/zora/templates/plugins/popeye-config.yaml |
139+
| scan.plugins.popeye.nodeSelector | object | `{}` | [Node selection](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node) to constrain a Pod to only be able to run on particular Node(s) |
140+
| scan.plugins.popeye.tolerations | list | `[]` | [Tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) for pod assignment |
141+
| scan.plugins.popeye.affinity | object | `{}` | Map of node/pod [affinities](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) |
131142
| scan.plugins.popeye.resources | object | `{"limits":{"cpu":"500m","memory":"500Mi"},"requests":{"cpu":"250m","memory":"256Mi"}}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) to add to `popeye` container |
143+
| scan.plugins.popeye.workerResources | object | `{"limits":{"cpu":"500m","memory":"256Mi"},"requests":{"cpu":"10m","memory":"64Mi"}}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) to add to `worker` container |
132144
| scan.plugins.popeye.podAnnotations | object | `{}` | Annotations added to the popeye pods |
133145
| scan.plugins.popeye.image.repository | string | `"ghcr.io/undistro/popeye"` | popeye plugin image repository |
134146
| scan.plugins.popeye.image.tag | float | `0.21` | popeye plugin image tag |

0 commit comments

Comments
 (0)