Skip to content

Commit a2d6792

Browse files
committed
Inject global custom ca mount into parser
1 parent 214ac12 commit a2d6792

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎operator/controllers/execution/scans/parse_reconciler.go‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package scancontrollers
33
import (
44
"context"
55
"fmt"
6+
"os"
67
"strings"
78

89
executionv1 "github.com/secureCodeBox/secureCodeBox/operator/apis/execution/v1"
@@ -174,6 +175,37 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
174175
parseDefinition.Spec.Volumes...,
175176
)
176177

178+
customCACertificate, isConfigured := os.LookupEnv("CUSTOM_CA_CERTIFICATE_EXISTING_CERTIFICATE")
179+
r.Log.Info("Configuring customCACerts for Parser", "customCACertificate", customCACertificate, "isConfigured", isConfigured)
180+
if isConfigured {
181+
job.Spec.Template.Spec.Volumes = append(job.Spec.Template.Spec.Volumes, corev1.Volume{
182+
Name: "ca-certificate",
183+
VolumeSource: corev1.VolumeSource{
184+
ConfigMap: &corev1.ConfigMapVolumeSource{
185+
LocalObjectReference: corev1.LocalObjectReference{
186+
Name: customCACertificate,
187+
},
188+
},
189+
},
190+
})
191+
192+
certificateName := os.Getenv("CUSTOM_CA_CERTIFICATE_NAME")
193+
mountPath := fmt.Sprintf("/etc/ssl/certs/%s", certificateName)
194+
195+
job.Spec.Template.Spec.Containers[0].VolumeMounts = append(job.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{
196+
Name: "ca-certificate",
197+
ReadOnly: true,
198+
MountPath: mountPath,
199+
SubPath: certificateName,
200+
})
201+
202+
// Add env var for node.js to load the custom ca certs
203+
job.Spec.Template.Spec.Containers[0].Env = append(job.Spec.Template.Spec.Containers[0].Env, corev1.EnvVar{
204+
Name: "NODE_EXTRA_CA_CERTS",
205+
Value: mountPath,
206+
})
207+
}
208+
177209
if err := ctrl.SetControllerReference(scan, job, r.Scheme); err != nil {
178210
return err
179211
}

0 commit comments

Comments
 (0)