Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(k8s): Add a port name to service definition #2933

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pipeline/backend/kubernetes/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package kubernetes

import (
"fmt"
6543 marked this conversation as resolved.
Show resolved Hide resolved

6543 marked this conversation as resolved.
Show resolved Hide resolved
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand All @@ -24,6 +26,7 @@ func Service(namespace, name string, ports []uint16) (*v1.Service, error) {
var svcPorts []v1.ServicePort
for _, port := range ports {
svcPorts = append(svcPorts, v1.ServicePort{
Name: fmt.Sprintf("port-%d", port),
Port: int32(port),
TargetPort: intstr.IntOrString{IntVal: int32(port)},
})
Expand Down
3 changes: 3 additions & 0 deletions pipeline/backend/kubernetes/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ func TestService(t *testing.T) {
"spec": {
"ports": [
{
"name": "port-1",
"port": 1,
"targetPort": 1
},
{
"name": "port-2",
"port": 2,
"targetPort": 2
},
{
"name": "port-3",
"port": 3,
"targetPort": 3
}
Expand Down