@@ -514,8 +514,6 @@ func retrieveLogs(cr *v1alpha1.AKSCluster, cluster *RemoteCluster, log *logrus.E
514514 return
515515 }
516516
517- log .Info (string (* data ))
518-
519517 err = json .Unmarshal (* data , & pods )
520518 if err != nil {
521519 log .Errorf ("Failed to collected pod list: %v" , err )
@@ -532,7 +530,7 @@ func retrieveLogs(cr *v1alpha1.AKSCluster, cluster *RemoteCluster, log *logrus.E
532530 continue
533531 }
534532
535- filename := "pod_" + pod .Namespace + "_" + pod .Pod + "_" + pod . PodID + ".txt"
533+ filename := "pod_" + pod .Namespace + "_" + pod .Pod + "_" + container + ".txt"
536534 err = uploadToArchive (cr , log , data , filename )
537535 if err != nil {
538536 log .Warningf ("Failed to upload log to archive: %v" , err )
@@ -568,6 +566,12 @@ func injectCollector(cluster *RemoteCluster, log *logrus.Entry) error {
568566 return err
569567 }
570568
569+ err = kubectlApply (cluster , newFluentbitConfigMap (), log )
570+ if err != nil {
571+ log .Errorf ("Failed to create fluent bit config map: %v" , err )
572+ return err
573+ }
574+
571575 err = kubectlApply (cluster , newCollectorDaemonSet (), log )
572576 if err != nil {
573577 log .Errorf ("Failed to create collector daemon set: %v" , err )
@@ -691,30 +695,83 @@ func newCollectorDeployment() *appsv1.Deployment {
691695 }
692696}
693697
698+ func newFluentbitConfigMap () * v1.ConfigMap {
699+ return & v1.ConfigMap {
700+ TypeMeta : metav1.TypeMeta {
701+ Kind : "ConfigMap" ,
702+ APIVersion : "v1" ,
703+ },
704+ ObjectMeta : metav1.ObjectMeta {
705+ Name : "infrabox-fluent-bit" ,
706+ Namespace : "infrabox-collector" ,
707+ },
708+ Data : map [string ]string {
709+ "parsers.conf" : `
710+ [PARSER]
711+ Name docker_utf8
712+ Format json
713+ Time_Key time
714+ Time_Format %Y-%m-%dT%H:%M:%S.%L
715+ Time_Keep On
716+ Decode_Field_as escaped_utf8 log do_next
717+ Decode_Field_as escaped log
718+ ` ,
719+ "fluent-bit.conf" : `
720+ [SERVICE]
721+ Flush 2
722+ Daemon Off
723+ Log_Level info
724+ Parsers_File parsers.conf
725+ [INPUT]
726+ Name tail
727+ Path /var/log/containers/*.log
728+ Parser docker_utf8
729+ Tag kube.*
730+ Refresh_Interval 2
731+ Mem_Buf_Limit 50MB
732+ Skip_Long_Lines On
733+ [FILTER]
734+ Name kubernetes
735+ Match kube.*
736+ Kube_URL https://kubernetes.default.svc.cluster.local:443
737+ Kube_CA_File /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
738+ Kube_Token_File /var/run/secrets/kubernetes.io/serviceaccount/token
739+ [OUTPUT]
740+ Name http
741+ Match *
742+ Host infrabox-collector-api.infrabox-collector
743+ Port 80
744+ URI /api/log
745+ Format json
746+ ` ,
747+ },
748+ }
749+ }
750+
694751func newCollectorDaemonSet () * appsv1.DaemonSet {
695752 return & appsv1.DaemonSet {
696753 TypeMeta : metav1.TypeMeta {
697754 Kind : "DaemonSet" ,
698755 APIVersion : "extensions/v1beta1" ,
699756 },
700757 ObjectMeta : metav1.ObjectMeta {
701- Name : "infrabox-collector-fluentd " ,
758+ Name : "infrabox-collector-fluent-bit " ,
702759 Namespace : "infrabox-collector" ,
703760 },
704761 Spec : appsv1.DaemonSetSpec {
705762 Template : v1.PodTemplateSpec {
706763 ObjectMeta : metav1.ObjectMeta {
707764 Labels : map [string ]string {
708- "app" : "fluentd .collector.infrabox.net" ,
765+ "app" : "fluentbit .collector.infrabox.net" ,
709766 },
710767 },
711768 Spec : v1.PodSpec {
712769 Containers : []v1.Container {{
713- Name : "fluentd " ,
714- Image : "quay.io/infrabox/collector-fluentd " ,
770+ Name : "fluent-bit " ,
771+ Image : "fluent/fluent-bit:0.13 " ,
715772 Resources : v1.ResourceRequirements {
716773 Limits : v1.ResourceList {
717- "memory" : resource .MustParse ("200Mi " ),
774+ "memory" : resource .MustParse ("100Mi " ),
718775 },
719776 Requests : v1.ResourceList {
720777 "cpu" : resource .MustParse ("100m" ),
@@ -728,10 +785,14 @@ func newCollectorDaemonSet() *appsv1.DaemonSet {
728785 Name : "varlibdockercontainers" ,
729786 MountPath : "/var/lib/docker/containers" ,
730787 ReadOnly : true ,
731- }},
732- Env : []v1.EnvVar {{
733- Name : "INFRABOX_COLLECTOR_ENDPOINT" ,
734- Value : "http://infrabox-collector-api.infrabox-collector/api/log" ,
788+ }, {
789+ Name : "config" ,
790+ MountPath : "/fluent-bit/etc/parsers.conf" ,
791+ SubPath : "parsers.conf" ,
792+ }, {
793+ Name : "config" ,
794+ MountPath : "/fluent-bit/etc/fluent-bit.conf" ,
795+ SubPath : "fluent-bit.conf" ,
735796 }},
736797 }},
737798 Volumes : []v1.Volume {{
@@ -748,11 +809,18 @@ func newCollectorDaemonSet() *appsv1.DaemonSet {
748809 Path : "/var/log" ,
749810 },
750811 },
812+ }, {
813+ Name : "config" ,
814+ VolumeSource : v1.VolumeSource {
815+ ConfigMap : & v1.ConfigMapVolumeSource {
816+ LocalObjectReference : v1.LocalObjectReference {
817+ Name : "infrabox-fluent-bit" ,
818+ },
819+ },
820+ },
751821 }},
752822 },
753823 },
754824 },
755825 }
756826}
757-
758- // newPodForCR returns a busybox pod with the same name/namespace as the cr
0 commit comments