Skip to content

Commit 75889a2

Browse files
volleynatorcsatib02
authored andcommitted
feat: add parameter to disable mount of /var/log directory
Signed-off-by: Edwin Rolle <[email protected]>
1 parent 8f70057 commit 75889a2

File tree

11 files changed

+37
-5
lines changed

11 files changed

+37
-5
lines changed

charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_fluentbitagents.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,8 @@ spec:
11421142
type: boolean
11431143
disableVarLibDockerContainers:
11441144
type: boolean
1145+
disableVarLog:
1146+
type: boolean
11451147
dnsConfig:
11461148
properties:
11471149
nameservers:

charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_loggings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,6 +1998,8 @@ spec:
19981998
type: boolean
19991999
disableVarLibDockerContainers:
20002000
type: boolean
2001+
disableVarLog:
2002+
type: boolean
20012003
dnsConfig:
20022004
properties:
20032005
nameservers:

charts/logging-operator/crds/logging.banzaicloud.io_fluentbitagents.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,8 @@ spec:
11391139
type: boolean
11401140
disableVarLibDockerContainers:
11411141
type: boolean
1142+
disableVarLog:
1143+
type: boolean
11421144
dnsConfig:
11431145
properties:
11441146
nameservers:

charts/logging-operator/crds/logging.banzaicloud.io_loggings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,6 +1995,8 @@ spec:
19951995
type: boolean
19961996
disableVarLibDockerContainers:
19971997
type: boolean
1998+
disableVarLog:
1999+
type: boolean
19982000
dnsConfig:
19992001
properties:
20002002
nameservers:

config/crd/bases/logging.banzaicloud.io_fluentbitagents.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,8 @@ spec:
11391139
type: boolean
11401140
disableVarLibDockerContainers:
11411141
type: boolean
1142+
disableVarLog:
1143+
type: boolean
11421144
dnsConfig:
11431145
properties:
11441146
nameservers:

config/crd/bases/logging.banzaicloud.io_loggings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,6 +1995,8 @@ spec:
19951995
type: boolean
19961996
disableVarLibDockerContainers:
19971997
type: boolean
1998+
disableVarLog:
1999+
type: boolean
19982000
dnsConfig:
19992001
properties:
20002002
nameservers:

docs/configuration/crds/v1beta1/fluentbit_types.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ Disable Kubernetes metadata filter
104104
DisableVarLibDockerContainers controls whether the /var/lib/docker/containers volume is mounted. If true, the volume is NOT mounted. If false (default), the volume is mounted.
105105

106106

107+
### disableVarLog (*bool, optional) {#fluentbitspec-disablevarlog}
108+
109+
DisableVarLog controls whether the /var/log volume is mounted. If true, the volume is NOT mounted. If false (default), the volume is mounted.
110+
111+
107112
### enableUpstream (bool, optional) {#fluentbitspec-enableupstream}
108113

109114

pkg/resources/fluentbit/daemonset.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,20 @@ func newConfigMapReloader(spec *v1beta1.FluentbitSpec) corev1.Container {
175175

176176
func (r *Reconciler) generateVolumeMounts() (v []corev1.VolumeMount) {
177177
v = []corev1.VolumeMount{
178-
{
179-
Name: "varlogs",
180-
ReadOnly: true,
181-
MountPath: "/var/log/",
182-
},
183178
{
184179
Name: "config",
185180
MountPath: OperatorConfigPath,
186181
},
187182
}
188183

184+
if !*r.fluentbitSpec.DisableVarLog {
185+
v = append(v, corev1.VolumeMount{
186+
Name: "varlogs",
187+
ReadOnly: true,
188+
MountPath: "/var/log/",
189+
})
190+
}
191+
189192
if !*r.fluentbitSpec.DisableVarLibDockerContainers {
190193
v = append(v, corev1.VolumeMount{
191194
Name: "varlibcontainers",

pkg/sdk/logging/api/v1beta1/fluentbit_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ type FluentbitSpec struct {
8080
// DisableVarLibDockerContainers controls whether the /var/lib/docker/containers volume is mounted.
8181
// If true, the volume is NOT mounted. If false (default), the volume is mounted.
8282
DisableVarLibDockerContainers *bool `json:"disableVarLibDockerContainers,omitempty"`
83+
// DisableVarLog controls whether the /var/log volume is mounted.
84+
// If true, the volume is NOT mounted. If false (default), the volume is mounted.
85+
DisableVarLog *bool `json:"disableVarLog,omitempty"`
8386
// HotReload pauses all inputs and waits until they finish. In certain situations this is unacceptable, for example if an output is down for a longer time.
8487
// An undocumented option called "Hot_Reload.Ensure_Thread_Safety Off" can be used at the [SERVICE] config to force hotreload after the grace period.
8588
// Please note that it might result in a SIGSEGV, but worst case kubelet will restart the container.

pkg/sdk/logging/api/v1beta1/logging_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ func FluentBitDefaults(fluentbitSpec *FluentbitSpec) error {
270270
if fluentbitSpec.DisableVarLibDockerContainers == nil {
271271
fluentbitSpec.DisableVarLibDockerContainers = util.BoolPointer(false)
272272
}
273+
// Set default value for DisableVarLog to false (meaning volume is mounted by default)
274+
if fluentbitSpec.DisableVarLog == nil {
275+
fluentbitSpec.DisableVarLog = util.BoolPointer(false)
276+
}
273277
if fluentbitSpec.PosisionDBLegacy != nil {
274278
return errors.New("`position_db` field is deprecated, use `positiondb`")
275279
}

0 commit comments

Comments
 (0)