Skip to content

Commit

Permalink
Set service traffic policy on replica service
Browse files Browse the repository at this point in the history
Co-authored-by: Baptiste Bourdet <[email protected]>
Issue: PGO-1659
See: #3812
  • Loading branch information
cbandy and baptman21 committed Sep 27, 2024
1 parent 34a3eee commit 66174ec
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions internal/controller/postgrescluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

"github.com/crunchydata/postgres-operator/internal/initialize"
"github.com/crunchydata/postgres-operator/internal/naming"
"github.com/crunchydata/postgres-operator/internal/patroni"
"github.com/crunchydata/postgres-operator/internal/pki"
Expand Down Expand Up @@ -237,6 +238,8 @@ func (r *Reconciler) generateClusterReplicaService(
}
servicePort.NodePort = *spec.NodePort
}
service.Spec.ExternalTrafficPolicy = initialize.FromPointer(spec.ExternalTrafficPolicy)
service.Spec.InternalTrafficPolicy = spec.InternalTrafficPolicy
}
service.Spec.Ports = []corev1.ServicePort{servicePort}

Expand Down
2 changes: 2 additions & 0 deletions internal/controller/postgrescluster/patroni.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ func (r *Reconciler) generatePatroniLeaderLeaseService(
}
servicePort.NodePort = *spec.NodePort
}
service.Spec.ExternalTrafficPolicy = initialize.FromPointer(spec.ExternalTrafficPolicy)
service.Spec.InternalTrafficPolicy = spec.InternalTrafficPolicy
}
service.Spec.Ports = []corev1.ServicePort{servicePort}

Expand Down
2 changes: 2 additions & 0 deletions internal/controller/postgrescluster/pgadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ func (r *Reconciler) generatePGAdminService(
}
servicePort.NodePort = *spec.NodePort
}
service.Spec.ExternalTrafficPolicy = initialize.FromPointer(spec.ExternalTrafficPolicy)
service.Spec.InternalTrafficPolicy = spec.InternalTrafficPolicy
}
service.Spec.Ports = []corev1.ServicePort{servicePort}

Expand Down
8 changes: 2 additions & 6 deletions internal/controller/postgrescluster/pgbouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,8 @@ func (r *Reconciler) generatePGBouncerService(
}
servicePort.NodePort = *spec.NodePort
}
if spec.ExternalTrafficPolicy != nil {
service.Spec.ExternalTrafficPolicy = *spec.ExternalTrafficPolicy
}
if spec.InternalTrafficPolicy != nil {
service.Spec.InternalTrafficPolicy = spec.InternalTrafficPolicy
}
service.Spec.ExternalTrafficPolicy = initialize.FromPointer(spec.ExternalTrafficPolicy)
service.Spec.InternalTrafficPolicy = spec.InternalTrafficPolicy
}
service.Spec.Ports = []corev1.ServicePort{servicePort}

Expand Down

0 comments on commit 66174ec

Please sign in to comment.