@@ -18,14 +18,16 @@ package gateways
1818
1919import (
2020 "github.com/banzaicloud/istio-operator/pkg/resources/templates"
21+ "github.com/banzaicloud/istio-operator/pkg/util"
2122 apiv1 "k8s.io/api/core/v1"
2223 "k8s.io/apimachinery/pkg/runtime"
2324 "k8s.io/apimachinery/pkg/util/intstr"
2425)
2526
2627func (r * Reconciler ) service (gw string ) runtime.Object {
28+ gwConfig := r .getGatewayConfig (gw )
2729 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 ),
2931 Spec : apiv1.ServiceSpec {
3032 Type : serviceType (gw ),
3133 Ports : servicePorts (gw ),
@@ -36,7 +38,7 @@ func (r *Reconciler) service(gw string) runtime.Object {
3638
3739func servicePorts (gw string ) []apiv1.ServicePort {
3840 switch gw {
39- case "ingressgateway" :
41+ case ingress :
4042 return []apiv1.ServicePort {
4143 {Port : 80 , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (80 ), Name : "http2" , NodePort : 31380 },
4244 {Port : 443 , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (443 ), Name : "https" , NodePort : 31390 },
@@ -47,7 +49,7 @@ func servicePorts(gw string) []apiv1.ServicePort {
4749 {Port : 15030 , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (15030 ), Name : "http2-prometheus" , NodePort : 31440 },
4850 {Port : 15031 , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (15031 ), Name : "http2-grafana" , NodePort : 31450 },
4951 }
50- case "egressgateway" :
52+ case egress :
5153 return []apiv1.ServicePort {
5254 {Port : 80 , Name : "http2" , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (80 )},
5355 {Port : 443 , Name : "https" , Protocol : apiv1 .ProtocolTCP , TargetPort : intstr .FromInt (443 )},
@@ -58,9 +60,9 @@ func servicePorts(gw string) []apiv1.ServicePort {
5860
5961func serviceType (gw string ) apiv1.ServiceType {
6062 switch gw {
61- case "ingressgateway" :
63+ case ingress :
6264 return apiv1 .ServiceTypeLoadBalancer
63- case "egressgateway" :
65+ case egress :
6466 return apiv1 .ServiceTypeClusterIP
6567 }
6668 return ""
0 commit comments