Skip to content

Commit

Permalink
feat: add envFrom support for daemonset and statefulsets Signed-off-b…
Browse files Browse the repository at this point in the history
…y: Bishwa Thapa <[email protected]>
  • Loading branch information
thapabishwa committed Jan 23, 2025
1 parent 9798273 commit 366c563
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/fluentbit/v1alpha2/plugins/output/kafka_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Kafka struct {
// Limit the maximum number of Chunks in the filesystem for the current output logical destination.
TotalLimitSize string `json:"totalLimitSize,omitempty"`
// Enables dedicated thread(s) for this output. Default value is set since version 1.8.13. For previous versions is 0.
Workers *int32 `json:"workers,omitempty"`
Workers *int32 `json:"workers,omitempty"`
}

func (*Kafka) Name() string {
Expand Down
2 changes: 1 addition & 1 deletion apis/fluentbit/v1alpha2/plugins/output/loki_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Loki struct {
// Limit the maximum number of Chunks in the filesystem for the current output logical destination.
TotalLimitSize string `json:"totalLimitSize,omitempty"`
// Enables dedicated thread(s) for this output. Default value is set since version 1.8.13. For previous versions is 0.
Workers *int32 `json:"workers,omitempty"`
Workers *int32 `json:"workers,omitempty"`
}

// implement Section() method
Expand Down
10 changes: 10 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/output/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apis/fluentd/v1alpha1/fluentd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type FluentdSpec struct {
Args []string `json:"args,omitempty"`
// EnvVars represent environment variables that can be passed to fluentd pods.
EnvVars []corev1.EnvVar `json:"envVars,omitempty"`
// EnvFrom represent environment variables that can be passed to fluentd pods directly from secret or configmap
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
// FluentdCfgSelector defines the selectors to select the fluentd config CRs.
FluentdCfgSelector metav1.LabelSelector `json:"fluentdCfgSelector,omitempty"`
// Buffer definition
Expand Down
7 changes: 7 additions & 0 deletions apis/fluentd/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,56 @@ spec:
description: By default will build the related service according to
the globalinputs definition.
type: boolean
envFrom:
description: EnvFrom represent environment variables that can be passed
to fluentd pods directly from secret or configmap
items:
description: EnvFromSource represents the source of a set of ConfigMaps
properties:
configMapRef:
description: The ConfigMap to select from
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the ConfigMap must be defined
type: boolean
type: object
x-kubernetes-map-type: atomic
prefix:
description: An optional identifier to prepend to each key in
the ConfigMap. Must be a C_IDENTIFIER.
type: string
secretRef:
description: The Secret to select from
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret must be defined
type: boolean
type: object
x-kubernetes-map-type: atomic
type: object
type: array
envVars:
description: EnvVars represent environment variables that can be passed
to fluentd pods.
Expand Down
50 changes: 50 additions & 0 deletions config/crd/bases/fluentd.fluent.io_fluentds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,56 @@ spec:
description: By default will build the related service according to
the globalinputs definition.
type: boolean
envFrom:
description: EnvFrom represent environment variables that can be passed
to fluentd pods directly from secret or configmap
items:
description: EnvFromSource represents the source of a set of ConfigMaps
properties:
configMapRef:
description: The ConfigMap to select from
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the ConfigMap must be defined
type: boolean
type: object
x-kubernetes-map-type: atomic
prefix:
description: An optional identifier to prepend to each key in
the ConfigMap. Must be a C_IDENTIFIER.
type: string
secretRef:
description: The Secret to select from
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret must be defined
type: boolean
type: object
x-kubernetes-map-type: atomic
type: object
type: array
envVars:
description: EnvVars represent environment variables that can be passed
to fluentd pods.
Expand Down
50 changes: 50 additions & 0 deletions manifests/setup/fluent-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25963,6 +25963,56 @@ spec:
description: By default will build the related service according to
the globalinputs definition.
type: boolean
envFrom:
description: EnvFrom represent environment variables that can be passed
to fluentd pods directly from secret or configmap
items:
description: EnvFromSource represents the source of a set of ConfigMaps
properties:
configMapRef:
description: The ConfigMap to select from
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the ConfigMap must be defined
type: boolean
type: object
x-kubernetes-map-type: atomic
prefix:
description: An optional identifier to prepend to each key in
the ConfigMap. Must be a C_IDENTIFIER.
type: string
secretRef:
description: The Secret to select from
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret must be defined
type: boolean
type: object
x-kubernetes-map-type: atomic
type: object
type: array
envVars:
description: EnvVars represent environment variables that can be passed
to fluentd pods.
Expand Down
50 changes: 50 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25963,6 +25963,56 @@ spec:
description: By default will build the related service according to
the globalinputs definition.
type: boolean
envFrom:
description: EnvFrom represent environment variables that can be passed
to fluentd pods directly from secret or configmap
items:
description: EnvFromSource represents the source of a set of ConfigMaps
properties:
configMapRef:
description: The ConfigMap to select from
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the ConfigMap must be defined
type: boolean
type: object
x-kubernetes-map-type: atomic
prefix:
description: An optional identifier to prepend to each key in
the ConfigMap. Must be a C_IDENTIFIER.
type: string
secretRef:
description: The Secret to select from
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret must be defined
type: boolean
type: object
x-kubernetes-map-type: atomic
type: object
type: array
envVars:
description: EnvVars represent environment variables that can be passed
to fluentd pods.
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/fluentd-daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ func MakeFluentdDaemonSet(fd fluentdv1alpha1.Fluentd) *appsv1.DaemonSet {
daemonSet.Spec.Template.Spec.Containers[0].Env = append(daemonSet.Spec.Template.Spec.Containers[0].Env, fd.Spec.EnvVars...)
}

if fd.Spec.EnvFrom != nil {
daemonSet.Spec.Template.Spec.Containers[0].EnvFrom = append(daemonSet.Spec.Template.Spec.Containers[0].EnvFrom, fd.Spec.EnvFrom...)
}

if fd.Spec.SecurityContext != nil {
daemonSet.Spec.Template.Spec.SecurityContext = fd.Spec.SecurityContext
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/sts.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ func MakeStatefulSet(fd fluentdv1alpha1.Fluentd) *appsv1.StatefulSet {
sts.Spec.Template.Spec.Containers[0].Env = append(sts.Spec.Template.Spec.Containers[0].Env, fd.Spec.EnvVars...)
}

if fd.Spec.EnvFrom != nil {
sts.Spec.Template.Spec.Containers[0].EnvFrom = append(sts.Spec.Template.Spec.Containers[0].EnvFrom, fd.Spec.EnvFrom...)
}

if fd.Spec.SecurityContext != nil {
sts.Spec.Template.Spec.SecurityContext = fd.Spec.SecurityContext
}
Expand Down

0 comments on commit 366c563

Please sign in to comment.