@@ -41,6 +41,20 @@ var nodepoolStatsdMappingConfigTemplate string
41
41
//go:embed static/nodepool/httpd-build-logs-dir.conf
42
42
var httpdBuildLogsDirConfig string
43
43
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
+
44
58
const (
45
59
nodepoolIdent = "nodepool"
46
60
launcherIdent = nodepoolIdent + "-launcher"
@@ -69,11 +83,47 @@ var nodepoolFluentBitLabels = []logging.FluentBitLabel{
69
83
},
70
84
}
71
85
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
+
72
120
func (r * SFController ) setNodepoolTooling () {
73
121
toolingData := make (map [string ]string )
74
122
toolingData ["generate-config.sh" ] = generateConfigScript
75
123
toolingData ["dib-ansible.py" ] = dibAnsibleWrapper
76
124
toolingData ["ssh_config" ] = builderSSHConfig
125
+ toolingData ["timestamp.py" ] = timestampOutputCallback
126
+ toolingData ["ansible.cfg" ] = ansibleConfiguration
77
127
r .EnsureConfigMap ("nodepool-tooling" , toolingData )
78
128
}
79
129
@@ -437,6 +487,18 @@ func (r *SFController) DeployNodepoolBuilder(statsdExporterVolume apiv1.Volume,
437
487
MountPath : "/etc/nodepool-logging/logging.yaml" ,
438
488
ReadOnly : true ,
439
489
},
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
+ },
440
502
}
441
503
442
504
nodepoolProvidersSecrets , volumeMount , ready := r .setProviderSecretsVolumeMounts (volumeMount )
@@ -488,6 +550,11 @@ func (r *SFController) DeployNodepoolBuilder(statsdExporterVolume apiv1.Volume,
488
550
489
551
extraLoggingEnvVars := logging .SetupLogForwarding ("nodepool-builder" , r .cr .Spec .FluentBitLogForwarding , nodepoolFluentBitLabels , annotations )
490
552
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
+ }
491
558
492
559
nb .Spec .Template .ObjectMeta .Annotations = annotations
493
560
0 commit comments