Skip to content

Commit

Permalink
Setting appProtocol for service objects
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenmat committed Feb 23, 2024
1 parent 1d90e1e commit 6415417
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion e2e-tests/init-deploy/compare/service_another-name-rs0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ metadata:
name: another-name
spec:
ports:
- name: mongodb
- appProtocol: mongo
name: mongodb
port: 27017
protocol: TCP
targetPort: 27017
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ metadata:
name: some-name
spec:
ports:
- name: mongodb
- appProtocol: mongo
name: mongodb
port: 27017
protocol: TCP
targetPort: 27017
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ metadata:
name: some-name
spec:
ports:
- name: mongodb
- appProtocol: mongo
name: mongodb
port: 27017
protocol: TCP
targetPort: 27017
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ metadata:
name: some-name
spec:
ports:
- name: mongodb
- appProtocol: mongo
name: mongodb
port: 27017
protocol: TCP
targetPort: 27017
Expand Down
16 changes: 10 additions & 6 deletions pkg/psmdb/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Service(cr *api.PerconaServerMongoDB, replset *api.ReplsetSpec) *corev1.Ser
"app.kubernetes.io/managed-by": "percona-server-mongodb-operator",
"app.kubernetes.io/part-of": "percona-server-mongodb",
}
appProtocol := "mongo"

svc := &corev1.Service{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Expand All @@ -42,10 +42,9 @@ func Service(cr *api.PerconaServerMongoDB, replset *api.ReplsetSpec) *corev1.Ser
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Name: mongodPortName,
Port: api.DefaultMongodPort,
TargetPort: intstr.FromInt(int(api.DefaultMongodPort)),
AppProtocol: &appProtocol,
Name: mongodPortName,
Port: api.DefaultMongodPort,
TargetPort: intstr.FromInt(int(api.DefaultMongodPort)),
},
},
ClusterIP: "None",
Expand All @@ -64,7 +63,12 @@ func Service(cr *api.PerconaServerMongoDB, replset *api.ReplsetSpec) *corev1.Ser
}
}
}

if cr.CompareVersion("1.16.0") < 0 {
appProtocol := "mongo"
for _, v := range svc.Spec.Ports {
v.AppProtocol = &appProtocol
}
}
return svc
}

Expand Down

0 comments on commit 6415417

Please sign in to comment.