Skip to content

Commit

Permalink
feat: add HostAliases support to Fluent Bit and Fluentd specifications
Browse files Browse the repository at this point in the history
Signed-off-by: Tomáš Novák <[email protected]>
  • Loading branch information
MioOgbeni committed Nov 19, 2024
1 parent e2f6c80 commit 30e77bf
Show file tree
Hide file tree
Showing 11 changed files with 113 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 @@ -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
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 @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_fluentbits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions config/crd/bases/fluentd.fluent.io_fluentds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/fluentbit.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/fluentd.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/fluentd-daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/sts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 30e77bf

Please sign in to comment.