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
1 change: 1 addition & 0 deletions operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ helm install securecodebox-operator oci://ghcr.io/securecodebox/helm/operator

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| allowIstioSidecarInjectionInJobs | bool | `false` | Sets the value of the istio sidecar annotation ("sidecar.istio.io/inject") for jobs started by the operator (scans, parser and hooks). defaults to false to prevent jobs hanging indefinitely due to the sidecar never terminating. If you aren't using istio this setting/annotation has no effect. |
| customCACertificate | object | `{"certificate":"public.crt","existingCertificate":null}` | Setup for Custom CA certificates. These are automatically mounted into every secureCodeBox component (lurker, parser & hooks). Requires that every namespace has a configmap with the CA certificate(s) |
| customCACertificate.certificate | string | `"public.crt"` | key in the configmap holding the certificate(s) |
| customCACertificate.existingCertificate | string | `nil` | name of the configMap holding the ca certificate(s), needs to be the same across all namespaces |
Expand Down
3 changes: 2 additions & 1 deletion operator/controllers/execution/scans/hook_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ func (r *ScanReconciler) createJobForHook(hookName string, hookSpec *executionv1
if len(hookSpec.Resources.Requests) != 0 || len(hookSpec.Resources.Limits) != 0 {
resources = hookSpec.Resources
}

job := &batch.Job{
ObjectMeta: metav1.ObjectMeta{
Annotations: make(map[string]string),
Expand All @@ -395,7 +396,7 @@ func (r *ScanReconciler) createJobForHook(hookName string, hookSpec *executionv1
},
Annotations: map[string]string{
"auto-discovery.securecodebox.io/ignore": "true",
"sidecar.istio.io/inject": "false",
"sidecar.istio.io/inject": allowIstioSidecarInjectionInJobs,
},
},
Spec: corev1.PodSpec{
Expand Down
8 changes: 8 additions & 0 deletions operator/controllers/execution/scans/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package scancontrollers

import (
"os"

"github.com/prometheus/client_golang/prometheus"
"sigs.k8s.io/controller-runtime/pkg/metrics"
)
Expand Down Expand Up @@ -37,7 +39,13 @@ var (
)
)

var allowIstioSidecarInjectionInJobs = "false"

func init() {
// Register custom metrics with the global prometheus registry
metrics.Registry.MustRegister(scansStartedMetric, scansDoneMetric, scansErroredMetric)

if allowIstioSidecarInjectionInJobsEnv, ok := os.LookupEnv("ALLOW_ISTIO_SIDECAR_INJECTION_IN_JOBS"); ok && (allowIstioSidecarInjectionInJobsEnv == "true" || allowIstioSidecarInjectionInJobsEnv == "false") {
allowIstioSidecarInjectionInJobs = allowIstioSidecarInjectionInJobsEnv
}
}
2 changes: 1 addition & 1 deletion operator/controllers/execution/scans/parse_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
},
Annotations: map[string]string{
"auto-discovery.securecodebox.io/ignore": "true",
"sidecar.istio.io/inject": "false",
"sidecar.istio.io/inject": allowIstioSidecarInjectionInJobs,
},
},
Spec: corev1.PodSpec{
Expand Down
3 changes: 2 additions & 1 deletion operator/controllers/execution/scans/scan_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@ func (r *ScanReconciler) constructJobForScan(scan *executionv1.Scan, scanTypeSpe
if podAnnotations == nil {
podAnnotations = make(map[string]string)
}

podAnnotations["auto-discovery.securecodebox.io/ignore"] = "true"
// Ensuring that istio doesn't inject a sidecar proxy.
podAnnotations["sidecar.istio.io/inject"] = "false"
podAnnotations["sidecar.istio.io/inject"] = allowIstioSidecarInjectionInJobs
job.Spec.Template.Annotations = podAnnotations

if job.Spec.Template.Spec.ServiceAccountName == "" {
Expand Down
1 change: 1 addition & 0 deletions operator/docs/README.ArtifactHub.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ helm install securecodebox-operator oci://ghcr.io/securecodebox/helm/operator

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| allowIstioSidecarInjectionInJobs | bool | `false` | Sets the value of the istio sidecar annotation ("sidecar.istio.io/inject") for jobs started by the operator (scans, parser and hooks). defaults to false to prevent jobs hanging indefinitely due to the sidecar never terminating. If you aren't using istio this setting/annotation has no effect. |
| customCACertificate | object | `{"certificate":"public.crt","existingCertificate":null}` | Setup for Custom CA certificates. These are automatically mounted into every secureCodeBox component (lurker, parser & hooks). Requires that every namespace has a configmap with the CA certificate(s) |
| customCACertificate.certificate | string | `"public.crt"` | key in the configmap holding the certificate(s) |
| customCACertificate.existingCertificate | string | `nil` | name of the configMap holding the ca certificate(s), needs to be the same across all namespaces |
Expand Down
2 changes: 2 additions & 0 deletions operator/templates/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ spec:
value: {{ .Values.presignedUrlExpirationTimes.parsers | quote }}
- name: URL_EXPIRATION_HOOK
value: {{ .Values.presignedUrlExpirationTimes.hooks | quote }}
- name: ALLOW_ISTIO_SIDECAR_INJECTION_IN_JOBS
value: {{ .Values.allowIstioSidecarInjectionInJobs | quote }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
securityContext:
Expand Down
4 changes: 4 additions & 0 deletions operator/tests/__snapshot__/operator_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ matches the snapshot:
value: 1h
- name: URL_EXPIRATION_HOOK
value: 1h
- name: ALLOW_ISTIO_SIDECAR_INJECTION_IN_JOBS
value: "false"
image: docker.io/securecodebox/operator:0.0.0
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down Expand Up @@ -683,6 +685,8 @@ properly-renders-the-service-monitor-when-enabled:
value: 1h
- name: URL_EXPIRATION_HOOK
value: 1h
- name: ALLOW_ISTIO_SIDECAR_INJECTION_IN_JOBS
value: "false"
image: docker.io/securecodebox/operator:0.0.0
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down
3 changes: 3 additions & 0 deletions operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ presignedUrlExpirationTimes:
scanners: "12h"
parsers: "1h"
hooks: "1h"

# -- Sets the value of the istio sidecar annotation ("sidecar.istio.io/inject") for jobs started by the operator (scans, parser and hooks). defaults to false to prevent jobs hanging indefinitely due to the sidecar never terminating. If you aren't using istio this setting/annotation has no effect.
allowIstioSidecarInjectionInJobs: false