Skip to content

Commit b983dd1

Browse files
naemonopebrc
andauthored
Add additional volume for Kibana logs when hardened security context is enabled (#8380) (#8408)
* Add additional volume for Kibana logs when hardened security context is enabled. Co-authored-by: Peter Brachwitz <[email protected]> --------- Signed-off-by: Michael Montgomery <[email protected]> Co-authored-by: Peter Brachwitz <[email protected]> (cherry picked from commit 186d4fb)
1 parent 8ecd6e0 commit b983dd1

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

pkg/controller/kibana/driver_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,12 @@ func expectedDeploymentParams() deployment.Params {
531531
EmptyDir: &corev1.EmptyDirVolumeSource{},
532532
},
533533
},
534+
{
535+
Name: "kibana-logs",
536+
VolumeSource: corev1.VolumeSource{
537+
EmptyDir: &corev1.EmptyDirVolumeSource{},
538+
},
539+
},
534540
{
535541
Name: "kibana-plugins",
536542
VolumeSource: corev1.VolumeSource{
@@ -586,6 +592,11 @@ func expectedDeploymentParams() deployment.Params {
586592
ReadOnly: falseVal,
587593
MountPath: DataVolumeMountPath,
588594
},
595+
{
596+
Name: "kibana-logs",
597+
ReadOnly: falseVal,
598+
MountPath: "/usr/share/kibana/logs",
599+
},
589600
{
590601
Name: "kibana-plugins",
591602
ReadOnly: falseVal,
@@ -632,6 +643,11 @@ func expectedDeploymentParams() deployment.Params {
632643
ReadOnly: falseVal,
633644
MountPath: DataVolumeMountPath,
634645
},
646+
{
647+
Name: "kibana-logs",
648+
ReadOnly: falseVal,
649+
MountPath: "/usr/share/kibana/logs",
650+
},
635651
{
636652
Name: "kibana-plugins",
637653
ReadOnly: falseVal,

pkg/controller/kibana/pod.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const (
3535
DataVolumeMountPath = "/usr/share/kibana/data"
3636
PluginsVolumeName = "kibana-plugins"
3737
PluginsVolumeMountPath = "/usr/share/kibana/plugins"
38+
LogsVolumeName = "kibana-logs"
39+
LogsVolumeMountPath = "/usr/share/kibana/logs"
3840
TempVolumeName = "temp-volume"
3941
TempVolumeMountPath = "/tmp"
4042
KibanaBasePathEnvName = "SERVER_BASEPATH"
@@ -53,6 +55,10 @@ var (
5355
// the Kibana pod has readOnlyRootFilesystem set to true.
5456
PluginsVolume = volume.NewEmptyDirVolume(PluginsVolumeName, PluginsVolumeMountPath)
5557

58+
// LogsVolume can be used to persist logs even when
59+
// the Kibana pod has readOnlyRootFilesystem set to true.
60+
LogsVolume = volume.NewEmptyDirVolume(LogsVolumeName, LogsVolumeMountPath)
61+
5662
// TempVolume can be used for some reporting features when the Kibana pod has
5763
// readOnlyRootFilesystem set to true.
5864
TempVolume = volume.NewEmptyDirVolume(TempVolumeName, TempVolumeMountPath)
@@ -143,8 +149,9 @@ func NewPodTemplateSpec(
143149
if v.GTE(version.From(7, 10, 0)) && setDefaultSecurityContext {
144150
builder.WithContainersSecurityContext(defaultSecurityContext).
145151
WithPodSecurityContext(defaultPodSecurityContext).
146-
WithVolumes(TempVolume.Volume()).WithVolumeMounts(TempVolume.VolumeMount()).
147-
WithVolumes(PluginsVolume.Volume()).WithVolumeMounts(PluginsVolume.VolumeMount())
152+
WithVolumes(LogsVolume.Volume()).WithVolumeMounts(LogsVolume.VolumeMount()).
153+
WithVolumes(PluginsVolume.Volume()).WithVolumeMounts(PluginsVolume.VolumeMount()).
154+
WithVolumes(TempVolume.Volume()).WithVolumeMounts(TempVolume.VolumeMount())
148155
}
149156

150157
if keystore != nil {

pkg/controller/kibana/pod_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ func TestNewPodTemplateSpec(t *testing.T) {
219219
}},
220220
assertions: func(pod corev1.PodTemplateSpec) {
221221
assert.Len(t, pod.Spec.InitContainers, 1)
222-
assert.Len(t, pod.Spec.InitContainers[0].VolumeMounts, 5)
223-
assert.Len(t, pod.Spec.Volumes, 3)
224-
assert.Len(t, GetKibanaContainer(pod.Spec).VolumeMounts, 3)
222+
assert.Len(t, pod.Spec.InitContainers[0].VolumeMounts, 6)
223+
assert.Len(t, pod.Spec.Volumes, 4)
224+
assert.Len(t, GetKibanaContainer(pod.Spec).VolumeMounts, 4)
225225
assert.Equal(t, GetKibanaContainer(pod.Spec).SecurityContext, &defaultSecurityContext)
226226
},
227227
},

0 commit comments

Comments
 (0)