Skip to content

Commit

Permalink
fix: Update service-port for existing Services on Gateway reconcile
Browse files Browse the repository at this point in the history
  • Loading branch information
rg0now committed Feb 1, 2024
1 parent fe7a8d7 commit 6f0de43
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/renderer/service_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
Expand Down Expand Up @@ -386,11 +387,13 @@ func (r *Renderer) createLbService4Gateway(c *RenderContext, gw *gwapiv1.Gateway

servicePortExists := false
// search for existing port
for _, s := range svc.Spec.Ports {
for i := range svc.Spec.Ports {
s := &svc.Spec.Ports[i]
if string(l.Name) == s.Name {
// found one, let's update it and move on
s.Protocol = corev1.Protocol(serviceProto)
s.Port = int32(l.Port)
s.TargetPort = intstr.FromInt(int(l.Port))
servicePortExists = true
break
}
Expand Down

0 comments on commit 6f0de43

Please sign in to comment.