@@ -25,6 +25,7 @@ import (
25
25
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26
26
"k8s.io/apimachinery/pkg/util/intstr"
27
27
28
+ "github.com/crunchydata/postgres-operator/internal/initialize"
28
29
"github.com/crunchydata/postgres-operator/internal/naming"
29
30
"github.com/crunchydata/postgres-operator/internal/patroni"
30
31
"github.com/crunchydata/postgres-operator/internal/pki"
@@ -143,10 +144,11 @@ func (r *Reconciler) generateClusterPrimaryService(
143
144
service .Spec .Selector = nil
144
145
145
146
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 ),
150
152
}}
151
153
152
154
// Resolve to the ClusterIP for which Patroni has configured the Endpoints.
@@ -158,9 +160,10 @@ func (r *Reconciler) generateClusterPrimaryService(
158
160
for _ , sp := range service .Spec .Ports {
159
161
endpoints .Subsets [0 ].Ports = append (endpoints .Subsets [0 ].Ports ,
160
162
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 ,
164
167
})
165
168
}
166
169
@@ -221,10 +224,11 @@ func (r *Reconciler) generateClusterReplicaService(
221
224
// ContainerPort. This name allows the port number to differ between Pods,
222
225
// which can happen during a rolling update.
223
226
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 ),
228
232
}}
229
233
230
234
err := errors .WithStack (r .setControllerReference (cluster , service ))
0 commit comments