Skip to content

Commit 8f3e93b

Browse files
committed
wip
1 parent ade9c02 commit 8f3e93b

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

internal/resources/storage_init_job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func (b *StorageInitJobBuilder) buildInitJobPodTemplateSpec() corev1.PodTemplate
7575
DNSConfig: &corev1.PodDNSConfig{
7676
Searches: dnsConfigSearches,
7777
},
78+
InitContainers: b.Spec.InitContainers,
7879
},
7980
}
8081

@@ -92,8 +93,7 @@ func (b *StorageInitJobBuilder) buildInitJobPodTemplateSpec() corev1.PodTemplate
9293
}
9394
}
9495

95-
// InitContainer only needed for CaBundle manipulation for now,
96-
// may be probably used for other stuff later
96+
// append an init container for updating the ca.crt if we have any certificates
9797
if b.AnyCertificatesAdded() {
9898
podTemplate.Spec.InitContainers = append(
9999
[]corev1.Container{b.buildCaStorePatchingInitContainer()},

tests/e2e/smoke_test.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,82 @@ var _ = Describe("Operator smoke test", func() {
768768
ExecuteSimpleTableE2ETestWithSDK(databaseSample.Name, testobjects.YdbNamespace, databasePath)
769769
})
770770

771+
It("Check init job has additional volumes", func() {
772+
By("create storage tls secret...")
773+
storageCert := testobjects.StorageCertificate()
774+
Expect(k8sClient.Create(ctx, storageCert)).Should(Succeed())
775+
776+
By("create storage...")
777+
storage := testobjects.DefaultStorage(filepath.Join("..", "data", "storage-mirror-3-dc-config.yaml"))
778+
779+
secretName := testobjects.StorageCertificateSecretName
780+
secretPath := fmt.Sprintf("%s/%s", resources.wellKnownDirForAdditionalSecrets, secretName)
781+
782+
storage.Spec.Secrets = []*corev1.LocalObjectReference{
783+
{
784+
Name: secretName,
785+
},
786+
}
787+
788+
storage.Spec.InitContainers = []corev1.Container{
789+
{
790+
Name: "init-container",
791+
Image: storage.Spec.Image.Name,
792+
Command: []string{"bash", "-xc"},
793+
Args: []string{fmt.Sprintf("ls -la %s", secretPath)},
794+
VolumeMounts: []corev1.VolumeMount{
795+
{
796+
Name: secretName,
797+
MountPath: secretPath,
798+
ReadOnly: true,
799+
},
800+
},
801+
},
802+
}
803+
804+
Expect(k8sClient.Create(ctx, storage)).Should(Succeed())
805+
defer DeleteStorageSafely(ctx, k8sClient, storage)
806+
807+
By("waiting until Storage is ready ...")
808+
WaitUntilStorageReady(ctx, k8sClient, storage.Name, testobjects.YdbNamespace)
809+
})
810+
811+
It("Check init job has additional volumes with GRPCS enabled", func() {
812+
By("create storage tls secret...")
813+
storageCert := testobjects.StorageCertificate()
814+
Expect(k8sClient.Create(ctx, storageCert)).Should(Succeed())
815+
816+
By("create storage...")
817+
storage := testobjects.DefaultStorage(filepath.Join("..", "data", "storage-mirror-3-dc-config-tls.yaml"))
818+
819+
secretName := testobjects.StorageCertificateSecretName
820+
secretPath := fmt.Sprintf("%s/%s", resources.wellKnownDirForAdditionalSecrets, secretName)
821+
822+
storage.Spec.Service.GRPC.TLSConfiguration = testobjects.TLSConfiguration(secretName)
823+
824+
storage.Spec.InitContainers = []corev1.Container{
825+
{
826+
Name: "init-container",
827+
Image: storage.Spec.Image.Name,
828+
Command: []string{"bash", "-xc"},
829+
Args: []string{fmt.Sprintf("ls -la %s", secretPath)},
830+
VolumeMounts: []corev1.VolumeMount{
831+
{
832+
Name: resources.grpcTLSVolumeName,
833+
MountPath: secretPath,
834+
ReadOnly: true,
835+
},
836+
},
837+
},
838+
}
839+
840+
Expect(k8sClient.Create(ctx, storage)).Should(Succeed())
841+
defer DeleteStorageSafely(ctx, k8sClient, storage)
842+
843+
By("waiting until Storage is ready ...")
844+
WaitUntilStorageReady(ctx, k8sClient, storage.Name, testobjects.YdbNamespace)
845+
})
846+
771847
AfterEach(func() {
772848
UninstallOperatorWithHelm(testobjects.YdbNamespace)
773849
Expect(k8sClient.Delete(ctx, &namespace)).Should(Succeed())

0 commit comments

Comments
 (0)