Skip to content

Commit

Permalink
Merge pull request #771 from ksdpmx/scheduler
Browse files Browse the repository at this point in the history
feat: add scheduler support for fluentbit & fluentd
  • Loading branch information
benjaminhuo committed Jun 3, 2023
2 parents 6080b20 + df8bc16 commit b2a709e
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apis/fluentbit/v1alpha2/fluentbit_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ type FluentBitSpec struct {
MetricsPort int32 `json:"metricsPort,omitempty"`
// Service represents configurations on the fluent-bit service.
Service FluentBitService `json:"service,omitempty"`
// SchedulerName represents the desired scheduler for fluent-bit pods.
SchedulerName string `json:"schedulerName,omitempty"`
}

// FluentBitService defines the service of the FluentBit
Expand Down
2 changes: 2 additions & 0 deletions apis/fluentd/v1alpha1/fluentd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ type FluentdSpec struct {
Service FluentDService `json:"service,omitempty"`
// PodSecurityContext represents the security context for the fluentd pods.
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
// SchedulerName represents the desired scheduler for fluentd pods.
SchedulerName string `json:"schedulerName,omitempty"`
}

// FluentDService the service of the FluentD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4302,6 +4302,10 @@ spec:
runtimeClassName:
description: RuntimeClassName represents the container runtime configuration.
type: string
schedulerName:
description: SchedulerName represents the desired scheduler for fluent-bit
pods.
type: string
secrets:
description: The Secrets are mounted into /fluent-bit/secrets/<secret-name>.
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,10 @@ spec:
runtimeClassName:
description: RuntimeClassName represents the container runtime configuration.
type: string
schedulerName:
description: SchedulerName represents the desired scheduler for fluentd
pods.
type: string
securityContext:
description: PodSecurityContext represents the security context for
the fluentd pods.
Expand Down
3 changes: 3 additions & 0 deletions charts/fluent-operator/templates/fluentbit-fluentBit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ spec:
{{- with .Values.fluentbit.affinity }}
affinity:
{{ toYaml . | indent 4 }}
{{- end }}
{{- if .Values.fluentbit.schedulerName }}
schedulerName: {{ .Values.fluentbit.schedulerName }}
{{- end }}
{{- if .Values.fluentbit.secrets }}
secrets:
Expand Down
3 changes: 3 additions & 0 deletions charts/fluent-operator/templates/fluentd-fluentd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ spec:
fluentdCfgSelector:
matchLabels:
config.fluentd.fluent.io/enabled: "true"
{{- if .Values.fluentd.schedulerName }}
schedulerName: {{ .Values.fluentd.schedulerName }}
{{- end }}
{{- if .Values.fluentd.logLevel }}
logLevel: {{ .Values.fluentd.logLevel }}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions charts/fluent-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ fluentbit:
envVars: []
# - name: FOO
# value: "bar"
schedulerName: ""

# Remove the above empty volumes and volumesMounts, and then set additionalVolumes and additionalVolumesMounts as below if you want to collect node exporter metrics
# additionalVolumes:
Expand Down Expand Up @@ -240,6 +241,7 @@ fluentd:
requests:
cpu: 100m
memory: 128Mi
schedulerName: ""
logLevel: ""
# Configure the output plugin parameter in Fluentd.
# Fluentd is disabled by default, if you enable it make sure to also set up an output to use.
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_fluentbits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4302,6 +4302,10 @@ spec:
runtimeClassName:
description: RuntimeClassName represents the container runtime configuration.
type: string
schedulerName:
description: SchedulerName represents the desired scheduler for fluent-bit
pods.
type: string
secrets:
description: The Secrets are mounted into /fluent-bit/secrets/<secret-name>.
items:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/fluentd.fluent.io_fluentds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,10 @@ spec:
runtimeClassName:
description: RuntimeClassName represents the container runtime configuration.
type: string
schedulerName:
description: SchedulerName represents the desired scheduler for fluentd
pods.
type: string
securityContext:
description: PodSecurityContext represents the security context for
the fluentd pods.
Expand Down
8 changes: 8 additions & 0 deletions manifests/setup/fluent-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15537,6 +15537,10 @@ spec:
runtimeClassName:
description: RuntimeClassName represents the container runtime configuration.
type: string
schedulerName:
description: SchedulerName represents the desired scheduler for fluent-bit
pods.
type: string
secrets:
description: The Secrets are mounted into /fluent-bit/secrets/<secret-name>.
items:
Expand Down Expand Up @@ -19925,6 +19929,10 @@ spec:
runtimeClassName:
description: RuntimeClassName represents the container runtime configuration.
type: string
schedulerName:
description: SchedulerName represents the desired scheduler for fluentd
pods.
type: string
securityContext:
description: PodSecurityContext represents the security context for
the fluentd pods.
Expand Down
8 changes: 8 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15537,6 +15537,10 @@ spec:
runtimeClassName:
description: RuntimeClassName represents the container runtime configuration.
type: string
schedulerName:
description: SchedulerName represents the desired scheduler for fluent-bit
pods.
type: string
secrets:
description: The Secrets are mounted into /fluent-bit/secrets/<secret-name>.
items:
Expand Down Expand Up @@ -19925,6 +19929,10 @@ spec:
runtimeClassName:
description: RuntimeClassName represents the container runtime configuration.
type: string
schedulerName:
description: SchedulerName represents the desired scheduler for fluentd
pods.
type: string
securityContext:
description: PodSecurityContext represents the security context for
the fluentd pods.
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ func MakeDaemonSet(fb fluentbitv1alpha2.FluentBit, logPath string) *appsv1.Daemo
ds.Spec.Template.Spec.PriorityClassName = fb.Spec.PriorityClassName
}

if fb.Spec.SchedulerName != "" {
ds.Spec.Template.Spec.SchedulerName = fb.Spec.SchedulerName
}

if fb.Spec.Volumes != nil {
ds.Spec.Template.Spec.Volumes = append(ds.Spec.Template.Spec.Volumes, fb.Spec.Volumes...)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/sts.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ func MakeStatefulset(fd fluentdv1alpha1.Fluentd) *appsv1.StatefulSet {
sts.Spec.Template.Spec.SecurityContext = fd.Spec.SecurityContext
}

if fd.Spec.SchedulerName != "" {
sts.Spec.Template.Spec.SchedulerName = fd.Spec.SchedulerName
}

// Mount host or emptydir VolumeSource
if fd.Spec.BufferVolume != nil && !fd.Spec.BufferVolume.DisableBufferVolume {
bufferVolName := fmt.Sprintf("%s-buffer", fd.Name)
Expand Down

0 comments on commit b2a709e

Please sign in to comment.