diff --git a/apis/fluentbit/v1alpha2/fluentbit_types.go b/apis/fluentbit/v1alpha2/fluentbit_types.go index 5f9047116..83d63f90e 100644 --- a/apis/fluentbit/v1alpha2/fluentbit_types.go +++ b/apis/fluentbit/v1alpha2/fluentbit_types.go @@ -107,6 +107,8 @@ type FluentBitSpec struct { SchedulerName string `json:"schedulerName,omitempty"` // Optional duration in seconds the pod needs to terminate gracefully. Value must be non-negative integer. TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"` + // HostAliases is an optional list of IPs and hostnames that will be injected into the pod's hosts file if specified. + HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"` } // FluentBitService defines the service of the FluentBit diff --git a/apis/fluentd/v1alpha1/fluentd_types.go b/apis/fluentd/v1alpha1/fluentd_types.go index a19d3e9be..664ec5861 100644 --- a/apis/fluentd/v1alpha1/fluentd_types.go +++ b/apis/fluentd/v1alpha1/fluentd_types.go @@ -117,6 +117,8 @@ type FluentdSpec struct { LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty"` // ReadinessProbe represents the readiness probe for the fluentd container. ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty"` + // HostAliases is an optional list of IPs and hostnames that will be injected into the pod's hosts file if specified. + HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"` } // FluentDService the service of the FluentD diff --git a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_fluentbits.yaml b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_fluentbits.yaml index 8c8d7ccd0..11c91c670 100644 --- a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_fluentbits.yaml +++ b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_fluentbits.yaml @@ -1315,6 +1315,32 @@ spec: network namespace. If this option is set, the ports that will be used must be specified. Default to false. type: boolean + hostAliases: + description: HostAliases is an optional list of IPs and hostnames that will + be injected into the pod's hosts file if specified. + items: + description: HostAlias holds the mapping between IP and hostnames + properties: + ip: + description: IP address of the host file entry. + pattern: "^(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$" + type: string + hostnames: + description: Hostnames for the above IP address. + items: + type: string + pattern: "^[a-zA-Z0-9.-]+$" + minItems: 1 + type: array + x-kubernetes-list-type: atomic + type: object + required: + - ip + - hostnames + x-kubernetes-list-map-keys: + - ip + x-kubernetes-list-type: map + type: array image: description: Fluent Bit image. type: string diff --git a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_fluentds.yaml b/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_fluentds.yaml index 06c93b14b..8e78a4adf 100644 --- a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_fluentds.yaml +++ b/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_fluentds.yaml @@ -2813,6 +2813,32 @@ spec: type: object type: object type: array + hostAliases: + description: HostAliases is an optional list of IPs and hostnames that will + be injected into the pod's hosts file if specified. + items: + description: HostAlias holds the mapping between IP and hostnames + properties: + ip: + description: IP address of the host file entry. + pattern: "^(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$" + type: string + hostnames: + description: Hostnames for the above IP address. + items: + type: string + pattern: "^[a-zA-Z0-9.-]+$" + minItems: 1 + type: array + x-kubernetes-list-type: atomic + type: object + required: + - ip + - hostnames + x-kubernetes-list-map-keys: + - ip + x-kubernetes-list-type: map + type: array image: description: Fluentd image. type: string diff --git a/config/crd/bases/fluentbit.fluent.io_fluentbits.yaml b/config/crd/bases/fluentbit.fluent.io_fluentbits.yaml index 8c8d7ccd0..11c91c670 100644 --- a/config/crd/bases/fluentbit.fluent.io_fluentbits.yaml +++ b/config/crd/bases/fluentbit.fluent.io_fluentbits.yaml @@ -1315,6 +1315,32 @@ spec: network namespace. If this option is set, the ports that will be used must be specified. Default to false. type: boolean + hostAliases: + description: HostAliases is an optional list of IPs and hostnames that will + be injected into the pod's hosts file if specified. + items: + description: HostAlias holds the mapping between IP and hostnames + properties: + ip: + description: IP address of the host file entry. + pattern: "^(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$" + type: string + hostnames: + description: Hostnames for the above IP address. + items: + type: string + pattern: "^[a-zA-Z0-9.-]+$" + minItems: 1 + type: array + x-kubernetes-list-type: atomic + type: object + required: + - ip + - hostnames + x-kubernetes-list-map-keys: + - ip + x-kubernetes-list-type: map + type: array image: description: Fluent Bit image. type: string diff --git a/config/crd/bases/fluentd.fluent.io_fluentds.yaml b/config/crd/bases/fluentd.fluent.io_fluentds.yaml index 06c93b14b..8e78a4adf 100644 --- a/config/crd/bases/fluentd.fluent.io_fluentds.yaml +++ b/config/crd/bases/fluentd.fluent.io_fluentds.yaml @@ -2813,6 +2813,32 @@ spec: type: object type: object type: array + hostAliases: + description: HostAliases is an optional list of IPs and hostnames that will + be injected into the pod's hosts file if specified. + items: + description: HostAlias holds the mapping between IP and hostnames + properties: + ip: + description: IP address of the host file entry. + pattern: "^(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$" + type: string + hostnames: + description: Hostnames for the above IP address. + items: + type: string + pattern: "^[a-zA-Z0-9.-]+$" + minItems: 1 + type: array + x-kubernetes-list-type: atomic + type: object + required: + - ip + - hostnames + x-kubernetes-list-map-keys: + - ip + x-kubernetes-list-type: map + type: array image: description: Fluentd image. type: string diff --git a/docs/fluentbit.md b/docs/fluentbit.md index 11d6a4670..12380bdce 100644 --- a/docs/fluentbit.md +++ b/docs/fluentbit.md @@ -432,6 +432,7 @@ FluentBitSpec defines the desired state of FluentBit | service | Service represents configurations on the fluent-bit service. | [FluentBitService](#fluentbitservice) | | schedulerName | SchedulerName represents the desired scheduler for fluent-bit pods. | string | | terminationGracePeriodSeconds | Optional duration in seconds the pod needs to terminate gracefully. Value must be non-negative integer. | *int64 | +| hostAliases | HostAliases is an optional list of IPs and hostnames that will be injected into the pod's hosts file if specified. | [][corev1.HostAlias](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#hostalias-v1-core) | [Back to TOC](#table-of-contents) # InputSpec diff --git a/docs/fluentd.md b/docs/fluentd.md index f424e703e..7272e23f8 100644 --- a/docs/fluentd.md +++ b/docs/fluentd.md @@ -362,6 +362,7 @@ FluentdSpec defines the desired state of Fluentd | positionDB | Storage for position db. You will use it if tail input is enabled. Applicable when the mode is \"agent\", and will be ignored when the mode is \"collector\" | [corev1.VolumeSource](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#volumesource-v1-core) | | livenessProbe | LivenessProbe represents the liveness probe for the fluentd container. | *[corev1.Probe](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#probe-v1-core) | | readinessProbe | ReadinessProbe represents the readiness probe for the fluentd container. | *[corev1.Probe](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#probe-v1-core) | +| hostAliases | HostAliases is an optional list of IPs and hostnames that will be injected into the pod's hosts file if specified. | [][corev1.HostAlias](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#hostalias-v1-core) | [Back to TOC](#table-of-contents) # FluentdStatus diff --git a/pkg/operator/daemonset.go b/pkg/operator/daemonset.go index 6c7fa63f3..8bb7b5141 100644 --- a/pkg/operator/daemonset.go +++ b/pkg/operator/daemonset.go @@ -94,6 +94,7 @@ func MakeDaemonSet(fb fluentbitv1alpha2.FluentBit, logPath string) *appsv1.Daemo SecurityContext: fb.Spec.SecurityContext, HostNetwork: fb.Spec.HostNetwork, TerminationGracePeriodSeconds: fb.Spec.TerminationGracePeriodSeconds, + HostAliases: fb.Spec.HostAliases, }, }, }, diff --git a/pkg/operator/fluentd-daemonset.go b/pkg/operator/fluentd-daemonset.go index 50018459f..52511e13c 100644 --- a/pkg/operator/fluentd-daemonset.go +++ b/pkg/operator/fluentd-daemonset.go @@ -114,6 +114,7 @@ func MakeFluentdDaemonSet(fd fluentdv1alpha1.Fluentd) *appsv1.DaemonSet { NodeSelector: fd.Spec.NodeSelector, Tolerations: fd.Spec.Tolerations, Affinity: fd.Spec.Affinity, + HostAliases: fd.Spec.HostAliases, }, }, }, diff --git a/pkg/operator/sts.go b/pkg/operator/sts.go index 676b1f72e..6a3097c06 100644 --- a/pkg/operator/sts.go +++ b/pkg/operator/sts.go @@ -112,6 +112,7 @@ func MakeStatefulSet(fd fluentdv1alpha1.Fluentd) *appsv1.StatefulSet { LivenessProbe: fd.Spec.LivenessProbe, }, }, + HostAliases: fd.Spec.HostAliases, NodeSelector: fd.Spec.NodeSelector, Tolerations: fd.Spec.Tolerations, Affinity: fd.Spec.Affinity,