[Bug]: Only one listener expose from k8s service when ballerina service contains two listeners
shanakama opened this issue · comments
Description
I have created a ballerina service that contains two listeners and I was able to invoke all resources via the both of listeners (by running ballerina service locally using bal run
).But once I build the service with --code=k8s
flag (to generate the k8s artifacts) , the generated artifact didn't contains any information related to the second listener (Didn't contain the port exposed in the k8s service).
Steps to Reproduce
- Create a simple ballerina service that contains two listeners
import ballerina/http;
# A service representing a network-accessible API
listener http:Listener endpoint1 = new (9090);
listener http:Listener endopoint2 = new (9091);
service / on endpoint1, endopoint2 {
# A resource for generating greetings
# + name - the input string name
# + return - string name with hello message or error
resource function get greeting(string name) returns string|error {
// Send a response back to the caller.
if name is "" {
return error("name should not be empty!");
}
return "Hello, " + name;
}
}
- Generate cloud resources for the above service
bal build --cloud=k8s
The output looks like below
---
apiVersion: "v1"
kind: "Service"
metadata:
labels:
app: "test_service"
name: "test-service-sv"
spec:
ports:
- name: "port-1-test-ser"
port: 9090
protocol: "TCP"
targetPort: 9090
selector:
app: "test_service"
type: "ClusterIP"
---
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
labels:
app: "test_service"
name: "test-service-deployment"
spec:
replicas: 1
selector:
matchLabels:
app: "test_service"
template:
metadata:
labels:
app: "test_service"
spec:
containers:
- image: "test_service:latest"
lifecycle:
preStop:
exec:
command:
- "sleep"
- "15"
name: "test-service-deployment"
ports:
- containerPort: 9090
name: "port-1-test-ser"
protocol: "TCP"
resources:
limits:
memory: "256Mi"
cpu: "500m"
requests:
memory: "100Mi"
cpu: "200m"
nodeSelector: {}
---
apiVersion: "autoscaling/v1"
kind: "HorizontalPodAutoscaler"
metadata:
labels:
app: "test_service"
name: "test-service-hp"
spec:
maxReplicas: 2
minReplicas: 1
scaleTargetRef:
apiVersion: "apps/v1"
kind: "Deployment"
name: "test-service-deployment"
targetCPUUtilizationPercentage: 50
As per the generated cloud artifact file , there are no any information regarding the port 9091
Affected Version(s)
Latest version as of now :
Ballerina 2201.3.1 (Swan Lake Update 3)
Language specification 2022R4
Update Tool 1.3.12
OS, DB, other environment details and versions
No response
Related area
-> Other Area
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response