@@ -25,6 +25,7 @@ import (
2525 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626 "k8s.io/apimachinery/pkg/util/intstr"
2727
28+ "github.com/crunchydata/postgres-operator/internal/initialize"
2829 "github.com/crunchydata/postgres-operator/internal/naming"
2930 "github.com/crunchydata/postgres-operator/internal/patroni"
3031 "github.com/crunchydata/postgres-operator/internal/pki"
@@ -143,10 +144,11 @@ func (r *Reconciler) generateClusterPrimaryService(
143144 service .Spec .Selector = nil
144145
145146 service .Spec .Ports = []corev1.ServicePort {{
146- Name : naming .PortPostgreSQL ,
147- Port : * cluster .Spec .Port ,
148- Protocol : corev1 .ProtocolTCP ,
149- TargetPort : intstr .FromString (naming .PortPostgreSQL ),
147+ Name : naming .PortPostgreSQL ,
148+ Port : * cluster .Spec .Port ,
149+ Protocol : corev1 .ProtocolTCP ,
150+ TargetPort : intstr .FromString (naming .PortPostgreSQL ),
151+ AppProtocol : initialize .String (postgres .IANAServiceName ),
150152 }}
151153
152154 // Resolve to the ClusterIP for which Patroni has configured the Endpoints.
@@ -158,9 +160,10 @@ func (r *Reconciler) generateClusterPrimaryService(
158160 for _ , sp := range service .Spec .Ports {
159161 endpoints .Subsets [0 ].Ports = append (endpoints .Subsets [0 ].Ports ,
160162 corev1.EndpointPort {
161- Name : sp .Name ,
162- Port : sp .Port ,
163- Protocol : sp .Protocol ,
163+ Name : sp .Name ,
164+ Port : sp .Port ,
165+ Protocol : sp .Protocol ,
166+ AppProtocol : sp .AppProtocol ,
164167 })
165168 }
166169
@@ -221,10 +224,11 @@ func (r *Reconciler) generateClusterReplicaService(
221224 // ContainerPort. This name allows the port number to differ between Pods,
222225 // which can happen during a rolling update.
223226 service .Spec .Ports = []corev1.ServicePort {{
224- Name : naming .PortPostgreSQL ,
225- Port : * cluster .Spec .Port ,
226- Protocol : corev1 .ProtocolTCP ,
227- TargetPort : intstr .FromString (naming .PortPostgreSQL ),
227+ Name : naming .PortPostgreSQL ,
228+ Port : * cluster .Spec .Port ,
229+ Protocol : corev1 .ProtocolTCP ,
230+ TargetPort : intstr .FromString (naming .PortPostgreSQL ),
231+ AppProtocol : initialize .String (postgres .IANAServiceName ),
228232 }}
229233
230234 err := errors .WithStack (r .setControllerReference (cluster , service ))
0 commit comments