Skip to content
Draft
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 api/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
AnnotationDataCenter = "ydb.tech/data-center"
AnnotationNodeHost = "ydb.tech/node-host"
AnnotationNodeDomain = "ydb.tech/node-domain"
AnnotationCABundleSecret = "ydb.tech/ca-bundle-secret"

AnnotationValueTrue = "true"

Expand Down
17 changes: 17 additions & 0 deletions internal/resources/database_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ func (b *DatabaseStatefulSetBuilder) buildVolumes() []corev1.Volume {
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
})
} else if value, ok := b.ObjectMeta.Annotations[v1alpha1.AnnotationCABundleSecret]; ok {
volumes = append(volumes, corev1.Volume{
Name: caCertificatesVolumeName,
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: value,
DefaultMode: ptr.Int32(0o644),
Optional: ptr.Bool(false),
},
},
})
}

return volumes
Expand Down Expand Up @@ -472,6 +483,12 @@ func (b *DatabaseStatefulSetBuilder) buildVolumeMounts() []corev1.VolumeMount {
Name: systemCertsVolumeName,
MountPath: systemCertsDir,
})
} else if _, ok := b.ObjectMeta.Annotations[v1alpha1.AnnotationCABundleSecret]; ok {
volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: caCertificatesVolumeName,
MountPath: systemCertsDir,
ReadOnly: true,
})
}

for _, secret := range b.Spec.Secrets {
Expand Down
20 changes: 19 additions & 1 deletion internal/resources/storage_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import (
)

const (
configVolumeName = "ydb-config"
configVolumeName = "ydb-config"
caCertificatesVolumeName = "ca-certificates"
)

type StorageStatefulSetBuilder struct {
Expand Down Expand Up @@ -229,6 +230,17 @@ func (b *StorageStatefulSetBuilder) buildVolumes() []corev1.Volume {
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
})
} else if value, ok := b.ObjectMeta.Annotations[v1alpha1.AnnotationCABundleSecret]; ok {
volumes = append(volumes, corev1.Volume{
Name: caCertificatesVolumeName,
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: value,
DefaultMode: ptr.Int32(0o644),
Optional: ptr.Bool(false),
},
},
})
}

return volumes
Expand Down Expand Up @@ -402,6 +414,12 @@ func (b *StorageStatefulSetBuilder) buildVolumeMounts() []corev1.VolumeMount {
Name: systemCertsVolumeName,
MountPath: systemCertsDir,
})
} else if _, ok := b.ObjectMeta.Annotations[v1alpha1.AnnotationCABundleSecret]; ok {
volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: caCertificatesVolumeName,
MountPath: systemCertsDir,
ReadOnly: true,
})
}

for _, secret := range b.Spec.Secrets {
Expand Down