@@ -18,14 +18,16 @@ package gateways
18
18
19
19
import (
20
20
"github.com/banzaicloud/istio-operator/pkg/resources/templates"
21
+ "github.com/banzaicloud/istio-operator/pkg/util"
21
22
apiv1 "k8s.io/api/core/v1"
22
23
"k8s.io/apimachinery/pkg/runtime"
23
24
"k8s.io/apimachinery/pkg/util/intstr"
24
25
)
25
26
26
27
func (r * Reconciler ) service (gw string ) runtime.Object {
28
+ gwConfig := r .getGatewayConfig (gw )
27
29
return & apiv1.Service {
28
- ObjectMeta : templates .ObjectMeta (gatewayName (gw ), labelSelector (gw ), r .Config ),
30
+ ObjectMeta : templates .ObjectMetaWithAnnotations (gatewayName (gw ), util . MergeLabels ( labelSelector (gw ), gwConfig . ServiceLabels ), gwConfig . ServiceAnnotations , r .Config ),
29
31
Spec : apiv1.ServiceSpec {
30
32
Type : serviceType (gw ),
31
33
Ports : servicePorts (gw ),
@@ -36,7 +38,7 @@ func (r *Reconciler) service(gw string) runtime.Object {
36
38
37
39
func servicePorts (gw string ) []apiv1.ServicePort {
38
40
switch gw {
39
- case "ingressgateway" :
41
+ case ingress :
40
42
return []apiv1.ServicePort {
41
43
{Port : 80 , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (80 ), Name : "http2" , NodePort : 31380 },
42
44
{Port : 443 , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (443 ), Name : "https" , NodePort : 31390 },
@@ -47,7 +49,7 @@ func servicePorts(gw string) []apiv1.ServicePort {
47
49
{Port : 15030 , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (15030 ), Name : "http2-prometheus" , NodePort : 31440 },
48
50
{Port : 15031 , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (15031 ), Name : "http2-grafana" , NodePort : 31450 },
49
51
}
50
- case "egressgateway" :
52
+ case egress :
51
53
return []apiv1.ServicePort {
52
54
{Port : 80 , Name : "http2" , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (80 )},
53
55
{Port : 443 , Name : "https" , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (443 )},
@@ -58,9 +60,9 @@ func servicePorts(gw string) []apiv1.ServicePort {
58
60
59
61
func serviceType (gw string ) apiv1.ServiceType {
60
62
switch gw {
61
- case "ingressgateway" :
63
+ case ingress :
62
64
return apiv1 .ServiceTypeLoadBalancer
63
- case "egressgateway" :
65
+ case egress :
64
66
return apiv1 .ServiceTypeClusterIP
65
67
}
66
68
return ""
0 commit comments