@@ -50,8 +50,10 @@ func MakeFluentdService(fd fluentdv1alpha1.Fluentd) *corev1.Service {
5050 },
5151 }
5252
53- // read inputs definition from globalInputs
53+ // Read inputs definition from globalInputs
5454 globalInputs := fd .Spec .GlobalInputs
55+ firstForwardPort := true
56+ firstHttpPort := true
5557 for _ , input := range globalInputs {
5658
5759 if input .Forward != nil {
@@ -60,13 +62,18 @@ func MakeFluentdService(fd fluentdv1alpha1.Fluentd) *corev1.Service {
6062 forwardPort = DefaultForwardPort
6163 }
6264
65+ forwardName := DefaultForwardName
66+ if ! firstForwardPort {
67+ forwardName = fmt .Sprintf ("%s-%d" , DefaultForwardName , forwardPort )
68+ }
6369 forwardContainerPort := corev1.ServicePort {
64- Name : DefaultForwardName ,
70+ Name : forwardName ,
6571 Port : forwardPort ,
6672 TargetPort : intstr .FromString (FluentdForwardPortName ),
6773 Protocol : corev1 .ProtocolTCP ,
6874 }
6975 svc .Spec .Ports = append (svc .Spec .Ports , forwardContainerPort )
76+ firstForwardPort = false
7077 continue
7178 }
7279
@@ -75,13 +82,18 @@ func MakeFluentdService(fd fluentdv1alpha1.Fluentd) *corev1.Service {
7582 if httpPort == 0 {
7683 httpPort = DefaultHttpPort
7784 }
85+ httpName := DefaultHttpName
86+ if ! firstHttpPort {
87+ httpName = fmt .Sprintf ("%s-%d" , DefaultHttpName , httpPort )
88+ }
7889 httpContainerPort := corev1.ServicePort {
79- Name : DefaultHttpName ,
90+ Name : httpName ,
8091 Port : httpPort ,
8192 TargetPort : intstr .FromString (FluentdHttpPortName ),
8293 Protocol : corev1 .ProtocolTCP ,
8394 }
8495 svc .Spec .Ports = append (svc .Spec .Ports , httpContainerPort )
96+ firstHttpPort = false
8597 }
8698 }
8799
0 commit comments