Skip to content

Commit

Permalink
Mount correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ruivieira committed Feb 27, 2024
1 parent 90403b3 commit 0de628e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
24 changes: 8 additions & 16 deletions controllers/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,28 +343,20 @@ var _ = Describe("TrustyAI operator", func() {

Expect(deployment.Spec.Template.Spec.ServiceAccountName).To(Equal(instance.Name + "-proxy"))

foundTrustedCAVolume := false
for _, volume := range deployment.Spec.Template.Spec.Volumes {
if volume.Name == caBundleName && volume.ConfigMap != nil && volume.ConfigMap.Name == caBundleName {
foundTrustedCAVolume = true
Expect(volume.ConfigMap.Items).To(ContainElement(corev1.KeyToPath{
Key: "ca-bundle.crt",
Path: "tls-ca-bundle.pem",
}))
}
}
Expect(foundTrustedCAVolume).To(BeTrue(), caBundleName+" volume not found")
foundCustomCertificatesBundleVolumeMount := false

foundTrustedCAVolumeMount := false
customCertificatesBundleMountPath := "/etc/ssl/certs/ca-bundle.crt" // Adjust this based on your actual mount path
for _, container := range deployment.Spec.Template.Spec.Containers {
for _, volumeMount := range container.VolumeMounts {
if volumeMount.Name == caBundleName && volumeMount.MountPath == "/etc/pki/ca-trust/extracted/pem" {
foundTrustedCAVolumeMount = true
if volumeMount.Name == caBundleName && volumeMount.MountPath == customCertificatesBundleMountPath {
foundCustomCertificatesBundleVolumeMount = true
}
}
}
Expect(foundTrustedCAVolumeMount).To(BeTrue(), caBundleName+"trusted-ca volume mount not found in any container")
Expect(k8sClient.Delete(ctx, caBundleConfigMap)).To(Succeed(), "failed to delete custom CA bundle ConfigMap")
Expect(foundCustomCertificatesBundleVolumeMount).To(BeTrue(), caBundleName+" volume mount not found in any container")

// Assuming you want to clean up after your test
Expect(k8sClient.Delete(ctx, caBundleConfigMap)).To(Succeed(), "failed to delete custom certificates bundle ConfigMap")

})
})
Expand Down
8 changes: 3 additions & 5 deletions controllers/templates/service/deployment.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ spec:
{{ if .CustomCertificatesBundle.IsDefined }}
- name: {{ .CustomCertificatesBundle.VolumeName }}
readOnly: true
mountPath: /etc/pki/ca-trust/extracted/pem
mountPath: /etc/ssl/certs/ca-bundle.crt
subPath: ca-bundle.crt
{{ end }}
- name: {{ .Instance.Name }}-tls
mountPath: /etc/tls/private
Expand All @@ -107,7 +108,7 @@ spec:
- '--email-domain=*'
- '--openshift-service-account={{ .Instance.Name }}-proxy'
{{ if .CustomCertificatesBundle.IsDefined }}
- '--openshift-ca=/etc/pki/tls/certs/ca-bundle.crt'
- '--openshift-ca=/etc/ssl/certs/ca-bundle.crt'
{{ end }}
- '--provider=openshift'
- '--tls-cert=/etc/tls/private/tls.crt'
Expand All @@ -128,9 +129,6 @@ spec:
- name: {{ .CustomCertificatesBundle.VolumeName}}
configMap:
name: {{ .CustomCertificatesBundle.ConfigMapName }}
items:
- key: ca-bundle.crt
path: tls-ca-bundle.pem
defaultMode: 420
{{ end }}
- name: {{ .Instance.Name}}-tls
Expand Down

0 comments on commit 0de628e

Please sign in to comment.