@@ -41,6 +41,20 @@ var nodepoolStatsdMappingConfigTemplate string
4141//go:embed static/nodepool/httpd-build-logs-dir.conf
4242var httpdBuildLogsDirConfig string
4343
44+ //go:embed static/nodepool/fluentbit/parsers.conf
45+ var fluentBitForwarderParsersConfig string
46+
47+ //go:embed static/nodepool/fluentbit/fluent-bit.conf.tmpl
48+ var fluentBitForwarderConfig string
49+
50+ // ansible.cfg and the timestamp callback could be hard-coded in the nodepool builder container.
51+ //
52+ //go:embed static/nodepool/ansible/ansible.cfg
53+ var ansibleConfiguration string
54+
55+ //go:embed static/nodepool/ansible/timestamp.py
56+ var timestampOutputCallback string
57+
4458const (
4559 nodepoolIdent = "nodepool"
4660 launcherIdent = nodepoolIdent + "-launcher"
@@ -69,11 +83,47 @@ var nodepoolFluentBitLabels = []logging.FluentBitLabel{
6983 },
7084}
7185
86+ func createImageBuildLogForwarderSidecar (r * SFController , annotations map [string ]string ) (apiv1.Volume , apiv1.Container ) {
87+ fbForwarderConfig := make (map [string ]string )
88+ fbForwarderConfig ["fluent-bit.conf" ], _ = utils .ParseString (
89+ fluentBitForwarderConfig ,
90+ struct {
91+ ExtraKeys []logging.FluentBitLabel
92+ FluentBitHTTPInputHost string
93+ FluentBitHTTPInputPort string
94+ }{[]logging.FluentBitLabel {}, r .cr .Spec .FluentBitLogForwarding .HTTPInputHost , strconv .Itoa (int (r .cr .Spec .FluentBitLogForwarding .HTTPInputPort ))})
95+ fbForwarderConfig ["parsers.conf" ] = fluentBitForwarderParsersConfig
96+ r .EnsureConfigMap ("fluentbit-dib-cfg" , fbForwarderConfig )
97+
98+ volume := base .MkVolumeCM ("dib-log-forwarder-config" ,
99+ "fluentbit-dib-cfg-config-map" )
100+
101+ volumeMounts := []apiv1.VolumeMount {
102+ {
103+ Name : builderIdent ,
104+ SubPath : "builds" ,
105+ MountPath : "/watch/" ,
106+ },
107+ {
108+ Name : "dib-log-forwarder-config" ,
109+ MountPath : "/fluent-bit/etc/" ,
110+ },
111+ }
112+ sidecar := logging .CreateFluentBitSideCarContainer ("diskimage-builder" , nodepoolFluentBitLabels , volumeMounts )
113+ annotations ["dib-fluent-bit.conf" ] = utils .Checksum ([]byte (fbForwarderConfig ["fluent-bit.conf" ]))
114+ annotations ["dib-fluent-bit-parser" ] = utils .Checksum ([]byte (fbForwarderConfig ["parsers.conf" ]))
115+ annotations ["dib-fluent-bit-image" ] = base .FluentBitImage
116+ return volume , sidecar
117+
118+ }
119+
72120func (r * SFController ) setNodepoolTooling () {
73121 toolingData := make (map [string ]string )
74122 toolingData ["generate-config.sh" ] = generateConfigScript
75123 toolingData ["dib-ansible.py" ] = dibAnsibleWrapper
76124 toolingData ["ssh_config" ] = builderSSHConfig
125+ toolingData ["timestamp.py" ] = timestampOutputCallback
126+ toolingData ["ansible.cfg" ] = ansibleConfiguration
77127 r .EnsureConfigMap ("nodepool-tooling" , toolingData )
78128}
79129
@@ -437,6 +487,18 @@ func (r *SFController) DeployNodepoolBuilder(statsdExporterVolume apiv1.Volume,
437487 MountPath : "/etc/nodepool-logging/logging.yaml" ,
438488 ReadOnly : true ,
439489 },
490+ {
491+ Name : "nodepool-tooling-vol" ,
492+ SubPath : "ansible.cfg" ,
493+ MountPath : "/etc/ansible/ansible.cfg" ,
494+ ReadOnly : true ,
495+ },
496+ {
497+ Name : "nodepool-tooling-vol" ,
498+ SubPath : "timestamp.py" ,
499+ MountPath : "/usr/share/ansible/plugins/callback/timestamp.py" ,
500+ ReadOnly : true ,
501+ },
440502 }
441503
442504 nodepoolProvidersSecrets , volumeMount , ready := r .setProviderSecretsVolumeMounts (volumeMount )
@@ -488,6 +550,11 @@ func (r *SFController) DeployNodepoolBuilder(statsdExporterVolume apiv1.Volume,
488550
489551 extraLoggingEnvVars := logging .SetupLogForwarding ("nodepool-builder" , r .cr .Spec .FluentBitLogForwarding , nodepoolFluentBitLabels , annotations )
490552 nb .Spec .Template .Spec .Containers [0 ].Env = append (nb .Spec .Template .Spec .Containers [0 ].Env , extraLoggingEnvVars ... )
553+ if r .cr .Spec .FluentBitLogForwarding != nil {
554+ fbVolume , fbSidecar := createImageBuildLogForwarderSidecar (r , annotations )
555+ nb .Spec .Template .Spec .Containers = append (nb .Spec .Template .Spec .Containers , fbSidecar )
556+ nb .Spec .Template .Spec .Volumes = append (nb .Spec .Template .Spec .Volumes , fbVolume )
557+ }
491558
492559 nb .Spec .Template .ObjectMeta .Annotations = annotations
493560
0 commit comments